Skip to content

armgit / godot

Public Imported from GitHub
0

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

Show inspector warning on deprecated properties

kobewi800a7cf9d812
diff --git a/editor/inspector/editor_inspector.cpp b/editor/inspector/editor_inspector.cpp
index d7229e9be1a..f520714cfc9 100644
--- a/editor/inspector/editor_inspector.cpp
+++ b/editor/inspector/editor_inspector.cpp
@@ -542,7 +542,7 @@ void EditorProperty::_notification(int p_what) {
Color color;
if (draw_warning || draw_prop_warning) {
color = is_read_only() ? theme_cache.readonly_warning_color : theme_cache.warning_color;
- } else if (is_read_only()) {
+ } else if (is_deprecated || is_read_only()) {
color = (sub_inspector_color_level >= 0) ? theme_cache.sub_inspector_property_color : theme_cache.readonly_property_color;
} else {
color = (sub_inspector_color_level >= 0) ? theme_cache.sub_inspector_property_color : theme_cache.property_color;
@@ -951,6 +951,24 @@ void EditorProperty::update_editor_property_status() {
new_warning = !String(object->call("_get_property_warning", property)).is_empty();
}
+ // Check if the property is deprecated.
+ if (!new_warning && !doc_path.is_empty()) {
+ EditorInspector *inspector = get_parent_inspector();
+ if (inspector) {
+ const String classname = doc_path.get_slicec(':', 1);
+ const String propname = doc_path.get_slicec(':', 2);
+ DocData::ClassDoc *cd = EditorHelp::get_doc(classname);
+ if (cd) {
+ for (const DocData::PropertyDoc &prop : cd->properties) {
+ if (prop.name == propname) {
+ is_deprecated = prop.is_deprecated;
+ break;
+ }
+ }
+ }
+ }
+ }
+
Variant current = object->get(_get_revert_property());
bool new_can_revert = EditorPropertyRevert::can_property_revert(object, property, &current) && !is_read_only();
diff --git a/editor/inspector/editor_inspector.h b/editor/inspector/editor_inspector.h
index ad69787606f..80efb66bc30 100644
--- a/editor/inspector/editor_inspector.h
+++ b/editor/inspector/editor_inspector.h
@@ -160,6 +160,7 @@ private:
bool checked = false;
bool draw_warning = false;
bool draw_prop_warning = false;
+ bool is_deprecated = false;
bool keying = false;
bool deletable = false;
bool label_overlayed = false;