From a805b0c6589a2c891d6cb66fd651d974c38d9033 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 18 Jun 2025 09:38:07 +0800 Subject: [PATCH] Show description for editor settings overrides Also marked the "Editor Overrides" section name for translation. --- core/config/project_settings.h | 2 +- editor/inspector/editor_inspector.cpp | 20 ++++++++++++++++---- editor/inspector/editor_inspector.h | 3 +++ editor/settings/project_settings_editor.cpp | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/core/config/project_settings.h b/core/config/project_settings.h index cf82d03c610..01228a914b1 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -49,7 +49,7 @@ class ProjectSettings : public Object { public: typedef HashMap CustomMap; static inline const String PROJECT_DATA_DIR_NAME_SUFFIX = "godot"; - static inline const String EDITOR_SETTING_OVERRIDE_PREFIX = "editor_overrides/"; + static inline const String EDITOR_SETTING_OVERRIDE_PREFIX = PNAME("editor_overrides") + String("/"); // Properties that are not for built in values begin from this value, so builtin ones are displayed first. constexpr static const int32_t NO_BUILTIN_ORDER_BASE = 1 << 16; diff --git a/editor/inspector/editor_inspector.cpp b/editor/inspector/editor_inspector.cpp index 86f2db05156..dc1e63ad693 100644 --- a/editor/inspector/editor_inspector.cpp +++ b/editor/inspector/editor_inspector.cpp @@ -4171,10 +4171,10 @@ void EditorInspector::update_tree() { String doc_path; String theme_item_name; String doc_tooltip_text; - StringName classname = doc_name; // Build the doc hint, to use as tooltip. if (use_doc_hints) { + StringName classname = doc_name; if (!object_class.is_empty()) { classname = object_class; } else if (Object::cast_to(object)) { @@ -4197,6 +4197,14 @@ void EditorInspector::update_tree() { } StringName propname = property_prefix + p.name; + for (const KeyValue &E : doc_property_class_remaps) { + if (property_prefix.begins_with(E.key)) { + propname = property_prefix.trim_prefix(E.key) + p.name; + classname = E.value; + break; + } + } + bool found = false; // Small hack for theme_overrides. They are listed under Control, but come from another class. @@ -4261,12 +4269,12 @@ void EditorInspector::update_tree() { if (p.name.contains("shader_parameter/")) { ShaderMaterial *shader_material = Object::cast_to(object); if (shader_material) { - doc_tooltip_text = "property|" + shader_material->get_shader()->get_path() + "|" + property_prefix + p.name; + doc_tooltip_text = "property|" + shader_material->get_shader()->get_path() + "|" + propname; } } else if (p.usage & PROPERTY_USAGE_INTERNAL) { - doc_tooltip_text = "internal_property|" + classname + "|" + property_prefix + p.name; + doc_tooltip_text = "internal_property|" + classname + "|" + propname; } else { - doc_tooltip_text = "property|" + classname + "|" + property_prefix + p.name; + doc_tooltip_text = "property|" + classname + "|" + propname; } } else { doc_tooltip_text = "theme_item|" + classname + "|" + theme_item_name; @@ -5562,6 +5570,10 @@ String EditorInspector::get_custom_property_description(const String &p_property return ""; } +void EditorInspector::remap_doc_property_class(const String &p_property_prefix, const String &p_class) { + doc_property_class_remaps[p_property_prefix] = p_class; +} + void EditorInspector::set_object_class(const String &p_class) { object_class = p_class; } diff --git a/editor/inspector/editor_inspector.h b/editor/inspector/editor_inspector.h index e8b18009fb0..e5bb17b321b 100644 --- a/editor/inspector/editor_inspector.h +++ b/editor/inspector/editor_inspector.h @@ -697,6 +697,7 @@ class EditorInspector : public ScrollContainer { HashMap> doc_cache; HashSet restart_request_props; HashMap custom_property_descriptions; + HashMap doc_property_class_remaps; HashMap scroll_cache; @@ -816,6 +817,8 @@ public: void add_custom_property_description(const String &p_class, const String &p_property, const String &p_description); String get_custom_property_description(const String &p_property) const; + void remap_doc_property_class(const String &p_property_prefix, const String &p_class); + void set_object_class(const String &p_class); String get_object_class() const; diff --git a/editor/settings/project_settings_editor.cpp b/editor/settings/project_settings_editor.cpp index 41aa2162586..b968c224570 100644 --- a/editor/settings/project_settings_editor.cpp +++ b/editor/settings/project_settings_editor.cpp @@ -758,6 +758,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { general_settings_inspector->connect("category_changed", callable_mp(this, &ProjectSettingsEditor::_on_category_changed)); general_settings_inspector->get_inspector()->set_use_filter(true); general_settings_inspector->get_inspector()->set_mark_unsaved(false); + general_settings_inspector->get_inspector()->remap_doc_property_class(ProjectSettings::EDITOR_SETTING_OVERRIDE_PREFIX, "EditorSettings"); general_settings_inspector->get_inspector()->connect("property_selected", callable_mp(this, &ProjectSettingsEditor::_setting_selected)); general_settings_inspector->get_inspector()->connect("property_edited", callable_mp(this, &ProjectSettingsEditor::_setting_edited)); general_settings_inspector->get_inspector()->connect("property_deleted", callable_mp(this, &ProjectSettingsEditor::_on_editor_override_deleted));