Author: jhinrichs
Date: Tue Apr 28 00:25:43 2009
New Revision: 35280
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35280&view=rev
Log:
Savegame reorganization Step 1: Providing a simpler interface to saving and
loading.
Some more savegame.cpp refactoring.
Modified:
trunk/data/gui/default/window/game_save_oos.cfg
trunk/src/savegame.cpp
trunk/src/savegame.hpp
Modified: trunk/data/gui/default/window/game_save_oos.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/game_save_oos.cfg?rev=35280&r1=35279&r2=35280&view=diff
==============================================================================
--- trunk/data/gui/default/window/game_save_oos.cfg (original)
+++ trunk/data/gui/default/window/game_save_oos.cfg Tue Apr 28 00:25:43 2009
@@ -154,6 +154,7 @@
[button]
id =
"quit_game"
definition = "default"
+
return_value = "2"
label =
_ "Quit Game"
[/button]
Modified: trunk/src/savegame.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=35280&r1=35279&r2=35280&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Tue Apr 28 00:25:43 2009
@@ -477,7 +477,6 @@
int res = 0;
- int overwrite = 0;
bool exit = true;
static bool ignore_all = false;
@@ -512,17 +511,8 @@
set_filename(filename);
}
- std::string filename = filename_;
- if (res == gui2::twindow::OK &&
savegame_manager::save_game_exists(filename, compress_saves_)) {
- std::stringstream s;
- s << _("Save already exists. Do you want to
overwrite it?")
- << std::endl << _("Name: ") << filename;
- overwrite = gui::dialog(gui,_("Overwrite?"),
- s.str(), gui::YES_NO).show();
- exit = (overwrite == 0);
- } else {
- exit = true;
- }
+ if (res == gui2::twindow::OK)
+ exit = check_overwrite(gui);
}
catch (illegal_filename_exception){
exit = false;
@@ -530,7 +520,7 @@
}
while (!exit);
- if (res == 2)
+ if (res == 2) //Quit game
throw end_level_exception(QUIT);
if (res != gui2::twindow::OK)
@@ -763,6 +753,21 @@
}
}
+bool savegame::check_overwrite(display& gui)
+{
+ std::string filename = filename_;
+ if (savegame_manager::save_game_exists(filename, compress_saves_)) {
+ std::stringstream s;
+ s << _("Save already exists. Do you want to overwrite it?")
+ << std::endl << _("Name: ") << filename;
+ int overwrite = gui::dialog(gui,_("Overwrite?"),
+ s.str(), gui::YES_NO).show();
+ return overwrite == 0;
+ } else {
+ return true;
+ }
+}
+
void savegame::check_filename(const std::string& filename, display& gui)
{
if (is_gzip_file(filename)) {
Modified: trunk/src/savegame.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.hpp?rev=35280&r1=35279&r2=35280&view=diff
==============================================================================
--- trunk/src/savegame.hpp (original)
+++ trunk/src/savegame.hpp Tue Apr 28 00:25:43 2009
@@ -174,6 +174,8 @@
virtual void create_filename() {}
/** Check, if the filename contains illegal constructs like ".gz". */
void check_filename(const std::string& filename, display& gui);
+ /** Ask the user if an existing file should be overwritten. */
+ bool savegame::check_overwrite(display& gui);
/** The actual method for saving the game to disk. All interactive
filename choosing and
data manipulation has to happen before calling this method. */
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits