aboutsummaryrefslogtreecommitdiff
path: root/game/src/OptionMenu/OptionsMenu.gd
diff options
context:
space:
mode:
Diffstat (limited to 'game/src/OptionMenu/OptionsMenu.gd')
-rw-r--r--game/src/OptionMenu/OptionsMenu.gd48
1 files changed, 17 insertions, 31 deletions
diff --git a/game/src/OptionMenu/OptionsMenu.gd b/game/src/OptionMenu/OptionsMenu.gd
index e3c8433..5aba7f2 100644
--- a/game/src/OptionMenu/OptionsMenu.gd
+++ b/game/src/OptionMenu/OptionsMenu.gd
@@ -1,27 +1,9 @@
extends Control
-@export
-var user_settings_file_path : String = "settings.cfg"
-
signal back_button_pressed
-signal save_settings(save_file: ConfigFile)
-signal load_settings(load_file: ConfigFile)
-signal reset_settings()
-
-@onready
-var _settings_file_path := "user://" + user_settings_file_path
-var _settings_file := ConfigFile.new()
-
func _ready():
# Prepare options menu before loading user settings
-
- print("TODO: Load user settings!")
-
- if FileAccess.file_exists(_settings_file_path):
- _settings_file.load(_settings_file_path)
- load_settings.emit(_settings_file)
-
var tab_bar : TabBar = $Margin/Tab.get_child(0, true)
# This ends up easier to manage then trying to manually recreate the TabContainer's behavior
@@ -33,7 +15,7 @@ func _ready():
var reset_button := Button.new()
reset_button.text = "R"
- reset_button.pressed.connect(func(): reset_settings.emit())
+ reset_button.pressed.connect(Events.Options.try_reset_settings)
button_list.add_child(reset_button)
var back_button := Button.new()
@@ -42,6 +24,8 @@ func _ready():
button_list.add_child(back_button)
get_viewport().get_window().close_requested.connect(_on_window_close_requested)
+ _save_overrides.call_deferred()
+ Events.Options.save_settings.connect(func(_f): self._save_overrides.call_deferred())
func _notification(what):
match what:
@@ -51,22 +35,24 @@ func _notification(what):
# Could pass the LocaleButton between the MainMenu and OptionsMenu
# but that seems a bit excessive
func toggle_locale_button_visibility(locale_visible : bool):
- print("Toggling locale button: %s" % locale_visible)
$LocaleVBox/LocaleHBox/LocaleButton.visible = locale_visible
-func _on_ear_exploder_toggled(button_pressed):
- print("KABOOM!!!" if button_pressed else "DEFUSED!!!")
-
-
func _on_back_button_pressed():
- save_settings.emit(_settings_file)
- _settings_file.save(_settings_file_path)
+ Events.Options.save_settings_from_file()
back_button_pressed.emit()
-
-func _on_spin_box_value_changed(value):
- print("Spinbox: %d" % value)
-
func _on_window_close_requested() -> void:
if visible:
- _on_back_button_pressed()
+ Events.Options.save_settings_from_file()
+
+func _save_overrides() -> void:
+ var override_path := ProjectSettings.get_setting("application/config/project_settings_override") as String
+ if override_path == null or override_path.is_empty():
+ override_path = ProjectSettings.get_setting("openvic2/settings/settings_file_path") as String
+ var file := ConfigFile.new()
+ file.load(override_path)
+ file.set_value("display", "window/size/mode", get_viewport().get_window().mode)
+ var resolution : Vector2i = Resolution.get_current_resolution()
+ file.set_value("display", "window/size/viewport_width", resolution.x)
+ file.set_value("display", "window/size/viewport_height", resolution.y)
+ file.save(override_path)