Add settings_changed signal to ProjectSettings
This commit is contained in:
parent
f7bc653cbe
commit
c5ec847aa0
|
@ -283,6 +283,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
|
|||
for (int i = 0; i < custom_feature_array.size(); i++) {
|
||||
custom_features.insert(custom_feature_array[i]);
|
||||
}
|
||||
_queue_changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -324,6 +325,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
|
|||
}
|
||||
}
|
||||
|
||||
_queue_changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -424,6 +426,22 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
}
|
||||
|
||||
void ProjectSettings::_queue_changed() {
|
||||
if (is_changed || !MessageQueue::get_singleton() || MessageQueue::get_singleton()->get_max_buffer_usage() == 0) {
|
||||
return;
|
||||
}
|
||||
is_changed = true;
|
||||
callable_mp(this, &ProjectSettings::_emit_changed).call_deferred();
|
||||
}
|
||||
|
||||
void ProjectSettings::_emit_changed() {
|
||||
if (!is_changed) {
|
||||
return;
|
||||
}
|
||||
is_changed = false;
|
||||
emit_signal("settings_changed");
|
||||
}
|
||||
|
||||
bool ProjectSettings::_load_resource_pack(const String &p_pack, bool p_replace_files, int p_offset) {
|
||||
if (PackedData::get_singleton()->is_disabled()) {
|
||||
return false;
|
||||
|
@ -1225,6 +1243,8 @@ void ProjectSettings::_bind_methods() {
|
|||
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("save_custom", "file"), &ProjectSettings::_save_custom_bnd);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("settings_changed"));
|
||||
}
|
||||
|
||||
void ProjectSettings::_add_builtin_input_map() {
|
||||
|
|
|
@ -45,6 +45,8 @@ class ProjectSettings : public Object {
|
|||
_THREAD_SAFE_CLASS_
|
||||
friend class TestProjectSettingsInternalsAccessor;
|
||||
|
||||
bool is_changed = false;
|
||||
|
||||
public:
|
||||
typedef HashMap<String, Variant> CustomMap;
|
||||
static const String PROJECT_DATA_DIR_NAME_SUFFIX;
|
||||
|
@ -115,6 +117,9 @@ protected:
|
|||
bool _property_can_revert(const StringName &p_name) const;
|
||||
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
|
||||
|
||||
void _queue_changed();
|
||||
void _emit_changed();
|
||||
|
||||
static ProjectSettings *singleton;
|
||||
|
||||
Error _load_settings_text(const String &p_path);
|
||||
|
|
|
@ -2710,4 +2710,11 @@
|
|||
If [code]true[/code], Godot will compile shaders required for XR.
|
||||
</member>
|
||||
</members>
|
||||
<signals>
|
||||
<signal name="settings_changed">
|
||||
<description>
|
||||
Emitted when any setting is changed, up to once per process frame.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
</class>
|
||||
|
|
Loading…
Reference in New Issue