1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

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>
This commit is contained in:
Invertex
2023-11-14 03:55:36 -08:00
parent c455cb6555
commit 59787683a9
8 changed files with 34 additions and 18 deletions

View File

@@ -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);