mail[Wesnoth-commits] r41460 - in /branches/fendrin_editor/src: editor/mouse_action.cpp editor/mouse_action.hpp map_label.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by fabianmueller5 on March 06, 2010 - 02:48:
Author: fendrin
Date: Sat Mar  6 02:48:24 2010
New Revision: 41460

URL: http://svn.gna.org/viewcvs/wesnoth?rev=41460&view=rev
Log:
Implemented drag and drop replacement for the Labels.

Modified:
    branches/fendrin_editor/src/editor/mouse_action.cpp
    branches/fendrin_editor/src/editor/mouse_action.hpp
    branches/fendrin_editor/src/map_label.hpp

Modified: branches/fendrin_editor/src/editor/mouse_action.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_editor/src/editor/mouse_action.cpp?rev=41460&r1=41459&r2=41460&view=diff
==============================================================================
--- branches/fendrin_editor/src/editor/mouse_action.cpp (original)
+++ branches/fendrin_editor/src/editor/mouse_action.cpp Sat Mar  6 02:48:24 
2010
@@ -416,11 +416,6 @@
        set_terrain_mouse_overlay(disp, terrain_left_, terrain_right_);
 }
 
-editor_action* mouse_action_map_label::click_left(editor_display& /*disp*/, 
int /*x*/, int /*y*/)
-{
-       click_ = true;
-       return NULL;
-}
 
 editor_action* mouse_action_map_label::click_right(editor_display& /*disp*/, 
int /*x*/, int /*y*/)
 {
@@ -449,17 +444,53 @@
                image = scale_surface(adjust_surface_alpha(image, alpha), 
zoom, zoom);
                disp.set_mouseover_hex_overlay(image);
                temp_unit_ = &(unit_it->second);
-       }
+       } else { temp_unit_ = NULL; }
 
        click_ = true;
        return NULL;
 }
 
-
+editor_action* mouse_action_map_label::click_left(editor_display& disp, int 
x, int y)
+{
+       click_ = true;
+       map_location hex = disp.hex_clicked_on(x, y);
+       clicked_on_ = hex;
+
+       return NULL;
+}
 editor_action* mouse_action_map_label::up_right(editor_display& disp, int x, 
int y)
 {
        map_location hex = disp.hex_clicked_on(x, y);
        return new editor_action_label_delete(hex);
+}
+editor_action* mouse_action_map_label::drag_left(editor_display& disp, int 
x, int y
+               , bool& partial, editor_action* last_undo)
+{
+       //TODO implement
+       return NULL;
+}
+editor_action* mouse_action_map_label::drag_end(editor_display& disp, int x, 
int y)
+{
+       map_location hex = disp.hex_clicked_on(x, y);
+       editor_action_chain* chain = NULL;
+       if (clicked_on_.valid()) {
+
+       const label& label_clicked = 
*(disp.map().get_game_labels().get_label(clicked_on_));
+
+//     label* label_moved = new label(label_clicked.team_name()
+//                     , label_clicked.team_name()
+//                     , label_clicked.location()
+//                     , disp.map().get_game_labels()
+//                     , label_clicked.colour()
+//                     , label_clicked.visible_in_fog()
+//                     , label_clicked.visible_in_shroud()
+//                     );
+
+       chain = new editor_action_chain();
+       chain->append_action(new editor_action_label(hex, 
label_clicked.text(), label_clicked.team_name()));
+       chain->append_action(new editor_action_label_delete(clicked_on_));
+       }
+       return chain;
 }
 
 editor_action* mouse_action_unit::up_right(editor_display& disp, int x, int 
y)

Modified: branches/fendrin_editor/src/editor/mouse_action.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_editor/src/editor/mouse_action.hpp?rev=41460&r1=41459&r2=41460&view=diff
==============================================================================
--- branches/fendrin_editor/src/editor/mouse_action.hpp (original)
+++ branches/fendrin_editor/src/editor/mouse_action.hpp Sat Mar  6 02:48:24 
2010
@@ -30,7 +30,7 @@
  * an appropriate editor_action object. Mouse actions may store some 
temporary data
  * such as the last clicked hex for better handling of click-drag. They 
should *not* modify
  * the map or trigger refreshes, but may set brush locations and similar 
overlays that
- * should be visible around the mouse cursor, hence the display references 
are not const.
+ * should be visible around the mouse cursor, hence the display references 
are no constants.
  */
 class mouse_action
 {
@@ -47,7 +47,7 @@
        virtual bool has_context_menu() const;
 
        /**
-        * Mouse move (not a drag). Never changes anything (other than 
temporary highlihts and similar)
+        * Mouse move (not a drag). Never changes anything (other than 
temporary highlights and similar)
         */
        void move(editor_display& disp, const map_location& hex);
 
@@ -57,7 +57,7 @@
        void update_brush_highlights(editor_display& disp, const 
map_location& hex);
 
        /**
-        * Locations that would be affected by a click, used by move to 
update highlights. Defauts to higlight the mouseover hex.
+        * Locations that would be affected by a click, used by move to 
update highlights. Defaults to highlight the mouseover hex.
         * Maybe also used for actually performing the action in click() or 
drag().
         */
        virtual std::set<map_location> affected_hexes(editor_display& disp, 
const map_location& hex);
@@ -460,7 +460,7 @@
 {
 public:
        mouse_action_map_label(const CKey& key)
-       : mouse_action(key), click_(false)
+       : mouse_action(key), click_(false), clicked_on_()
          {
          }
 
@@ -478,10 +478,21 @@
         */
        editor_action* up_right(editor_display& disp, int x, int y);
 
+       /**
+        * Drag operation. A click should have occured earlier. Defaults to 
no action.
+        */
+       editor_action* drag_left(editor_display& disp, int x, int y, bool& 
partial, editor_action* last_undo);
+
+       /**
+        * TODO
+        */
+       editor_action* drag_end(editor_display& disp, int x, int y);
+
        virtual void set_mouse_overlay(editor_display& disp);
 
 private:
        bool click_;
+       map_location clicked_on_;
 };
 
 } //end namespace editor

Modified: branches/fendrin_editor/src/map_label.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_editor/src/map_label.hpp?rev=41460&r1=41459&r2=41460&view=diff
==============================================================================
--- branches/fendrin_editor/src/map_label.hpp (original)
+++ branches/fendrin_editor/src/map_label.hpp Sat Mar  6 02:48:24 2010
@@ -128,10 +128,10 @@
 class label
 {
 public:
-       label(const std::string&,
-                       const std::string&,
-                       const map_location&,
-                       const labels&,
+       label(const std::string& text,
+                       const std::string& team_name,
+                       const map_location& loc,
+                       const labels& parent,
                        const SDL_Color colour = font::NORMAL_COLOUR,
                        const bool visible_in_fog = true,
                        const bool visible_in_shroud = false);




Related Messages


Powered by MHonArc, Updated Sat Mar 06 11:20:08 2010