aboutsummaryrefslogtreecommitdiff
path: root/client/system
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-09-22 23:13:58 +0200
committermetamuffin <metamuffin@disroot.org>2025-09-22 23:14:21 +0200
commitfed8a4f8cd2adc9191211f74f284f93eb8f1ac53 (patch)
tree27a2db9896c112fb903b38f0cf2392b676d2270a /client/system
parentaba816f923b8bcd33d53eabd93b01c6e85f4dc75 (diff)
downloadhurrycurry-fed8a4f8cd2adc9191211f74f284f93eb8f1ac53.tar
hurrycurry-fed8a4f8cd2adc9191211f74f284f93eb8f1ac53.tar.bz2
hurrycurry-fed8a4f8cd2adc9191211f74f284f93eb8f1ac53.tar.zst
Disable setting reset if default; refactor setting hook system (fix #379)
Diffstat (limited to 'client/system')
-rw-r--r--client/system/settings.gd39
1 files changed, 19 insertions, 20 deletions
diff --git a/client/system/settings.gd b/client/system/settings.gd
index a3aece89..cd990216 100644
--- a/client/system/settings.gd
+++ b/client/system/settings.gd
@@ -123,16 +123,16 @@ static func save():
f.store_string(JSON.stringify(changed))
static func trigger_hook(key: String, value):
- if change_hooks_display.get(key) != null: change_hooks_display.get(key).callv([value] if value != null else [])
- if change_hooks_apply.get(key) != null: change_hooks_apply.get(key).callv([value] if value != null else [])
+ for slot in change_hooks.get(key, {}):
+ change_hooks[key][slot].callv([value] if value != null else [])
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
+static func hook_changed(key: String, slot: String, callable: Callable):
+ if not change_hooks.has(key): change_hooks[key] = {}
+ change_hooks[key][slot] = callable
-static func hook_changed_init(key: String, display: bool, callable: Callable):
- hook_changed(key, display, callable)
+static func hook_changed_init(key: String, slot: String, callable: Callable):
+ hook_changed(key, slot, callable)
callable.call(read(key))
static func get_category_dict(prefix: String):
@@ -146,19 +146,18 @@ static func get_category_dict(prefix: String):
static func launch_setup():
Global.focused_menu.submenu("res://gui/menus/setup/setup.tscn")
-static var change_hooks_display = {}
-static var change_hooks_apply = {
- "input": h_input,
- "gameplay.hints_started": h_hints_started,
- "graphics.aa": h_aa,
- "graphics.taa": h_taa,
- "graphics.fullscreen": h_fullscreen,
- "ui.scale_mode": h_scale_mode,
- "ui.scale_factor": h_scale_factor,
- "ui.language": h_language,
- "audio.master_volume": h_volume_master,
- "audio.music_volume": h_volume_music,
- "audio.sfx_volume": h_volume_sfx,
+static var change_hooks = {
+ "input": { "static": h_input },
+ "gameplay.hints_started": { "static": h_hints_started },
+ "graphics.aa": { "static": h_aa },
+ "graphics.taa": { "static": h_taa },
+ "graphics.fullscreen": { "static": h_fullscreen },
+ "ui.scale_mode": { "static": h_scale_mode },
+ "ui.scale_factor": { "static": h_scale_factor },
+ "ui.language": { "static": h_language },
+ "audio.master_volume": { "static": h_volume_master },
+ "audio.music_volume": { "static": h_volume_music },
+ "audio.sfx_volume": { "static": h_volume_sfx },
}
static func h_aa(_mode):