Merge pull request #64334 from YuriSizov/core-bind-property-revert-methods

Make `property_*_revert` methods multilevel and expose them for scripting
This commit is contained in:
Yuri Sizov 2022-08-19 20:41:41 +03:00 committed by GitHub
commit 7895a66cf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 327 additions and 126 deletions

View file

@ -100,11 +100,6 @@ bool EditorPropertyFontOTObject::_get(const StringName &p_name, Variant &r_ret)
return false;
}
void EditorPropertyFontOTObject::_bind_methods() {
ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &EditorPropertyFontOTObject::property_can_revert);
ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &EditorPropertyFontOTObject::property_get_revert);
}
void EditorPropertyFontOTObject::set_dict(const Dictionary &p_dict) {
dict = p_dict;
}
@ -121,7 +116,7 @@ Dictionary EditorPropertyFontOTObject::get_defaults() {
return defaults_dict;
}
bool EditorPropertyFontOTObject::property_can_revert(const String &p_name) {
bool EditorPropertyFontOTObject::_property_can_revert(const StringName &p_name) const {
String name = p_name;
if (name.begins_with("keys")) {
@ -136,18 +131,19 @@ bool EditorPropertyFontOTObject::property_can_revert(const String &p_name) {
return false;
}
Variant EditorPropertyFontOTObject::property_get_revert(const String &p_name) {
bool EditorPropertyFontOTObject::_property_get_revert(const StringName &p_name, Variant &r_property) const {
String name = p_name;
if (name.begins_with("keys")) {
int key = name.get_slicec('/', 1).to_int();
if (defaults_dict.has(key)) {
Vector3i range = defaults_dict[key];
return range.z;
r_property = range.z;
return true;
}
}
return Variant();
return false;
}
/*************************************************************************/

View file

@ -66,7 +66,8 @@ class EditorPropertyFontOTObject : public RefCounted {
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
static void _bind_methods();
bool _property_can_revert(const StringName &p_name) const;
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
public:
void set_dict(const Dictionary &p_dict);
@ -75,9 +76,6 @@ public:
void set_defaults(const Dictionary &p_dict);
Dictionary get_defaults();
bool property_can_revert(const String &p_name);
Variant property_get_revert(const String &p_name);
EditorPropertyFontOTObject(){};
};