Author: jhinrichs
Date: Tue Apr 28 22:32:50 2009
New Revision: 35309

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35309&view=rev
Log:
Refactor savegame.cpp: Get rid of display references for the savegame class and 
move messages to gui2.

Modified:
    trunk/src/play_controller.cpp
    trunk/src/playcampaign.cpp
    trunk/src/playmp_controller.cpp
    trunk/src/playsingle_controller.cpp
    trunk/src/savegame.cpp
    trunk/src/savegame.hpp

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=35309&r1=35308&r2=35309&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Tue Apr 28 22:32:50 2009
@@ -294,7 +294,7 @@
        if(save_blocker::try_block()) {
                save_blocker::save_unblocker unblocker;
                game_savegame save(gamestate_, level_, *gui_, teams_, units_, 
status_, map_, preferences::compress_saves());
-               save.save_game_interactive(*gui_, "", gui::OK_CANCEL);
+               save.save_game_interactive((*gui_).video(), "", gui::OK_CANCEL);
        } else {
                save_blocker::on_unblock(this,&play_controller::save_game);
        }
@@ -304,7 +304,7 @@
        if(save_blocker::try_block()) {
                save_blocker::save_unblocker unblocker;
                replay_savegame save(gamestate_, preferences::compress_saves());
-               save.save_game_interactive(*gui_, "", gui::OK_CANCEL);
+               save.save_game_interactive((*gui_).video(), "", gui::OK_CANCEL);
        } else {
                save_blocker::on_unblock(this,&play_controller::save_replay);
        }

Modified: trunk/src/playcampaign.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playcampaign.cpp?rev=35309&r1=35308&r2=35309&view=diff
==============================================================================
--- trunk/src/playcampaign.cpp (original)
+++ trunk/src/playcampaign.cpp Tue Apr 28 22:32:50 2009
@@ -395,7 +395,7 @@
 
                        if (preferences::save_replays()) {
                                replay_savegame save(gamestate, 
preferences::compress_saves());
-                               save.save_game_interactive(disp, "", 
gui::OK_CANCEL, false, false);
+                               save.save_game_interactive(disp.video(), "", 
gui::OK_CANCEL, false, false);
                        }
                }
 

Modified: trunk/src/playmp_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playmp_controller.cpp?rev=35309&r1=35308&r2=35309&view=diff
==============================================================================
--- trunk/src/playmp_controller.cpp (original)
+++ trunk/src/playmp_controller.cpp Tue Apr 28 22:32:50 2009
@@ -539,7 +539,7 @@
        }
 
        game_savegame save(gamestate_, level_, *gui_, teams_, units_, status_, 
map_, preferences::compress_saves());
-       save.save_game_interactive(*gui_, temp_buf.str(), gui::YES_NO, true);
+       save.save_game_interactive((*gui_).video(), temp_buf.str(), 
gui::YES_NO, true);
 }
 
 void playmp_controller::handle_generic_event(const std::string& name){

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=35309&r1=35308&r2=35309&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Tue Apr 28 22:32:50 2009
@@ -507,7 +507,7 @@
                }
 
                game_savegame save(gamestate_, level_, *gui_, teams_, units_, 
status_, map_, preferences::compress_saves());
-               save.save_game_interactive(*gui_, _("A network disconnection 
has occurred, and the game\ncannot continue. Do you want to save the game?"), 
gui::YES_NO);
+               save.save_game_interactive((*gui_).video(), _("A network 
disconnection has occurred, and the game\ncannot continue. Do you want to save 
the game?"), gui::YES_NO);
                if(disconnect) {
                        throw network::error();
                } else {

Modified: trunk/src/savegame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=35309&r1=35308&r2=35309&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Tue Apr 28 22:32:50 2009
@@ -479,7 +479,7 @@
        , compress_saves_(compress_saves)
 {}
 
-bool savegame::save_game_interactive(display& gui, const std::string& message,
+bool savegame::save_game_interactive(CVideo& video, const std::string& message,
                                                                         
gui::DIALOG_TYPE dialog_type, const bool has_exit_button,
                                                                         const 
bool ask_for_filename)
 {
@@ -492,12 +492,12 @@
        do{ 
                try{
                        if (ask_for_filename){
-                               res = show_save_dialog(gui.video(), 
has_exit_button, message, dialog_type);
+                               res = show_save_dialog(video, has_exit_button, 
message, dialog_type);
                                exit = true;
                        }
 
                        if (res == gui2::twindow::OK)
-                               exit = check_overwrite(gui.video());
+                               exit = check_overwrite(video);
                }
                catch (illegal_filename_exception){
                        exit = false;
@@ -511,7 +511,7 @@
        if (res != gui2::twindow::OK)
                return false;
 
-       return save_game(&gui);
+       return save_game(&video);
 }
 
 int savegame::show_save_dialog(CVideo& video, bool is_oos, const std::string& 
message, const gui::DIALOG_TYPE dialog_type)
@@ -588,7 +588,7 @@
        return save_game();
 }
 
-bool savegame::save_game(display* gui)
+bool savegame::save_game(CVideo* video)
 {
        try {
                Uint32 start, end;
@@ -600,14 +600,13 @@
                end = SDL_GetTicks();
                LOG_SAVE << "Milliseconds to save " << filename_ << ": " << end 
- start << "\n";
 
-               if (gui != NULL && show_confirmation_)
-                       gui::message_dialog(*gui,_("Saved"),_("The game has 
been saved")).show();
+               if (video != NULL && show_confirmation_)
+                       gui2::show_message(*video, _("Saved"), _("The game has 
been saved"));
                
                return true;
        } catch(game::save_game_failed&) {
-               if (gui != NULL){
-                       gui::message_dialog to_show(*gui,_("Error"), 
error_message_);
-                       to_show.show();
+               if (video != NULL){
+                       gui2::show_message(*video,_("Error"), error_message_);
                        //do not bother retrying, since the user can just try 
to save the game again
                        //maybe show a yes-no dialog for "disable autosaves 
now"?
                }
@@ -844,7 +843,7 @@
        if(disable_autosave)
                return;
 
-       save_game(&gui_);
+       save_game(&gui_.video());
 
        savegame_manager::remove_old_auto_saves(autosave_max, 
infinite_autosaves);
 }

Modified: trunk/src/savegame.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.hpp?rev=35309&r1=35308&r2=35309&view=diff
==============================================================================
--- trunk/src/savegame.hpp (original)
+++ trunk/src/savegame.hpp Tue Apr 28 22:32:50 2009
@@ -144,11 +144,11 @@
                to appear, you have to provide the gui parameter. 
                The return value denotes, if the save was successful or not.
        */
-       bool save_game(display* gui = NULL);
+       bool save_game(CVideo* video = NULL);
 
        /** Save a game interactively through the savegame dialog. Used for 
manual midgame and replay
                saves. The return value denotes, if the save was successful or 
not. */
-       bool save_game_interactive(display& gui, const std::string& message,
+       bool save_game_interactive(CVideo& gui, const std::string& message,
                gui::DIALOG_TYPE dialog_type, const bool has_exit_button = 
false,
                const bool ask_for_filename = true);
 


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

Reply via email to