From 3798205c740e7e2faf2594866cb497260012508c Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Fri, 10 Feb 2023 04:18:46 -0500 Subject: Implement a usable settings UI, should fulfill: SS-58, SS-61, SS-6, SS-9, SS-10, SS-11, SS-13 UI-11, UI-12, UI-19, UI-44, UI-47, UI-22 --- game/src/OptionMenu/SettingNodes/SettingHSlider.gd | 20 ++++++++++++++++++++ .../OptionMenu/SettingNodes/SettingOptionButton.gd | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 game/src/OptionMenu/SettingNodes/SettingHSlider.gd create mode 100644 game/src/OptionMenu/SettingNodes/SettingOptionButton.gd (limited to 'game/src/OptionMenu/SettingNodes') diff --git a/game/src/OptionMenu/SettingNodes/SettingHSlider.gd b/game/src/OptionMenu/SettingNodes/SettingHSlider.gd new file mode 100644 index 0000000..da9348f --- /dev/null +++ b/game/src/OptionMenu/SettingNodes/SettingHSlider.gd @@ -0,0 +1,20 @@ +extends HSlider +class_name SettingHSlider + +@export +var section_name : String = "Setting" + +@export +var setting_name : String = "SettingHSlider" + +@export +var default_value : float = 0 + +func load_setting(file : ConfigFile): + value = file.get_value(section_name, setting_name, default_value) + +func save_setting(file : ConfigFile): + file.set_value(section_name, setting_name, value) + +func reset_setting(): + value = default_value diff --git a/game/src/OptionMenu/SettingNodes/SettingOptionButton.gd b/game/src/OptionMenu/SettingNodes/SettingOptionButton.gd new file mode 100644 index 0000000..46fc825 --- /dev/null +++ b/game/src/OptionMenu/SettingNodes/SettingOptionButton.gd @@ -0,0 +1,22 @@ +extends OptionButton +class_name SettingOptionButton + +@export +var section_name : String = "Setting" + +@export +var setting_name : String = "SettingOptionMenu" + +@export +var default_value : int = 0 + +func load_setting(file : ConfigFile): + selected = file.get_value(section_name, setting_name, default_value) + item_selected.emit(selected) + +func save_setting(file : ConfigFile): + file.set_value(section_name, setting_name, selected) + +func reset_setting(): + selected = default_value + item_selected.emit(selected) -- cgit v1.2.3-56-ga3b1