diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-08-11 11:20:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 11:20:45 +0200 |
commit | c00303ff55f2a67d5cb1a031070e3b1fe7b15a9e (patch) | |
tree | 41c169c558961c715283d70822a703bd0a7c0706 /editor | |
parent | a902f760634432adcb5f74b3b6cd27a7275a320f (diff) | |
parent | fa3a32a2d6b054543645b0d4752514c90732b935 (diff) |
Merge pull request #47378 from aaronfranke/use-input-enums
Use key enum instead of plain integers for input code
Diffstat (limited to 'editor')
-rw-r--r-- | editor/action_map_editor.cpp | 38 | ||||
-rw-r--r-- | editor/animation_track_editor.cpp | 2 | ||||
-rw-r--r-- | editor/create_dialog.cpp | 2 | ||||
-rw-r--r-- | editor/editor_command_palette.cpp | 4 | ||||
-rw-r--r-- | editor/editor_command_palette.h | 2 | ||||
-rw-r--r-- | editor/editor_help_search.cpp | 2 | ||||
-rw-r--r-- | editor/editor_layouts_dialog.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 4 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | editor/editor_settings.h | 2 | ||||
-rw-r--r-- | editor/plugins/animation_player_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/texture_region_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/theme_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/property_selector.cpp | 2 | ||||
-rw-r--r-- | editor/quick_open.cpp | 2 |
17 files changed, 49 insertions, 33 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 9126e0512e..7aa63f899b 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -249,10 +249,10 @@ void InputEventConfigurationDialog::_listen_window_input(const Ref<InputEvent> & // Maintain physical keycode option state if (physical_key_checkbox->is_pressed()) { k->set_physical_keycode(k->get_keycode()); - k->set_keycode(0); + k->set_keycode(KEY_NONE); } else { - k->set_keycode(k->get_physical_keycode()); - k->set_physical_keycode(0); + k->set_keycode((Key)k->get_physical_keycode()); + k->set_physical_keycode(KEY_NONE); } } @@ -435,10 +435,10 @@ void InputEventConfigurationDialog::_physical_keycode_toggled(bool p_checked) { if (p_checked) { k->set_physical_keycode(k->get_keycode()); - k->set_keycode(0); + k->set_keycode(KEY_NONE); } else { - k->set_keycode(k->get_physical_keycode()); - k->set_physical_keycode(0); + k->set_keycode((Key)k->get_physical_keycode()); + k->set_physical_keycode(KEY_NONE); } _set_event(k); @@ -452,20 +452,20 @@ void InputEventConfigurationDialog::_input_list_item_selected() { return; } - int input_type = selected->get_parent()->get_meta("__type"); + InputEventConfigurationDialog::InputType input_type = (InputEventConfigurationDialog::InputType)(int)selected->get_parent()->get_meta("__type"); switch (input_type) { case InputEventConfigurationDialog::INPUT_KEY: { - int kc = selected->get_meta("__keycode"); + Key keycode = (Key)(int)selected->get_meta("__keycode"); Ref<InputEventKey> k; k.instantiate(); if (physical_key_checkbox->is_pressed()) { - k->set_physical_keycode(kc); - k->set_keycode(0); + k->set_physical_keycode(keycode); + k->set_keycode(KEY_NONE); } else { - k->set_physical_keycode(0); - k->set_keycode(kc); + k->set_physical_keycode(KEY_NONE); + k->set_keycode(keycode); } // Maintain modifier state from checkboxes @@ -479,10 +479,10 @@ void InputEventConfigurationDialog::_input_list_item_selected() { _set_event(k); } break; case InputEventConfigurationDialog::INPUT_MOUSE_BUTTON: { - int idx = selected->get_meta("__index"); + MouseButton idx = (MouseButton)(int)selected->get_meta("__index"); Ref<InputEventMouseButton> mb; mb.instantiate(); - mb->set_button_index((MouseButton)idx); + mb->set_button_index(idx); // Maintain modifier state from checkboxes mb->set_alt_pressed(mod_checkboxes[MOD_ALT]->is_pressed()); mb->set_shift_pressed(mod_checkboxes[MOD_SHIFT]->is_pressed()); @@ -494,22 +494,20 @@ void InputEventConfigurationDialog::_input_list_item_selected() { _set_event(mb); } break; case InputEventConfigurationDialog::INPUT_JOY_BUTTON: { - int idx = selected->get_meta("__index"); - Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference((JoyButton)idx); + JoyButton idx = (JoyButton)(int)selected->get_meta("__index"); + Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference(idx); _set_event(jb); } break; case InputEventConfigurationDialog::INPUT_JOY_MOTION: { - int axis = selected->get_meta("__axis"); + JoyAxis axis = (JoyAxis)(int)selected->get_meta("__axis"); int value = selected->get_meta("__value"); Ref<InputEventJoypadMotion> jm; jm.instantiate(); - jm->set_axis((JoyAxis)axis); + jm->set_axis(axis); jm->set_axis_value(value); _set_event(jm); } break; - default: - break; } } diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index f40dc3c64a..964c37906f 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -5759,6 +5759,8 @@ void AnimationTrackEditor::_pick_track_filter_input(const Ref<InputEvent> &p_ie) pick_track->get_scene_tree()->get_scene_tree()->call("_gui_input", k); pick_track->get_filter_line_edit()->accept_event(); } break; + default: + break; } } } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 3389b53317..eeab0fc2f5 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -359,6 +359,8 @@ void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) { search_options->call("_gui_input", k); search_box->accept_event(); } break; + default: + break; } } } diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index 5a4fcff0f8..bffd0655a7 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -153,6 +153,8 @@ void EditorCommandPalette::_sbox_input(const Ref<InputEvent> &p_ie) { case KEY_PAGEDOWN: { search_options->call("_gui_input", k); } break; + default: + break; } } } @@ -289,7 +291,7 @@ EditorCommandPalette::EditorCommandPalette() { set_hide_on_ok(false); } -Ref<Shortcut> ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name, uint32_t p_keycode, String p_command_name) { +Ref<Shortcut> ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name, Key p_keycode, String p_command_name) { if (p_command_name.is_empty()) { p_command_name = p_name; } diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h index ddf897c250..cfd8b964c8 100644 --- a/editor/editor_command_palette.h +++ b/editor/editor_command_palette.h @@ -90,6 +90,6 @@ public: static EditorCommandPalette *get_singleton(); }; -Ref<Shortcut> ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name, uint32_t p_keycode = 0, String p_command = ""); +Ref<Shortcut> ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name, Key p_keycode = KEY_NONE, String p_command = ""); #endif //EDITOR_COMMAND_PALETTE_H diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 57f0345dad..2b5eee4c1f 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -74,6 +74,8 @@ void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) { results_tree->call("_gui_input", key); search_box->accept_event(); } break; + default: + break; } } } diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 0c8660c216..b1f8ba5d20 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -58,6 +58,8 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) { hide(); set_input_as_handled(); } break; + default: + break; } } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 52672e9cc8..8748d021b6 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6301,7 +6301,7 @@ EditorNode::EditorNode() { p = project_menu->get_popup(); - p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/project_settings", TTR("Project Settings..."), 0, TTR("Project Settings")), RUN_SETTINGS); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/project_settings", TTR("Project Settings..."), KEY_NONE, TTR("Project Settings")), RUN_SETTINGS); p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); vcs_actions_menu = VersionControlEditorPlugin::get_singleton()->get_version_control_actions_panel(); @@ -6314,7 +6314,7 @@ EditorNode::EditorNode() { vcs_actions_menu->add_item(TTR("Shut Down Version Control"), RUN_VCS_SHUT_DOWN); p->add_separator(); - p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/export", TTR("Export..."), 0, TTR("Export")), FILE_EXPORT_PROJECT); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/export", TTR("Export..."), KEY_NONE, TTR("Export")), FILE_EXPORT_PROJECT); p->add_item(TTR("Install Android Build Template..."), FILE_INSTALL_ANDROID_SOURCE); p->add_item(TTR("Open Project Data Folder"), RUN_PROJECT_DATA_FOLDER); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b1cd53092d..16c2a0f028 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -1519,7 +1519,7 @@ Ref<Shortcut> ED_GET_SHORTCUT(const String &p_path) { return sc; } -Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) { +Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode) { #ifdef OSX_ENABLED // Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS if (p_keycode == KEY_DELETE) { diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 3a28c18b27..6d28b26623 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -200,7 +200,7 @@ Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_re Variant _EDITOR_GET(const String &p_setting); #define ED_IS_SHORTCUT(p_name, p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name, p_ev)) -Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode = 0); +Ref<Shortcut> ED_SHORTCUT(const String &p_path, const String &p_name, Key p_keycode = KEY_NONE); Ref<Shortcut> ED_GET_SHORTCUT(const String &p_path); #endif // EDITOR_SETTINGS_H diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 681c3e7195..b4e9f468de 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1246,6 +1246,8 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { } accept_event(); } break; + default: + break; } } } diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 7acf5c2013..7e143241f3 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2457,7 +2457,7 @@ static bool is_shortcut_pressed(const String &p_path) { return false; } const Input &input = *Input::get_singleton(); - int keycode = k->get_keycode(); + Key keycode = k->get_keycode(); return input.is_key_pressed(keycode); } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index bb8b87ed83..64381c0d9e 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1925,12 +1925,12 @@ void ScriptTextEditor::register_editor() { // Leave these at zero, same can be accomplished with tab/shift-tab, including selection. // The next/previous in history shortcut in this case makes a lot more sense. - ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), 0); - ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), 0); + ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), KEY_NONE); + ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), KEY_NONE); ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD | KEY_K); ED_SHORTCUT("script_text_editor/toggle_fold_line", TTR("Fold/Unfold Line"), KEY_MASK_ALT | KEY_F); - ED_SHORTCUT("script_text_editor/fold_all_lines", TTR("Fold All Lines"), 0); - ED_SHORTCUT("script_text_editor/unfold_all_lines", TTR("Unfold All Lines"), 0); + ED_SHORTCUT("script_text_editor/fold_all_lines", TTR("Fold All Lines"), KEY_NONE); + ED_SHORTCUT("script_text_editor/unfold_all_lines", TTR("Unfold All Lines"), KEY_NONE); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_C); #else @@ -1965,7 +1965,7 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/toggle_bookmark", TTR("Toggle Bookmark"), KEY_MASK_CMD | KEY_MASK_ALT | KEY_B); ED_SHORTCUT("script_text_editor/goto_next_bookmark", TTR("Go to Next Bookmark"), KEY_MASK_CMD | KEY_B); ED_SHORTCUT("script_text_editor/goto_previous_bookmark", TTR("Go to Previous Bookmark"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B); - ED_SHORTCUT("script_text_editor/remove_all_bookmarks", TTR("Remove All Bookmarks"), 0); + ED_SHORTCUT("script_text_editor/remove_all_bookmarks", TTR("Remove All Bookmarks"), KEY_NONE); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/goto_function", TTR("Go to Function..."), KEY_MASK_CTRL | KEY_MASK_CMD | KEY_J); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index b277f2ab42..1a6eb7b63b 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -330,7 +330,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { for (const Rect2 &E : autoslice_cache) { if (E.has_point(point)) { rect = E; - if (Input::get_singleton()->is_key_pressed(KEY_CTRL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { + if (Input::get_singleton()->is_key_pressed(KEY_CTRL) && !(Input::get_singleton()->is_key_pressed(Key(KEY_SHIFT | KEY_ALT)))) { Rect2 r; if (node_sprite) { r = node_sprite->get_region_rect(); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 7ea3deedb9..165a381407 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -1721,6 +1721,8 @@ void ThemeItemEditorDialog::_edit_theme_item_gui_input(const Ref<InputEvent> &p_ edit_theme_item_dialog->hide(); edit_theme_item_dialog->set_input_as_handled(); } break; + default: + break; } } } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 96fcb4fe29..1272d064a0 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -67,6 +67,8 @@ void PropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) { current->select(0); } break; + default: + break; } } } diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index ed94f859e2..f8af3e8f36 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -190,6 +190,8 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { current->set_as_cursor(0); } } break; + default: + break; } } } |