Author: ilor
Date: Tue Apr 14 13:14:52 2009
New Revision: 34900
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34900&view=rev
Log:
Editor: 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
Modified:
trunk/changelog
trunk/data/core/editor/tool-hints.cfg
trunk/data/themes/editor2.cfg
trunk/src/editor2/editor_controller.cpp
trunk/src/editor2/mouse_action.cpp
trunk/src/editor2/mouse_action.hpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=34900&r1=34899&r2=34900&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Apr 14 13:14:52 2009
@@ -36,6 +36,8 @@
* Added ability to load maps referenced in scenario files
* Added ability to work with maps embedded in scenario files (saving works
in a limited scope)
+ * 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
* FormulaAI:
* Fixed bug #13230: added debug_float FormulaAI function to allow debugging
via floating popups on the specified hex
Modified: trunk/data/core/editor/tool-hints.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/core/editor/tool-hints.cfg?rev=34900&r1=34899&r2=34900&view=diff
==============================================================================
--- trunk/data/core/editor/tool-hints.cfg (original)
+++ trunk/data/core/editor/tool-hints.cfg Tue Apr 14 13:14: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: trunk/data/themes/editor2.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/themes/editor2.cfg?rev=34900&r1=34899&r2=34900&view=diff
==============================================================================
--- trunk/data/themes/editor2.cfg (original)
+++ trunk/data/themes/editor2.cfg Tue Apr 14 13:14: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: trunk/src/editor2/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=34900&r1=34899&r2=34900&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Tue Apr 14 13:14:52 2009
@@ -423,7 +423,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()
@@ -1333,7 +1334,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)
@@ -1346,6 +1347,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;
}
@@ -1373,6 +1375,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: trunk/src/editor2/mouse_action.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/mouse_action.cpp?rev=34900&r1=34899&r2=34900&view=diff
==============================================================================
--- trunk/src/editor2/mouse_action.cpp (original)
+++ trunk/src/editor2/mouse_action.cpp Tue Apr 14 13:14: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)
-{
+ 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: trunk/src/editor2/mouse_action.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/mouse_action.hpp?rev=34900&r1=34899&r2=34900&view=diff
==============================================================================
--- trunk/src/editor2/mouse_action.hpp (original)
+++ trunk/src/editor2/mouse_action.hpp Tue Apr 14 13:14: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