Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
#include "servers/navigation_server_3d.h"
#include "servers/rendering_server.h"

#include "docks/uid_viewer_dock.h"
#include "editor/animation/animation_player_editor_plugin.h"
#include "editor/asset_library/asset_library_editor_plugin.h"
#include "editor/audio/audio_stream_preview.h"
Expand Down Expand Up @@ -110,6 +109,7 @@
#include "editor/export/shader_baker_export_plugin.h"
#include "editor/file_system/dependency_editor.h"
#include "editor/file_system/editor_paths.h"
#include "editor/file_system/uid_viewer.h"
#include "editor/gui/editor_about.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/gui/editor_file_dialog.h"
Expand Down Expand Up @@ -3667,6 +3667,9 @@ void EditorNode::_tool_menu_option(int p_idx) {
case TOOLS_PROJECT_UPGRADE: {
project_upgrade_tool->popup_dialog();
} break;
case TOOLS_UID_VIEWER: {
uid_viewer->_open_tool();
} break;
case TOOLS_CUSTOM: {
if (tool_menu->get_item_submenu(p_idx) == "") {
Callable callback = tool_menu->get_item_metadata(p_idx);
Expand Down Expand Up @@ -8072,6 +8075,9 @@ EditorNode::EditorNode() {
build_profile_manager = memnew(EditorBuildProfileManager);
gui_base->add_child(build_profile_manager);

uid_viewer = memnew(UIDViewer);
gui_base->add_child(uid_viewer);

about = memnew(EditorAbout);
gui_base->add_child(about);
feature_profile_manager->connect("current_feature_profile_changed", callable_mp(this, &EditorNode::_feature_profile_changed));
Expand Down Expand Up @@ -8179,6 +8185,7 @@ EditorNode::EditorNode() {
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/orphan_resource_explorer", TTRC("Orphan Resource Explorer...")), TOOLS_ORPHAN_RESOURCES);
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/engine_compilation_configuration_editor", TTRC("Engine Compilation Configuration Editor...")), TOOLS_BUILD_PROFILE_MANAGER);
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/upgrade_project", TTRC("Upgrade Project Files...")), TOOLS_PROJECT_UPGRADE);
tool_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/uid_viewer", TTRC("UID Viewer...")), TOOLS_UID_VIEWER);

project_menu->add_separator();
project_menu->add_shortcut(ED_SHORTCUT("editor/reload_current_project", TTRC("Reload Current Project")), PROJECT_RELOAD_CURRENT_PROJECT);
Expand Down Expand Up @@ -8450,13 +8457,6 @@ EditorNode::EditorNode() {
center_split->add_child(bottom_panel);
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);

//UIDViewer

UIDViewerDock *uid_viewer_dock = memnew(UIDViewerDock);
uid_viewer_dock->set_name("UID Viewer");
bottom_panel->add_item(TTR("UID Viewer"), uid_viewer_dock,
EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ResourceUID"), SNAME("EditorIcons")));

log = memnew(EditorLog);
Button *output_button = bottom_panel->add_item(TTRC("Output"), log, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_output_bottom_panel", TTRC("Toggle Output Bottom Panel"), KeyModifierMask::ALT | Key::O));
log->set_tool_button(output_button);
Expand Down
4 changes: 4 additions & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class ProjectExportDialog;
class ProjectSettingsEditor;
class SceneImportSettingsDialog;
class ProjectUpgradeTool;
class UIDViewer;

#ifdef ANDROID_ENABLED
class TouchActionsPanel;
Expand Down Expand Up @@ -175,6 +176,7 @@ class EditorNode : public Node {
TOOLS_ORPHAN_RESOURCES,
TOOLS_BUILD_PROFILE_MANAGER,
TOOLS_PROJECT_UPGRADE,
TOOLS_UID_VIEWER,
TOOLS_CUSTOM,

VCS_METADATA,
Expand Down Expand Up @@ -497,6 +499,8 @@ class EditorNode : public Node {
ProjectUpgradeTool *project_upgrade_tool = nullptr;
bool run_project_upgrade_tool = false;

UIDViewer *uid_viewer = nullptr;

bool was_window_windowed_last = false;

bool unfocused_low_processor_usage_mode_enabled = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* uid_viewer_dock.cpp */
/* uid_viewer.cpp */
/**************************************************************************/
/* This file is part of: */
/* REDOT ENGINE */
Expand Down Expand Up @@ -30,33 +30,37 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#include "editor/docks/uid_viewer_dock.h"
#include "editor/file_system/uid_viewer.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_uid.h"
#include "editor/docks/filesystem_dock.h"
#include "editor/file_system/editor_file_system.h"
#include "scene/main/window.h" // For MouseButton enum in Godot 4.3+
#include "editor/themes/editor_scale.h"
#include "servers/display_server.h"

UIDViewerDock::UIDViewerDock() {
set_name("UID Viewer");
UIDViewer::UIDViewer() {
// Create container
container = memnew(VBoxContainer);
add_child(container);

set_mouse_filter(Control::MOUSE_FILTER_STOP);
set_focus_mode(Control::FOCUS_ALL);
container->set_name("UID Viewer");
container->set_anchors_preset(Control::PRESET_FULL_RECT);
container->set_mouse_filter(Control::MOUSE_FILTER_STOP);
container->set_focus_mode(Control::FOCUS_ALL);

// Top bar
HBoxContainer *top_bar = memnew(HBoxContainer);
add_child(top_bar);
container->add_child(top_bar);

search_edit = memnew(LineEdit);
search_edit->set_placeholder("Search for UID or path...");
search_edit->set_h_size_flags(SIZE_EXPAND_FILL);
search_edit->connect("text_changed", callable_mp(this, &UIDViewerDock::_on_search_text_changed));
search_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_edit->connect("text_changed", callable_mp(this, &UIDViewer::_on_search_text_changed));
top_bar->add_child(search_edit);

refresh_button = memnew(Button);
refresh_button->set_text("Refresh");
refresh_button->connect("pressed", callable_mp(this, &UIDViewerDock::_on_refresh_pressed));
refresh_button->connect("pressed", callable_mp(this, &UIDViewer::_on_refresh_pressed));
top_bar->add_child(refresh_button);

// Tree
Expand All @@ -67,28 +71,33 @@ UIDViewerDock::UIDViewerDock() {
uid_tree->set_column_title(1, "Resource Path");
uid_tree->set_column_custom_minimum_width(0, 280);
uid_tree->set_column_expand(1, true);
uid_tree->set_v_size_flags(SIZE_EXPAND_FILL);
uid_tree->set_h_size_flags(SIZE_EXPAND_FILL);
uid_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
uid_tree->set_h_size_flags(Control::SIZE_EXPAND_FILL);
uid_tree->set_allow_rmb_select(true);
uid_tree->connect("item_activated", callable_mp(this, &UIDViewerDock::_on_item_activated));
add_child(uid_tree);
uid_tree->connect("item_activated", callable_mp(this, &UIDViewer::_on_item_activated));
container->add_child(uid_tree);

// Context menu (owned by dock)
// Context menu
context_menu = memnew(PopupMenu);
context_menu->add_item("Copy UID");
context_menu->add_item("Copy Path");
context_menu->connect("id_pressed", callable_mp(this, &UIDViewerDock::_on_context_menu_id_pressed));
add_child(context_menu);
context_menu->connect("id_pressed", callable_mp(this, &UIDViewer::_on_context_menu_id_pressed));
container->add_child(context_menu);

_refresh_uid_list();

uid_tree->connect("item_mouse_selected", callable_mp(this, &UIDViewerDock::_on_tree_rmb_selected));
uid_tree->connect("item_mouse_selected", callable_mp(this, &UIDViewer::_on_tree_rmb_selected));

// Auto-refresh on filesystem changes
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &UIDViewerDock::_refresh_uid_list));
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &UIDViewer::_refresh_uid_list));

// Prepare window
set_title("UID Viewer Tool");
set_size(Size2i(850 * EDSCALE, 450 * EDSCALE));
hide();
}

void UIDViewerDock::_refresh_uid_list() {
void UIDViewer::_refresh_uid_list() {
uid_tree->clear();
TreeItem *root = uid_tree->create_item();

Expand Down Expand Up @@ -131,7 +140,7 @@ void UIDViewerDock::_refresh_uid_list() {
_on_search_text_changed(search_edit->get_text());
}

void UIDViewerDock::_on_search_text_changed(const String &text) {
void UIDViewer::_on_search_text_changed(const String &text) {
String search_lower = text.to_lower().strip_edges();

TreeItem *root = uid_tree->get_root();
Expand All @@ -148,12 +157,12 @@ void UIDViewerDock::_on_search_text_changed(const String &text) {
_filter_tree_recursive(root, search_lower);
}

void UIDViewerDock::_on_refresh_pressed() {
void UIDViewer::_on_refresh_pressed() {
EditorFileSystem::get_singleton()->scan();
_refresh_uid_list();
}

void UIDViewerDock::_on_item_activated() {
void UIDViewer::_on_item_activated() {
TreeItem *selected = uid_tree->get_selected();
if (!selected) {
return;
Expand All @@ -168,7 +177,7 @@ void UIDViewerDock::_on_item_activated() {
}
}

void UIDViewerDock::_on_context_menu_id_pressed(int id) {
void UIDViewer::_on_context_menu_id_pressed(int id) {
if (!last_selected_item) {
return;
}
Expand All @@ -185,7 +194,7 @@ void UIDViewerDock::_on_context_menu_id_pressed(int id) {
}
}

void UIDViewerDock::_show_all_items(TreeItem *item) {
void UIDViewer::_show_all_items(TreeItem *item) {
if (!item) {
item = uid_tree->get_root();
if (!item) {
Expand All @@ -202,7 +211,7 @@ void UIDViewerDock::_show_all_items(TreeItem *item) {
}
}

bool UIDViewerDock::_filter_tree_recursive(TreeItem *item, const String &search_lower) {
bool UIDViewer::_filter_tree_recursive(TreeItem *item, const String &search_lower) {
if (!item) {
return false;
}
Expand All @@ -229,7 +238,7 @@ bool UIDViewerDock::_filter_tree_recursive(TreeItem *item, const String &search_
return result;
}

void UIDViewerDock::_on_tree_rmb_selected(const Vector2 &p_pos, MouseButton p_button) {
void UIDViewer::_on_tree_rmb_selected(const Vector2 &p_pos, MouseButton p_button) {
if (p_button != MouseButton::RIGHT) {
return;
}
Expand All @@ -245,3 +254,21 @@ void UIDViewerDock::_on_tree_rmb_selected(const Vector2 &p_pos, MouseButton p_bu
}
}
}

void UIDViewer::_on_tool_closed() {
if (is_open) {
hide();
disconnect("close_requested", callable_mp(this, &UIDViewer::_on_tool_closed));
is_open = false;
}
}

void UIDViewer::_open_tool() {
if (!is_open) {
connect("close_requested", callable_mp(this, &UIDViewer::_on_tool_closed));
popup_centered();
is_open = true;
} else {
grab_focus();
}
}
15 changes: 11 additions & 4 deletions editor/docks/uid_viewer_dock.h → editor/file_system/uid_viewer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* uid_viewer_dock.h */
/* uid_viewer.h */
/**************************************************************************/
/* This file is part of: */
/* REDOT ENGINE */
Expand Down Expand Up @@ -34,14 +34,19 @@

#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/control.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/popup_menu.h"
#include "scene/gui/tree.h"
#include "scene/main/window.h"

class UIDViewerDock : public VBoxContainer {
GDCLASS(UIDViewerDock, VBoxContainer);
class UIDViewer : public Window {
GDCLASS(UIDViewer, Window);

private:
bool is_open = false;

VBoxContainer *container = nullptr;
Tree *uid_tree = nullptr;
LineEdit *search_edit = nullptr;
Button *refresh_button = nullptr;
Expand All @@ -54,9 +59,11 @@ class UIDViewerDock : public VBoxContainer {
void _on_item_activated();
void _on_context_menu_id_pressed(int id);
void _on_tree_rmb_selected(const Vector2 &p_pos, MouseButton p_button);
void _on_tool_closed();
void _show_all_items(TreeItem *item);
bool _filter_tree_recursive(TreeItem *item, const String &search_lower);

public:
UIDViewerDock();
UIDViewer();
void _open_tool();
};
Loading