diff options
author | metamuffin <metamuffin@disroot.org> | 2025-09-17 00:25:40 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-09-17 00:25:43 +0200 |
commit | a291e301402a8271c33a9a09d4b5035bf734be3c (patch) | |
tree | 983fd66e48b121b3660f21c54a286540ab589f31 /client | |
parent | 6130b4e67340af360b5907f3b57bbc3ec1aa2d04 (diff) | |
download | hurrycurry-a291e301402a8271c33a9a09d4b5035bf734be3c.tar hurrycurry-a291e301402a8271c33a9a09d4b5035bf734be3c.tar.bz2 hurrycurry-a291e301402a8271c33a9a09d4b5035bf734be3c.tar.zst |
Store config files in their proper locations
Diffstat (limited to 'client')
-rw-r--r-- | client/global.gd | 4 | ||||
-rw-r--r-- | client/system/profile.gd | 10 | ||||
-rw-r--r-- | client/system/settings.gd | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/client/global.gd b/client/global.gd index 461693ce..23e9756c 100644 --- a/client/global.gd +++ b/client/global.gd @@ -37,8 +37,8 @@ var focused_node: Control var focused_menu: Menu # only use this as a last resort, currently exists to open setup menu from settings func _ready(): - Profile.load("user://profile") - Settings.load("user://settings.json") + Profile.load(OS.get_data_dir().path_join("hurrycurry").path_join("profile")) + Settings.load(OS.get_config_dir().path_join("hurrycurry").path_join("settings.json")) get_viewport().gui_focus_changed.connect(Sound.play_hover_maybe) get_viewport().gui_focus_changed.connect(func(node): focused_node = node) diff --git a/client/system/profile.gd b/client/system/profile.gd index 438e8e66..35706f2d 100644 --- a/client/system/profile.gd +++ b/client/system/profile.gd @@ -44,17 +44,21 @@ static var loaded_path: String static func load(path: String): # TOCTOU here. Godot docs says its fine. + print("Loading profile from %s" % path) if not FileAccess.file_exists(path): - print("Skip profile load") - return default_profile + print(" -> using default profile") + values = default_profile.duplicate_deep() + loaded_path = path + return var f = FileAccess.open(path, FileAccess.READ) values = f.get_var(true) + loaded_path = path if values != null and values is Dictionary: G.add_missing_keys(values, default_profile) - loaded_path = path static func save(): + DirAccess.make_dir_recursive_absolute(loaded_path.rsplit("/", true, 1)[0]) var f = FileAccess.open(loaded_path, FileAccess.WRITE) var to_save = values.duplicate(true) f.store_var(to_save, true) diff --git a/client/system/settings.gd b/client/system/settings.gd index 1cacfce9..43613de0 100644 --- a/client/system/settings.gd +++ b/client/system/settings.gd @@ -105,6 +105,7 @@ static func write(key: String, value): else: write_unchecked(key, value) static func load(path: String): + print("Loading settings from %s" % path) tree = get_root() loaded_path = path var changed = {} @@ -116,6 +117,7 @@ static func load(path: String): static func save(): var changed = {} tree.save(changed) + DirAccess.make_dir_recursive_absolute(loaded_path.rsplit("/", true, 1)[0]) var f = FileAccess.open(loaded_path, FileAccess.WRITE) f.store_string(JSON.stringify(changed)) |