From 7c9e68ed7e0ffb35dd081f14bd3a8a6396766f30 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Sat, 11 Jun 2016 18:40:11 -0500 Subject: [PATCH 1/4] Added customizable shortcuts for tile map editor --- .../editor/plugins/tile_map_editor_plugin.cpp | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 5a40777665d..b335771e5f6 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) { + canvas_item_editor->update(); - if (k.scancode==KEY_F) { + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/duplicate_selection", p_event)) { + _update_copydata(); - search_box->select_all(); - search_box->grab_focus(); - - return true; - } - if (k.scancode==KEY_B) { - - tool=TOOL_SELECTING; - selection_active=false; + if (selection_active) { + tool=TOOL_DUPLICATING; canvas_item_editor->update(); return true; } - if (k.scancode==KEY_D) { + } + if (ED_IS_SHORTCUT("tile_map_editor/find_tile", p_event)) { + search_box->select_all(); + search_box->grab_focus(); - _update_copydata(); - - if (selection_active) { - tool=TOOL_DUPLICATING; - - canvas_item_editor->update(); - - 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"); From 7427cbee7b866f589386f5ddd60ded445e6ae0bd Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Sat, 11 Jun 2016 20:29:12 -0500 Subject: [PATCH 2/4] Added some shortcutable actions for animation player editor --- .../animation_player_editor_plugin.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index 4bbcb396aff..c5cf4547e2f 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -1350,19 +1350,23 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { add_anim = memnew( ToolButton ); + ED_SHORTCUT("animation_player_editor/add_animation", TTR("Create new animation in player.")); + add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/add_animation")); add_anim->set_tooltip(TTR("Create new animation in player.")); hb->add_child(add_anim); load_anim = memnew( ToolButton ); + ED_SHORTCUT("animation_player_editor/load_from_disk", TTR("Load animation from disk.")); + add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/load_from_disk")); load_anim->set_tooltip(TTR("Load an animation from disk.")); hb->add_child(load_anim); save_anim = memnew(MenuButton); save_anim->set_tooltip(TTR("Save the current animation")); - save_anim->get_popup()->add_item(TTR("Save"), ANIM_SAVE); - save_anim->get_popup()->add_item(TTR("Save As.."), ANIM_SAVE_AS); + save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save", TTR("Save")), ANIM_SAVE); + save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save_as", TTR("Save As")), ANIM_SAVE_AS); save_anim->set_focus_mode(Control::FOCUS_NONE); hb->add_child(save_anim); @@ -1372,15 +1376,21 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { duplicate_anim = memnew( ToolButton ); hb->add_child(duplicate_anim); + ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate Animation")); + duplicate_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/duplicate_animation")); duplicate_anim->set_tooltip(TTR("Duplicate Animation")); rename_anim = memnew( ToolButton ); hb->add_child(rename_anim); + ED_SHORTCUT("animation_player_editor/rename_animation", TTR("Rename Animation")); + rename_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/rename_animation")); rename_anim->set_tooltip(TTR("Rename Animation")); remove_anim = memnew( ToolButton ); hb->add_child(remove_anim); + ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove Animation")); + remove_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/remove_animation")); remove_anim->set_tooltip(TTR("Remove Animation")); @@ -1402,8 +1412,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { tool_anim = memnew( MenuButton); //tool_anim->set_flat(false); tool_anim->set_tooltip(TTR("Animation Tools")); - tool_anim->get_popup()->add_item(TTR("Copy Animation"),TOOL_COPY_ANIM); - tool_anim->get_popup()->add_item(TTR("Paste Animation"),TOOL_PASTE_ANIM); + tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy Animation")),TOOL_COPY_ANIM); + tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("Paste Animation")),TOOL_PASTE_ANIM); //tool_anim->get_popup()->add_separator(); //tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM); hb->add_child(tool_anim); @@ -1487,8 +1497,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { animation->connect("item_selected", this,"_animation_selected",Vector(),true); resource_edit_anim->connect("pressed", this,"_animation_resource_edit"); file->connect("file_selected", this,"_dialog_action"); - frame->connect("value_changed", this, "_seek_value_changed",Vector(),true); - scale->connect("text_entered", this, "_scale_changed",Vector(),true); + frame->connect("value_changed", this, "_seek_value_changed",Vector(),true); + scale->connect("text_entered", this, "_scale_changed",Vector(),true); From 9b7e21698dc613504de04f4809fca8391047ea42 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Sat, 11 Jun 2016 21:51:54 -0500 Subject: [PATCH 3/4] Added shortcuts to convert_to/MeshLibrary and convert_to/TileSet (pretty handy), dissabled by default. --- tools/editor/editor_node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index b90b017f536..228f564acd2 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -5629,8 +5629,8 @@ EditorNode::EditorNode() { p->add_submenu_item(TTR("Convert To.."),"Export"); pm_export->add_item(TTR("Translatable Strings.."),FILE_DUMP_STRINGS); pm_export->add_separator(); - pm_export->add_item(TTR("MeshLibrary.."),FILE_EXPORT_MESH_LIBRARY); - pm_export->add_item(TTR("TileSet.."),FILE_EXPORT_TILESET); + pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_MeshLibrary", TTR("MeshLibrary..")), FILE_EXPORT_MESH_LIBRARY); + pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_TileSet", TTR("TileSet..")), FILE_EXPORT_TILESET); pm_export->connect("item_pressed",this,"_menu_option"); p->add_separator(); From 5524bcd2b5dd798c2ef054e5c475d2d3e4845d51 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Sun, 12 Jun 2016 17:19:18 -0500 Subject: [PATCH 4/4] Completed shortcuts for Tile Map Editor --- .../editor/plugins/tile_map_editor_plugin.cpp | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index b335771e5f6..d5f85d3333c 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -923,22 +923,23 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { return true; } - - if (!k.mod.command) { - if (k.scancode==KEY_A) { - - flip_h=!flip_h; - mirror_x->set_pressed(flip_h); - canvas_item_editor->update(); - return true; - } - if (k.scancode==KEY_S) { - - flip_v=!flip_v; - mirror_y->set_pressed(flip_v); - canvas_item_editor->update(); - return true; - } + if (ED_IS_SHORTCUT("tile_map_editor/mirror_x", p_event)) { + flip_h=!flip_h; + mirror_x->set_pressed(flip_h); + canvas_item_editor->update(); + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) { + flip_v=!flip_v; + mirror_y->set_pressed(flip_v); + canvas_item_editor->update(); + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/transpose", p_event)) { + transpose = !transpose; + transp->set_pressed(transpose); + canvas_item_editor->update(); + return true; } } break; } @@ -1303,6 +1304,9 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { 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); + ED_SHORTCUT("tile_map_editor/transpose", TTR("Transpose")); + ED_SHORTCUT("tile_map_editor/mirror_x", TTR("Mirror X"), KEY_A); + ED_SHORTCUT("tile_map_editor/mirror_y", TTR("Mirror Y"), KEY_S); search_box = memnew( LineEdit ); search_box->set_h_size_flags(SIZE_EXPAND_FILL); @@ -1347,7 +1351,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { p->add_separator(); 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->add_shortcut(ED_GET_SHORTCUT("tile_map_editor/erase_selection"), OPTION_ERASE_SELECTION); p->connect("item_pressed", this, "_menu_option"); @@ -1357,19 +1361,19 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { transp = memnew( ToolButton ); transp->set_toggle_mode(true); - transp->set_tooltip(TTR("Transpose")); + transp->set_tooltip(TTR("Transpose") + " ("+ED_GET_SHORTCUT("tile_map_editor/transpose")->get_as_text()+")"); transp->set_focus_mode(FOCUS_NONE); transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp)); toolbar->add_child(transp); mirror_x = memnew( ToolButton ); mirror_x->set_toggle_mode(true); - mirror_x->set_tooltip(TTR("Mirror X (A)")); + mirror_x->set_tooltip(TTR("Mirror X") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_x")->get_as_text()+")"); mirror_x->set_focus_mode(FOCUS_NONE); mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x)); toolbar->add_child(mirror_x); mirror_y = memnew( ToolButton ); mirror_y->set_toggle_mode(true); - mirror_y->set_tooltip(TTR("Mirror Y (S)")); + mirror_y->set_tooltip(TTR("Mirror Y") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_y")->get_as_text()+")"); mirror_y->set_focus_mode(FOCUS_NONE); mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y)); toolbar->add_child(mirror_y);