Author: jhinrichs
Date: Sun Apr 26 00:16:46 2009
New Revision: 35220
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35220&view=rev
Log:
Savegame reorganization Step 1: Providing a simpler interface to saving and
loading.
Refactor calling the start-of-scenario save and (hopefully) fix the broken
compilation for TINY_GUI.
Modified:
trunk/src/playcampaign.cpp
trunk/src/savegame.cpp
trunk/src/savegame.hpp
Modified: trunk/src/playcampaign.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playcampaign.cpp?rev=35220&r1=35219&r2=35220&view=diff
==============================================================================
--- trunk/src/playcampaign.cpp (original)
+++ trunk/src/playcampaign.cpp Sun Apr 26 00:16:46 2009
@@ -548,28 +548,20 @@
gamestate.starting_pos = config();
}
+ scenariostart_savegame save(gamestate,
preferences::compress_saves());
+
+#ifdef TINY_GUI
bool retry = true;
while(retry) {
retry = false;
-
-#ifdef TINY_GUI
- const int should_save =
dialogs::get_save_name(disp,
+ retry =
!save.save_game_interactive(disp,
_("Do you want to save your
game?"),
- _("Name:"),
- &gamestate.label);
- if(should_save == 0)
+ gui::YES_NO)
+ }
+#else
+ save.save_game();
#endif /* TINY_GUI */
- {
- try {
- scenariostart_savegame
save(gamestate, preferences::compress_saves());
- save.save_game();
- }
catch(game::save_game_failed&) {
-
gui::show_error_message(disp, _("The game could not be saved"));
- retry = true;
- }
- }
- }
}
if (gamestate.campaign_type != "multiplayer"){
Modified: trunk/src/savegame.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=35220&r1=35219&r2=35220&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Sun Apr 26 00:16:46 2009
@@ -469,7 +469,7 @@
, compress_saves_(compress_saves)
{}
-void savegame::save_game_interactive(display& gui, const std::string& message,
+bool savegame::save_game_interactive(display& gui, const std::string& message,
gui::DIALOG_TYPE dialog_type, const bool has_exit_button,
const
bool ask_for_filename)
{
@@ -529,9 +529,9 @@
throw end_level_exception(QUIT);
if (res != gui2::twindow::OK)
- return;
-
- save_game(&gui);
+ return false;
+
+ return save_game(&gui);
}
void savegame::before_save()
@@ -539,13 +539,13 @@
gamestate_.replay_data = recorder.get_replay_data();
}
-void savegame::save_game(const std::string& filename)
+bool savegame::save_game(const std::string& filename)
{
filename_ = filename;
- save_game();
-}
-
-void savegame::save_game(display* gui)
+ return save_game();
+}
+
+bool savegame::save_game(display* gui)
{
try {
Uint32 start, end;
@@ -559,6 +559,8 @@
if (gui != NULL && show_confirmation_)
gui::message_dialog(*gui,_("Saved"),_("The game has
been saved")).show();
+
+ return true;
} catch(game::save_game_failed&) {
if (gui != NULL){
gui::message_dialog to_show(*gui,_("Error"),
error_message_);
@@ -566,6 +568,8 @@
//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"?
}
+
+ return false;
};
}
Modified: trunk/src/savegame.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.hpp?rev=35220&r1=35219&r2=35220&view=diff
==============================================================================
--- trunk/src/savegame.hpp (original)
+++ trunk/src/savegame.hpp Sun Apr 26 00:16:46 2009
@@ -135,17 +135,20 @@
virtual ~savegame() {}
/** Save a game without any further user interaction. Atm, this is only
used by the
- console_handler save actions */
- void save_game(const std::string& filename);
-
- /** Save a game without any further user interaction. This is used by
autosaves and
+ console_handler save actions. The return value denotes, if the
save was successful or not. */
+ bool save_game(const std::string& filename);
+
+ /**
+ Save a game without any further user interaction. This is used
by autosaves and
automatically generated replay saves. If you want notifying
messages or error messages
- to appear, you have to provide the gui parameter. */
- void save_game(display* gui = NULL);
+ 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);
/** Save a game interactively through the savegame dialog. Used for
manual midgame and replay
- saves. */
- void save_game_interactive(display& gui, const std::string& message,
+ saves. The return value denotes, if the save was successful or
not. */
+ bool save_game_interactive(display& 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