aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Menu/OptionMenu
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-07-21 18:02:38 +0200
committer GitHub <noreply@github.com>2023-07-21 18:02:38 +0200
commit40e412da4a11de97dda041287e306ca285c50ccf (patch)
treea0b28dffaba50d351cab1619f54516be23d2aa6f /game/src/Game/Menu/OptionMenu
parentf3f240853b15a9f9b7cb561dc6626e7f342c5c74 (diff)
parent62d001b0fa209f259440e160503dc5ffe5bcaa8f (diff)
Merge pull request #142 from OpenVicProject/tidying
Tidying: missing req comments, submodules, hotkeys, user data folder
Diffstat (limited to 'game/src/Game/Menu/OptionMenu')
-rw-r--r--game/src/Game/Menu/OptionMenu/OptionsMenu.gd9
-rw-r--r--game/src/Game/Menu/OptionMenu/ResolutionSelector.gd11
-rw-r--r--game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd1
-rw-r--r--game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd4
-rw-r--r--game/src/Game/Menu/OptionMenu/SoundTab.gd4
5 files changed, 15 insertions, 14 deletions
diff --git a/game/src/Game/Menu/OptionMenu/OptionsMenu.gd b/game/src/Game/Menu/OptionMenu/OptionsMenu.gd
index c74c458..93ef3e4 100644
--- a/game/src/Game/Menu/OptionMenu/OptionsMenu.gd
+++ b/game/src/Game/Menu/OptionMenu/OptionsMenu.gd
@@ -66,11 +66,12 @@ func _save_overrides() -> void:
if override_path.is_empty():
override_path = ProjectSettings.get_setting(Events.Options.settings_file_path_setting, Events.Options.settings_file_path_default)
var file := ConfigFile.new()
- var err_ret := file.load(override_path)
- if err_ret != OK: push_error("Failed to load overrides from %s" % override_path)
+ if FileAccess.file_exists(override_path):
+ if file.load(override_path) != OK:
+ push_error("Failed to load overrides from %s" % override_path)
file.set_value("display", "window/size/mode", Resolution.get_current_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)
- err_ret = file.save(override_path)
- if err_ret != OK: push_error("Failed to save overrides to %s" % override_path)
+ if file.save(override_path) != OK:
+ push_error("Failed to save overrides to %s" % override_path)
diff --git a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
index f843815..cb7a1fb 100644
--- a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
+++ b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
@@ -1,10 +1,7 @@
extends SettingRevertButton
# REQUIREMENTS
-# * UIFUN-21
-# * UIFUN-28
-# * UIFUN-301
-# * UIFUN-302
+# * UIFUN-21, UIFUN-28, UIFUN-301, UIFUN-302
@export var default_value : Vector2i = Resolution.error_resolution
@@ -14,7 +11,7 @@ func _find_resolution_index_by_value(value : Vector2i) -> int:
return item_index
return -1
-func _sync_resolutions(value : Vector2i = Resolution.error_resolution) -> void:
+func _sync_resolutions() -> void:
clear()
default_selected = -1
selected = -1
@@ -59,7 +56,7 @@ func _update_resolution_options_text() -> void:
set_item_text(index, display_name)
func _setup_button() -> void:
- Resolution.resolution_added.connect(_sync_resolutions)
+ Resolution.resolution_added.connect(func (_value : Vector2i): _sync_resolutions())
if default_value.x <= 0:
default_value.x = ProjectSettings.get_setting("display/window/size/viewport_width")
if default_value.y <= 0:
@@ -75,6 +72,8 @@ func _get_value_for_file(select_value : int) -> Variant:
else:
return null
+# REQUIREMENTS:
+# * SS-25
func _set_value_from_file(load_value) -> void:
var target_resolution := Resolution.error_resolution
match typeof(load_value):
diff --git a/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd b/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd
index a1a26a0..cb7566f 100644
--- a/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd
+++ b/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd
@@ -1,6 +1,7 @@
extends SettingRevertButton
# REQUIREMENTS
+# * SS-26, SS-127, SS-128
# * UIFUN-42
enum ScreenMode { Unknown = -1, Fullscreen, Borderless, Windowed }
diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
index c5a805e..079dd4d 100644
--- a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
+++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
@@ -57,9 +57,9 @@ func _ready():
item_selected.connect(func(index : int): option_selected.emit(index, true))
_setup_button()
if not _valid_index(default_selected) or selected == -1:
- var msg := "Failed to generate %s %s options." % [setting_name, section_name]
+ var msg := "Failed to generate any valid %s %s options." % [setting_name, section_name]
push_error(msg)
- OS.alert(msg, "%s Options Error" % section_name)
+ OS.alert(msg, "Options Error: %s / %s" % [section_name, setting_name])
get_tree().quit()
func load_setting(file : ConfigFile) -> void:
diff --git a/game/src/Game/Menu/OptionMenu/SoundTab.gd b/game/src/Game/Menu/OptionMenu/SoundTab.gd
index e0d9bcf..d1daf3d 100644
--- a/game/src/Game/Menu/OptionMenu/SoundTab.gd
+++ b/game/src/Game/Menu/OptionMenu/SoundTab.gd
@@ -1,6 +1,6 @@
extends HBoxContainer
-@export var _startup_music_button : Button
+@export var _startup_music_button : SettingCheckBox
func _ready():
- _startup_music_button.option_selected.connect(func (pressed : bool, by_user : bool): MusicConductor.set_startup_music(pressed))
+ _startup_music_button.option_selected.connect(func (pressed : bool, _by_user : bool): MusicConductor.set_startup_music(pressed))