Author: alink
Date: Wed May 28 23:39:24 2008
New Revision: 26907

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26907&view=rev
Log:
Cleaner fix for the previous commit about refreshing titlescreen

Modified:
    trunk/src/game.cpp
    trunk/src/titlescreen.cpp
    trunk/src/titlescreen.hpp

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=26907&r1=26906&r2=26907&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Wed May 28 23:39:24 2008
@@ -1968,6 +1968,10 @@
 
 void game_controller::refresh_game_cfg(bool reset_translations)
 {
+       // The loadscreen will erase the titlescreen
+       // NOTE: even without loadscreen, needed after MP lobby
+       gui::set_background_dirty();
+
        try {
                if(old_defines_map_.empty() || defines_map_ != old_defines_map_ 
|| reset_translations) {
                        cursor::setter cur(cursor::WAIT);
@@ -2429,8 +2433,6 @@
 
        LOG_CONFIG << "time elapsed: "<<  (SDL_GetTicks() - start_ticks) << " 
ms\n";
 
-       bool redraw_background = true;
-
        for(int first_time = true;;first_time = false){
         //init_config already processed the configs, so we don't need to do it 
for the
         //first loop pass.
@@ -2471,12 +2473,10 @@
                gui::TITLE_RESULT res = game.is_loading() ? gui::LOAD_GAME : 
gui::NOTHING;
 
                while(res == gui::NOTHING) {
-                       res = gui::show_title(game.disp(),tips_of_day, 
redraw_background);
+                       res = gui::show_title(game.disp(),tips_of_day);
                        if (res == gui::REDRAW_BACKGROUND) {
-                               redraw_background = true;
+                               gui::set_background_dirty();
                                res = gui::NOTHING;
-                       } else {
-                               redraw_background = false;
                        }
                }
 
@@ -2499,12 +2499,7 @@
                        }
                } else if(res == gui::MULTIPLAYER) {
                        if(game.play_multiplayer() == false) {
-                               // Need a redraw because we can left the lobby 
without playing.
-                               // (the redraw is only useless when canceling 
the multiplayer dialog)
-                               // TODO: game.play_multiplayer() always return 
false (why?),
-                               // perhaps change this to identify real 
"cancel" cases?
-                               redraw_background = true;
-                               continue;       
+                               continue;
                        }
                } else if(res == gui::CHANGE_LANGUAGE) {
                        if(game.change_language() == true) {
@@ -2514,7 +2509,7 @@
                } else if(res == gui::EDIT_PREFERENCES) {
                        game.show_preferences();
                        if (game.disp().video().modeChanged()) {
-                               redraw_background = true;
+                               gui::set_background_dirty();
                        }
                        continue;
                } else if(res == gui::SHOW_ABOUT) {
@@ -2526,9 +2521,6 @@
                        continue;
                } else if(res == gui::GET_ADDONS) {
                        game.manage_addons();
-                       // after the loadscreen, need a redraw
-                       // TODO: detect cancel action, to avoid the redraw when 
possible
-                       redraw_background = true;
                        continue;
                } else if(res == gui::BEG_FOR_UPLOAD) {
                        game.show_upload_begging();
@@ -2536,7 +2528,7 @@
 #ifdef MAP_EDITOR
                } else if(res == gui::START_MAP_EDITOR) {
                        gui::show_error_message(game.disp(), "The map editor is 
not available. Yet.");
-                       //NOTE: will probably need a "redraw_background = true";
+                       gui::set_background_dirty()
                        continue;
 #endif
                }
@@ -2547,9 +2539,6 @@
                else{
                        game.play_replay();
                }
-
-               // We played something, refresh background
-               redraw_background = true;
        }
 
        return 0;

Modified: trunk/src/titlescreen.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/titlescreen.cpp?rev=26907&r1=26906&r2=26907&view=diff
==============================================================================
--- trunk/src/titlescreen.cpp (original)
+++ trunk/src/titlescreen.cpp Wed May 28 23:39:24 2008
@@ -338,7 +338,14 @@
 
 namespace gui {
 
-TITLE_RESULT show_title(game_display& screen, config& tips_of_day, bool 
redraw_background)
+
+static bool background_is_dirty_ = true;
+void set_background_dirty() {
+       background_is_dirty_ = true;
+}
+
+
+TITLE_RESULT show_title(game_display& screen, config& tips_of_day)
 {
        cursor::set(cursor::NORMAL);
 
@@ -349,8 +356,9 @@
 
        screen.video().modeChanged(); // resets modeChanged value
 
-       if (redraw_background)
+       if (background_is_dirty_) {
                draw_background(screen);
+       }
 
        //- Texts for the menu-buttons.
        //- Members of this array must correspond to the enumeration 
TITLE_RESULT
@@ -425,7 +433,7 @@
 
        // we only redraw transparent parts when asked,
        // to prevent alpha growing
-       if (redraw_background) {
+       if (background_is_dirty_) {
                main_frame.draw_background();
                main_frame.draw_border();
        }
@@ -471,6 +479,7 @@
        bool last_escape = key[SDLK_ESCAPE] != 0;
 
        update_whole_screen();
+       background_is_dirty_ = false;
 
        LOG_DP << "entering interactive loop...\n";
 

Modified: trunk/src/titlescreen.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/titlescreen.hpp?rev=26907&r1=26906&r2=26907&view=diff
==============================================================================
--- trunk/src/titlescreen.hpp (original)
+++ trunk/src/titlescreen.hpp Wed May 28 23:39:24 2008
@@ -39,6 +39,9 @@
                                        NOTHING                         /**< 
Default, nothing done, no redraw needed */
                                  };
 
+/** Mark the titlescreen background as dirty */
+void set_background_dirty();
+
 /**
  *  Show titlepage with logo and background, menu-buttons and tip-of-the-day.
  * 
@@ -48,12 +51,11 @@
  * 
  *  @param     screen                  display object
  *  @param     tips_of_day             list of tips
- *  @param     redraw_background redraw background and buttons box, see 
draw_background()
- * 
+ *
  *  @return    the value of the menu-item the user has choosen.
  *  @retval    see @ref TITLE_RESULT for possible values
  */ 
-TITLE_RESULT show_title(game_display& screen, config& tips_of_day, bool 
redraw_background);
+TITLE_RESULT show_title(game_display& screen, config& tips_of_day);
 }
 
 #endif


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

Reply via email to