From 8426817a95379216752087e247001b9452dffe81 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 2 Mar 2025 19:37:48 +0100 Subject: [PATCH] Use get_file_uid() where applicable --- editor/editor_file_system.cpp | 2 +- editor/editor_properties.cpp | 3 ++- editor/filesystem_dock.cpp | 8 ++++---- editor/plugins/script_editor_plugin.cpp | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index e78f77b5bf19..2d8b8d7b682a 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -3033,7 +3033,7 @@ Error EditorFileSystem::_copy_file(const String &p_from, const String &p_to) { if (err != OK) { return err; } - } else if (ResourceLoader::get_resource_uid(p_from) == ResourceUID::INVALID_ID) { + } else if (get_file_uid(p_from) == ResourceUID::INVALID_ID) { // Files which do not use an uid can just be copied. Error err = da->copy(p_from, p_to); if (err != OK) { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 52780d7c5889..59878d0fd1cb 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -32,6 +32,7 @@ #include "core/config/project_settings.h" #include "editor/create_dialog.h" +#include "editor/editor_file_system.h" #include "editor/editor_node.h" #include "editor/editor_properties_array_dict.h" #include "editor/editor_properties_vector.h" @@ -477,7 +478,7 @@ void EditorPropertyPath::_path_selected(const String &p_path) { String full_path = p_path; if (!global) { - const ResourceUID::ID id = ResourceLoader::get_resource_uid(full_path); + const ResourceUID::ID id = EditorFileSystem::get_singleton()->get_file_uid(full_path); if (id != ResourceUID::INVALID_ID) { full_path = ResourceUID::get_singleton()->id_to_text(id); } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 4fafdefbb598..f0c93d346363 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2006,7 +2006,7 @@ void FileSystemDock::_before_move(HashMap &r_uids, Hash for (int i = 0; i < to_move.size(); i++) { if (to_move[i].is_file) { renamed_files.insert(to_move[i].path); - ResourceUID::ID uid = ResourceLoader::get_resource_uid(to_move[i].path); + ResourceUID::ID uid = EditorFileSystem::get_singleton()->get_file_uid(to_move[i].path); if (uid != ResourceUID::INVALID_ID) { r_uids[to_move[i].path] = uid; } @@ -2019,7 +2019,7 @@ void FileSystemDock::_before_move(HashMap &r_uids, Hash for (int j = 0; j < current_folder->get_file_count(); j++) { const String file_path = current_folder->get_file_path(j); renamed_files.insert(file_path); - ResourceUID::ID uid = ResourceLoader::get_resource_uid(file_path); + ResourceUID::ID uid = EditorFileSystem::get_singleton()->get_file_uid(file_path); if (uid != ResourceUID::INVALID_ID) { r_uids[file_path] = uid; } @@ -2549,7 +2549,7 @@ void FileSystemDock::_file_option(int p_option, const Vector &p_selected case FILE_COPY_UID: { if (!p_selected.is_empty()) { - ResourceUID::ID uid = ResourceLoader::get_resource_uid(p_selected[0]); + ResourceUID::ID uid = EditorFileSystem::get_singleton()->get_file_uid(p_selected[0]); if (uid != ResourceUID::INVALID_ID) { String uid_string = ResourceUID::get_singleton()->id_to_text(uid); DisplayServer::get_singleton()->clipboard_set(uid_string); @@ -3273,7 +3273,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect if (p_paths.size() == 1) { p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); p_popup->add_shortcut(ED_GET_SHORTCUT("filesystem_dock/copy_absolute_path"), FILE_COPY_ABSOLUTE_PATH); - if (ResourceLoader::get_resource_uid(p_paths[0]) != ResourceUID::INVALID_ID) { + if (EditorFileSystem::get_singleton()->get_file_uid(p_paths[0]) != ResourceUID::INVALID_ID) { p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("filesystem_dock/copy_uid"), FILE_COPY_UID); } if (root_path_not_selected) { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index af7812abe806..7301e827e42d 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1008,7 +1008,7 @@ void ScriptEditor::_copy_script_uid() { ScriptEditorBase *se = _get_current_editor(); if (se) { Ref scr = se->get_edited_resource(); - ResourceUID::ID uid = ResourceLoader::get_resource_uid(scr->get_path()); + ResourceUID::ID uid = EditorFileSystem::get_singleton()->get_file_uid(scr->get_path()); DisplayServer::get_singleton()->clipboard_set(ResourceUID::get_singleton()->id_to_text(uid)); } } @@ -1746,7 +1746,7 @@ void ScriptEditor::_prepare_file_menu() { menu->set_item_disabled(menu->get_item_index(FILE_TOOL_RELOAD_SOFT), res.is_null()); menu->set_item_disabled(menu->get_item_index(FILE_COPY_PATH), res.is_null() || res->get_path().is_empty()); - menu->set_item_disabled(menu->get_item_index(FILE_COPY_UID), res.is_null() || ResourceLoader::get_resource_uid(res->get_path()) == ResourceUID::INVALID_ID); + menu->set_item_disabled(menu->get_item_index(FILE_COPY_UID), res.is_null() || EditorFileSystem::get_singleton()->get_file_uid(res->get_path()) == ResourceUID::INVALID_ID); menu->set_item_disabled(menu->get_item_index(SHOW_IN_FILE_SYSTEM), res.is_null()); menu->set_item_disabled(menu->get_item_index(WINDOW_PREV), history_pos <= 0); @@ -3447,7 +3447,7 @@ void ScriptEditor::_make_script_list_context_menu() { context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/copy_path"), FILE_COPY_PATH); context_menu->set_item_disabled(-1, se->get_edited_resource()->get_path().is_empty()); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/copy_uid"), FILE_COPY_UID); - context_menu->set_item_disabled(-1, ResourceLoader::get_resource_uid(se->get_edited_resource()->get_path()) == ResourceUID::INVALID_ID); + context_menu->set_item_disabled(-1, EditorFileSystem::get_singleton()->get_file_uid(se->get_edited_resource()->get_path()) == ResourceUID::INVALID_ID); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/show_in_file_system"), SHOW_IN_FILE_SYSTEM); context_menu->add_separator(); }