aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Autoload/Events/Options.gd
blob: 726960b461f9a2f5ae06de4a481682cb019a2d1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class_name OptionsEventsObject
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
# * UIFUN-13
# * FS-563
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"
# REQUIREMENTS
# * FS-561
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, UIFUN-12
# * FS-562
func _init():
   if FileAccess.file_exists(_settings_file_path):
      _settings_file.load(_settings_file_path)