Author: ilor
Date: Thu Apr 23 23:55:52 2009
New Revision: 35147

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35147&view=rev
Log:
backport r34900, r34918 from trunk (added terrain sampler and move clipboard 
ops to RMB context menu)

Modified:
    branches/1.6/changelog
    branches/1.6/data/core/editor/tool-hints.cfg
    branches/1.6/data/themes/editor2.cfg
    branches/1.6/src/editor2/editor_controller.cpp
    branches/1.6/src/editor2/mouse_action.cpp
    branches/1.6/src/editor2/mouse_action.hpp

Modified: branches/1.6/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/changelog?rev=35147&r1=35146&r2=35147&view=diff
==============================================================================
--- branches/1.6/changelog (original)
+++ branches/1.6/changelog Thu Apr 23 23:55:52 2009
@@ -14,6 +14,8 @@
      are not incapacitated (for example, it now ignores stoned units )
  * Editor2:
    * New feature: exporting of selection coordinates to system clipboard
+   * Moved the clipboard actions to a context menu available in paste mode
+   * Added a terrain sampler feature -- ctrl+click when in paint or fill mode 
    * Made "wesnoth -e FILE" work like "wesnoth -e --load FILE" (load the map)
    * Made "wesnoth -e --load DIR" (and consequently "wesnoth -e DIR") set
      DIR as the default map directory for the current session, and start with 

Modified: branches/1.6/data/core/editor/tool-hints.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/data/core/editor/tool-hints.cfg?rev=35147&r1=35146&r2=35147&view=diff
==============================================================================
--- branches/1.6/data/core/editor/tool-hints.cfg (original)
+++ branches/1.6/data/core/editor/tool-hints.cfg Thu Apr 23 23:55:52 2009
@@ -4,13 +4,13 @@
 [editor_tool_hint]
     # wmllint: local spelling left/right
     id="editor-tool-paint"
-    text= _ "Use left/right mouse button to draw fore-/background terrain. 
Hold Shift to paint base layer only."
+    text= _ "Use left/right mouse button to draw fore-/background terrain. 
Hold Shift to paint base layer only. Ctrl+click to sample terrain under cursor."
 [/editor_tool_hint]
 
 [editor_tool_hint]
     # wmllint: local spelling fore-/background
     id="editor-tool-fill"
-    text= _ "Use left/right mouse button to draw fore-/background terrain. 
Hold Shift to paint base layer only."
+    text= _ "Use left/right mouse button to draw fore-/background terrain. 
Hold Shift to paint base layer only. Ctrl+click to sample terrain under cursor."
 [/editor_tool_hint]
 
 [editor_tool_hint]

Modified: branches/1.6/data/themes/editor2.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/data/themes/editor2.cfg?rev=35147&r1=35146&r2=35147&view=diff
==============================================================================
--- branches/1.6/data/themes/editor2.cfg (original)
+++ branches/1.6/data/themes/editor2.cfg Thu Apr 23 23:55:52 2009
@@ -130,7 +130,7 @@
             id=menu-editor-edit
             title= _ "Edit"
             image=lite
-            
items=undo,redo,editor-cut,editor-copy,editor-paste,editor-export-selection-coords,editor-select-all,editor-select-inverse,editor-select-none,
 editor-selection-fill,editor-selection-rotate,editor-selection-flip, 
editor-selection-generate,editor-selection-randomize, 
editor-clipboard-rotate-cw,editor-clipboard-rotate-ccw, 
editor-clipboard-flip-horizontal,editor-clipboard-flip-vertical
+            
items=undo,redo,editor-cut,editor-copy,editor-paste,editor-export-selection-coords,editor-select-all,editor-select-inverse,editor-select-none,
 editor-selection-fill,editor-selection-rotate,editor-selection-flip, 
editor-selection-generate,editor-selection-randomize
             rect="+2,=,+100,="
             xanchor=fixed
             yanchor=fixed
@@ -157,9 +157,9 @@
         [/menu]
 
         [menu]
-            id=menu-editor-selection
+            id=menu-editor-paste-context
             is_context_menu=true
-            
items=menu-editor-starting-position,undo,redo,editor-cut,editor-copy,editor-paste,editor-selection-fill,editor-selection-rotate,editor-selection-flip,editor-selection-generate,editor-selection-randomize
+            
items=editor-paste,editor-clipboard-rotate-cw,editor-clipboard-rotate-ccw,editor-clipboard-flip-horizontal,editor-clipboard-flip-vertical
         [/menu]
 
         [mini_map]
@@ -176,7 +176,7 @@
             image=draw_button_editor
             items=editor-tool-paint
             # wmllint: local spelling left/right
-            tooltip= _ "Use left/right mouse button to draw fore-/background 
terrain. Hold Shift to paint base layer only."
+            tooltip= _ "Use left/right mouse button to draw fore-/background 
terrain. Hold Shift to paint base layer only. Ctrl+click to sample terrain 
under cursor."
             tooltip_name_prepend=yes
             ref=top-right-panel
             #harcoded since the brushes are above, which are hardcoded in 
