diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-07 14:11:05 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-07 14:11:05 +0200 |
commit | 5e105902f0abfaba01bc878956fe3c9a096aa455 (patch) | |
tree | 8d26374137a1f9d6cf4dc9f526de59103dc82f11 | |
parent | 923b4d1aa63b6226365a53a7fe227a734760ed1e (diff) | |
download | hurrycurry-5e105902f0abfaba01bc878956fe3c9a096aa455.tar hurrycurry-5e105902f0abfaba01bc878956fe3c9a096aa455.tar.bz2 hurrycurry-5e105902f0abfaba01bc878956fe3c9a096aa455.tar.zst |
wildcard hooks
-rw-r--r-- | client/global.gd | 5 | ||||
-rw-r--r-- | client/settings.gd | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/client/global.gd b/client/global.gd index 7629b05d..0923b457 100644 --- a/client/global.gd +++ b/client/global.gd @@ -144,10 +144,9 @@ func get_setting(key: String): func set_setting_unchecked(key: String, value): value = value.duplicate(true) if value is Array else value - if key in settings and typeof(settings[key]) == typeof(value) and settings[key] == value: return + if key in settings and typeof(settings[key]) == typeof(value) and not value is Array and settings[key] == value: return settings[key] = value - if Settings.change_hooks_display.get(key) != null: Settings.change_hooks_display.get(key).call(value) - if Settings.change_hooks_apply.get(key) != null: Settings.change_hooks_apply.get(key).call(value) + Settings.trigger_hook(key, value) save_settings() func set_setting(key: String, value): diff --git a/client/settings.gd b/client/settings.gd index 5501f1ab..341db7cc 100644 --- a/client/settings.gd +++ b/client/settings.gd @@ -66,6 +66,11 @@ static func get_root(): ]) ]) +static func trigger_hook(key: String, value): + if Settings.change_hooks_display.get(key) != null: Settings.change_hooks_display.get(key).call(value) + if Settings.change_hooks_apply.get(key) != null: Settings.change_hooks_apply.get(key).call(value) + if key.find(".") != -1: trigger_hook(key.rsplit(".", false, 1)[0], null) + static func hook_changed(key: String, display: bool, callable: Callable): if display: change_hooks_display[key] = callable else: change_hooks_apply[key] = callable @@ -76,6 +81,7 @@ static func hook_changed_init(key: String, display: bool, callable: Callable): static var change_hooks_display = {} static var change_hooks_apply = { + "input": h_input, "graphics.aa": h_aa, "graphics.taa": h_taa, "graphics.fullscreen": h_fullscreen, @@ -142,10 +148,11 @@ static func h_fullscreen(mode: String): "never": if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) +static func h_input(_x): + pass + # InputManager.apply_input_map(InputManager.settings_dictionary_to_input_map()) + # TODO whatever this does # if not get_setting("tutorial_started"): # for k in profile["hints"].keys(): # set_hint(k, false) - -# TODO update input map for *all* input with a single hook -# InputManager.apply_input_map(InputManager.settings_dictionary_to_input_map(get_category_settings("input"))) |