aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Menu/OptionMenu/SettingNodes
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-12-24 19:23:18 +0100
committer GitHub <noreply@github.com>2023-12-24 19:23:18 +0100
commitd26c990d9a5596a3ef3b32ba1cb0f99950cd6d34 (patch)
tree1b99c935438692bb2ebadeac412b990c82089b65 /game/src/Game/Menu/OptionMenu/SettingNodes
parent50b0b935b0bf0724f40b5140aca85d1830a8b1b3 (diff)
parentb6413251a866c76538869b84ed1c9b9852f7c507 (diff)
Merge pull request #178 from Spartan322/add-menu-type-hints
Diffstat (limited to 'game/src/Game/Menu/OptionMenu/SettingNodes')
-rw-r--r--game/src/Game/Menu/OptionMenu/SettingNodes/SettingCheckBox.gd6
-rw-r--r--game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd10
-rw-r--r--game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd8
-rw-r--r--game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd2
4 files changed, 13 insertions, 13 deletions
diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingCheckBox.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingCheckBox.gd
index 344a2b5..46fe4d7 100644
--- a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingCheckBox.gd
+++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingCheckBox.gd
@@ -15,14 +15,14 @@ var default_pressed : bool = true
func _setup_button() -> void:
pass
-func _ready():
+func _ready() -> void:
Events.Options.load_settings.connect(load_setting)
Events.Options.save_settings.connect(save_setting)
Events.Options.reset_settings.connect(reset_setting)
- toggled.connect(func(p : bool): option_selected.emit(p, true))
+ toggled.connect(func(p : bool) -> void: option_selected.emit(p, true))
_setup_button()
-func _set_value_from_file(load_value) -> void:
+func _set_value_from_file(load_value : Variant) -> void:
match typeof(load_value):
TYPE_BOOL, TYPE_INT:
set_pressed_no_signal(load_value as bool)
diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd
index 6fa30ed..a728ba0 100644
--- a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd
+++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd
@@ -10,14 +10,14 @@ var setting_name : String = "setting_hslider"
@export
var default_value : float = 0
-func _ready():
+func _ready() -> void:
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):
+func load_setting(file : ConfigFile) -> void:
if file == null: return
- var load_value = file.get_value(section_name, setting_name, default_value)
+ var load_value : Variant = 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)
@@ -33,9 +33,9 @@ func load_setting(file : ConfigFile):
push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name])
value = default_value
-func save_setting(file : ConfigFile):
+func save_setting(file : ConfigFile) -> void:
if file == null: return
file.set_value(section_name, setting_name, value)
-func reset_setting():
+func reset_setting() -> void:
value = default_value
diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
index 079dd4d..a972ed6 100644
--- a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
+++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd
@@ -21,13 +21,13 @@ var default_selected : int = -1:
func _valid_index(index : int) -> bool:
return 0 <= index and index < item_count
-func _get_value_for_file(select_value : int):
+func _get_value_for_file(select_value : int) -> Variant:
if _valid_index(select_value):
return select_value
else:
return null
-func _set_value_from_file(load_value) -> void:
+func _set_value_from_file(load_value : Variant) -> void:
match typeof(load_value):
TYPE_INT:
if _valid_index(load_value):
@@ -50,11 +50,11 @@ func _set_value_from_file(load_value) -> void:
func _setup_button() -> void:
pass
-func _ready():
+func _ready() -> void:
Events.Options.load_settings.connect(load_setting)
Events.Options.save_settings.connect(save_setting)
Events.Options.reset_settings.connect(reset_setting)
- item_selected.connect(func(index : int): option_selected.emit(index, true))
+ item_selected.connect(func(index : int) -> void: option_selected.emit(index, true))
_setup_button()
if not _valid_index(default_selected) or selected == -1:
var msg := "Failed to generate any valid %s %s options." % [setting_name, section_name]
diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd
index 431e3e5..6785f73 100644
--- a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd
+++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd
@@ -6,7 +6,7 @@ class_name SettingRevertButton
var previous_index : int = -1
-func _ready():
+func _ready() -> void:
super()
if revert_dialog != null:
revert_dialog.visibility_changed.connect(_on_revert_dialog_visibility_changed)