wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src display.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src display.cpp
Date: Sat, 04 Dec 2004 06:58:51 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/12/04 11:51:45

Modified files:
        src            : display.cpp 

Log message:
        Simplify zoom and fix #9890 along the way.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.cpp.diff?tr1=1.280&tr2=1.281&r1=text&r2=text

Patches:
Index: wesnoth/src/display.cpp
diff -u wesnoth/src/display.cpp:1.280 wesnoth/src/display.cpp:1.281
--- wesnoth/src/display.cpp:1.280       Sat Nov 27 09:49:44 2004
+++ wesnoth/src/display.cpp     Sat Dec  4 11:51:44 2004
@@ -1,4 +1,4 @@
-/* $Id: display.cpp,v 1.280 2004/11/27 09:49:44 silene Exp $ */
+/* $Id: display.cpp,v 1.281 2004/12/04 11:51:44 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -365,52 +365,22 @@
 
 double display::zoom(int amount)
 {
-       if(amount == 0 || !team_valid()) {
-               return double(zoom_)/double(DefaultZoom);
-       }
-
-       const int orig_xpos = xpos_;
-       const int orig_ypos = ypos_;
-
-       xpos_ /= zoom_;
-       ypos_ /= zoom_;
-
-       const int orig_zoom = zoom_;
-
-       zoom_ += amount;
-       if(zoom_ < MinZoom(map_,map_area()) || zoom_ > MaxZoom) {
-               zoom_ = orig_zoom;
-               xpos_ = orig_xpos;
-               ypos_ = orig_ypos;
-               return double(zoom_)/double(DefaultZoom);
-       }
-
-       xpos_ *= zoom_;
-       ypos_ *= zoom_;
-
-       xpos_ += amount*2;
-       ypos_ += amount*2;
-
-       const int prev_zoom = zoom_;
-
-       bounds_check_position();
+       int new_zoom = zoom_ + amount;
+       if (amount != 0 && team_valid() && new_zoom >= MinZoom(map_, 
map_area()) && new_zoom <= MaxZoom) {
+               SDL_Rect const &area = map_area();
+               xpos_ += (xpos_ + area.w / 2) * amount / zoom_;
+               ypos_ += (ypos_ + area.h / 2) * amount / zoom_;
+               zoom_ = new_zoom;
+               bounds_check_position();
 
-       if(zoom_ != prev_zoom) {
-               xpos_ = orig_xpos;
-               ypos_ = orig_ypos;
-               zoom_ = orig_zoom;
+               energy_bar_rects_.clear();
                image::set_zoom(zoom_);
-               return double(zoom_)/double(DefaultZoom);
-       }
-
-       energy_bar_rects_.clear();
-
-       image::set_zoom(zoom_);
-       map_labels_.recalculate_labels();
-       invalidate_all();
+               map_labels_.recalculate_labels();
+               invalidate_all();
 
-       // Forces a redraw after zooming. This prevents some graphic glitches 
from occuring.
-       draw();
+               // Forces a redraw after zooming. This prevents some graphic 
glitches from occuring.
+               draw();
+       }
 
        return double(zoom_)/double(DefaultZoom);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]