summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/EditorSettings.xml20
-rw-r--r--editor/editor_settings.cpp29
-rw-r--r--editor/editor_settings.h5
3 files changed, 54 insertions, 0 deletions
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 81472c09ee..ac2250ab6d 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -70,6 +70,13 @@
[/codeblocks]
</description>
</method>
+ <method name="check_changed_settings_in_group" qualifiers="const">
+ <return type="bool" />
+ <argument index="0" name="setting_prefix" type="String" />
+ <description>
+ Checks if any settings with the prefix [code]setting_prefix[/code] exist in the set of changed settings. See also [method get_changed_settings].
+ </description>
+ </method>
<method name="erase">
<return type="void" />
<argument index="0" name="property" type="String" />
@@ -77,6 +84,12 @@
Erases the setting whose name is specified by [code]property[/code].
</description>
</method>
+ <method name="get_changed_settings" qualifiers="const">
+ <return type="Array" />
+ <description>
+ Gets an array of the settings which have been changed since the last save. Note that internally [code]changed_settings[/code] is cleared after a successful save, so generally the most appropriate place to use this method is when processing [constant NOTIFICATION_EDITOR_SETTINGS_CHANGED]
+ </description>
+ </method>
<method name="get_favorites" qualifiers="const">
<return type="PackedStringArray" />
<description>
@@ -118,6 +131,13 @@
Returns [code]true[/code] if the setting specified by [code]name[/code] exists, [code]false[/code] otherwise.
</description>
</method>
+ <method name="mark_setting_changed">
+ <return type="void" />
+ <argument index="0" name="setting" type="String" />
+ <description>
+ Marks the passed editor setting as being changed, see [method get_changed_settings]. Only settings which exist (see [method has_setting]) will be accepted.
+ </description>
+ </method>
<method name="property_can_revert">
<return type="bool" />
<argument index="0" name="name" type="String" />
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 6bd11fcdd6..0135b33bca 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -63,6 +63,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
bool changed = _set_only(p_name, p_value);
if (changed) {
+ changed_settings.insert(p_name);
emit_signal(SNAME("settings_changed"));
}
return true;
@@ -941,10 +942,34 @@ void EditorSettings::save() {
if (err != OK) {
ERR_PRINT("Error saving editor settings to " + singleton->config_file_path);
} else {
+ singleton->changed_settings.clear();
print_verbose("EditorSettings: Save OK!");
}
}
+Array EditorSettings::get_changed_settings() const {
+ Array arr;
+ for (const String &setting : changed_settings) {
+ arr.push_back(setting);
+ }
+
+ return arr;
+}
+
+bool EditorSettings::check_changed_settings_in_group(const String &p_setting_prefix) const {
+ for (const String &setting : changed_settings) {
+ if (setting.begins_with(p_setting_prefix)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void EditorSettings::mark_setting_changed(const String &p_setting) {
+ changed_settings.insert(p_setting);
+}
+
void EditorSettings::destroy() {
if (!singleton.ptr()) {
return;
@@ -1621,6 +1646,10 @@ void EditorSettings::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_builtin_action_override", "name", "actions_list"), &EditorSettings::set_builtin_action_override);
+ ClassDB::bind_method(D_METHOD("check_changed_settings_in_group", "setting_prefix"), &EditorSettings::check_changed_settings_in_group);
+ ClassDB::bind_method(D_METHOD("get_changed_settings"), &EditorSettings::get_changed_settings);
+ ClassDB::bind_method(D_METHOD("mark_setting_changed", "setting"), &EditorSettings::mark_setting_changed);
+
ADD_SIGNAL(MethodInfo("settings_changed"));
BIND_CONSTANT(NOTIFICATION_EDITOR_SETTINGS_CHANGED);
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index f0fec3acc7..65723a24f8 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -77,6 +77,8 @@ private:
static Ref<EditorSettings> singleton;
+ Set<String> changed_settings;
+
HashMap<String, PropertyInfo> hints;
HashMap<String, VariantContainer> props;
int last_order;
@@ -140,6 +142,9 @@ public:
bool property_can_revert(const String &p_setting);
Variant property_get_revert(const String &p_setting);
void add_property_hint(const PropertyInfo &p_hint);
+ Array get_changed_settings() const;
+ bool check_changed_settings_in_group(const String &p_setting_prefix) const;
+ void mark_setting_changed(const String &p_setting);
void set_resource_clipboard(const Ref<Resource> &p_resource) { clipboard = p_resource; }
Ref<Resource> get_resource_clipboard() const { return clipboard; }