From 7c9e68ed7e0ffb35dd081f14bd3a8a6396766f30 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Sat, 11 Jun 2016 18:40:11 -0500 Subject: Added customizable shortcuts for tile map editor --- tools/editor/plugins/tile_map_editor_plugin.cpp | 50 ++++++++++++------------- 1 file changed, 23 insertions(+), 27 deletions(-) (limited to 'tools') diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 5a40777665..b335771e5f 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -893,45 +893,38 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { if (tool!=TOOL_NONE || !mouse_over) return false; - if (k.scancode==KEY_DELETE) { - + if (ED_IS_SHORTCUT("tile_map_editor/erase_selection", p_event)) { _menu_option(OPTION_ERASE_SELECTION); return true; } + if (ED_IS_SHORTCUT("tile_map_editor/select", p_event)) { + tool=TOOL_SELECTING; + selection_active=false; - if (k.mod.command) { - - if (k.scancode==KEY_F) { - - search_box->select_all(); - search_box->grab_focus(); + canvas_item_editor->update(); - return true; - } - if (k.scancode==KEY_B) { + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/duplicate_selection", p_event)) { + _update_copydata(); - tool=TOOL_SELECTING; - selection_active=false; + if (selection_active) { + tool=TOOL_DUPLICATING; canvas_item_editor->update(); return true; } - if (k.scancode==KEY_D) { - - _update_copydata(); - - if (selection_active) { - tool=TOOL_DUPLICATING; - - canvas_item_editor->update(); + } + if (ED_IS_SHORTCUT("tile_map_editor/find_tile", p_event)) { + search_box->select_all(); + search_box->grab_focus(); - return true; - } - } - } else { + return true; + } + if (!k.mod.command) { if (k.scancode==KEY_A) { flip_h=!flip_h; @@ -1308,6 +1301,9 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { flip_v=false; transpose=false; + ED_SHORTCUT("tile_map_editor/erase_selection", TTR("Erase selection"), KEY_DELETE); + ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find tile"), KEY_MASK_CMD+KEY_F); + search_box = memnew( LineEdit ); search_box->set_h_size_flags(SIZE_EXPAND_FILL); search_box->connect("text_entered", this, "_text_entered"); @@ -1349,8 +1345,8 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { p->add_separator(); p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL); p->add_separator(); - p->add_item(TTR("Select"), OPTION_SELECT, KEY_MASK_CMD+KEY_B); - p->add_item(TTR("Duplicate Selection"), OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D); + p->add_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD+KEY_B), OPTION_SELECT); + p->add_shortcut(ED_SHORTCUT("tile_map_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD+KEY_D), OPTION_DUPLICATE); p->add_item(TTR("Erase Selection"), OPTION_ERASE_SELECTION, KEY_DELETE); p->connect("item_pressed", this, "_menu_option"); -- cgit v1.2.3