Author: mordante
Date: Sat Mar 19 22:04:08 2011
New Revision: 48937
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48937&view=rev
Log:
Polish the tsave_game dialogs.
Modified:
trunk/src/gui/dialogs/game_save.cpp
trunk/src/gui/dialogs/game_save.hpp
trunk/src/savegame.cpp
trunk/src/tests/gui/test_gui2.cpp
Modified: trunk/src/gui/dialogs/game_save.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/game_save.cpp?rev=48937&r1=48936&r2=48937&view=diff
==============================================================================
--- trunk/src/gui/dialogs/game_save.cpp (original)
+++ trunk/src/gui/dialogs/game_save.cpp Sat Mar 19 22:04:08 2011
@@ -47,56 +47,36 @@
REGISTER_DIALOG(game_save)
-tgame_save::tgame_save(const std::string& title, const std::string& filename) :
- txtFilename_(register_text("txtFilename", false)),
- title_(title),
- filename_(filename)
+tgame_save::tgame_save(std::string& filename, const std::string& title)
{
+ register_text2("txtFilename", false, filename, true);
+ register_label2("lblTitle", true, title);
}
-
-void tgame_save::pre_show(CVideo& /*video*/, twindow& window)
-{
- assert(txtFilename_);
-
- find_widget<tlabel>(&window, "lblTitle", false).set_label(title_);
-
- txtFilename_->set_widget_value(window, filename_);
- window.keyboard_capture(txtFilename_->widget(window));
-}
-
-void tgame_save::post_show(twindow& window)
-{
- filename_ = txtFilename_->get_widget_value(window);
-}
-
REGISTER_DIALOG(game_save_message)
-tgame_save_message::tgame_save_message(const std::string& title, const
std::string& filename, const std::string& message)
- : tgame_save(title, filename),
- message_(message)
-{}
-
-void tgame_save_message::pre_show(CVideo& video, twindow& window)
+tgame_save_message::tgame_save_message(
+ const std::string& title
+ , const std::string& filename
+ , const std::string& message)
{
- find_widget<tlabel>(&window, "lblMessage", false).set_label(message_);
-
- tgame_save::pre_show(video, window);
+ register_label2("lblTitle", true, title);
+ register_label2("txtFilename", false, filename);
+ register_label2("lblMessage", true, message);
}
REGISTER_DIALOG(game_save_oos)
-tgame_save_oos::tgame_save_oos(const std::string& title, const std::string&
filename, const std::string& message)
- : tgame_save_message(title, filename, message),
- btnIgnoreAll_(register_bool("ignore_all", false)),
- ignore_all_(false)
-{}
-
-void tgame_save_oos::post_show(twindow& window)
+tgame_save_oos::tgame_save_oos(
+ bool& ignore_all
+ , const std::string& title
+ , const std::string& filename
+ , const std::string& message)
{
- tgame_save::post_show(window);
-
- ignore_all_ = btnIgnoreAll_->get_widget_value(window);
+ register_label2("lblTitle", true, title);
+ register_label2("txtFilename", false, filename);
+ register_label2("lblMessage", true, message);
+ register_bool2("ignore_all", true, ignore_all);
}
} // 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=48937&r1=48936&r2=48937&view=diff
==============================================================================
--- trunk/src/gui/dialogs/game_save.hpp (original)
+++ trunk/src/gui/dialogs/game_save.hpp Sat Mar 19 22:04:08 2011
@@ -24,58 +24,66 @@
class tgame_save : public tdialog
{
public:
- tgame_save(const std::string& title, const std::string& filename="");
- const std::string& filename() const { return filename_; }
+ tgame_save(std::string& filename, const std::string& title);
-protected:
- /** Inherited from tdialog. */
- void pre_show(CVideo& video, twindow& window);
-
- /** Inherited from tdialog. */
- void post_show(twindow& window);
+ static bool execute(std::string& filename
+ , const std::string& title
+ , CVideo& video)
+ {
+ return tgame_save(filename, title).show(video);
+ }
private:
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
-
- tfield_text* txtFilename_;
- std::string title_;
- std::string filename_;
};
-class tgame_save_message : public tgame_save
+class tgame_save_message : public tdialog
{
public:
- tgame_save_message(const std::string& title, const std::string&
filename="", const std::string& message="");
+ tgame_save_message(const std::string& title
+ , const std::string& filename
+ , const std::string& message);
+ static bool execute(
+ const std::string& title
+ , const std::string& filename
+ , const std::string& message
+ , CVideo& video)
+ {
+ return tgame_save_message(title, filename, message).show(video);
+ }
+
+private:
+
+ /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
+ virtual const std::string& window_id() const;
+};
+
+class tgame_save_oos : public tdialog
+{
+public:
+ tgame_save_oos(
+ bool& ignore_all
+ , const std::string& title
+ , const std::string& filename
+ , const std::string& message);
+
+ static bool execute(
+ bool& ignore_all
+ , const std::string& title
+ , const std::string& filename
+ , const std::string& message
+ , CVideo& video)
+ {
+ return tgame_save_oos(ignore_all, title, filename,
message).show(video);
+ }
private:
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
- /** Inherited from tgame_save. */
- void pre_show(CVideo& video, twindow& window);
-
- std::string message_;
-};
-
-class tgame_save_oos : public tgame_save_message
-{
-public:
- tgame_save_oos(const std::string& title, const std::string&
filename="", const std::string& message="");
-
- bool ignore_all() const { return ignore_all_; }
-
-private:
- /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
- virtual const std::string& window_id() const;
-
- /** Inherited from tdialog. */
- void post_show(twindow& window);
-
- tfield_bool* btnIgnoreAll_;
- bool ignore_all_;
};
}
Modified: trunk/src/savegame.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/savegame.cpp?rev=48937&r1=48936&r2=48937&view=diff
==============================================================================
--- trunk/src/savegame.cpp (original)
+++ trunk/src/savegame.cpp Sat Mar 19 22:04:08 2011
@@ -680,15 +680,13 @@
std::string filename = filename_;
if (dialog_type == gui::OK_CANCEL){
- gui2::tgame_save dlg(title_, filename);
+ gui2::tgame_save dlg(filename, title_);
dlg.show(video);
- filename = dlg.filename();
res = dlg.get_retval();
}
else if (dialog_type == gui::YES_NO){
gui2::tgame_save_message dlg(title_, filename, message);
dlg.show(video);
- filename = dlg.filename();
res = dlg.get_retval();
}
@@ -1006,10 +1004,8 @@
std::string filename = this->filename();
if (!ignore_all){
- gui2::tgame_save_oos dlg(title(), filename, message);
+ gui2::tgame_save_oos dlg(ignore_all, title(), filename,
message);
dlg.show(video);
- filename = dlg.filename();
- ignore_all = dlg.ignore_all();
res = dlg.get_retval();
}
Modified: trunk/src/tests/gui/test_gui2.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/gui/test_gui2.cpp?rev=48937&r1=48936&r2=48937&view=diff
==============================================================================
--- trunk/src/tests/gui/test_gui2.cpp (original)
+++ trunk/src/tests/gui/test_gui2.cpp Sat Mar 19 22:04:08 2011
@@ -507,7 +507,9 @@
{
static gui2::tgame_save* create()
{
- return new gui2::tgame_save("Title", "filename");
+ static std::string title = "Title";
+ static std::string filename = "filename";
+ return new gui2::tgame_save(title, filename);
}
};
@@ -517,7 +519,10 @@
{
static gui2::tgame_save_message* create()
{
- return new gui2::tgame_save_message("Title", "filename",
"message");
+ static std::string title = "Title";
+ static std::string filename = "filename";
+ static std::string message = "message";
+ return new gui2::tgame_save_message(title, filename, message);
}
};
@@ -527,7 +532,11 @@
{
static gui2::tgame_save_oos* create()
{
- return new gui2::tgame_save_oos("Title", "filename", "message");
+ static bool ignore_all = false;
+ static std::string title = "Title";
+ static std::string filename = "filename";
+ static std::string message = "message";
+ return new gui2::tgame_save_oos(ignore_all, title, filename,
message);
}
};
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits