Author: mordante
Date: Sat May 26 21:38:43 2007
New Revision: 17872

URL: http://svn.gna.org/viewcvs/wesnoth?rev=17872&view=rev
Log:
did some cleaning up; zoom() could change the zoom value and return the factor
now splitted in 2 functions, also namechange of default_zoom()

Modified:
    trunk/src/display.cpp
    trunk/src/display.hpp
    trunk/src/editor/editor.cpp
    trunk/src/hotkeys.cpp
    trunk/src/unit.cpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=17872&r1=17871&r2=17872&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sat May 26 21:38:43 2007
@@ -24,7 +24,6 @@
 #include "gettext.hpp"
 #include "halo.hpp"
 #include "hotkeys.hpp"
-#include "image.hpp"
 #include "language.hpp"
 #include "log.hpp"
 #include "marked-up_text.hpp"
@@ -479,7 +478,7 @@
        }
 }
 
-double display::zoom(int amount)
+void display::set_zoom(int amount)
 {
        int new_zoom = zoom_ + amount;
        if (new_zoom < MinZoom) {
@@ -503,8 +502,11 @@
                // Forces a redraw after zooming. This prevents some graphic 
glitches from occurring.
                draw();
        }
-
-       return double(zoom_)/double(image::tile_size);
+}
+
+void display::set_default_zoom()
+{ 
+       set_zoom(DefaultZoom - zoom_); 
 }
 
 void display::screenshot()
@@ -528,11 +530,6 @@
        } while(file_exists(name));
 
        SDL_SaveBMP(screen_.getSurface().get(), name.c_str());
-}
-
-void display::default_zoom()
-{ 
-       zoom(DefaultZoom - zoom_); 
 }
 
 void display::scroll_to_tile(int x, int y, SCROLL_TYPE scroll_type, bool 
check_fogged)
@@ -1348,7 +1345,7 @@
 void display::draw_bar(const std::string& image, int xpos, int ypos, size_t 
height, double filled, const SDL_Color& col, fixed_t alpha)
 {
        filled = minimum<double>(maximum<double>(filled,0.0),1.0);
-       height = static_cast<size_t>(height*zoom());
+       height = static_cast<size_t>(height*get_zoom_factor());
 #ifdef USE_TINY_GUI
        height /= 2;
 #endif
@@ -1753,9 +1750,9 @@
                // FIXME: This 16/9 must be defined elsewhere,
                // It's the ratio of the font size bewteen the two gui.
                // It makes the text fill the hex like it does in the normal 
gui.
-               const int font_size = static_cast<int>(font::SIZE_PLUS * zoom() 
* 16/9);
+               const int font_size = static_cast<int>(font::SIZE_PLUS * 
get_zoom_factor() * 16/9);
 #else
-               const int font_size = static_cast<int>(font::SIZE_PLUS * 
zoom());
+               const int font_size = static_cast<int>(font::SIZE_PLUS * 
get_zoom_factor());
 #endif
                const SDL_Rect& text_area = font::text_area(str,font_size);
                const int x = xloc + zoom_/2 - text_area.w/2;

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=17872&r1=17871&r2=17872&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sat May 26 21:38:43 2007
@@ -76,12 +76,14 @@
        //redrawing will be scheduled.
        void scroll(int xmov, int ymov);
 
-       //function which zooms the display by the specified amount. Negative
-       //values zoom out. Returns the current zoom ratio
-       double zoom(int amount=0);
-
-       //function to take the zoom amount to the default.
-       void default_zoom();
+       // Zzooms the display by the specified amount. Negative values zoom out.
+       void set_zoom(int amount);
+
+       // sets the zoom amount to the default.
+       void set_default_zoom();
+
+       // Returns the current zoom factor.
+       double get_zoom_factor() { return 
double(zoom_)/double(image::tile_size); }
 
        //function to make a screenshot and save it in a default location
        void screenshot();

Modified: trunk/src/editor/editor.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.cpp?rev=17872&r1=17871&r2=17872&view=diff
==============================================================================
--- trunk/src/editor/editor.cpp (original)
+++ trunk/src/editor/editor.cpp Sat May 26 21:38:43 2007
@@ -961,7 +961,7 @@
        static const int quarter_size = size / 4;
        static const int offset = 2;
        static const int new_size = half_size - 2;
-       const int zoom = static_cast<int>(size * gui_.zoom());
+       const int zoom = static_cast<int>(size * gui_.get_zoom_factor());
 
        // create a transparant surface of the right size, not sure
        // what's the best way, but this works (but probably not efficient)

Modified: trunk/src/hotkeys.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/hotkeys.cpp?rev=17872&r1=17871&r2=17872&view=diff
==============================================================================
--- trunk/src/hotkeys.cpp (original)
+++ trunk/src/hotkeys.cpp Sat May 26 21:38:43 2007
@@ -731,13 +731,13 @@
        }
        switch(command) {
                case HOTKEY_ZOOM_IN:
-                       disp.zoom(zoom_amount);
+                       disp.set_zoom(zoom_amount);
                        break;
                case HOTKEY_ZOOM_OUT:
-                       disp.zoom(-zoom_amount);
+                       disp.set_zoom(-zoom_amount);
                        break;
                case HOTKEY_ZOOM_DEFAULT:
-                       disp.default_zoom();
+                       disp.set_default_zoom();
                        break;
                case HOTKEY_FULLSCREEN:
                        preferences::set_fullscreen(!preferences::fullscreen());

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=17872&r1=17871&r2=17872&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sat May 26 21:38:43 2007
@@ -1674,7 +1674,7 @@
        const double submerge = is_flying() ? 0.0 : 
terrain_info.unit_submerge();
        int height_adjust = terrain_info.unit_height_adjust();
        if (is_flying() && height_adjust <= 0) height_adjust = 0;
-       else height_adjust = int(height_adjust * disp.zoom());
+       else height_adjust = int(height_adjust * disp.get_zoom_factor());
 
        unit_frame current_frame;
        if(anim_->animation_finished()) current_frame = anim_->get_last_frame();
@@ -1699,8 +1699,8 @@
        if(!current_frame.halo(anim_->get_current_frame_time()).empty()) {
                int d = disp.hex_size() / 2;
                int ft = anim_->get_current_frame_time();
-               int dx = int(current_frame.halo_x(ft) * disp.zoom());
-               int hy = y + d - height_adjust + int(current_frame.halo_y(ft) * 
disp.zoom());
+               int dx = int(current_frame.halo_x(ft) * disp.get_zoom_factor());
+               int hy = y + d - height_adjust + int(current_frame.halo_y(ft) * 
disp.get_zoom_factor());
                if (facing_ == gamemap::location::NORTH_WEST ||
                    facing_ == gamemap::location::SOUTH_WEST)
                        unit_anim_halo_ = halo::add(x + d - dx, hy,
@@ -1845,9 +1845,9 @@
                        unit_energy = 
double(hitpoints())/double(max_hitpoints());
                }
 #ifdef USE_TINY_GUI
-               const int bar_shift = static_cast<int>(-2.5*disp.zoom());
+               const int bar_shift = 
static_cast<int>(-2.5*disp.get_zoom_factor());
 #else
-               const int bar_shift = static_cast<int>(-5*disp.zoom());
+               const int bar_shift = 
static_cast<int>(-5*disp.get_zoom_factor());
 #endif
                
disp.draw_bar(*energy_file,xsrc+bar_shift,ysrc-height_adjust,(max_hitpoints()*2)/3,unit_energy,hp_color(),bar_alpha);
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to