Author: mordante
Date: Fri Jul 25 19:41:17 2008
New Revision: 28192
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28192&view=rev
Log:
Switch the editor dialog to the new field types.
Modified:
trunk/src/gui/dialogs/editor_new_map.cpp
trunk/src/gui/dialogs/editor_new_map.hpp
Modified: trunk/src/gui/dialogs/editor_new_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_new_map.cpp?rev=28192&r1=28191&r2=28192&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_new_map.cpp (original)
+++ trunk/src/gui/dialogs/editor_new_map.cpp Fri Jul 25 19:41:17 2008
@@ -15,6 +15,7 @@
#include "gui/dialogs/editor_new_map.hpp"
#include "foreach.hpp"
+#include "gui/dialogs/field.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/listbox.hpp"
#include "gui/widgets/settings.hpp"
@@ -34,9 +35,30 @@
namespace gui2 {
-teditor_new_map::teditor_new_map()
-: map_width_(0), map_height_(0)
+teditor_new_map::teditor_new_map() :
+ map_width_(register_text("width", false)),
+ map_height_(register_text("height", false))
{
+}
+
+void teditor_new_map::set_map_width(int value)
+{
+ map_width_->set_value(lexical_cast<std::string>(value));
+}
+
+int teditor_new_map::map_width() const
+{
+ return lexical_cast_default<int>(map_width_->get_value());
+}
+
+void teditor_new_map::set_map_height(int value)
+{
+ map_height_->set_value(lexical_cast<std::string>(value));
+}
+
+int teditor_new_map::map_height() const
+{
+ return lexical_cast_default<int>(map_height_->get_value());
}
twindow teditor_new_map::build_window(CVideo& video)
@@ -44,27 +66,4 @@
return build(video, get_id(EDITOR_NEW_MAP));
}
-void teditor_new_map::pre_show(CVideo& /*video*/, twindow& window)
-{
- ttext_box* width_widget =
dynamic_cast<ttext_box*>(window.find_widget("width", false));
- VALIDATE(width_widget, missing_widget("width"));
- width_widget->set_value(lexical_cast<std::string>(map_width_));
-
- ttext_box* height_widget =
dynamic_cast<ttext_box*>(window.find_widget("height", false));
- VALIDATE(height_widget, missing_widget("height"));
- height_widget->set_value(lexical_cast<std::string>(map_height_));
-}
-
-void teditor_new_map::post_show(twindow& window)
-{
- if(get_retval() == tbutton::OK) {
- ttext_box* width_widget =
dynamic_cast<ttext_box*>(window.find_widget("width", false));
- ttext_box* height_widget =
dynamic_cast<ttext_box*>(window.find_widget("height", false));
- assert(width_widget);
- assert(height_widget);
- map_width_ =
lexical_cast_default<int>(width_widget->get_value(), 0);
- map_height_ =
lexical_cast_default<int>(height_widget->get_value(), 0);
- }
-}
-
} // namespace gui2
Modified: trunk/src/gui/dialogs/editor_new_map.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_new_map.hpp?rev=28192&r1=28191&r2=28192&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_new_map.hpp (original)
+++ trunk/src/gui/dialogs/editor_new_map.hpp Fri Jul 25 19:41:17 2008
@@ -24,23 +24,21 @@
public:
teditor_new_map();
- void set_map_width(int value) { map_width_ = value; }
- int map_width() const { return map_width_; }
- void set_map_height(int value) { map_height_ = value; }
- int map_height() const { return map_height_; }
+ void set_map_width(int value);
+ int map_width() const;
+ void set_map_height(int value);
+ int map_height() const;
private:
- int map_width_;
- int map_height_;
+ /**
+ * NOTE the map sizes are stored in a text variable since there is no
+ * integer edit widget yet.
+ */
+ tfield_text* map_width_;
+ tfield_text* map_height_;
/** Inherited from tdialog. */
twindow build_window(CVideo& video);
-
- /** Inherited from tdialog. */
- void pre_show(CVideo& video, twindow& window);
-
- /** Inherited from tdialog. */
- void post_show(twindow& window);
};
} // namespace gui2
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits