Author: jhinrichs
Date: Tue Apr 28 22:12:39 2009
New Revision: 35308
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35308&view=rev
Log:
Moving the savefile overwrite dialog to gui2.
Added:
trunk/data/gui/default/window/game_save_overwrite.cfg (with props)
Modified:
trunk/src/gui/dialogs/game_save.cpp
trunk/src/gui/dialogs/game_save.hpp
trunk/src/gui/widgets/settings.cpp
trunk/src/gui/widgets/settings.hpp
trunk/src/savegame.cpp
trunk/src/savegame.hpp
Added: trunk/data/gui/default/window/game_save_overwrite.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/game_save_overwrite.cfg?rev=35308&view=auto
==============================================================================
--- trunk/data/gui/default/window/game_save_overwrite.cfg (added)
+++ trunk/data/gui/default/window/game_save_overwrite.cfg Tue Apr 28 22:12:39
2009
@@ -1,0 +1,120 @@
+#textdomain wesnoth-lib
+###
+### Definition of the window to ask for the savegame filename
+###
+
+[window]
+ id = "game_save_overwrite"
+ description = "Ask if an existing savefile should be overwritten."
+
+ [resolution]
+ definition = "default"
+
+ automatic_placement = "true"
+ vertical_placement = "center"
+ horizontal_placement = "center"
+
+ [grid]
+
+ [row]
+ grow_factor = 0
+
+ [column]
+ grow_factor = 1
+
+ border = "all"
+ border_size = 5
+ horizontal_alignment = "left"
+ [label]
+ id = "lblTitle"
+ definition = "title"
+
+ label = _ "Overwrite?"
+ [/label]
+
+ [/column]
+
+ [/row]
+
+ [row]
+ grow_factor = 0
+
+ [column]
+ grow_factor = 1
+
+ border = "all"
+ border_size = 5
+ horizontal_alignment = "left"
+ [label]
+ id = "lblMessage"
+ definition = "default"
+
+ label = _ "Save already exists.
Do you want to overwrite it?"
+ [/label]
+
+ [/column]
+
+ [/row]
+
+ [row]
+ grow_factor = 0
+
+ [column]
+ grow_factor = 1
+ horizontal_grow = "true"
+
+ [grid]
+
+ [row]
+ grow_factor = 0
+
+ [column]
+
+ [spacer]
+
definition = "default"
+ [/spacer]
+
+ [/column]
+
+ [column]
+ border = "all"
+ border_size = 5
+
horizontal_alignment = "right"
+
+ [button]
+ id =
"ok"
+
definition = "default"
+
+
size_text = _ "Yes"
+ label =
_ "Yes"
+ [/button]
+
+ [/column]
+
+ [column]
+ border = "all"
+ border_size = 5
+
horizontal_alignment = "right"
+
+ [button]
+ id =
"cancel"
+
definition = "default"
+
+ label =
_ "No"
+ [/button]
+
+ [/column]
+
+ [/row]
+
+ [/grid]
+
+ [/column]
+
+ [/row]
+
+ [/grid]
+
+ [/resolution]
+
+[/window]
Propchange: trunk/data/gui/default/window/game_save_overwrite.cfg
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/src/gui/dialogs/game_save.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/game_save.cpp?rev=35308&r1=35307&r2=35308&view=diff
==============================================================================
--- trunk/src/gui/dialogs/game_save.cpp (original)
+++ trunk/src/gui/dialogs/game_save.cpp Tue Apr 28 22:12:39 2009
@@ -17,6 +17,7 @@
#include "gui/dialogs/game_save.hpp"
#include "foreach.hpp"
+#include "gettext.hpp"
#include "gui/dialogs/field.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/label.hpp"
@@ -101,5 +102,21 @@
ignore_all_ = btnIgnoreAll_->get_widget_value(window);
}
+tgame_save_overwrite::tgame_save_overwrite(const std::string& filename)
+ : filename_(filename)
+{}
+
+twindow* tgame_save_overwrite::build_window(CVideo& video)
+{
+ return build(video, get_id(GAME_SAVE_OVERWRITE));
+}
+
+void tgame_save_overwrite::pre_show(CVideo& video, twindow& window)
+{
+ tlabel* lblMessage =
dynamic_cast<tlabel*>(window.find_widget("lblMessage", false));
+ VALIDATE(lblMessage, missing_widget("lblMessage"));
+ lblMessage->set_label(lblMessage->label() + "\n" + _("Name: ") +
filename_);
+}
+
} // namespace gui2
Modified: trunk/src/gui/dialogs/game_save.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/game_save.hpp?rev=35308&r1=35307&r2=35308&view=diff
==============================================================================
--- trunk/src/gui/dialogs/game_save.hpp (original)
+++ trunk/src/gui/dialogs/game_save.hpp Tue Apr 28 22:12:39 2009
@@ -76,6 +76,22 @@
bool ignore_all_;
};
+class tgame_save_overwrite : public tdialog
+{
+public:
+ tgame_save_overwrite(const std::string& filename);
+
+private:
+ /** Inherited from tdialog. */
+ twindow* build_window(CVideo& video);
+
+ /** Inherited from tgame_save. */
+ void pre_show(CVideo& video, twindow& window);
+
+
+ std::string filename_;
+};
+
}
#endif
Modified: trunk/src/gui/widgets/settings.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=35308&r1=35307&r2=35308&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Tue Apr 28 22:12:39 2009
@@ -90,6 +90,7 @@
window_type_list[GAME_SAVE] = "game_save";
window_type_list[GAME_SAVE_MESSAGE] = "game_save_message";
window_type_list[GAME_SAVE_OOS] = "game_save_oos";
+ window_type_list[GAME_SAVE_OVERWRITE] = "game_save_overwrite";
#ifndef DISABLE_EDITOR2
window_type_list[EDITOR_NEW_MAP] = "editor_new_map";
window_type_list[EDITOR_GENERATE_MAP] = "editor_generate_map";
Modified: trunk/src/gui/widgets/settings.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=35308&r1=35307&r2=35308&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Tue Apr 28 22:12:39 2009
@@ -68,6 +68,7 @@
GAME_SAVE, /**< Save game dialog. */
GAME_SAVE_MESSAGE, /**< Save game dialog with additional
message. */
GAME_SAVE_OOS, /**< Save game dialog for processing
OOS. */
+ GAME_SAVE_OVERWRITE, /**< Ask for overwriting an existing savegame.
*/
COUNT /**<
* The last one to hold the number of items
and as
* sentinel.
Modified: trunk/src/savegame.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=35308&r1=35307&r2=35308&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Tue Apr 28 22:12:39 2009
@@ -39,6 +39,16 @@
#define ERR_SAVE LOG_STREAM(err, log_engine)
#ifdef _WIN32
+ #ifdef INADDR_ANY
+ #undef INADDR_ANY
+ #endif
+ #ifdef INADDR_BROADCAST
+ #undef INADDR_BROADCAST
+ #endif
+ #ifdef INADDR_NONE
+ #undef INADDR_NONE
+ #endif
+
#include <windows.h>
/**
@@ -481,11 +491,13 @@
do{
try{
- if (ask_for_filename)
+ if (ask_for_filename){
res = show_save_dialog(gui.video(),
has_exit_button, message, dialog_type);
+ exit = true;
+ }
if (res == gui2::twindow::OK)
- exit = check_overwrite(gui);
+ exit = check_overwrite(gui.video());
}
catch (illegal_filename_exception){
exit = false;
@@ -537,16 +549,13 @@
return res;
}
-bool savegame::check_overwrite(display& gui)
+bool savegame::check_overwrite(CVideo& video)
{
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;
+ gui2::tgame_save_overwrite dlg(filename);
+ dlg.show(video);
+ return dlg.get_retval() == gui2::twindow::OK;
} else {
return true;
}
@@ -557,9 +566,6 @@
if (is_gzip_file(filename)) {
gui2::show_message(video, _("Error"), _("Save names should not
end on '.gz'. "
"Please choose a different name."));
- //gui::message_dialog(gui, _("Error"),
- // _("Save names should not end on '.gz'. "
- // "Please choose a different name.")).show();
throw illegal_filename_exception();
}
}
Modified: trunk/src/savegame.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.hpp?rev=35308&r1=35307&r2=35308&view=diff
==============================================================================
--- trunk/src/savegame.hpp (original)
+++ trunk/src/savegame.hpp Tue Apr 28 22:12:39 2009
@@ -177,7 +177,7 @@
/** Display the save game dialog. */
int show_save_dialog(CVideo& video, bool is_oos, const std::string&
message, const gui::DIALOG_TYPE dialog_type);
/** Ask the user if an existing file should be overwritten. */
- bool check_overwrite(display& gui);
+ bool check_overwrite(CVideo& video);
/** 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