src/editor/editor_layout.cpp
@@ -189,7 +189,7 @@
             image=flood_button_editor
             items=editor-tool-fill
             # wmllint: local spelling fore-/background
-            tooltip= _ "Use left/right mouse button to draw fore-/background 
terrain. Hold Shift to paint base layer only."
+            tooltip= _ "Use left/right mouse button to draw fore-/background 
terrain. Hold Shift to paint base layer only. Ctrl+click to sample terrain 
under cursor."
             tooltip_name_prepend=yes
             rect="+6,=,+24,+24"
             xanchor=right

Modified: branches/1.6/src/editor2/editor_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/editor2/editor_controller.cpp?rev=35147&r1=35146&r2=35147&view=diff
==============================================================================
--- branches/1.6/src/editor2/editor_controller.cpp (original)
+++ branches/1.6/src/editor2/editor_controller.cpp Thu Apr 23 23:55:52 2009
@@ -414,7 +414,8 @@
        }
        int res = dialogs::show_file_chooser_dialog(gui(), fn, _("Choose a Map 
to Open"));
        if (res == 0) {
-               load_map(fn, force_same_context ? false : use_mdi_);    }
+               load_map(fn, force_same_context ? false : use_mdi_);
+       }
 }
 
 void editor_controller::new_map_dialog()
@@ -1314,7 +1315,7 @@
 
 bool editor_controller::right_click_show_menu(int /*x*/, int /*y*/, const bool 
/*browse*/)
 {
-       return false;
+       return get_mouse_action()->has_context_menu();
 }
 
 bool editor_controller::left_click(int x, int y, const bool browse)
@@ -1327,6 +1328,7 @@
        LOG_ED << "Left click action " << hex_clicked.x << " " << hex_clicked.y 
<< "\n";
        editor_action* a = get_mouse_action()->click_left(*gui_, x, y);
        perform_refresh_delete(a, true);
+       palette_->draw(true);
        return false;
 }
 
@@ -1354,6 +1356,7 @@
        LOG_ED << "Right click action " << hex_clicked.x << " " << 
hex_clicked.y << "\n";
        editor_action* a = get_mouse_action()->click_right(*gui_, x, y);
        perform_refresh_delete(a, true);
+       palette_->draw(true);
        return false;
 }
 

