Explorar o código

Added customizable shortcuts for tile map editor

Daniel J. Ramirez %!s(int64=9) %!d(string=hai) anos
pai
achega
7c9e68ed7e
Modificáronse 1 ficheiros con 23 adicións e 27 borrados
  1. 23 27
      tools/editor/plugins/tile_map_editor_plugin.cpp

+ 23 - 27
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");