Author: ilor
Date: Mon Apr 13 22:56:23 2009
New Revision: 34886

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34886&view=rev
Log:
editor action debugging aid

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

Modified: trunk/src/editor2/action.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action.cpp?rev=34886&r1=34885&r2=34886&view=diff
==============================================================================
--- trunk/src/editor2/action.cpp (original)
+++ trunk/src/editor2/action.cpp Mon Apr 13 22:56:23 2009
@@ -60,7 +60,7 @@
        return 1;
 }
 
-std::string editor_action::get_description()
+std::string editor_action::get_description() const
 {
        return "Unknown action";
 }

Modified: trunk/src/editor2/action.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action.hpp?rev=34886&r1=34885&r2=34886&view=diff
==============================================================================
--- trunk/src/editor2/action.hpp (original)
+++ trunk/src/editor2/action.hpp Mon Apr 13 22:56:23 2009
@@ -48,6 +48,7 @@
                {
                }
                void perform_without_undo(map_context& m) const;
+               const char* get_name() const { return "whole_map"; }
        protected:
                editor_map m_;
 };
@@ -71,6 +72,7 @@
                 * the drag.
                 */
                virtual void extend(const editor_map& map, const 
std::set<map_location>& locs) = 0;
+               const char* get_name() const { return "extendable"; }
 };
 
 /**
@@ -156,6 +158,8 @@
                 */
                void perform_without_undo(map_context& m) const;
 
+               const char* get_name() const { return "chain"; }
+
        protected:
                /**
                 * The action pointers owned by this action chain
@@ -175,6 +179,7 @@
                : loc_(loc)
                {
                }
+               const char* get_name() const { return "location"; }
        protected:
                map_location loc_;
 };
@@ -190,6 +195,7 @@
                : editor_action_location(loc), t_(t)
                {
                }
+               const char* get_name() const { return "location_terrain"; }
        protected:
                t_translation::t_terrain t_;
 };
@@ -207,6 +213,7 @@
                bool add_location(const map_location& loc);
                void add_locations(const std::set<map_location>& locs);
                void extend(const editor_map& map, const 
std::set<map_location>& locs);
+               const char* get_name() const { return "area"; }
        protected:
                std::set<map_location> area_;
 };
@@ -224,6 +231,7 @@
                editor_action_paste* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
                void extend(const editor_map& map, const 
std::set<map_location>& locs);
+               const char* get_name() const { return "paste"; }
        protected:
                map_location offset_;
                map_fragment paste_;
@@ -243,6 +251,7 @@
                }
                editor_action_paint_hex* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "paint_hex"; }
 };
 
 /**
@@ -258,6 +267,7 @@
                }
                editor_action_paste* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "paint_area"; }
        protected:
                t_translation::t_terrain t_;
                bool one_layer_;
@@ -276,6 +286,7 @@
                }
                editor_action_paint_area* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "fill"; }
        protected:
                bool one_layer_;
 };
@@ -292,6 +303,7 @@
                }
                editor_action* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "starting_pos"; }
        protected:
                int player_;
 };
@@ -309,6 +321,7 @@
                void extend(const editor_map& map, const 
std::set<map_location>& locs);
                editor_action* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "select"; }
 };
 
 /**
@@ -324,6 +337,7 @@
                void extend(const editor_map& map, const 
std::set<map_location>& locs);
                editor_action* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "deselect"; }
 };
 
 /**
@@ -337,6 +351,7 @@
                }
                editor_action_deselect* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "select_all"; }
 };
 
 /**
@@ -350,6 +365,7 @@
                }
                editor_action_select* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "select_none"; }
 };
 
 /**
@@ -363,6 +379,7 @@
                }
                editor_action_select_inverse* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "select_inverse"; }
 };
 
 /**
@@ -378,6 +395,7 @@
                {
                }
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "resize"; }
        protected:
                int x_size_;
                int y_size_;
@@ -399,6 +417,7 @@
                }
                editor_action_rotate_map* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "rotate"; }
        protected:
                int angle_;
 };
@@ -411,6 +430,7 @@
                {
                }
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "apply_mask"; }
        private:
                gamemap mask_;
 };
@@ -423,6 +443,7 @@
                {
                }
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "create_mask"; }
        private:
                gamemap target_;
 };
@@ -439,6 +460,7 @@
                }
                editor_action_paste* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "plot_route"; }
        protected:
                map_location loc2_;
 };
@@ -455,6 +477,7 @@
                }
                editor_action_paste* perform(map_context& mc) const;
                void perform_without_undo(map_context& mc) const;
+               const char* get_name() const { return "shuffle_area"; }
 };
 
 

Modified: trunk/src/editor2/action_base.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action_base.hpp?rev=34886&r1=34885&r2=34886&view=diff
==============================================================================
--- trunk/src/editor2/action_base.hpp (original)
+++ trunk/src/editor2/action_base.hpp Mon Apr 13 22:56:23 2009
@@ -70,13 +70,18 @@
                virtual int action_count() const;
 
                /**
+                * @return a short name of this action type, defaults to unknown
+                */
+               virtual const char* get_name() const { return "unknown"; }
+
+               /**
                 * A textual description of the action. For use
                 * e.g. in the undo menu, to have a "Undo: Fill with
                 * Grassland" item rather than just "Undo". Should be
                 * overriden by derived Actions, defaults to a debug
                 * message.
                 */
-               virtual std::string get_description();
+               virtual std::string get_description() const;
 
                /**
                 * Debugging aid. Return an unique identifier of this Action.

Modified: trunk/src/editor2/map_context.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/map_context.cpp?rev=34886&r1=34885&r2=34886&view=diff
==============================================================================
--- trunk/src/editor2/map_context.cpp (original)
+++ trunk/src/editor2/map_context.cpp Mon Apr 13 22:56:23 2009
@@ -184,7 +184,8 @@
 
 void map_context::perform_action(const editor_action& action)
 {
-       LOG_ED << "Performing action " << action.get_id() << ", actions count 
is " << action.get_instance_count() << "\n";
+       LOG_ED << "Performing action " << action.get_id() << ": " << 
action.get_name() 
+               << ", actions count is " << action.get_instance_count() << "\n";
        editor_action* undo = action.perform(*this);
        if (actions_since_save_ < 0) {
                //set to a value that will make it impossible to get to zero, 
as at this point
@@ -199,7 +200,8 @@
 
 void map_context::perform_partial_action(const editor_action& action)
 {
-       LOG_ED << "Performing (partial) action " << action.get_id() << ", 
actions count is " << action.get_instance_count() << "\n";
+       LOG_ED << "Performing (partial) action " << action.get_id() << ": " << 
action.get_name() 
+               << ", actions count is " << action.get_instance_count() << "\n";
        if (!can_undo()) {
                throw editor_logic_exception("Empty undo stack in 
perform_partial_action()");
        }
@@ -212,7 +214,6 @@
        undo_chain->prepend_action(undo);
        clear_stack(redo_stack_);
 }
-
 bool map_context::modified() const
 {
        return actions_since_save_ != 0;


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

Reply via email to