aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Autoload/Events/Options.gd
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-06-03 20:37:10 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-06-03 20:37:10 +0200
commitcef940108fe15752c3ef66f43f5169403fa2f71d (patch)
treefe4de5a05830e3bddeae78f74f729503b7cee1e9 /game/src/Game/Autoload/Events/Options.gd
parent73e29d02e48739aba5ca5db1b9575c67e795400f (diff)
Reorganize the file structure of the files in `game/src`
Diffstat (limited to 'game/src/Game/Autoload/Events/Options.gd')
-rw-r--r--game/src/Game/Autoload/Events/Options.gd30
1 files changed, 30 insertions, 0 deletions
diff --git a/game/src/Game/Autoload/Events/Options.gd b/game/src/Game/Autoload/Events/Options.gd
new file mode 100644
index 0000000..fbeccef
--- /dev/null
+++ b/game/src/Game/Autoload/Events/Options.gd
@@ -0,0 +1,30 @@
+extends RefCounted
+
+signal save_settings(save_file: ConfigFile)
+signal load_settings(load_file: ConfigFile)
+signal reset_settings()
+
+func load_settings_from_file() -> void:
+ load_settings.emit(_settings_file)
+
+# REQUIREMENTS
+# * SS-11
+func save_settings_to_file() -> void:
+ save_settings.emit(_settings_file)
+ _settings_file.save(_settings_file_path)
+
+func try_reset_settings() -> void:
+ reset_settings.emit()
+
+const settings_file_path_setting : String = "openvic/settings/settings_file_path"
+const settings_file_path_default : String = "user://settings.cfg"
+
+var _settings_file_path : String = ProjectSettings.get_setting(settings_file_path_setting, settings_file_path_default)
+var _settings_file := ConfigFile.new()
+
+# REQUIREMENTS
+# * SS-9
+# * UIFUN-7
+func _init():
+ if FileAccess.file_exists(_settings_file_path):
+ _settings_file.load(_settings_file_path)