Modified: branches/1.6/src/editor2/mouse_action.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/editor2/mouse_action.cpp?rev=35147&r1=35146&r2=35147&view=diff
==============================================================================
--- branches/1.6/src/editor2/mouse_action.cpp (original)
+++ branches/1.6/src/editor2/mouse_action.cpp Thu Apr 23 23:55:52 2009
@@ -22,6 +22,11 @@
 #include "../gettext.hpp"
 
 namespace editor2 {
+
+bool mouse_action::has_context_menu() const
+{
+       return false;
+}
 
 void mouse_action::move(editor_display& disp, const map_location& hex)
 {
@@ -130,6 +135,15 @@
 bool mouse_action::has_shift_modifier() const
 {
        return key_[SDLK_RSHIFT] || key_[SDLK_LSHIFT];
+}
+
+bool mouse_action::has_ctrl_modifier() const
+{
+#ifdef __APPLE__
+       return key_[SDLK_RMETA] || key_[SDLK_LMETA];
+#else
+       return key_[SDLK_RCTRL] || key_[SDLK_LCTRL];
+#endif
 }
 
 void mouse_action::set_terrain_mouse_overlay(editor_display& disp, 
t_translation::t_terrain fg,
@@ -249,15 +263,39 @@
 }
 
 
+editor_action* mouse_action_paint::click_left(editor_display& disp, int x, int 
y)
+{
+       if (has_ctrl_modifier()) {
+               map_location hex = disp.hex_clicked_on(x, y);
+               terrain_left_ = disp.map().get_terrain(hex);
+               return NULL;
+       } else {
+               return brush_drag_mouse_action::click_left(disp, x, y);
+       }
+}
+
+editor_action* mouse_action_paint::click_right(editor_display& disp, int x, 
int y)
+{
+       if (has_ctrl_modifier()) {
+               map_location hex = disp.hex_clicked_on(x, y);
+               terrain_right_ = disp.map().get_terrain(hex);
+               return NULL;
+       } else {
+               return brush_drag_mouse_action::click_right(disp, x, y);
+       }
+}
+
 editor_action* mouse_action_paint::click_perform_left(
                editor_display& /*disp*/, const std::set<map_location>& hexes)
 {
+       if (has_ctrl_modifier()) return NULL;
        return new editor_action_chain(new editor_action_paint_area(hexes, 
terrain_left_, has_shift_modifier()));
 }
 
 editor_action* mouse_action_paint::click_perform_right(
                editor_display& /*disp*/, const std::set<map_location>& hexes)
 {
+       if (has_ctrl_modifier()) return NULL;
        return new editor_action_chain(new editor_action_paint_area(hexes, 
terrain_right_, has_shift_modifier()));
 }
 
@@ -315,6 +353,11 @@
 }
 
 
+bool mouse_action_paste::has_context_menu() const
+{
+       return true;
+}
+
 std::set<map_location> mouse_action_paste::affected_hexes(
        editor_display& /*disp*/, const map_location& hex)
 {
@@ -348,19 +391,30 @@
 editor_action* mouse_action_fill::click_left(editor_display& disp, int x, int 
y)
 {
        map_location hex = disp.hex_clicked_on(x, y);
-       //TODO only take the base terrain into account when searching for 
contigious terrain when painting base only
-       //or use a different key modifier for that
-       editor_action_fill* a = new editor_action_fill(hex, terrain_left_, 
has_shift_modifier());
-       return a;
+       if (has_ctrl_modifier()) {
+               terrain_left_ = disp.map().get_terrain(hex);
+               return NULL;
+       } else {
+               //TODO only take the base terrain into account when searching 
for contigious terrain when painting base only
+               //or use a different key modifier for that
+               editor_action_fill* a = new editor_action_fill(hex, 
terrain_left_, has_shift_modifier());
+               return a;
+       }
 }
 
 editor_action* mouse_action_fill::click_right(editor_display& disp, int x, int 
y)
 {
        map_location hex = disp.hex_clicked_on(x, y);
-       //TODO only take the base terrain into account when searching for 
contigious terrain when painting base only
-       //or use a different key modifier for that
-       editor_action_fill* a = new editor_action_fill(hex, terrain_right_, 
has_shift_modifier());
-       return a;
+       if (has_ctrl_modifier()) {
+               map_location hex = disp.hex_clicked_on(x, y);
+               terrain_right_ = disp.map().get_terrain(hex);
+               return NULL;
+       } else {
+               //TODO only take the base terrain into account when searching 
for contigious terrain when painting base only
+               //or use a different key modifier for that
+               editor_action_fill* a = new editor_action_fill(hex, 
terrain_right_, has_shift_modifier());
+               return a;
+       }
 }
 
 void mouse_action_fill::set_mouse_overlay(editor_display& disp)

Modified: branches/1.6/src/editor2/mouse_action.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/editor2/mouse_action.hpp?rev=35147&r1=35146&r2=35147&view=diff
==============================================================================
--- branches/1.6/src/editor2/mouse_action.hpp (original)
+++ branches/1.6/src/editor2/mouse_action.hpp Thu Apr 23 23:55:52 2009
@@ -43,6 +43,8 @@
 
        virtual ~mouse_action() {}
 
+       virtual bool has_context_menu() const;
+
        /**
         * Mouse move (not a drag). Never changes anything (other than 
temporary highlihts and similar)
         */
@@ -114,6 +116,7 @@
 protected:
        bool has_alt_modifier() const;
        bool has_shift_modifier() const;
+       bool has_ctrl_modifier() const;
 
        /**
         * Helper function for derived classes that need a active-terrain mouse 
overlay
@@ -228,8 +231,8 @@
 class mouse_action_paint : public brush_drag_mouse_action
 {
 public:
-       mouse_action_paint(const t_translation::t_terrain& terrain_left,
-               const t_translation::t_terrain& terrain_right,
+       mouse_action_paint(t_translation::t_terrain& terrain_left,
+               t_translation::t_terrain& terrain_right,
                const brush* const * const brush, const CKey& key)
        : brush_drag_mouse_action(brush, key)
        , terrain_left_(terrain_left)
@@ -238,6 +241,16 @@
        }
 
        /**
+        * Handle terrain sampling before calling generic handler
+        */
+       editor_action* click_left(editor_display& disp, int x, int y);
+
+       /**
+        * Handle terrain sampling before calling generic handler
+        */
+       editor_action* click_right(editor_display& disp, int x, int y);
+
+       /**
         * Create an appropriate editor_action and return it
         */
        editor_action* click_perform_left(editor_display& disp, const 
std::set<map_location>& hexes);
@@ -250,8 +263,8 @@
        void set_mouse_overlay(editor_display& disp);
 
 protected:
-       const t_translation::t_terrain& terrain_left_;
-       const t_translation::t_terrain& terrain_right_;
+       t_translation::t_terrain& terrain_left_;
+       t_translation::t_terrain& terrain_right_;
 };
 
 /**
@@ -299,6 +312,8 @@
        {
        }
 
+       bool has_context_menu() const;
+
        /**
         * Show an outline of where the paste will go
         */
@@ -329,8 +344,8 @@
 class mouse_action_fill : public mouse_action
 {
 public:
-       mouse_action_fill(const t_translation::t_terrain& terrain_left,
-               const t_translation::t_terrain& terrain_right, const CKey& key)
+       mouse_action_fill(t_translation::t_terrain& terrain_left,
+               t_translation::t_terrain& terrain_right, const CKey& key)
        : mouse_action(key)
        , terrain_left_(terrain_left)
        , terrain_right_(terrain_right)
@@ -355,8 +370,8 @@
        virtual void set_mouse_overlay(editor_display& disp);
 
 protected:
-       const t_translation::t_terrain& terrain_left_;
-       const t_translation::t_terrain& terrain_right_;
+       t_translation::t_terrain& terrain_left_;
+       t_translation::t_terrain& terrain_right_;
 };
 
 /**


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

Reply via email to