Author: ilor
Date: Tue Jul 29 12:02:25 2008
New Revision: 28260

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28260&view=rev
Log:
editor2: flip and resize actions, minor action tweaks

Modified:
    trunk/src/editor2/action.cpp
    trunk/src/editor2/action.hpp
    trunk/src/editor2/action_base.hpp

Modified: trunk/src/editor2/action.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action.cpp?rev=28260&r1=28259&r2=28260&view=diff
==============================================================================
--- trunk/src/editor2/action.cpp (original)
+++ trunk/src/editor2/action.cpp Tue Jul 29 12:02:25 2008
@@ -27,6 +27,13 @@
 std::string editor_action::get_description()
 {
        return "Unknown action";
+}
+
+editor_action* editor_action::perform(editor_map& map) const
+{
+       editor_action* undo = new editor_action_whole_map(map);
+       perform_without_undo(map);
+       return undo;
 }
 
 void draw_terrain(editor_map& map, t_translation::t_terrain terrain, 
@@ -67,11 +74,6 @@
        }
 }
        
-editor_action_whole_map* editor_action_whole_map::perform(editor_map& m) const 
{
-       editor_action_whole_map* undo = new editor_action_whole_map(m);
-       perform_without_undo(m);
-       return undo;
-}
 void editor_action_whole_map::perform_without_undo(editor_map& m) const {
        m = m_;
 }
@@ -202,40 +204,32 @@
        }
 }
 
-editor_action_whole_map* editor_action_resize_map::perform(editor_map& 
/*map*/) const
+void editor_action_resize_map::perform_without_undo(editor_map& map) const
+{
+       map.resize(x_size_, y_size_, x_offset_, y_offset_);
+}
+
+void editor_action_rotate_map::perform_without_undo(editor_map& /*map*/) const
 {
        throw editor_action_not_implemented();
 }
-void editor_action_resize_map::perform_without_undo(editor_map& /*map*/) const
+
+void editor_action_flip_x::perform_without_undo(editor_map& map) const
+{
+       map.flip_x();
+}
+void editor_action_flip_y::perform_without_undo(editor_map& map) const
+{
+       map.flip_y();
+}
+
+editor_action_paste* editor_action_plot_route::perform(editor_map& /*map*/) 
const
 {
        throw editor_action_not_implemented();
 }
-
-editor_action_rotate_map* editor_action_rotate_map::perform(editor_map& 
/*map*/) const
+void editor_action_plot_route::perform_without_undo(editor_map& /*map*/) const
 {
        throw editor_action_not_implemented();
 }
-void editor_action_rotate_map::perform_without_undo(editor_map& /*map*/) const
-{
-       throw editor_action_not_implemented();
-}
-
-editor_action_mirror_map* editor_action_mirror_map::perform(editor_map& 
/*map*/) const
-{
-       throw editor_action_not_implemented();
-}
-void editor_action_mirror_map::perform_without_undo(editor_map& /*map*/) const
-{
-       throw editor_action_not_implemented();
-}
-
-editor_action_paste* editor_action_plot_route::perform(editor_map& /*map*/) 
const
-{
-       throw editor_action_not_implemented();
-}
-void editor_action_plot_route::perform_without_undo(editor_map& /*map*/) const
-{
-       throw editor_action_not_implemented();
-}
 
 } //end namespace editor2

Modified: trunk/src/editor2/action.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action.hpp?rev=28260&r1=28259&r2=28260&view=diff
==============================================================================
--- trunk/src/editor2/action.hpp (original)
+++ trunk/src/editor2/action.hpp Tue Jul 29 12:02:25 2008
@@ -38,7 +38,6 @@
         : m_(m)
         {
         }
-        editor_action_whole_map* perform(editor_map& m) const;
         void perform_without_undo(editor_map& m) const;
     protected:
         editor_map m_;
@@ -193,18 +192,19 @@
 class editor_action_resize_map : public editor_action
 {
        public:
-               editor_action_resize_map(int to_x_size, int to_y_size)
-               : to_x_size_(to_x_size), to_y_size_(to_y_size)
-               {
-               }
-               editor_action_whole_map* perform(editor_map& map) const;
+               editor_action_resize_map(int x_size, int y_size, int x_offset, 
int y_offset)
+               : x_size_(x_size), y_size_(y_size), x_offset_(x_offset), 
y_offset_(y_offset)
+               {
+               }
                void perform_without_undo(editor_map& map) const;
        protected:
-               int to_x_size_;
-               int to_y_size_;
-};
-
-//basic rotations. angle is multiplied by 60 degrees so 3 does a 180 turn
+               int x_size_;
+               int y_size_;
+               int x_offset_;
+               int y_offset_;
+};
+
+//basic rotations. angle is multiplied by 90 degrees so 2 does a 180 turn
 class editor_action_rotate_map : public editor_action
 {
        public:
@@ -218,19 +218,22 @@
                int angle_;
 };
 
-//mirror. angle is multiplied by 30 degrees
-//e.g. 0 is mirror by x axis, 3 is by y axis.
-class editor_action_mirror_map : public editor_action
-{
-       public:
-               editor_action_mirror_map(int angle)
-               : angle_(angle)
-               {
-               }
-               editor_action_mirror_map* perform(editor_map& map) const;
-               void perform_without_undo(editor_map& map) const;
-       protected:
-               int angle_;
+class editor_action_flip_x : public editor_action
+{
+       public:
+               editor_action_flip_x()
+               {
+               }
+               void perform_without_undo(editor_map& map) const;
+};
+
+class editor_action_flip_y : public editor_action
+{
+       public:
+               editor_action_flip_y()
+               {
+               }
+               void perform_without_undo(editor_map& map) const;
 };
 
 //plot a route between two points

Modified: trunk/src/editor2/action_base.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action_base.hpp?rev=28260&r1=28259&r2=28260&view=diff
==============================================================================
--- trunk/src/editor2/action_base.hpp (original)
+++ trunk/src/editor2/action_base.hpp Tue Jul 29 12:02:25 2008
@@ -47,9 +47,10 @@
                
                /**
                 * Perform the action, returning an undo action that, when 
performed, will reverse any effects of this action.
-                * The undo action object is owned by the caller.
+                * The undo action object is owned by the caller. Default 
behaviour is to create a whole-map undo, call
+                * the perform_without_undo function and return the undo object.
                 */
-               virtual editor_action* perform(editor_map&) const = 0;
+               virtual editor_action* perform(editor_map&) const;
                
                /**
                 * Perform the action without creating an undo action.


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to