Author: mordante
Date: Sat Apr 5 14:25:18 2008
New Revision: 25567
URL: http://svn.gna.org/viewcvs/wesnoth?rev=25567&view=rev
Log:
Let buttons define the return_value in their definition.
Modified:
trunk/src/gui/widgets/window_builder.cpp
Modified: trunk/src/gui/widgets/window_builder.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=25567&r1=25566&r2=25567&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Sat Apr 5 14:25:18 2008
@@ -55,10 +55,18 @@
private:
tbuilder_button();
public:
- tbuilder_button(const config& cfg) : tbuilder_widget(cfg) {}
+ tbuilder_button(const config& cfg) :
+ tbuilder_widget(cfg),
+ retval_(0)
+ { read_extra(cfg); }
twidget* build () const;
+private:
+ int retval_;
+
+ //! After reading the general part in the constructor read extra data.
+ void read_extra(const config& cfg);
};
struct tbuilder_label : public tbuilder_widget
@@ -67,7 +75,9 @@
private:
tbuilder_label();
public:
- tbuilder_label(const config& cfg) : tbuilder_widget(cfg) {}
+ tbuilder_label(const config& cfg) :
+ tbuilder_widget(cfg)
+ {}
twidget* build () const;
@@ -79,7 +89,9 @@
private:
tbuilder_text_box();
public:
- tbuilder_text_box(const config& cfg) : tbuilder_widget(cfg) {}
+ tbuilder_text_box(const config& cfg) :
+ tbuilder_widget(cfg)
+ {}
twidget* build () const;
@@ -148,7 +160,6 @@
resolutions.push_back(tresolution(**itor));
}
-
return id_;
}
@@ -242,7 +253,6 @@
DBG_G_P << "Window builder: found widget with id '"
<< id << "' and definition '" << definition << "'.\n";
-
}
twidget* tbuilder_button::build() const
@@ -253,16 +263,21 @@
button->set_definition(definition);
button->set_label(label);
- //fixme the reader for button needs to read return_value
- //if 0 test the id to be a common id.
-
- //FIXME needs to be a map as lookup
- button->set_retval(tbutton::get_retval_by_id(id));
+ if(retval_) {
+ button->set_retval(retval_);
+ } else {
+ button->set_retval(tbutton::get_retval_by_id(id));
+ }
DBG_G << "Window builder: placed button '" << id << "' with defintion
'"
<< definition << "'.\n";
return button;
+}
+
+void tbuilder_button::read_extra(const config& cfg)
+{
+ retval_ = lexical_cast_default<int>(cfg["return_value"]);
}
twidget* tbuilder_label::build() const
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits