Author: mordante
Date: Sun Mar 13 20:18:25 2011
New Revision: 48897
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48897&view=rev
Log:
Add a function to always save dialog fields.
Sometimes it's wanted to always save the fields when the dialog closes,
this option allows that.
Modified:
trunk/src/gui/dialogs/dialog.cpp
trunk/src/gui/dialogs/dialog.hpp
Modified: trunk/src/gui/dialogs/dialog.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.cpp?rev=48897&r1=48896&r2=48897&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.cpp (original)
+++ trunk/src/gui/dialogs/dialog.cpp Sun Mar 13 20:18:25 2011
@@ -64,7 +64,7 @@
*/
events::discard(SDL_EVENTMASK(DOUBLE_CLICK_EVENT));
- if(retval_ == twindow::OK) {
+ if(retval_ == twindow::OK || always_save_fields_) {
finalize_fields(*window);
}
Modified: trunk/src/gui/dialogs/dialog.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.hpp?rev=48897&r1=48896&r2=48897&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.hpp (original)
+++ trunk/src/gui/dialogs/dialog.hpp Sun Mar 13 20:18:25 2011
@@ -133,6 +133,7 @@
public:
tdialog() :
retval_(0),
+ always_save_fields_(false),
fields_(),
focus_(),
restore_(true)
@@ -159,6 +160,11 @@
/***** ***** ***** setters / getters for members ***** ****** *****/
int get_retval() const { return retval_; }
+
+ void set_always_save_fields(const bool always_save_fields)
+ {
+ always_save_fields_ = always_save_fields;
+ }
void set_restore(const bool restore) { restore_ = restore; }
@@ -339,6 +345,16 @@
int retval_;
/**
+ * Always save the fields upon closing.
+ *
+ * Normally fields are only saved when the twindow::OK button is
pressed.
+ * With this flag set is always saves. Be careful with the flag since it
+ * also updates upon canceling, which can be a problem when the field
sets
+ * a preference.
+ */
+ bool always_save_fields_;
+
+ /**
* Contains the automatically managed fields.
*
* Since the fields are automatically managed and there are no search
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits