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 display.hpp video.cpp v...


From: Yann Dirson
Subject: [Wesnoth-cvs-commits] wesnoth/src display.cpp display.hpp video.cpp v...
Date: Wed, 16 Mar 2005 16:49:38 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Yann Dirson <address@hidden>    05/03/16 21:49:37

Modified files:
        src            : display.cpp display.hpp video.cpp video.hpp 
                         replay.cpp playlevel.cpp 

Log message:
        moved update_lock stuff from display to video

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.cpp.diff?tr1=1.300&tr2=1.301&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.hpp.diff?tr1=1.97&tr2=1.98&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/video.cpp.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/video.hpp.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.cpp.diff?tr1=1.95&tr2=1.96&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playlevel.cpp.diff?tr1=1.184&tr2=1.185&r1=text&r2=text

Patches:
Index: wesnoth/src/display.cpp
diff -u wesnoth/src/display.cpp:1.300 wesnoth/src/display.cpp:1.301
--- wesnoth/src/display.cpp:1.300       Wed Mar 16 21:02:45 2005
+++ wesnoth/src/display.cpp     Wed Mar 16 21:49:37 2005
@@ -1,4 +1,4 @@
-/* $Id: display.cpp,v 1.300 2005/03/16 21:02:45 gruikya Exp $ */
+/* $Id: display.cpp,v 1.301 2005/03/16 21:49:37 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -74,7 +74,7 @@
        invalidateAll_(true), invalidateUnit_(true),
        invalidateGameStatus_(true), panelsDrawn_(false),
        currentTeam_(0), activeTeam_(0), hideEnergy_(false),
-       deadAmount_(ftofxp(0.0)), advancingAmount_(0.0), updatesLocked_(0),
+       deadAmount_(ftofxp(0.0)), advancingAmount_(0.0),
        turbo_(false), grid_(false), sidebarScaling_(1.0),
        theme_(theme_cfg,screen_area()), builder_(cfg, level, map),
        first_turn_(true), in_game_(false), map_labels_(*this,map),
@@ -82,7 +82,7 @@
        fps_handle_(0)
 {
        if(non_interactive())
-               updatesLocked_++;
+               screen_.lock_updates(true);
 
        std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
 
@@ -419,7 +419,7 @@
 
 void display::scroll_to_tile(int x, int y, SCROLL_TYPE scroll_type, bool 
check_fogged)
 {
-       if(update_locked() || (check_fogged && fogged(x,y)))
+       if(screen_.update_locked() || (check_fogged && fogged(x,y)))
                return;
 
        const gamemap::location loc(x,y);
@@ -517,7 +517,7 @@
 
 void display::redraw_everything()
 {
-       if(update_locked() || teams_.empty())
+       if(screen_.update_locked() || teams_.empty())
                return;
 
        bounds_check_position();
@@ -686,7 +686,7 @@
 
 void display::update_display()
 {
-       if(updatesLocked_ > 0)
+       if(screen_.update_locked())
                return;
 
        if(preferences::show_fps()) {
@@ -1118,7 +1118,7 @@
 void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
                fixed_t highlight_ratio, Uint32 blend_with)
 {
-       if(updatesLocked_)
+       if(screen_.update_locked())
                return;
 
        const gamemap::location loc(x,y);
@@ -1383,7 +1383,7 @@
 
 void display::draw_tile(int x, int y, surface unit_image, fixed_t alpha, 
Uint32 blend_to)
 {
-       if(updatesLocked_)
+       if(screen_.update_locked())
                return;
 
        draw_halo_on_tile(x,y);
@@ -2041,19 +2041,6 @@
        draw_tile(loc.x,loc.y);
 }
 
-void display::lock_updates(bool value)
-{
-       if(value == true)
-               ++updatesLocked_;
-       else
-               --updatesLocked_;
-}
-
-bool display::update_locked() const
-{
-       return updatesLocked_ > 0;
-}
-
 bool display::turbo() const
 {
        bool res = turbo_;
@@ -2162,7 +2149,7 @@
 
        const std::vector<theme::menu>& buttons = theme_.menus();
        for(std::vector<theme::menu>::const_iterator i = buttons.begin(); i != 
buttons.end(); ++i) {
-               gui::button 
b(*this,i->title(),gui::button::TYPE_PRESS,i->image());
+               gui::button 
b(screen_,i->title(),gui::button::TYPE_PRESS,i->image());
                const SDL_Rect& loc = i->location(screen_area());
                b.set_location(loc.x,loc.y);
 
Index: wesnoth/src/display.hpp
diff -u wesnoth/src/display.hpp:1.97 wesnoth/src/display.hpp:1.98
--- wesnoth/src/display.hpp:1.97        Wed Mar 16 20:50:11 2005
+++ wesnoth/src/display.hpp     Wed Mar 16 21:49:37 2005
@@ -1,4 +1,4 @@
-/* $Id: display.hpp,v 1.97 2005/03/16 20:50:11 ydirson Exp $ */
+/* $Id: display.hpp,v 1.98 2005/03/16 21:49:37 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -265,13 +265,9 @@
        //by amount.
        void set_advancing_unit(const gamemap::location& loc, double amount);
 
-       //function to stop the screen being redrawn. Anything that happens while
-       //the update is locked will be hidden from the user's view.
-       //note that this function is re-entrant, meaning that if 
lock_updates(true)
-       //is called twice, lock_updates(false) must be called twice to unlock
-       //updates.
-       void lock_updates(bool value);
-       bool update_locked() const;
+       //compat methods to be dropped after full migration
+       void lock_updates(bool value) {screen_.lock_updates(value); };
+       bool update_locked() const {return screen_.update_locked(); };
 
        //functions to set/get whether 'turbo' mode is on. When turbo mode is 
on,
        //everything moves much faster.
@@ -451,8 +447,6 @@
        gamemap::location advancingUnit_;
        double advancingAmount_;
 
-       int updatesLocked_;
-
        bool turbo_, grid_;
        double sidebarScaling_;
 
@@ -503,31 +497,6 @@
        int fps_handle_;
 };
 
-//an object which will lock the display for the duration of its lifetime.
-struct update_locker
-{
-       update_locker(display& d, bool lock=true) : disp(d), unlock(lock) {
-               if(lock) {
-                       disp.lock_updates(true);
-               }
-       }
-
-       ~update_locker() {
-               unlock_update();
-       }
-
-       void unlock_update() {
-               if(unlock) {
-                       disp.lock_updates(false);
-                       unlock = false;
-               }
-       }
-
-private:
-       display& disp;
-       bool unlock;
-};
-
 bool angle_is_northern(size_t n);
 const std::string& get_angle_direction(size_t n);
 
Index: wesnoth/src/playlevel.cpp
diff -u wesnoth/src/playlevel.cpp:1.184 wesnoth/src/playlevel.cpp:1.185
--- wesnoth/src/playlevel.cpp:1.184     Tue Mar 15 00:45:00 2005
+++ wesnoth/src/playlevel.cpp   Wed Mar 16 21:49:37 2005
@@ -1,4 +1,4 @@
-/* $Id: playlevel.cpp,v 1.184 2005/03/15 00:45:00 ydirson Exp $ */
+/* $Id: playlevel.cpp,v 1.185 2005/03/16 21:49:37 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -480,7 +480,7 @@
                                const hotkey::basic_handler 
key_events_handler(&gui);
 
                                LOG_NG << "first_time..." << 
(recorder.skipping() ? "skipping" : "no skip") << "\n";
-                               update_locker 
lock_display(gui,recorder.skipping());
+                               update_locker 
lock_display(gui.video(),recorder.skipping());
                                events::raise_draw_event();
                                if(!loading_game) {
                                        game_events::fire("start");
@@ -706,7 +706,7 @@
 
                        {
                                LOG_NG << "turn event..." << 
(recorder.skipping() ? "skipping" : "no skip") << "\n";
-                               update_locker 
lock_display(gui,recorder.skipping());
+                               update_locker 
lock_display(gui.video(),recorder.skipping());
                                const std::string turn_num = event_stream.str();
                                
game_events::set_variable("turn_number",turn_num);
                                game_events::fire("turn " + turn_num);
Index: wesnoth/src/replay.cpp
diff -u wesnoth/src/replay.cpp:1.95 wesnoth/src/replay.cpp:1.96
--- wesnoth/src/replay.cpp:1.95 Thu Mar 10 20:43:48 2005
+++ wesnoth/src/replay.cpp      Wed Mar 16 21:49:37 2005
@@ -1,4 +1,4 @@
-/* $Id: replay.cpp,v 1.95 2005/03/10 20:43:48 ydirson Exp $ */
+/* $Id: replay.cpp,v 1.96 2005/03/16 21:49:37 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -624,7 +624,7 @@
 
        const set_random_generator generator_setter(&replayer);
 
-       update_locker lock_update(disp,replayer.skipping());
+       update_locker lock_update(disp.video(),replayer.skipping());
 
        //a list of units that have promoted from the last attack
        std::deque<gamemap::location> advancing_units;
Index: wesnoth/src/video.cpp
diff -u wesnoth/src/video.cpp:1.60 wesnoth/src/video.cpp:1.61
--- wesnoth/src/video.cpp:1.60  Wed Mar 16 20:50:11 2005
+++ wesnoth/src/video.cpp       Wed Mar 16 21:49:37 2005
@@ -1,4 +1,4 @@
-/* $Id: video.cpp,v 1.60 2005/03/16 20:50:11 ydirson Exp $ */
+/* $Id: video.cpp,v 1.61 2005/03/16 21:49:37 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -202,7 +202,7 @@
 {
        update_all = true;
 }
-CVideo::CVideo() : bpp(0), fake_screen(false), help_string_(0)
+CVideo::CVideo() : bpp(0), fake_screen(false), help_string_(0), 
updatesLocked_(0)
 {
        const int res = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | 
SDL_INIT_NOPARACHUTE);
 
@@ -213,7 +213,7 @@
 }
 
 CVideo::CVideo( int x, int y, int bits_per_pixel, int flags)
-                : bpp(0), fake_screen(false), help_string_(0)
+                : bpp(0), fake_screen(false), help_string_(0), 
updatesLocked_(0)
 {
        const int res = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | 
SDL_INIT_NOPARACHUTE);
        if(res < 0) {
@@ -352,6 +352,19 @@
        halo::unrender();
 }
 
+void CVideo::lock_updates(bool value)
+{
+       if(value == true)
+               ++updatesLocked_;
+       else
+               --updatesLocked_;
+}
+
+bool CVideo::update_locked() const
+{
+       return updatesLocked_ > 0;
+}
+
 void CVideo::lock()
 {
        if( SDL_MUSTLOCK(frameBuffer) )
Index: wesnoth/src/video.hpp
diff -u wesnoth/src/video.hpp:1.32 wesnoth/src/video.hpp:1.33
--- wesnoth/src/video.hpp:1.32  Wed Mar 16 20:50:11 2005
+++ wesnoth/src/video.hpp       Wed Mar 16 21:49:37 2005
@@ -1,4 +1,4 @@
-/* $Id: video.hpp,v 1.32 2005/03/16 20:50:11 ydirson Exp $ */
+/* $Id: video.hpp,v 1.33 2005/03/16 21:49:37 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -85,6 +85,14 @@
        void clear_help_string(int handle);
        void clear_all_help_strings();
 
+       //function to stop the screen being redrawn. Anything that happens while
+       //the update is locked will be hidden from the user's view.
+       //note that this function is re-entrant, meaning that if 
lock_updates(true)
+       //is called twice, lock_updates(false) must be called twice to unlock
+       //updates.
+       void lock_updates(bool value);
+       bool update_locked() const;
+
 private:
 
        bool mode_changed_;
@@ -96,6 +104,33 @@
 
        //variables for help strings
        int help_string_;
+
+       int updatesLocked_;
+};
+
+//an object which will lock the display for the duration of its lifetime.
+struct update_locker
+{
+       update_locker(CVideo& v, bool lock=true) : video(v), unlock(lock) {
+               if(lock) {
+                       video.lock_updates(true);
+               }
+       }
+
+       ~update_locker() {
+               unlock_update();
+       }
+
+       void unlock_update() {
+               if(unlock) {
+                       video.lock_updates(false);
+                       unlock = false;
+               }
+       }
+
+private:
+       CVideo& video;
+       bool unlock;
 };
 
 #endif




reply via email to

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