Skip to content

Added ability to get list of Project Settings changed, similar to Editor Settings functionality #13244

@MauriceButler

Description

@MauriceButler

Describe the project you are working on

I am working on multiple addons that listen to settings changes.

The main one affected by this is https://github.com/MauriceButler/godot-layer-name-enums, as it needs to do processing when specific project settings change.

Anything that needs to respond or change to project settings changes is affected by this, as currently debouncing and / or checking the specific setting each time is required.

Describe the problem or limitation you are having in your project

When any project setting is saved, regardless of whether the saved value is different, the generic settings_changed signal is fired.

If multiple settings are changed, this signal is fired multiple times.

Currently, I need to debounce these changes (wait for an amount of time with no signals), then read and process all settings I am interested in, then create a checksum to see if anything has changed vs the cached versions I have stored.

func _on_project_setting_changed() -> void:
	wait_tickets += 1
	var wait_number := wait_tickets
	await get_tree().create_timer(INPUT_WAIT_SECONDS).timeout
	if wait_number != wait_tickets: return
	
	layer_settings_cache.clear()

        for setting_key in setting_keys:
            # - Read setting
            # - Add to layer_settings_cache

        var new_hash = generate_hash(layer_settings_cache)

        if old_hash == new_hash:
            return

        old_hash = new_hash

Describe the feature / enhancement and how it helps to overcome the problem or limitation

With this proposal, new functions get_changed_settings and check_changed_settings_in_group would be added to allow this data to be retrieved in the same way as the Editor Settings work. This would allow signal listeners to decide if the change was related to a setting my addon is interested in and only process when necessary.

This would also ensure that only actual changes are signalled.
This will fix a related bug (godotengine/godot#110747) and would provide enough context to enable this bug to be addressed (godotengine/godot#80808)

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

This change will introduce new functions get_changed_settings and check_changed_settings_in_group and capturing the current value before setting a change, and confirming a difference before triggering the event.

This brings Project Settings to parity with the Editor Settings functionality.

I have created a PR to demonstrate the proposal godotengine/godot#110748

In this PR, the original signal settings_changed has not been changed and is thus non-breaking.

The new functions can be used in a signal handler to make decisions on the changes.

func _on_project_setting_changed() -> void:
	if !ProjectSettings.check_changed_settings_in_group('my_settings'):
		return

	var changed_settings = ProjectSettings.get_changed_settings()

	# process settings

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be worked around, but it is inefficient and "hacky".

See the code in the limitation section.

Regardless, bringing Project and Editor settings into functional alignment would be great.

Is there a reason why this should be core and not an add-on in the asset library?

This is a core signal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions