aboutsummaryrefslogtreecommitdiff
path: root/game/src/OptionMenu/SettingNodes/SettingHSlider.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/SettingNodes/SettingHSlider.gd
parent73e29d02e48739aba5ca5db1b9575c67e795400f (diff)
Reorganize the file structure of the files in `game/src`
Diffstat (limited to 'game/src/OptionMenu/SettingNodes/SettingHSlider.gd')
-rw-r--r--game/src/OptionMenu/SettingNodes/SettingHSlider.gd41
1 files changed, 0 insertions, 41 deletions
diff --git a/game/src/OptionMenu/SettingNodes/SettingHSlider.gd b/game/src/OptionMenu/SettingNodes/SettingHSlider.gd
deleted file mode 100644
index 6fa30ed..0000000
--- a/game/src/OptionMenu/SettingNodes/SettingHSlider.gd
+++ /dev/null
@@ -1,41 +0,0 @@
-extends HSlider
-class_name SettingHSlider
-
-@export
-var section_name : String = "setting"
-
-@export
-var setting_name : String = "setting_hslider"
-
-@export
-var default_value : float = 0
-
-func _ready():
- Events.Options.load_settings.connect(load_setting)
- Events.Options.save_settings.connect(save_setting)
- Events.Options.reset_settings.connect(reset_setting)
-
-func load_setting(file : ConfigFile):
- if file == null: return
- var load_value = file.get_value(section_name, setting_name, default_value)
- match typeof(load_value):
- TYPE_FLOAT, TYPE_INT:
- if value == load_value: value_changed.emit(value)
- value = load_value
- return
- TYPE_STRING, TYPE_STRING_NAME:
- var load_string := load_value as String
- if load_string.is_valid_float():
- load_value = load_string.to_float()
- if value == load_value: value_changed.emit(value)
- value = load_value
- return
- push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name])
- value = default_value
-
-func save_setting(file : ConfigFile):
- if file == null: return
- file.set_value(section_name, setting_name, value)
-
-func reset_setting():
- value = default_value