diff options
author | Yuri Sizov <yuris@humnom.net> | 2022-08-12 21:43:14 +0300 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2022-08-18 00:03:53 +0300 |
commit | 980f5f32f492ad7e55915f37a6104789d43c89e1 (patch) | |
tree | 4636e77949b93decb9c2fe2fbb950d19db2d9ab1 /core/config | |
parent | dbd15243621ec595742b18abc4c26f3cb2e00f3d (diff) |
Make `property_*_revert` methods multilevel and expose them for scripting
Diffstat (limited to 'core/config')
-rw-r--r-- | core/config/project_settings.cpp | 11 | ||||
-rw-r--r-- | core/config/project_settings.h | 5 |
2 files changed, 7 insertions, 9 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 5c4bcc687a..f383cefca5 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1070,7 +1070,7 @@ bool ProjectSettings::is_using_datapack() const { return using_datapack; } -bool ProjectSettings::property_can_revert(const String &p_name) { +bool ProjectSettings::_property_can_revert(const StringName &p_name) const { if (!props.has(p_name)) { return false; } @@ -1078,12 +1078,13 @@ bool ProjectSettings::property_can_revert(const String &p_name) { return props[p_name].initial != props[p_name].variant; } -Variant ProjectSettings::property_get_revert(const String &p_name) { +bool ProjectSettings::_property_get_revert(const StringName &p_name, Variant &r_property) const { if (!props.has(p_name)) { - return Variant(); + return false; } - return props[p_name].initial; + r_property = props[p_name].initial; + return true; } void ProjectSettings::set_setting(const String &p_setting, const Variant &p_value) { @@ -1134,8 +1135,6 @@ void ProjectSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("globalize_path", "path"), &ProjectSettings::globalize_path); ClassDB::bind_method(D_METHOD("save"), &ProjectSettings::save); ClassDB::bind_method(D_METHOD("load_resource_pack", "pack", "replace_files", "offset"), &ProjectSettings::_load_resource_pack, DEFVAL(true), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert); - ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ProjectSettings::property_get_revert); ClassDB::bind_method(D_METHOD("save_custom", "file"), &ProjectSettings::_save_custom_bnd); } diff --git a/core/config/project_settings.h b/core/config/project_settings.h index c3992a4db2..c845120a26 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -102,6 +102,8 @@ protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; + bool _property_can_revert(const StringName &p_name) const; + bool _property_get_revert(const StringName &p_name, Variant &r_property) const; static ProjectSettings *singleton; @@ -147,9 +149,6 @@ public: void set_ignore_value_in_docs(const String &p_name, bool p_ignore); bool get_ignore_value_in_docs(const String &p_name) const; - bool property_can_revert(const String &p_name); - Variant property_get_revert(const String &p_name); - String get_project_data_dir_name() const; String get_project_data_path() const; String get_resource_path() const; |