Author: mordante
Date: Sat Mar 5 14:54:30 2011
New Revision: 48757
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48757&view=rev
Log:
Change the new map dialog to the new execute.
The unit test 'seems' to function; it worked before rebasing. After
rebasing the tests are broken by fendrin's recent commits. So the test
is not conclusive.
Modified:
trunk/src/editor/editor_controller.cpp
trunk/src/gui/dialogs/editor_new_map.cpp
trunk/src/gui/dialogs/editor_new_map.hpp
trunk/src/tests/gui/test_gui2.cpp
Modified: trunk/src/editor/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor_controller.cpp?rev=48757&r1=48756&r2=48757&view=diff
==============================================================================
--- trunk/src/editor/editor_controller.cpp (original)
+++ trunk/src/editor/editor_controller.cpp Sat Mar 5 14:54:30 2011
@@ -444,17 +444,14 @@
void editor_controller::new_map_dialog()
{
- if (!use_mdi_ && !confirm_discard()) return;
- gui2::teditor_new_map dialog;
- dialog.set_map_width(get_map().w());
- dialog.set_map_height(get_map().h());
-
- dialog.show(gui().video());
- int res = dialog.get_retval();
- if(res == gui2::twindow::OK) {
- int w = dialog.map_width();
- int h = dialog.map_height();
- t_translation::t_terrain fill = t_translation::GRASS_LAND;
+ if (!use_mdi_ && !confirm_discard()) {
+ return;
+ }
+
+ int w = get_map().w();
+ int h = get_map().h();
+ if(gui2::teditor_new_map::execute(w, h, gui().video())) {
+ const t_translation::t_terrain fill = t_translation::GRASS_LAND;
new_map(w, h, fill, use_mdi_);
}
}
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=48757&r1=48756&r2=48757&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_new_map.cpp (original)
+++ trunk/src/gui/dialogs/editor_new_map.cpp Sat Mar 5 14:54:30 2011
@@ -42,30 +42,10 @@
REGISTER_DIALOG(editor_new_map)
-teditor_new_map::teditor_new_map() :
- map_width_(register_integer("width", false)),
- map_height_(register_integer("height", false))
+teditor_new_map::teditor_new_map(int& width, int& height)
+ : map_width_(register_integer("width", false, width))
+ , map_height_(register_integer("height", false, height))
{
-}
-
-void teditor_new_map::set_map_width(int value)
-{
- map_width_->set_cache_value(value);
-}
-
-int teditor_new_map::map_width() const
-{
- return map_width_->get_cache_value();
-}
-
-void teditor_new_map::set_map_height(int value)
-{
- map_height_->set_cache_value(value);
-}
-
-int teditor_new_map::map_height() const
-{
- return map_height_->get_cache_value();
}
} // 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=48757&r1=48756&r2=48757&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_new_map.hpp (original)
+++ trunk/src/gui/dialogs/editor_new_map.hpp Sat Mar 5 14:54:30 2011
@@ -23,12 +23,24 @@
class teditor_new_map : public tdialog
{
public:
- teditor_new_map();
- void set_map_width(int value);
- int map_width() const;
- void set_map_height(int value);
- int map_height() const;
+ /**
+ * Constructor.
+ *
+ * @param width [in] The initial width of the map.
+ * @param width [out] The selected width of the map if the
dialog
+ * returns @ref twindow::OK undefined
otherwise.
+ * @param height [in] The initial height of the map.
+ * @param height [out] The selected height of the map if the
dialog
+ * returns @ref twindow::OK undefined
otherwise.
+ */
+ teditor_new_map(int& width, int& height);
+
+ /** The excute function see @ref tdialog for more information. */
+ static bool execute(int& width, int& height, CVideo& video)
+ {
+ return teditor_new_map(width, height).show(video);
+ }
private:
/**
Modified: trunk/src/tests/gui/test_gui2.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/gui/test_gui2.cpp?rev=48757&r1=48756&r2=48757&view=diff
==============================================================================
--- trunk/src/tests/gui/test_gui2.cpp (original)
+++ trunk/src/tests/gui/test_gui2.cpp Sat Mar 5 14:54:30 2011
@@ -474,6 +474,17 @@
};
template<>
+struct twrapper<gui2::teditor_new_map>
+{
+ static gui2::teditor_new_map* create()
+ {
+ static int width;
+ static int height;
+ return new gui2::teditor_new_map(width, height);
+ }
+};
+
+template<>
struct twrapper<gui2::teditor_settings>
{
static void dummy_callback(int, int, int) {}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits