aboutsummaryrefslogtreecommitdiff
path: root/game/src/OptionMenu/OptionsMenu.gd
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-02-26 17:12:07 +0100
committer GitHub <noreply@github.com>2023-02-26 17:12:07 +0100
commit93c6b207c11fdaba484410eb53fc11b35fbbb3bd (patch)
tree911753c663adb3955ab15cc8b5ac37498c2fda6e /game/src/OptionMenu/OptionsMenu.gd
parenta37c5085c3b7ee515789d681c8c18d71071fb771 (diff)
Add Setting Sanatization (#21)
Diffstat (limited to 'game/src/OptionMenu/OptionsMenu.gd')
-rw-r--r--game/src/OptionMenu/OptionsMenu.gd16
1 files changed, 9 insertions, 7 deletions
diff --git a/game/src/OptionMenu/OptionsMenu.gd b/game/src/OptionMenu/OptionsMenu.gd
index 5aba7f2..c25c3b8 100644
--- a/game/src/OptionMenu/OptionsMenu.gd
+++ b/game/src/OptionMenu/OptionsMenu.gd
@@ -38,21 +38,23 @@ func toggle_locale_button_visibility(locale_visible : bool):
$LocaleVBox/LocaleHBox/LocaleButton.visible = locale_visible
func _on_back_button_pressed():
- Events.Options.save_settings_from_file()
+ Events.Options.save_settings_to_file()
back_button_pressed.emit()
func _on_window_close_requested() -> void:
if visible:
- Events.Options.save_settings_from_file()
+ Events.Options.save_settings_to_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 override_path : String = ProjectSettings.get_setting("application/config/project_settings_override", "")
+ 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()
- file.load(override_path)
+ var err_ret := file.load(override_path)
+ if err_ret != OK: push_error("Failed to load overrides from %s" % 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)
+ err_ret = file.save(override_path)
+ if err_ret != OK: push_error("Failed to save overrides to %s" % override_path)