Browse Source

Merge pull request #69343 from YuriSizov/core-missing-property-revert-getters

Add missing public `property_*_revert` getters
Rémi Verschelde 2 years ago
parent
commit
a50e4fed18
2 changed files with 18 additions and 0 deletions
  1. 2 0
      core/object/object.cpp
  2. 16 0
      doc/classes/Object.xml

+ 2 - 0
core/object/object.cpp

@@ -1473,6 +1473,8 @@ void Object::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_indexed", "property_path"), &Object::_get_indexed_bind);
 	ClassDB::bind_method(D_METHOD("get_property_list"), &Object::_get_property_list_bind);
 	ClassDB::bind_method(D_METHOD("get_method_list"), &Object::_get_method_list_bind);
+	ClassDB::bind_method(D_METHOD("property_can_revert", "property"), &Object::property_can_revert);
+	ClassDB::bind_method(D_METHOD("property_get_revert", "property"), &Object::property_get_revert);
 	ClassDB::bind_method(D_METHOD("notification", "what", "reversed"), &Object::notification, DEFVAL(false));
 	ClassDB::bind_method(D_METHOD("to_string"), &Object::to_string);
 	ClassDB::bind_method(D_METHOD("get_instance_id"), &Object::get_instance_id);

+ 16 - 0
doc/classes/Object.xml

@@ -764,6 +764,22 @@
 				Emits the [signal property_list_changed] signal. This is mainly used to refresh the editor, so that the Inspector and editor plugins are properly updated.
 			</description>
 		</method>
+		<method name="property_can_revert" qualifiers="const">
+			<return type="bool" />
+			<param index="0" name="property" type="StringName" />
+			<description>
+				Returns [code]true[/code] if the given [param property] has a custom default value. Use [method property_get_revert] to get the [param property]'s default value.
+				[b]Note:[/b] This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_can_revert] to customize the default value. If [method _property_can_revert] is not implemented, this method returns [code]false[/code].
+			</description>
+		</method>
+		<method name="property_get_revert" qualifiers="const">
+			<return type="Variant" />
+			<param index="0" name="property" type="StringName" />
+			<description>
+				Returns the custom default value of the given [param property]. Use [method property_can_revert] to check if the [param property] has a custom default value.
+				[b]Note:[/b] This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_get_revert] to customize the default value. If [method _property_get_revert] is not implemented, this method returns [code]null[/code].
+			</description>
+		</method>
 		<method name="remove_meta">
 			<return type="void" />
 			<param index="0" name="name" type="StringName" />