From fc09ac19addda751cd41a9f7a11861ea14f6ad05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=9Aniatowski?= Date: Sun, 17 Aug 2008 14:17:19 +0100 Subject: [PATCH] editor2 hotkey tweaks --- data/themes/editor2.cfg | 2 +- src/editor2/action.cpp | 15 +++++++++++++++ src/editor2/action.hpp | 13 +++++++++++++ src/editor2/editor_controller.cpp | 10 +++++++--- src/hotkeys.cpp | 1 + src/hotkeys.hpp | 2 +- 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/data/themes/editor2.cfg b/data/themes/editor2.cfg index 9543a14690b..759813d58c4 100644 --- a/data/themes/editor2.cfg +++ b/data/themes/editor2.cfg @@ -130,7 +130,7 @@ id=menu-editor-edit title= _ "Edit" image=lite - items=undo,redo,editor-cut,editor-copy,editor-paste,editor-select-all,editor-select-inverse,editor-selection-fill,editor-selection-rotate,editor-selection-flip,editor-selection-generate,editor-selection-randomize + items=undo,redo,editor-cut,editor-copy,editor-paste,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 diff --git a/src/editor2/action.cpp b/src/editor2/action.cpp index 139b5d750cb..7ed85577540 100644 --- a/src/editor2/action.cpp +++ b/src/editor2/action.cpp @@ -248,6 +248,21 @@ void editor_action_select_all::perform_without_undo(map_context& mc) const mc.set_everything_changed(); } +editor_action_select_xor* editor_action_select_none::perform(map_context& mc) const +{ + + std::set current = mc.get_map().selection(); + mc.get_map().clear_selection(); + mc.set_everything_changed(); + return new editor_action_select_xor(current); +} +void editor_action_select_none::perform_without_undo(map_context& mc) const +{ + mc.get_map().clear_selection(); + mc.set_everything_changed(); +} + + editor_action_select_inverse* editor_action_select_inverse::perform(map_context& mc) const { perform_without_undo(mc); diff --git a/src/editor2/action.hpp b/src/editor2/action.hpp index 7f16dd8beb5..e5be2b462cd 100644 --- a/src/editor2/action.hpp +++ b/src/editor2/action.hpp @@ -250,6 +250,19 @@ class editor_action_select_all : public editor_action void perform_without_undo(map_context& mc) const; }; +/** + * Clear selection + */ +class editor_action_select_none : public editor_action +{ + public: + editor_action_select_none() + { + } + editor_action_select_xor* perform(map_context& mc) const; + void perform_without_undo(map_context& mc) const; +}; + /** * Invert the selection */ diff --git a/src/editor2/editor_controller.cpp b/src/editor2/editor_controller.cpp index 818123a866d..a6ad5c31e33 100644 --- a/src/editor2/editor_controller.cpp +++ b/src/editor2/editor_controller.cpp @@ -101,7 +101,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video) } } hotkey_set_mouse_action(hotkey::HOTKEY_EDITOR_TOOL_PAINT); - + hotkey::get_hotkey(hotkey::HOTKEY_QUIT_GAME).set_description(_("Quit Editor")); background_terrain_ = t_translation::GRASS_LAND; foreground_terrain_ = t_translation::MOUNTAIN; set_mouseover_overlay(); @@ -459,17 +459,18 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int return true; //tool selection always possible case HOTKEY_EDITOR_CUT: case HOTKEY_EDITOR_COPY: - case HOTKEY_EDITOR_SELECTION_ROTATE: - case HOTKEY_EDITOR_SELECTION_FLIP: case HOTKEY_EDITOR_SELECTION_FILL: case HOTKEY_EDITOR_SELECTION_RANDOMIZE: return !get_map().selection().empty(); + case HOTKEY_EDITOR_SELECTION_ROTATE: + case HOTKEY_EDITOR_SELECTION_FLIP: case HOTKEY_EDITOR_SELECTION_GENERATE: return false; //not implemented case HOTKEY_EDITOR_PASTE: return !clipboard_.empty(); case HOTKEY_EDITOR_SELECT_ALL: case HOTKEY_EDITOR_SELECT_INVERSE: + case HOTKEY_EDITOR_SELECT_NONE: case HOTKEY_EDITOR_MAP_RESIZE: case HOTKEY_EDITOR_MAP_FLIP_X: case HOTKEY_EDITOR_MAP_FLIP_Y: @@ -514,6 +515,7 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde return true; case HOTKEY_EDITOR_TERRAIN_PALETTE_SWAP: palette_->swap(); + if (get_mouse_action()->uses_terrains()) set_mouseover_overlay(); return true; case HOTKEY_EDITOR_TOOL_PAINT: case HOTKEY_EDITOR_TOOL_FILL: @@ -541,6 +543,8 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde case HOTKEY_EDITOR_SELECT_INVERSE: perform_refresh(editor_action_select_inverse()); return true; + case HOTKEY_EDITOR_SELECT_NONE: + perform_refresh(editor_action_select_none()); case HOTKEY_EDITOR_SELECTION_FILL: fill_selection(); return true; diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 720ddb6e678..ec9e39f8f6f 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -137,6 +137,7 @@ const struct { { hotkey::HOTKEY_EDITOR_MAP_SAVE, "editor-map-save", N_("Save Map"), false, hotkey::SCOPE_EDITOR }, { hotkey::HOTKEY_EDITOR_MAP_SAVE_AS, "editor-map-save-as", N_("Save Map As"), false, hotkey::SCOPE_EDITOR }, { hotkey::HOTKEY_EDITOR_MAP_REVERT, "editor-map-revert", N_("Revert All Changes"), false, hotkey::SCOPE_EDITOR }, + { hotkey::HOTKEY_EDITOR_MAP_INFO, "editor-map-info", N_("Map Information"), false, hotkey::SCOPE_EDITOR }, { hotkey::HOTKEY_EDITOR_TERRAIN_PALETTE_SWAP, "editor-terrain-palette-swap", N_("Swap fore- and background terrains"), false, hotkey::SCOPE_EDITOR }, { hotkey::HOTKEY_EDITOR_TOOL_NEXT, "editor-tool-next", N_("Next Tool"), false, hotkey::SCOPE_EDITOR }, diff --git a/src/hotkeys.hpp b/src/hotkeys.hpp index e6c0f9d7b57..84cb2db4dfa 100644 --- a/src/hotkeys.hpp +++ b/src/hotkeys.hpp @@ -73,7 +73,7 @@ enum HOTKEY_COMMAND { #ifdef USE_EDITOR2 HOTKEY_EDITOR_QUIT_TO_DESKTOP, HOTKEY_EDITOR_MAP_NEW, HOTKEY_EDITOR_MAP_LOAD, HOTKEY_EDITOR_MAP_SAVE, - HOTKEY_EDITOR_MAP_SAVE_AS, HOTKEY_EDITOR_MAP_REVERT, + HOTKEY_EDITOR_MAP_SAVE_AS, HOTKEY_EDITOR_MAP_REVERT, HOTKEY_EDITOR_MAP_INFO, HOTKEY_EDITOR_TERRAIN_PALETTE_SWAP, HOTKEY_EDITOR_TOOL_NEXT, HOTKEY_EDITOR_TOOL_PAINT, HOTKEY_EDITOR_TOOL_FILL, HOTKEY_EDITOR_TOOL_SELECT, HOTKEY_EDITOR_TOOL_STARTING_POSITION,