Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

List project settings in file owners

kobewi3243410c26ff
diff --git a/editor/docks/filesystem_dock.cpp b/editor/docks/filesystem_dock.cpp
index f5e2ed44714..0b4f531b4b0 100644
--- a/editor/docks/filesystem_dock.cpp
+++ b/editor/docks/filesystem_dock.cpp
@@ -4853,6 +4853,14 @@ FileSystemDock::FileSystemDock() {
old_display_mode = DISPLAY_MODE_TREE_ONLY;
file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
+ List<PropertyInfo> property_list;
+ ProjectSettings::get_singleton()->get_property_list(&property_list);
+ for (const PropertyInfo &pi : property_list) {
+ if (pi.type == Variant::STRING && pi.hint == PROPERTY_HINT_FILE) {
+ path_project_settings.push_back(pi.name);
+ }
+ }
+
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &FileSystemDock::_project_settings_changed));
EditorSettings::get_singleton()->connect("_favorites_changed", callable_mp(this, &FileSystemDock::update_all));
main_scene_path = ResourceUID::ensure_path(GLOBAL_GET("application/run/main_scene"));
diff --git a/editor/docks/filesystem_dock.h b/editor/docks/filesystem_dock.h
index c0c2c325b04..2f84d2be27e 100644
--- a/editor/docks/filesystem_dock.h
+++ b/editor/docks/filesystem_dock.h
@@ -257,6 +257,7 @@ private:
String current_path = "res://";
String select_after_scan;
String main_scene_path;
+ LocalVector<StringName> path_project_settings;
bool updating_tree = false;
int tree_update_id;
@@ -422,6 +423,7 @@ public:
static constexpr double ITEM_BG_DARK_SCALE = 0.3;
static Color get_dir_icon_color(const String &p_dir_path, const Color &p_default);
+ const LocalVector<StringName> &get_path_project_settings() const { return path_project_settings; }
const HashMap<String, Color> &get_folder_colors() const;
Dictionary get_assigned_folder_colors() const;
diff --git a/editor/file_system/dependency_editor.cpp b/editor/file_system/dependency_editor.cpp
index 8518ed8a094..abca3144ceb 100644
--- a/editor/file_system/dependency_editor.cpp
+++ b/editor/file_system/dependency_editor.cpp
@@ -35,6 +35,7 @@
#include "core/io/resource_loader.h"
#include "core/object/callable_mp.h"
#include "core/os/os.h"
+#include "editor/docks/filesystem_dock.h"
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "editor/file_system/editor_file_system.h"
@@ -537,6 +538,14 @@ void DependencyEditorOwners::show(const String &p_path) {
owners->clear();
_fill_owners(EditorFileSystem::get_singleton()->get_filesystem());
+ for (const StringName &setting : FileSystemDock::get_singleton()->get_path_project_settings()) {
+ const String path = ResourceUID::ensure_path(GLOBAL_GET(setting));
+ if (path == p_path) {
+ owners->add_item(vformat(TTR("Project setting: %s"), setting));
+ owners->set_item_icon(-1, get_editor_theme_icon(SNAME("ClassList")));
+ }
+ }
+
int count = owners->get_item_count();
if (count > 0) {
empty->hide();
@@ -643,6 +652,24 @@ void DependencyRemoveDialog::_find_all_removed_dependencies(EditorFileSystemDire
}
}
+void DependencyRemoveDialog::_find_setting_owners_of_removed_files(Vector<RemovedDependency> &p_removed) {
+ for (KeyValue<String, String> &files : all_remove_files) {
+ const String &path = files.key;
+
+ for (const StringName &setting : FileSystemDock::get_singleton()->get_path_project_settings()) {
+ const String setting_path = ResourceUID::ensure_path(GLOBAL_GET(setting));
+ if (setting_path == path) {
+ RemovedDependency dep;
+ dep.file = vformat(TTR("Project setting: %s"), setting);
+ dep.file_type = "ClassList";
+ dep.dependency = path;
+ dep.dependency_folder = files.value;
+ p_removed.push_back(dep);
+ }
+ }
+ }
+}
+
void DependencyRemoveDialog::_find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed) {
for (KeyValue<String, String> &files : all_remove_files) {
const String &path = files.key;
@@ -712,10 +739,11 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed
}
//List this file under this dependency
- Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(rd.file_type);
TreeItem *file_item = owners->create_item(tree_items[rd.dependency]);
file_item->set_text(0, rd.file);
- file_item->set_icon(0, icon);
+ if (!rd.file_type.is_empty()) {
+ file_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(rd.file_type));
+ }
}
}
@@ -753,6 +781,7 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
Vector<RemovedDependency> removed_deps;
_find_all_removed_dependencies(EditorFileSystem::get_singleton()->get_filesystem(), removed_deps);
+ _find_setting_owners_of_removed_files(removed_deps);
_find_localization_remaps_of_removed_files(removed_deps);
removed_deps.sort();
if (removed_deps.is_empty()) {
@@ -772,7 +801,7 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
void DependencyRemoveDialog::ok_pressed() {
HashMap<String, StringName> setting_path_map;
- for (const StringName &setting : path_project_settings) {
+ for (const StringName &setting : FileSystemDock::get_singleton()->get_path_project_settings()) {
const String path = ResourceUID::ensure_path(GLOBAL_GET(setting));
setting_path_map[path] = setting;
}
@@ -908,14 +937,6 @@ DependencyRemoveDialog::DependencyRemoveDialog() {
owners->set_accessibility_name(TTRC("Owners"));
mc->add_child(owners);
owners->set_v_size_flags(Control::SIZE_EXPAND_FILL);
-
- List<PropertyInfo> property_list;
- ProjectSettings::get_singleton()->get_property_list(&property_list);
- for (const PropertyInfo &pi : property_list) {
- if (pi.type == Variant::STRING && pi.hint == PROPERTY_HINT_FILE) {
- path_project_settings.push_back(pi.name);
- }
- }
}
//////////////
diff --git a/editor/file_system/dependency_editor.h b/editor/file_system/dependency_editor.h
index 63950a1fc01..695852ddda9 100644
--- a/editor/file_system/dependency_editor.h
+++ b/editor/file_system/dependency_editor.h
@@ -149,10 +149,9 @@ class DependencyRemoveDialog : public ConfirmationDialog {
}
};
- LocalVector<StringName> path_project_settings;
-
void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);
void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);
+ void _find_setting_owners_of_removed_files(Vector<RemovedDependency> &p_removed);
void _find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed);
void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
void _show_files_to_delete_list();