diff options
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor_command_palette.cpp | 300 | ||||
| -rw-r--r-- | editor/editor_command_palette.h | 95 | ||||
| -rw-r--r-- | editor/editor_node.cpp | 127 | ||||
| -rw-r--r-- | editor/editor_node.h | 6 | ||||
| -rw-r--r-- | editor/editor_plugin.cpp | 5 | ||||
| -rw-r--r-- | editor/editor_plugin.h | 3 | ||||
| -rw-r--r-- | editor/editor_themes.cpp | 1 | ||||
| -rw-r--r-- | editor/icons/GridLayout.svg | 1 | ||||
| -rw-r--r-- | editor/icons/PrismMesh.svg | 2 | ||||
| -rw-r--r-- | editor/import/editor_import_collada.cpp | 4 | ||||
| -rw-r--r-- | editor/plugins/animation_blend_space_1d_editor.h | 2 | ||||
| -rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 2 | ||||
| -rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 4 | ||||
| -rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 8 | ||||
| -rw-r--r-- | editor/plugins/gpu_particles_2d_editor_plugin.cpp | 4 | ||||
| -rw-r--r-- | editor/plugins/gpu_particles_3d_editor_plugin.cpp | 4 | ||||
| -rw-r--r-- | editor/plugins/node_3d_editor_gizmos.h | 2 | ||||
| -rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 16 | ||||
| -rw-r--r-- | editor/plugins/node_3d_editor_plugin.h | 6 | ||||
| -rw-r--r-- | editor/plugins/script_text_editor.cpp | 7 | ||||
| -rw-r--r-- | editor/plugins/skeleton_3d_editor_plugin.cpp | 2 |
21 files changed, 517 insertions, 84 deletions
diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp new file mode 100644 index 0000000000..5a4fcff0f8 --- /dev/null +++ b/editor/editor_command_palette.cpp @@ -0,0 +1,300 @@ +/*************************************************************************/ +/* editor_command_palette.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "editor/editor_command_palette.h" +#include "core/os/keyboard.h" +#include "editor/editor_node.h" +#include "editor/editor_scale.h" +#include "scene/gui/control.h" +#include "scene/gui/tree.h" + +EditorCommandPalette *EditorCommandPalette::singleton = nullptr; + +float EditorCommandPalette::_score_path(const String &p_search, const String &p_path) { + float score = 0.9f + .1f * (p_search.length() / (float)p_path.length()); + + // Positive bias for matches close to the beginning of the file name. + int pos = p_path.findn(p_search); + if (pos != -1) { + return score * (1.0f - 0.1f * (float(pos) / p_path.length())); + } + + // Positive bias for matches close to the end of the path. + pos = p_path.rfindn(p_search); + if (pos != -1) { + return score * (0.8f - 0.1f * (float(p_path.length() - pos) / p_path.length())); + } + + // Remaining results belong to the same class of results. + return score * 0.69f; +} + +void EditorCommandPalette::_update_command_search(const String &search_text) { + commands.get_key_list(&command_keys); + ERR_FAIL_COND(command_keys.is_empty()); + + const bool empty_search = search_text.is_empty(); + Map<String, TreeItem *> sections; + TreeItem *first_section = nullptr; + + // Filter possible candidates. + Vector<CommandEntry> entries; + for (int i = 0; i < command_keys.size(); i++) { + CommandEntry r; + r.key_name = command_keys[i]; + r.display_name = commands[r.key_name].name; + r.shortcut_text = commands[r.key_name].shortcut; + if (!empty_search && search_text.is_subsequence_ofi(r.display_name)) { + r.score = _score_path(search_text, r.display_name.to_lower()); + entries.push_back(r); + } + } + + command_keys.clear(); + + TreeItem *root = search_options->get_root(); + root->clear_children(); + + if (entries.size() > 0) { + if (!empty_search) { + SortArray<CommandEntry, CommandEntryComparator> sorter; + sorter.sort(entries.ptrw(), entries.size()); + } + + const int entry_limit = MIN(entries.size(), 300); + for (int i = 0; i < entry_limit; i++) { + String section_name = entries[i].key_name.get_slice("/", 0); + TreeItem *section; + + if (sections.has(section_name)) { + section = sections[section_name]; + } else { + section = search_options->create_item(root); + + if (!first_section) { + first_section = section; + } + + String item_name = section_name.capitalize(); + section->set_text(0, item_name); + + sections[section_name] = section; + section->set_custom_bg_color(0, search_options->get_theme_color("prop_subsection", "Editor")); + section->set_custom_bg_color(1, search_options->get_theme_color("prop_subsection", "Editor")); + } + + TreeItem *ti = search_options->create_item(section); + String shortcut_text = entries[i].shortcut_text == "None" ? "" : entries[i].shortcut_text; + ti->set_text(0, entries[i].display_name); + ti->set_metadata(0, entries[i].key_name); + ti->set_text_align(1, TreeItem::TextAlign::ALIGN_RIGHT); + ti->set_text(1, shortcut_text); + Color c = Color(1, 1, 1, 0.5); + ti->set_custom_color(1, c); + } + + TreeItem *to_select = first_section->get_first_child(); + to_select->select(0); + to_select->set_as_cursor(0); + search_options->scroll_to_item(to_select); + + get_ok_button()->set_disabled(false); + } else { + TreeItem *ti = search_options->create_item(root); + ti->set_text(0, TTR("No Matching Command")); + ti->set_metadata(0, ""); + Color c = Color(0.5, 0.5, 0.5, 0.5); + ti->set_custom_color(0, c); + search_options->deselect_all(); + + get_ok_button()->set_disabled(true); + } +} + +void EditorCommandPalette::_bind_methods() { + ClassDB::bind_method(D_METHOD("add_command", "command_name", "key_name", "binded_callable", "shortcut_text"), &EditorCommandPalette::_add_command, DEFVAL("None")); + ClassDB::bind_method(D_METHOD("remove_command", "key_name"), &EditorCommandPalette::remove_command); +} + +void EditorCommandPalette::_sbox_input(const Ref<InputEvent> &p_ie) { + Ref<InputEventKey> k = p_ie; + if (k.is_valid()) { + switch (k->get_keycode()) { + case KEY_UP: + case KEY_DOWN: + case KEY_PAGEUP: + case KEY_PAGEDOWN: { + search_options->call("_gui_input", k); + } break; + } + } +} + +void EditorCommandPalette::_confirmed() { + TreeItem *selected_option = search_options->get_selected(); + String command_key = selected_option != nullptr ? selected_option->get_metadata(0) : ""; + if (command_key != "") { + hide(); + execute_command(command_key); + } +} + +void EditorCommandPalette::open_popup() { + popup_centered_clamped(Size2i(600, 440), 0.8f); + command_search_box->clear(); + command_search_box->grab_focus(); +} + +void EditorCommandPalette::get_actions_list(List<String> *p_list) const { + commands.get_key_list(p_list); +} + +void EditorCommandPalette::remove_command(String p_key_name) { + ERR_FAIL_COND_MSG(!commands.has(p_key_name), "The EditorAction '" + String(p_key_name) + "' Doesn't exists. Unable to remove it."); + + commands.erase(p_key_name); +} + +void EditorCommandPalette::add_command(String p_command_name, String p_key_name, Callable p_action, Vector<Variant> arguments, String p_shortcut_text) { + ERR_FAIL_COND_MSG(commands.has(p_key_name), "The EditorAction '" + String(p_command_name) + "' already exists. Unable to add it."); + + const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * arguments.size()); + for (int i = 0; i < arguments.size(); i++) { + argptrs[i] = &arguments[i]; + } + Command p_command; + p_command.name = p_command_name; + p_command.callable = p_action.bind(argptrs, arguments.size()); + p_command.shortcut = p_shortcut_text; + + commands[p_key_name] = p_command; +} + +void EditorCommandPalette::_add_command(String p_command_name, String p_key_name, Callable p_binded_action, String p_shortcut_text) { + ERR_FAIL_COND_MSG(commands.has(p_key_name), "The EditorAction '" + String(p_command_name) + "' already exists. Unable to add it."); + + Command p_command; + p_command.name = p_command_name; + p_command.callable = p_binded_action; + p_command.shortcut = p_shortcut_text; + + commands[p_key_name] = p_command; +} + +void EditorCommandPalette::execute_command(String &p_command_key) { + ERR_FAIL_COND_MSG(!commands.has(p_command_key), p_command_key + " not found."); + commands[p_command_key].callable.call_deferred(nullptr, 0); +} + +void EditorCommandPalette::register_shortcuts_as_command() { + const String *p_key = nullptr; + p_key = unregistered_shortcuts.next(p_key); + while (p_key != nullptr) { + String command_name = unregistered_shortcuts[*p_key].first; + Ref<Shortcut> p_shortcut = unregistered_shortcuts[*p_key].second; + Ref<InputEventShortcut> ev; + ev.instantiate(); + ev->set_shortcut(p_shortcut); + String shortcut_text = String(p_shortcut->get_as_text()); + add_command(command_name, *p_key, callable_mp(EditorNode::get_singleton()->get_viewport(), &Viewport::unhandled_input), varray(ev, false), shortcut_text); + p_key = unregistered_shortcuts.next(p_key); + } + unregistered_shortcuts.clear(); +} + +Ref<Shortcut> EditorCommandPalette::add_shortcut_command(const String &p_command, const String &p_key, Ref<Shortcut> p_shortcut) { + if (is_inside_tree()) { + Ref<InputEventShortcut> ev; + ev.instantiate(); + ev->set_shortcut(p_shortcut); + String shortcut_text = String(p_shortcut->get_as_text()); + add_command(p_command, p_key, callable_mp(EditorNode::get_singleton()->get_viewport(), &Viewport::unhandled_input), varray(ev, false), shortcut_text); + } else { + const String key_name = String(p_key); + const String command_name = String(p_command); + Pair p_pair = Pair(command_name, p_shortcut); + unregistered_shortcuts[key_name] = p_pair; + } + return p_shortcut; +} + +void EditorCommandPalette::_theme_changed() { + command_search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); +} + +EditorCommandPalette *EditorCommandPalette::get_singleton() { + if (singleton == nullptr) { + singleton = memnew(EditorCommandPalette); + } + return singleton; +} + +EditorCommandPalette::EditorCommandPalette() { + VBoxContainer *vbc = memnew(VBoxContainer); + vbc->connect("theme_changed", callable_mp(this, &EditorCommandPalette::_theme_changed)); + add_child(vbc); + + command_search_box = memnew(LineEdit); + command_search_box->set_placeholder("search for a command"); + command_search_box->set_placeholder_alpha(0.5); + command_search_box->connect("gui_input", callable_mp(this, &EditorCommandPalette::_sbox_input)); + command_search_box->connect("text_changed", callable_mp(this, &EditorCommandPalette::_update_command_search)); + command_search_box->connect("text_submitted", callable_mp(this, &EditorCommandPalette::_confirmed).unbind(1)); + command_search_box->set_v_size_flags(Control::SIZE_EXPAND_FILL); + MarginContainer *margin_container_csb = memnew(MarginContainer); + margin_container_csb->add_child(command_search_box); + vbc->add_child(margin_container_csb); + register_text_enter(command_search_box); + + search_options = memnew(Tree); + search_options->connect("item_activated", callable_mp(this, &EditorCommandPalette::_confirmed)); + search_options->create_item(); + search_options->set_hide_root(true); + search_options->set_hide_folding(true); + search_options->add_theme_constant_override("draw_guides", 1); + search_options->set_columns(2); + search_options->set_v_size_flags(Control::SIZE_EXPAND_FILL); + search_options->set_h_size_flags(Control::SIZE_EXPAND_FILL); + search_options->set_column_custom_minimum_width(0, int(8 * EDSCALE)); + + vbc->add_child(search_options, true); + + 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) { + if (p_command_name.is_empty()) { + p_command_name = p_name; + } + + Ref<Shortcut> p_shortcut = ED_SHORTCUT(p_path, p_name, p_keycode); + EditorCommandPalette::get_singleton()->add_shortcut_command(p_command_name, p_path, p_shortcut); + return p_shortcut; +} diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h new file mode 100644 index 0000000000..ddf897c250 --- /dev/null +++ b/editor/editor_command_palette.h @@ -0,0 +1,95 @@ +/*************************************************************************/ +/* editor_command_palette.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef EDITOR_COMMAND_PALETTE_H +#define EDITOR_COMMAND_PALETTE_H + +#include "core/os/thread_safe.h" +#include "scene/gui/dialogs.h" +#include "scene/gui/shortcut.h" +#include "scene/gui/tree.h" + +class EditorCommandPalette : public ConfirmationDialog { + GDCLASS(EditorCommandPalette, ConfirmationDialog); + + static EditorCommandPalette *singleton; + LineEdit *command_search_box; + Tree *search_options; + + struct Command { + Callable callable; + String name; + String shortcut; + }; + + struct CommandEntry { + String key_name; + String display_name; + String shortcut_text; + float score; + }; + + struct CommandEntryComparator { + _FORCE_INLINE_ bool operator()(const CommandEntry &A, const CommandEntry &B) const { + return A.score > B.score; + } + }; + + HashMap<String, Command> commands; + HashMap<String, Pair<String, Ref<Shortcut>>> unregistered_shortcuts; + + List<String> command_keys; + + void _update_command_search(const String &search_text); + float _score_path(const String &p_search, const String &p_path); + void _sbox_input(const Ref<InputEvent> &p_ie); + void _confirmed(); + void _update_command_keys(); + void _add_command(String p_command_name, String p_key_name, Callable p_binded_action, String p_shortcut_text = "None"); + void _theme_changed(); + EditorCommandPalette(); + +protected: + static void _bind_methods(); + +public: + void open_popup(); + void get_actions_list(List<String> *p_list) const; + void add_command(String p_command_name, String p_key_name, Callable p_action, Vector<Variant> arguments, String p_shortcut_text = "None"); + void execute_command(String &p_command_name); + void register_shortcuts_as_command(); + Ref<Shortcut> add_shortcut_command(const String &p_command, const String &p_key, Ref<Shortcut> p_shortcut); + void remove_command(String p_key_name); + 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 = ""); + +#endif //EDITOR_COMMAND_PALETTE_H diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2126a7b8be..52672e9cc8 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -75,6 +75,7 @@ #include "editor/dependency_editor.h" #include "editor/editor_about.h" #include "editor/editor_audio_buses.h" +#include "editor/editor_command_palette.h" #include "editor/editor_export.h" #include "editor/editor_feature_profile.h" #include "editor/editor_file_system.h" @@ -404,7 +405,7 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); Ref<InputEventKey> k = p_event; - if (k.is_valid() && k->is_pressed() && !k->is_echo()) { + if ((k.is_valid() && k->is_pressed() && !k->is_echo()) || Object::cast_to<InputEventShortcut>(*p_event)) { EditorPlugin *old_editor = editor_plugin_screen; if (ED_IS_SHORTCUT("editor/next_tab", p_event)) { @@ -435,6 +436,9 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { _editor_select_next(); } else if (ED_IS_SHORTCUT("editor/editor_prev", p_event)) { _editor_select_prev(); + } else if (ED_IS_SHORTCUT("editor/command_palette", p_event)) { + _open_command_palette(); + } else { } if (old_editor != editor_plugin_screen) { @@ -565,13 +569,15 @@ void EditorNode::_notification(int p_what) { Engine::get_singleton()->set_editor_hint(true); OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); - get_tree()->get_root()->set_as_audio_listener(false); + get_tree()->get_root()->set_as_audio_listener_3d(false); get_tree()->get_root()->set_as_audio_listener_2d(false); get_tree()->get_root()->set_snap_2d_transforms_to_pixel(false); get_tree()->get_root()->set_snap_2d_vertices_to_pixel(false); get_tree()->set_auto_accept_quit(false); get_tree()->get_root()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files)); + command_palette->register_shortcuts_as_command(); + /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } break; @@ -1063,6 +1069,10 @@ void EditorNode::_editor_select_next() { _editor_select(editor); } +void EditorNode::_open_command_palette() { + command_palette->open_popup(); +} + void EditorNode::_editor_select_prev() { int editor = _get_current_main_editor(); @@ -2815,6 +2825,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case HELP_SEARCH: { emit_signal(SNAME("request_help_search"), ""); } break; + case HELP_COMMAND_PALETTE: { + command_palette->open_popup(); + } break; case HELP_DOCS: { OS::get_singleton()->shell_open("https://docs.godotengine.org/"); } break; @@ -3802,6 +3815,7 @@ void EditorNode::register_editor_types() { // FIXME: Is this stuff obsolete, or should it be ported to new APIs? GDREGISTER_CLASS(EditorScenePostImport); //ClassDB::register_type<EditorImportExport>(); + GDREGISTER_CLASS(EditorCommandPalette); GDREGISTER_CLASS(EditorDebuggerPlugin); NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR); @@ -6129,9 +6143,9 @@ EditorNode::EditorNode() { distraction_free = memnew(Button); distraction_free->set_flat(true); #ifdef OSX_ENABLED - distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_D)); + distraction_free->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_D)); #else - distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11)); + distraction_free->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11)); #endif distraction_free->set_tooltip(TTR("Toggle distraction-free mode.")); distraction_free->connect("pressed", callable_mp(this, &EditorNode::_toggle_distraction_free_mode)); @@ -6225,28 +6239,33 @@ EditorNode::EditorNode() { ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB); ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB); ED_SHORTCUT("editor/filter_files", TTR("Filter Files..."), KEY_MASK_CMD + KEY_MASK_ALT + KEY_P); + + command_palette = EditorCommandPalette::get_singleton(); + command_palette->set_title(TTR("Command Palette")); + gui_base->add_child(command_palette); + PopupMenu *p; file_menu->set_tooltip(TTR("Operations with scene files.")); p = file_menu->get_popup(); - p->add_shortcut(ED_SHORTCUT("editor/new_scene", TTR("New Scene"), KEY_MASK_CMD + KEY_N), FILE_NEW_SCENE); - p->add_shortcut(ED_SHORTCUT("editor/new_inherited_scene", TTR("New Inherited Scene..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_N), FILE_NEW_INHERITED_SCENE); - p->add_shortcut(ED_SHORTCUT("editor/open_scene", TTR("Open Scene..."), KEY_MASK_CMD + KEY_O), FILE_OPEN_SCENE); - p->add_shortcut(ED_SHORTCUT("editor/reopen_closed_scene", TTR("Reopen Closed Scene"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_T), FILE_OPEN_PREV); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/new_scene", TTR("New Scene"), KEY_MASK_CMD + KEY_N), FILE_NEW_SCENE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/new_inherited_scene", TTR("New Inherited Scene..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_N), FILE_NEW_INHERITED_SCENE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/open_scene", TTR("Open Scene..."), KEY_MASK_CMD + KEY_O), FILE_OPEN_SCENE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/reopen_closed_scene", TTR("Reopen Closed Scene"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_T), FILE_OPEN_PREV); p->add_submenu_item(TTR("Open Recent"), "RecentScenes", FILE_OPEN_RECENT); p->add_separator(); - p->add_shortcut(ED_SHORTCUT("editor/save_scene", TTR("Save Scene"), KEY_MASK_CMD + KEY_S), FILE_SAVE_SCENE); - p->add_shortcut(ED_SHORTCUT("editor/save_scene_as", TTR("Save Scene As..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_S), FILE_SAVE_AS_SCENE); - p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes", TTR("Save All Scenes"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_S), FILE_SAVE_ALL_SCENES); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/save_scene", TTR("Save Scene"), KEY_MASK_CMD + KEY_S), FILE_SAVE_SCENE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/save_scene_as", TTR("Save Scene As..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_S), FILE_SAVE_AS_SCENE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/save_all_scenes", TTR("Save All Scenes"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_S), FILE_SAVE_ALL_SCENES); p->add_separator(); - p->add_shortcut(ED_SHORTCUT("editor/quick_open", TTR("Quick Open..."), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_O), FILE_QUICK_OPEN); - p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene", TTR("Quick Open Scene..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_O), FILE_QUICK_OPEN_SCENE); - p->add_shortcut(ED_SHORTCUT("editor/quick_open_script", TTR("Quick Open Script..."), KEY_MASK_CMD + KEY_MASK_ALT + KEY_O), FILE_QUICK_OPEN_SCRIPT); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quick_open", TTR("Quick Open..."), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_O), FILE_QUICK_OPEN); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quick_open_scene", TTR("Quick Open Scene..."), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_O), FILE_QUICK_OPEN_SCENE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quick_open_script", TTR("Quick Open Script..."), KEY_MASK_CMD + KEY_MASK_ALT + KEY_O), FILE_QUICK_OPEN_SCRIPT); p->add_separator(); PopupMenu *pm_export = memnew(PopupMenu); @@ -6261,8 +6280,8 @@ EditorNode::EditorNode() { p->add_shortcut(ED_GET_SHORTCUT("ui_redo"), EDIT_REDO, true); p->add_separator(); - p->add_shortcut(ED_SHORTCUT("editor/reload_saved_scene", TTR("Reload Saved Scene")), EDIT_RELOAD_SAVED_SCENE); - p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_W), FILE_CLOSE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/reload_saved_scene", TTR("Reload Saved Scene")), EDIT_RELOAD_SAVED_SCENE); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/close_scene", TTR("Close Scene"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_W), FILE_CLOSE); recent_scenes = memnew(PopupMenu); recent_scenes->set_name("RecentScenes"); @@ -6270,7 +6289,7 @@ EditorNode::EditorNode() { recent_scenes->connect("id_pressed", callable_mp(this, &EditorNode::_open_recent_scene)); p->add_separator(); - p->add_shortcut(ED_SHORTCUT("editor/file_quit", TTR("Quit"), KEY_MASK_CMD + KEY_Q), FILE_QUIT, true); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/file_quit", TTR("Quit"), KEY_MASK_CMD + KEY_Q), FILE_QUIT, true); project_menu = memnew(MenuButton); project_menu->set_flat(false); @@ -6282,7 +6301,7 @@ EditorNode::EditorNode() { p = project_menu->get_popup(); - p->add_shortcut(ED_SHORTCUT("editor/project_settings", TTR("Project Settings...")), RUN_SETTINGS); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/project_settings", TTR("Project Settings..."), 0, 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(); @@ -6295,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("editor/export", TTR("Export...")), FILE_EXPORT_PROJECT); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/export", TTR("Export..."), 0, 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); @@ -6313,9 +6332,9 @@ EditorNode::EditorNode() { p->add_separator(); p->add_shortcut(ED_SHORTCUT("editor/reload_current_project", TTR("Reload Current Project")), RUN_RELOAD_CURRENT_PROJECT); #ifdef OSX_ENABLED - p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q), RUN_PROJECT_MANAGER, true); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q), RUN_PROJECT_MANAGER, true); #else - p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_Q), RUN_PROJECT_MANAGER, true); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_Q), RUN_PROJECT_MANAGER, true); #endif menu_hb->add_spacer(); @@ -6342,9 +6361,9 @@ EditorNode::EditorNode() { p = settings_menu->get_popup(); #ifdef OSX_ENABLED - p->add_shortcut(ED_SHORTCUT("editor/editor_settings", TTR("Editor Settings..."), KEY_MASK_CMD + KEY_COMMA), SETTINGS_PREFERENCES); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/editor_settings", TTR("Editor Settings..."), KEY_MASK_CMD + KEY_COMMA), SETTINGS_PREFERENCES); #else - p->add_shortcut(ED_SHORTCUT("editor/editor_settings", TTR("Editor Settings...")), SETTINGS_PREFERENCES); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/editor_settings", TTR("Editor Settings...")), SETTINGS_PREFERENCES); #endif p->add_separator(); @@ -6355,15 +6374,15 @@ EditorNode::EditorNode() { p->add_submenu_item(TTR("Editor Layout"), "Layouts"); p->add_separator(); #ifdef OSX_ENABLED - p->add_shortcut(ED_SHORTCUT("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CMD | KEY_F12), EDITOR_SCREENSHOT); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CMD | KEY_F12), EDITOR_SCREENSHOT); #else - p->add_shortcut(ED_SHORTCUT("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CTRL | KEY_F12), EDITOR_SCREENSHOT); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CTRL | KEY_F12), EDITOR_SCREENSHOT); #endif p->set_item_tooltip(p->get_item_count() - 1, TTR("Screenshots are stored in the Editor Data/Settings Folder.")); #ifdef OSX_ENABLED - p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_F), SETTINGS_TOGGLE_FULLSCREEN); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_F), SETTINGS_TOGGLE_FULLSCREEN); #else - p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREEN); + p->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREEN); #endif #if defined(WINDOWS_ENABLED) && defined(WINDOWS_SUBSYSTEM_CONSOLE) // The console can only be toggled if the application was built for the console subsystem, @@ -6396,20 +6415,20 @@ EditorNode::EditorNode() { p = help_menu->get_popup(); p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); #ifdef OSX_ENABLED - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_MASK_ALT | KEY_SPACE), HELP_SEARCH); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/editor_help", TTR("Search Help"), KEY_MASK_ALT | KEY_SPACE), HELP_SEARCH); #else - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1), HELP_SEARCH); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/editor_help", TTR("Search Help"), KEY_F1), HELP_SEARCH); #endif p->add_separator(); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/q&a", TTR("Questions & Answers")), HELP_QA); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/q&a", TTR("Questions & Answers")), HELP_QA); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/community", TTR("Community")), HELP_COMMUNITY); p->add_separator(); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons")), ED_SHORTCUT("editor/about", TTR("About Godot")), HELP_ABOUT); - p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons")), ED_SHORTCUT("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/about", TTR("About Godot")), HELP_ABOUT); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons")), ED_SHORTCUT_AND_COMMAND("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); HBoxContainer *play_hb = memnew(HBoxContainer); menu_hb->add_child(play_hb); @@ -6423,9 +6442,9 @@ EditorNode::EditorNode() { play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY)); play_button->set_tooltip(TTR("Play the project.")); #ifdef OSX_ENABLED - play_button->set_shortcut(ED_SHORTCUT("editor/play", TTR("Play"), KEY_MASK_CMD | KEY_B)); + play_button->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/play", TTR("Play"), KEY_MASK_CMD | KEY_B)); #else - play_button->set_shortcut(ED_SHORTCUT("editor/play", TTR("Play"), KEY_F5)); + play_button->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/play", TTR("Play"), KEY_F5)); #endif pause_button = memnew(Button); @@ -6469,9 +6488,9 @@ EditorNode::EditorNode() { play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_SCENE)); play_scene_button->set_tooltip(TTR("Play the edited scene.")); #ifdef OSX_ENABLED - play_scene_button->set_shortcut(ED_SHORTCUT("editor/play_scene", TTR("Play Scene"), KEY_MASK_CMD | KEY_R)); + play_scene_button->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/play_scene", TTR("Play Scene"), KEY_MASK_CMD | KEY_R)); #else - play_scene_button->set_shortcut(ED_SHORTCUT("editor/play_scene", TTR("Play Scene"), KEY_F6)); + play_scene_button->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/play_scene", TTR("Play Scene"), KEY_F6)); #endif play_custom_scene_button = memnew(Button); @@ -6483,9 +6502,9 @@ EditorNode::EditorNode() { play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_CUSTOM_SCENE)); play_custom_scene_button->set_tooltip(TTR("Play custom scene")); #ifdef OSX_ENABLED - play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_R)); + play_custom_scene_button->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_R)); #else - play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5)); + play_custom_scene_button->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5)); #endif HBoxContainer *right_menu_hb = memnew(HBoxContainer); @@ -7020,19 +7039,21 @@ EditorNode::EditorNode() { ResourceLoader::set_load_callback(_resource_loaded); #ifdef OSX_ENABLED - ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_MASK_ALT | KEY_1); - ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_MASK_ALT | KEY_2); - ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_MASK_ALT | KEY_3); - ED_SHORTCUT("editor/editor_assetlib", TTR("Open Asset Library"), KEY_MASK_ALT | KEY_4); + ED_SHORTCUT_AND_COMMAND("editor/editor_2d", TTR("Open 2D Editor"), KEY_MASK_ALT | KEY_1); + ED_SHORTCUT_AND_COMMAND("editor/editor_3d", TTR("Open 3D Editor"), KEY_MASK_ALT | KEY_2); + ED_SHORTCUT_AND_COMMAND("editor/editor_script", TTR("Open Script Editor"), KEY_MASK_ALT | KEY_3); + ED_SHORTCUT_AND_COMMAND("editor/editor_assetlib", TTR("Open Asset Library"), KEY_MASK_ALT | KEY_4); + ED_SHORTCUT("editor/command_palette", TTR("Open Command Palette"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_P); #else // Use the Ctrl modifier so F2 can be used to rename nodes in the scene tree dock. - ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_MASK_CTRL | KEY_F1); - ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_MASK_CTRL | KEY_F2); - ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_MASK_CTRL | KEY_F3); - ED_SHORTCUT("editor/editor_assetlib", TTR("Open Asset Library"), KEY_MASK_CTRL | KEY_F4); + ED_SHORTCUT_AND_COMMAND("editor/editor_2d", TTR("Open 2D Editor"), KEY_MASK_CTRL | KEY_F1); + ED_SHORTCUT_AND_COMMAND("editor/editor_3d", TTR("Open 3D Editor"), KEY_MASK_CTRL | KEY_F2); + ED_SHORTCUT_AND_COMMAND("editor/editor_script", TTR("Open Script Editor"), KEY_MASK_CTRL | KEY_F3); + ED_SHORTCUT_AND_COMMAND("editor/editor_assetlib", TTR("Open Asset Library"), KEY_MASK_CTRL | KEY_F4); + ED_SHORTCUT("editor/command_palette", TTR("Open Command Palette"), KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_P); #endif - ED_SHORTCUT("editor/editor_next", TTR("Open the next Editor")); - ED_SHORTCUT("editor/editor_prev", TTR("Open the previous Editor")); + ED_SHORTCUT_AND_COMMAND("editor/editor_next", TTR("Open the next Editor")); + ED_SHORTCUT_AND_COMMAND("editor/editor_prev", TTR("Open the previous Editor")); screenshot_timer = memnew(Timer); screenshot_timer->set_one_shot(true); diff --git a/editor/editor_node.h b/editor/editor_node.h index 6b91856a59..fed4d23704 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -32,6 +32,7 @@ #define EDITOR_NODE_H #include "core/templates/safe_refcount.h" +#include "editor/editor_command_palette.h" #include "editor/editor_data.h" #include "editor/editor_export.h" #include "editor/editor_folding.h" @@ -55,6 +56,7 @@ class Control; class DependencyEditor; class DependencyErrorDialog; class EditorAbout; +class EditorCommandPalette; class EditorExport; class EditorFeatureProfileManager; class EditorFileServer; @@ -192,6 +194,7 @@ private: EDITOR_OPEN_SCREENSHOT, HELP_SEARCH, + HELP_COMMAND_PALETTE, HELP_DOCS, HELP_QA, HELP_REPORT_A_BUG, @@ -342,6 +345,7 @@ private: CenterContainer *tabs_center; EditorQuickOpen *quick_open; EditorQuickOpen *quick_run; + EditorCommandPalette *command_palette; HBoxContainer *main_editor_button_vb; Vector<Button *> main_editor_buttons; @@ -505,6 +509,7 @@ private: void _quick_opened(); void _quick_run(); + void _open_command_palette(); void _run(bool p_current = false, const String &p_custom = ""); void _run_native(const Ref<EditorExportPreset> &p_preset); @@ -703,6 +708,7 @@ public: EditorInspector *get_inspector() { return inspector_dock->get_inspector(); } Container *get_inspector_dock_addon_area() { return inspector_dock->get_addon_area(); } ScriptCreateDialog *get_script_create_dialog() { return scene_tree_dock->get_script_create_dialog(); } + EditorCommandPalette *get_editor_command_palette() { return command_palette; } ProjectSettingsEditor *get_project_settings() { return project_settings; } diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 07e9357e67..b71a3944fc 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -310,6 +310,10 @@ bool EditorInterface::is_distraction_free_mode_enabled() const { return EditorNode::get_singleton()->is_distraction_free_mode_enabled(); } +EditorCommandPalette *EditorInterface::get_command_palette() const { + return EditorNode::get_singleton()->get_editor_command_palette(); +} + EditorInterface *EditorInterface::singleton = nullptr; void EditorInterface::_bind_methods() { @@ -340,6 +344,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_current_path"), &EditorInterface::get_current_path); ClassDB::bind_method(D_METHOD("get_file_system_dock"), &EditorInterface::get_file_system_dock); ClassDB::bind_method(D_METHOD("get_editor_paths"), &EditorInterface::get_editor_paths); + ClassDB::bind_method(D_METHOD("get_command_palette"), &EditorInterface::get_command_palette); ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled); ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 2e1dd0a0c1..d665278144 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -45,6 +45,7 @@ class EditorNode; class Node3D; class Camera3D; +class EditorCommandPalette; class EditorSelection; class EditorExport; class EditorSettings; @@ -87,6 +88,8 @@ public: Array get_open_scenes() const; ScriptEditor *get_script_editor(); + EditorCommandPalette *get_command_palette() const; + void select_file(const String &p_file); String get_selected_path() const; String get_current_path() const; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 08dd37bc73..5adce2951d 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1232,6 +1232,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("reset", "GraphEdit", theme->get_icon("ZoomReset", "EditorIcons")); theme->set_icon("snap", "GraphEdit", theme->get_icon("SnapGrid", "EditorIcons")); theme->set_icon("minimap", "GraphEdit", theme->get_icon("GridMinimap", "EditorIcons")); + theme->set_icon("layout", "GraphEdit", theme->get_icon("GridLayout", "EditorIcons")); theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE); theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE); diff --git a/editor/icons/GridLayout.svg b/editor/icons/GridLayout.svg new file mode 100644 index 0000000000..71ad504477 --- /dev/null +++ b/editor/icons/GridLayout.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m14 2.1992188v2.6152343l-2.625 1.3125v-2.6152343zm-12 4.0644531 2.625 1.3125v2.5507811l-2.625-1.3124999zm12 0v2.5507812l-2.625 1.3124999v-2.5507811zm-8 1.4550781h4v2.640625h-4zm-4 2.560547 2.625 1.3125v2.521484l-2.625-1.3125zm12 0v2.521484l-2.625 1.3125v-2.521484zm-8 1.455078h4v2.640625h-4zm1.7014535-8.109375h2.2985465v2.734375h-4.15625s-.7487346.647119-.8746377.640625c-.1310411-.0067594-1.5097373-1.4558594-1.5097373-1.4558594l-1.459375-.7296875v-2.6152343l.068419.034223s.026411-.4573464.062111-.6760553c.0346282-.2121439.1970747-.59225724.1970747-.59225724l-1.0483078-.52372301c-.0795772-.04012218-.1668141-.06276382-.2558594-.06640625-.35427845-.01325803-.64865004.27047362-.6484375.625v12c.00021484.236623.13402736.45284.34570312.558594l3.99999998 2c.086686.043505.1823067.06624.2792969.066406h6c.09699-.000166.192611-.0229.279297-.06641l4-2c.211676-.10575.345488-.321967.345703-.55859v-12c-.000468-.46423753-.488958-.76598317-.904297-.55859375l-3.869141 1.93359375h-2.9709527s.033448.4166167.015891.625c-.029188.3464401-.1950466.625-.1950468.625z" fill="#b05b5b"/><path d="m5 6s-2.21875-2.1616704-2.21875-3.2425057c0-1.0808352 0-2.6072392 2.21875-2.6072392s2.21875 1.526404 2.21875 2.6072392c0 1.0808353-2.21875 3.2425057-2.21875 3.2425057z" fill="#fff" fill-opacity=".68627"/></svg> diff --git a/editor/icons/PrismMesh.svg b/editor/icons/PrismMesh.svg index cca52bb7b0..0fd169cc8c 100644 --- a/editor/icons/PrismMesh.svg +++ b/editor/icons/PrismMesh.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.9824 1.002a1.0001 1.0001 0 0 0 -.81445.44336l-5.9727 8.9609-.027344.03906a1 1 0 0 0 -.0625.10742 1 1 0 0 0 .44727 1.3418l6 3a1.0001 1.0001 0 0 0 .89453 0l6-3a1 1 0 0 0 .44726-1.3418 1 1 0 0 0 -.0625-.10742l-6-9a1.0001 1.0001 0 0 0 -.84961-.44336zm-.98242 4.3008v7.0801l-3.5391-1.7715zm2 0 3.5391 5.3086-3.5391 1.7715z" fill="#ffca5f"/></svg> +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3.9168678 1.8860265c-.3598509 1.0771598-1.9743383 5.9072035-2.95075512 8.8641335-.15505871.56144.26297692 1.081021.77506042 1.256186 1.9729807.978051 3.9341568 1.98391 5.9144721 2.944682.5872542.201411 1.0933197-.27019 1.6046594-.478049 1.7521944-.878995 3.5092364-1.748814 5.2583944-2.633556.53543-.305954.598247-1.041459.264856-1.51829-.991782-1.9723689-1.966021-3.9544106-2.968743-5.9207481-.320568-.4259931-.882722-.5397422-1.322158-.8066387-1.7413894-.8632626-4.7187151-2.3492561-5.2199521-2.59935915-.501237-.2501031-.9959833-.18552039-1.3558341.89163945zm1.6236276 1.4766588 4.2114703 2.1046892-2.3703904 7.1132625-4.2114703-2.104688zm5.6257546 4.2135626 1.479141 2.9582811-2.9603737 1.481232z" fill="#ffca5f"/></svg> diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index b615c73422..54b93edcdd 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -1414,7 +1414,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones //animation->set_loop(true); //create animation tracks - Vector<float> base_snapshots; + Vector<real_t> base_snapshots; float f = 0; float snapshot_interval = 1.0 / bake_fps; //should be customizable somewhere... @@ -1466,7 +1466,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones animation->track_set_path(track, path); animation->track_set_imported(track, true); //helps merging later - Vector<float> snapshots = base_snapshots; + Vector<real_t> snapshots = base_snapshots; if (nm.anim_tracks.size() == 1) { //use snapshot keys from anim track instead, because this was most likely exported baked diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h index 24c950fdee..fe98a91ab3 100644 --- a/editor/plugins/animation_blend_space_1d_editor.h +++ b/editor/plugins/animation_blend_space_1d_editor.h @@ -92,7 +92,7 @@ class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { PopupMenu *animations_menu; Vector<String> animations_to_add; float add_point_pos; - Vector<float> points; + Vector<real_t> points; bool dragging_selected_attempt; bool dragging_selected; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index c440064898..7fe12089c8 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4073,7 +4073,7 @@ void CanvasItemEditor::_popup_warning_depop(Control *p_control) { info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); } -void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const float p_duration) { +void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const double p_duration) { Timer *timer; if (!popup_temporarily_timers.has(p_control)) { timer = memnew(Timer); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 1f59dfbc49..495cd5f515 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -56,7 +56,7 @@ public: Transform2D pre_drag_xform; Rect2 pre_drag_rect; - List<float> pre_drag_bones_length; + List<real_t> pre_drag_bones_length; List<Dictionary> pre_drag_bones_undo_state; Dictionary undo_state; @@ -540,7 +540,7 @@ private: VSplitContainer *bottom_split; void _update_context_menu_stylebox(); - void _popup_warning_temporarily(Control *p_control, const float p_duration); + void _popup_warning_temporarily(Control *p_control, const double p_duration); void _popup_warning_depop(Control *p_control); void _set_owner_for_node_and_children(Node *p_node, Node *p_owner); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index d7618b973e..d47bd2d410 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -386,7 +386,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { Vector<Vector3> vertices; Vector<Vector3> normals; Vector<Vector2> uvs; - Vector<float> tangents; + Vector<real_t> tangents; Basis tt = Basis(Vector3(0, 1, 0), Math_PI * 0.5); for (int i = 1; i <= lats; i++) { @@ -635,7 +635,7 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Ref<AudioStreamPlayback> playback = stream->instance_playback(); ERR_FAIL_COND_V(playback.is_null(), Ref<Texture2D>()); - float len_s = stream->get_length(); + real_t len_s = stream->get_length(); if (len_s == 0) { len_s = 60; //one minute audio if no length specified } @@ -649,8 +649,8 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const playback->stop(); for (int i = 0; i < w; i++) { - float max = -1000; - float min = 1000; + real_t max = -1000; + real_t min = 1000; int from = uint64_t(i) * frame_length / w; int to = (uint64_t(i) + 1) * frame_length / w; to = MIN(to, frame_length); diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 5184e837ce..efec5a709d 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -60,7 +60,7 @@ void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) { void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { switch (p_idx) { case MENU_GENERATE_VISIBILITY_RECT: { - float gen_time = particles->get_lifetime(); + double gen_time = particles->get_lifetime(); if (gen_time < 1.0) { generate_seconds->set_value(1.0); } else { @@ -100,7 +100,7 @@ void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { } void GPUParticles2DEditorPlugin::_generate_visibility_rect() { - float time = generate_seconds->get_value(); + double time = generate_seconds->get_value(); float running = 0.0; diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 8576082597..fff25b6f59 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -282,9 +282,9 @@ void GPUParticles3DEditor::_menu_option(int p_option) { } void GPUParticles3DEditor::_generate_aabb() { - float time = generate_seconds->get_value(); + double time = generate_seconds->get_value(); - float running = 0.0; + double running = 0.0; EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time)); diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index 53f602460c..64f46f2b1a 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -63,7 +63,7 @@ class EditorNode3DGizmo : public Node3DGizmo { Vector<Vector3> secondary_handles; Vector<int> secondary_handle_ids; - float selectable_icon_size; + real_t selectable_icon_size; bool billboard_handle; bool valid; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 931c50fc44..7acf5c2013 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2735,7 +2735,7 @@ void Node3DEditorViewport::_notification(int p_what) { if (show_fps) { cpu_time_history[cpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_cpu(viewport->get_viewport_rid()); cpu_time_history_index = (cpu_time_history_index + 1) % FRAME_TIME_HISTORY; - float cpu_time = 0.0; + double cpu_time = 0.0; for (int i = 0; i < FRAME_TIME_HISTORY; i++) { cpu_time += cpu_time_history[i]; } @@ -2745,7 +2745,7 @@ void Node3DEditorViewport::_notification(int p_what) { gpu_time_history[gpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_gpu(viewport->get_viewport_rid()); gpu_time_history_index = (gpu_time_history_index + 1) % FRAME_TIME_HISTORY; - float gpu_time = 0.0; + double gpu_time = 0.0; for (int i = 0; i < FRAME_TIME_HISTORY; i++) { gpu_time += gpu_time_history[i]; } @@ -2769,7 +2769,7 @@ void Node3DEditorViewport::_notification(int p_what) { frame_time_gradient->get_color_at_offset( Math::range_lerp(gpu_time, 0, 30, 0, 1))); - const float fps = 1000.0 / gpu_time; + const double fps = 1000.0 / gpu_time; fps_label->set_text(vformat(TTR("FPS: %d"), fps)); // Middle point is at 60 FPS. fps_label->add_theme_color_override( @@ -3187,7 +3187,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; - viewport->set_as_audio_listener(current); + viewport->set_as_audio_listener_3d(current); view_menu->get_popup()->set_item_checked(idx, current); } break; @@ -3634,7 +3634,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { bool listener = p_state["listener"]; int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER); - viewport->set_as_audio_listener(listener); + viewport->set_as_audio_listener_3d(listener); view_menu->get_popup()->set_item_checked(idx, listener); } if (p_state.has("doppler")) { @@ -3718,7 +3718,7 @@ Dictionary Node3DEditorViewport::get_state() const { } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS))) { d["display_mode"] = VIEW_DISPLAY_SHADELESS; } - d["listener"] = viewport->is_audio_listener(); + d["listener"] = viewport->is_audio_listener_3d(); d["doppler"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER)); d["gizmos"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS)); d["information"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); @@ -4363,7 +4363,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito if (p_index == 0) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER), true); - viewport->set_as_audio_listener(true); + viewport->set_as_audio_listener_3d(true); } name = ""; @@ -6820,7 +6820,7 @@ void Node3DEditor::clear() { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(Node3DEditorViewport::VIEW_AUDIO_LISTENER), i == 0); - viewports[i]->viewport->set_as_audio_listener(i == 0); + viewports[i]->viewport->set_as_audio_listener_3d(i == 0); } view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index cb2edbcbc1..0c1456aaf8 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -166,9 +166,9 @@ public: }; private: - float cpu_time_history[FRAME_TIME_HISTORY]; + double cpu_time_history[FRAME_TIME_HISTORY]; int cpu_time_history_index; - float gpu_time_history[FRAME_TIME_HISTORY]; + double gpu_time_history[FRAME_TIME_HISTORY]; int gpu_time_history_index; int index; @@ -336,7 +336,7 @@ private: String last_message; String message; - float message_time; + double message_time; void set_message(String p_message, float p_time = 5); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 5bbe56a800..bb8b87ed83 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -33,6 +33,7 @@ #include "core/math/expression.h" #include "core/os/keyboard.h" #include "editor/debugger/editor_debugger_node.h" +#include "editor/editor_command_palette.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" @@ -1941,15 +1942,15 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/convert_indent_to_tabs", TTR("Convert Indent to Tabs"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_I); ED_SHORTCUT("script_text_editor/auto_indent", TTR("Auto Indent"), KEY_MASK_CMD | KEY_I); - ED_SHORTCUT("script_text_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F); + ED_SHORTCUT_AND_COMMAND("script_text_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/find_next", TTR("Find Next"), KEY_MASK_CMD | KEY_G); ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_G); - ED_SHORTCUT("script_text_editor/replace", TTR("Replace..."), KEY_MASK_ALT | KEY_MASK_CMD | KEY_F); + ED_SHORTCUT_AND_COMMAND("script_text_editor/replace", TTR("Replace..."), KEY_MASK_ALT | KEY_MASK_CMD | KEY_F); #else ED_SHORTCUT("script_text_editor/find_next", TTR("Find Next"), KEY_F3); ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3); - ED_SHORTCUT("script_text_editor/replace", TTR("Replace..."), KEY_MASK_CMD | KEY_R); + ED_SHORTCUT_AND_COMMAND("script_text_editor/replace", TTR("Replace..."), KEY_MASK_CMD | KEY_R); #endif ED_SHORTCUT("script_text_editor/find_in_files", TTR("Find in Files..."), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 4202d8b611..3de2ffc137 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -397,7 +397,7 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi bone_shape->set_transform(capsule_transform); Transform3D body_transform; - body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin); + body_transform.basis = Basis::looking_at(child_rest.origin); body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height)); Transform3D joint_transform; |
