diff options
author | Invertex <Invertex@users.noreply.github.com> | 2023-11-14 03:55:36 -0800 |
---|---|---|
committer | Invertex <Invertex@users.noreply.github.com> | 2023-12-13 07:43:39 -0800 |
commit | 59787683a91c25d28e69b67ae9a56eac6f6d83bd (patch) | |
tree | b040ac03e1dcf07be4338f602306533fe12ff88b | |
parent | c455cb65550c19afbbf657a1dbf9af2ca3b603da (diff) | |
download | redot-engine-59787683a91c25d28e69b67ae9a56eac6f6d83bd.tar.gz |
Added "Show In FileSystem" right-click option to Scene hierarchy nodes.
-Implemented shared function for focusing FileSystem tab and highlighting the node path.
-Created right-click option that shows up in the Scene-Hierarchy on Nodes that have a file-system source path.
-Created custom icon for this right-click option
-Implemented the shared function and icon for other places that already had this features (Open Node tab, Inspector Resource)
Co-authored-by: MewPurPur <mew.pur.pur@gmail.com>
-rw-r--r-- | editor/editor_audio_buses.cpp | 2 | ||||
-rw-r--r-- | editor/editor_resource_picker.cpp | 13 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 8 | ||||
-rw-r--r-- | editor/gui/editor_scene_tabs.cpp | 2 | ||||
-rw-r--r-- | editor/icons/ShowInFileSystem.svg | 1 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 19 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 1 |
8 files changed, 34 insertions, 18 deletions
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index f244bc0da8..985a789e41 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -1192,7 +1192,7 @@ void EditorAudioBuses::_server_save() { } void EditorAudioBuses::_select_layout() { - FileSystemDock::get_singleton()->select_file(edited_path); + FileSystemDock::get_singleton()->navigate_to_path(edited_path); } void EditorAudioBuses::_save_as_layout() { diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 3b7cce60bf..a70ec230bf 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -237,7 +237,7 @@ void EditorResourcePicker::_update_menu_items() { if (edited_resource->get_path().is_resource_file()) { edit_menu->add_separator(); - edit_menu->add_item(TTR("Show in FileSystem"), OBJ_MENU_SHOW_IN_FILE_SYSTEM); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("ShowInFileSystem")), TTR("Show in FileSystem"), OBJ_MENU_SHOW_IN_FILE_SYSTEM); } } @@ -418,16 +418,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } break; case OBJ_MENU_SHOW_IN_FILE_SYSTEM: { - FileSystemDock *file_system_dock = FileSystemDock::get_singleton(); - file_system_dock->navigate_to_path(edited_resource->get_path()); - - // Ensure that the FileSystem dock is visible. - if (file_system_dock->get_window() == get_tree()->get_root()) { - TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock)); - } else { - file_system_dock->get_window()->grab_focus(); - } + FileSystemDock::get_singleton()->navigate_to_path(edited_resource->get_path()); } break; default: { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 944da47242..2705033507 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -756,6 +756,14 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa void FileSystemDock::navigate_to_path(const String &p_path) { file_list_search_box->clear(); _navigate_to_path(p_path); + + // Ensure that the FileSystem dock is visible. + if (get_window() == get_tree()->get_root()) { + TabContainer *tab_container = (TabContainer *)get_parent_control(); + tab_container->set_current_tab(tab_container->get_tab_idx_from_control((Control *)this)); + } else { + get_window()->grab_focus(); + } } void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { diff --git a/editor/gui/editor_scene_tabs.cpp b/editor/gui/editor_scene_tabs.cpp index 1fe8eee6d7..b15871aa23 100644 --- a/editor/gui/editor_scene_tabs.cpp +++ b/editor/gui/editor_scene_tabs.cpp @@ -165,7 +165,7 @@ void EditorSceneTabs::_update_context_menu() { if (tab_id >= 0) { scene_tabs_context_menu->add_separator(); - scene_tabs_context_menu->add_item(TTR("Show in FileSystem"), EditorNode::FILE_SHOW_IN_FILESYSTEM); + scene_tabs_context_menu->add_icon_item(get_editor_theme_icon(SNAME("ShowInFileSystem")), TTR("Show in FileSystem"), EditorNode::FILE_SHOW_IN_FILESYSTEM); _disable_menu_option_if(EditorNode::FILE_SHOW_IN_FILESYSTEM, !ResourceLoader::exists(EditorNode::get_editor_data().get_scene_path(tab_id))); scene_tabs_context_menu->add_item(TTR("Play This Scene"), EditorNode::FILE_RUN_SCENE); _disable_menu_option_if(EditorNode::FILE_RUN_SCENE, no_root_node); diff --git a/editor/icons/ShowInFileSystem.svg b/editor/icons/ShowInFileSystem.svg new file mode 100644 index 0000000000..9cfeaf48d2 --- /dev/null +++ b/editor/icons/ShowInFileSystem.svg @@ -0,0 +1 @@ +<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M1 1v2.25h6v4.5h3v4.5h5V10h-2.75V7.75H15V5.5H9.25V3.25H15V1z" fill="#e0e0e0"/><path d="M5.04 8.04c-1.534 0-3.475 1.169-4.173 3.423a.6.6 0 0 0 0 .33c.67 2.374 2.673 3.447 4.173 3.447s3.502-1.073 4.177-3.435a.6.6 0 0 0 0-.33C8.557 9.201 6.572 8.04 5.04 8.04zm0 1.2a2.4 2.4 0 0 1 0 4.8 2.4 2.4 0 0 1 0-4.8zm0 1.2a1.2 1.2 0 0 0 0 2.4 1.2 1.2 0 0 0 0-2.4z" fill="#5fb2ff"/></svg> diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 6c4636dba3..04ab30f2c2 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1427,11 +1427,7 @@ void ScriptEditor::_menu_option(int p_option) { path = path.get_slice("::", 0); // Show the scene instead. } - FileSystemDock *file_system_dock = FileSystemDock::get_singleton(); - file_system_dock->navigate_to_path(path); - // Ensure that the FileSystem dock is visible. - TabContainer *dock_tab_container = (TabContainer *)file_system_dock->get_parent_control(); - dock_tab_container->set_current_tab(dock_tab_container->get_tab_idx_from_control(file_system_dock)); + FileSystemDock::get_singleton()->navigate_to_path(path); } } break; case CLOSE_DOCS: { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a94c978a1a..a6fb543ce6 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -46,6 +46,7 @@ #include "editor/editor_settings.h" #include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" +#include "editor/filesystem_dock.h" #include "editor/gui/editor_file_dialog.h" #include "editor/inspector_dock.h" #include "editor/multi_node_edit.h" @@ -148,6 +149,8 @@ void SceneTreeDock::shortcut_input(const Ref<InputEvent> &p_event) { _tool_selected(TOOL_ERASE, true); } else if (ED_IS_SHORTCUT("scene_tree/copy_node_path", p_event)) { _tool_selected(TOOL_COPY_NODE_PATH); + } else if (ED_IS_SHORTCUT("scene_tree/show_in_file_system", p_event)) { + _tool_selected(TOOL_SHOW_IN_FILE_SYSTEM); } else if (ED_IS_SHORTCUT("scene_tree/toggle_unique_name", p_event)) { _tool_selected(TOOL_TOGGLE_SCENE_UNIQUE_NAME); } else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) { @@ -1016,6 +1019,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } } break; + case TOOL_SHOW_IN_FILE_SYSTEM: { + List<Node *> selection = editor_selection->get_selected_node_list(); + List<Node *>::Element *e = selection.front(); + if (e) { + const Node *node = e->get(); + if (node) { + FileSystemDock::get_singleton()->navigate_to_path(node->get_scene_file_path()); + } + } + } break; case TOOL_OPEN_DOCUMENTATION: { List<Node *> selection = editor_selection->get_selected_node_list(); for (int i = 0; i < selection.size(); i++) { @@ -3266,6 +3279,11 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } #endif // MODULE_REGEX_ENABLED menu->add_separator(); + + if (full_selection.size() == 1 && !selection[0]->get_scene_file_path().is_empty()) { + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ShowInFileSystem")), ED_GET_SHORTCUT("scene_tree/show_in_file_system"), TOOL_SHOW_IN_FILE_SYSTEM); + } + menu->add_icon_item(get_editor_theme_icon(SNAME("Help")), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); if (profile_allow_editing) { @@ -3967,6 +3985,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec ED_SHORTCUT("scene_tree/make_root", TTR("Make Scene Root")); ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene")); ED_SHORTCUT("scene_tree/copy_node_path", TTR("Copy Node Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::C); + ED_SHORTCUT("scene_tree/show_in_file_system", TTR("Show In FileSystem")); ED_SHORTCUT("scene_tree/toggle_unique_name", TTR("Toggle Access as Unique Name")); ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KeyModifierMask::SHIFT | Key::KEY_DELETE); ED_SHORTCUT("scene_tree/delete", TTR("Delete"), Key::KEY_DELETE); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 93c0e16db7..fc9c271526 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -79,6 +79,7 @@ class SceneTreeDock : public VBoxContainer { TOOL_MULTI_EDIT, TOOL_ERASE, TOOL_COPY_NODE_PATH, + TOOL_SHOW_IN_FILE_SYSTEM, TOOL_OPEN_DOCUMENTATION, TOOL_AUTO_EXPAND, TOOL_SCENE_EDITABLE_CHILDREN, |