aboutsummaryrefslogtreecommitdiff
path: root/game/src/OptionMenu/OptionsMenu.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/OptionMenu/OptionsMenu.gd
parent73e29d02e48739aba5ca5db1b9575c67e795400f (diff)
Reorganize the file structure of the files in `game/src`
Diffstat (limited to 'game/src/OptionMenu/OptionsMenu.gd')
-rw-r--r--game/src/OptionMenu/OptionsMenu.gd68
1 files changed, 0 insertions, 68 deletions
diff --git a/game/src/OptionMenu/OptionsMenu.gd b/game/src/OptionMenu/OptionsMenu.gd
deleted file mode 100644
index 5f6a088..0000000
--- a/game/src/OptionMenu/OptionsMenu.gd
+++ /dev/null
@@ -1,68 +0,0 @@
-extends Control
-
-# REQUIREMENTS
-# * SS-13
-
-signal back_button_pressed
-
-func _ready():
- # Prepare options menu before loading user settings
- 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
- # These buttons can be accessed regardless of the tab
- var button_list := HBoxContainer.new()
- button_list.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
- button_list.alignment = BoxContainer.ALIGNMENT_END
- tab_bar.add_child(button_list)
-
- # REQUIREMENTS
- # * UI-12
- # * UIFUN-14
- var reset_button := Button.new()
- reset_button.text = "OPTIONS_RESET"
- reset_button.pressed.connect(Events.Options.try_reset_settings)
- button_list.add_child(reset_button)
-
- # REQUIREMENTS
- # * UI-11
- # * UIFUN-17
- var back_button := Button.new()
- back_button.text = "OPTIONS_BACK"
- back_button.pressed.connect(_on_back_button_pressed)
- 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:
- NOTIFICATION_CRASH:
- _on_window_close_requested()
-
-func _input(event):
- if self.is_visible_in_tree():
- if event.is_action_pressed("ui_cancel"):
- _on_back_button_pressed()
-
-func _on_back_button_pressed():
- Events.Options.save_settings_to_file()
- back_button_pressed.emit()
-
-func _on_window_close_requested() -> void:
- if visible:
- Events.Options.save_settings_to_file()
-
-func _save_overrides() -> void:
- 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()
- 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)
- err_ret = file.save(override_path)
- if err_ret != OK: push_error("Failed to save overrides to %s" % override_path)