diff options
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/blur_setup.gd | 8 | ||||
-rw-r--r-- | client/menu/entry.gd | 2 | ||||
-rw-r--r-- | client/menu/game.gd | 2 | ||||
-rw-r--r-- | client/menu/main.tscn | 10 | ||||
-rw-r--r-- | client/menu/popup_message.gd | 14 | ||||
-rw-r--r-- | client/menu/settings.gd | 43 | ||||
-rw-r--r-- | client/menu/settings.tscn | 9 | ||||
-rw-r--r-- | client/menu/settings/dropdown_setting.gd | 21 | ||||
-rw-r--r-- | client/menu/settings/game_setting.gd | 50 | ||||
-rw-r--r-- | client/menu/settings/input/input_manager.gd | 35 | ||||
-rw-r--r-- | client/menu/settings/input/input_setting.gd | 16 | ||||
-rw-r--r-- | client/menu/settings/input/input_value_node.gd | 5 | ||||
-rw-r--r-- | client/menu/settings/preset_row.gd (renamed from client/menu/settings/preset.gd) | 13 | ||||
-rw-r--r-- | client/menu/settings/range_setting.gd | 18 | ||||
-rw-r--r-- | client/menu/settings/settings_category.gd | 51 | ||||
-rw-r--r-- | client/menu/settings/settings_root.gd | 36 | ||||
-rw-r--r-- | client/menu/settings/settings_row.gd | 1 | ||||
-rw-r--r-- | client/menu/settings/text_setting.gd | 19 | ||||
-rw-r--r-- | client/menu/settings/toggle_setting.gd | 19 | ||||
-rw-r--r-- | client/menu/setup.gd | 2 |
20 files changed, 177 insertions, 197 deletions
diff --git a/client/menu/blur_setup.gd b/client/menu/blur_setup.gd index 97729074..b5b5dde9 100644 --- a/client/menu/blur_setup.gd +++ b/client/menu/blur_setup.gd @@ -16,8 +16,8 @@ extends Control func _ready(): - update() - Global.settings_changed.connect(update) + update(Global.get_setting("ui.blur")) + Settings.hook_changed("ui.blur", update) -func update(): - material.set_shader_parameter("enable_blur", Global.get_setting("ui_blur")) +func update(state): + material.set_shader_parameter("enable_blur", state) diff --git a/client/menu/entry.gd b/client/menu/entry.gd index 5ca6dacb..456709ed 100644 --- a/client/menu/entry.gd +++ b/client/menu/entry.gd @@ -18,7 +18,7 @@ extends Menu func _ready(): super() - if not Global.get_setting("setup_complete"): + if not Global.get_setting("gameplay.setup_complete"): await submenu("res://menu/setup.tscn") else: await submenu("res://menu/main.tscn") diff --git a/client/menu/game.gd b/client/menu/game.gd index f50a43a6..a2eb858c 100644 --- a/client/menu/game.gd +++ b/client/menu/game.gd @@ -43,7 +43,7 @@ func _menu_cover(state): game.camera.update_disable_input() func _process(_delta): - if Global.get_setting("debug_info"): + if Global.get_setting("graphics.debug_info"): debug_label.show() debug_label.text = "%d FPS\nDriver: %s" % [Engine.get_frames_per_second(), ProjectSettings.get_setting("rendering/rendering_device/driver")] else: debug_label.hide() diff --git a/client/menu/main.tscn b/client/menu/main.tscn index 94726109..26decd2b 100644 --- a/client/menu/main.tscn +++ b/client/menu/main.tscn @@ -63,27 +63,27 @@ layout_mode = 2 [node name="play" type="Button" parent="side/margin/options/first"] layout_mode = 2 -text = "Play" +text = "c.menu.play" alignment = 0 [node name="change_character" type="Button" parent="side/margin/options/first"] layout_mode = 2 -text = "My Chef" +text = "c.menu.my_chef" alignment = 0 [node name="settings" type="Button" parent="side/margin/options/first"] layout_mode = 2 -text = "Settings" +text = "c.menu.settings" alignment = 0 [node name="credits" type="Button" parent="side/margin/options/first"] layout_mode = 2 -text = "Credits" +text = "c.menu.credits" alignment = 0 [node name="quit" type="Button" parent="side/margin/options/first"] layout_mode = 2 -text = "Quit" +text = "c.menu.quit" alignment = 0 [connection signal="pressed" from="side/margin/options/first/play" to="." method="_on_play_pressed"] diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd index 90e86faa..1464e20c 100644 --- a/client/menu/popup_message.gd +++ b/client/menu/popup_message.gd @@ -109,24 +109,24 @@ func _input(_event): Global.set_hint("has_reset", true) func _on_boost_timeout(): - if not Global.get_hint("has_boosted") and not Global.get_setting("touch_controls"): + if not Global.get_hint("has_boosted") and not Global.get_setting("ui.touch_controls"): display_hint_msg(tr("Press %s to boost") % display_keybind(tr("SHIFT"), "B")) func _on_move_timeout(): - if not Global.get_hint("has_moved") and not Global.get_setting("touch_controls"): + if not Global.get_hint("has_moved") and not Global.get_setting("ui.touch_controls"): display_hint_msg(tr("Use %s to move") % display_keybind("WASD", tr("left stick"))) func _on_interact_timeout(): - if not Global.get_hint("has_interacted") and not Global.get_setting("touch_controls"): + if not Global.get_hint("has_interacted") and not Global.get_setting("ui.touch_controls"): var keybind = display_keybind(tr("SPACE"), "A") display_hint_msg(tr("Press %s to pick up items and hold %s to interact with tools") % [keybind, keybind]) func _on_reset_timeout(): - if not Global.get_hint("has_reset") and not Global.get_setting("touch_controls"): + if not Global.get_hint("has_reset") and not Global.get_setting("ui.touch_controls"): display_hint_msg(tr("Press %s to reset the camera view") % display_keybind("R", "Y")) func _on_zoom_timeout(): - if not Global.get_hint("has_zoomed") and not Global.get_setting("touch_controls"): + if not Global.get_hint("has_zoomed") and not Global.get_setting("ui.touch_controls"): display_hint_msg(tr("Use %s to zoom in/out") % display_keybind(tr("PageUp/PageDown"), "LT/RT")) func display_keybind(keyboard: String, joypad: String, touch = null) -> String: @@ -143,11 +143,11 @@ func any_action_just_pressed(actions: Array) -> bool: return false func _on_rotate_camera_timeout(): - if not Global.get_hint("has_rotated") and not Global.get_setting("touch_controls"): + if not Global.get_hint("has_rotated") and not Global.get_setting("ui.touch_controls"): display_hint_msg(tr("Use %s to rotate the camera view") % display_keybind(tr("arrow keys"), tr("right stick"))) func _on_nametags_timeout(): - if not Global.get_hint("has_seen_nametags") and not Global.get_setting("usernames"): + if not Global.get_hint("has_seen_nametags") and not Global.get_setting("graphics.usernames"): Global.set_hint("has_seen_nametags", true) display_hint_msg(tr("Username tags can be enabled/disabled in the settings")) diff --git a/client/menu/settings.gd b/client/menu/settings.gd index eb143900..b47331c6 100644 --- a/client/menu/settings.gd +++ b/client/menu/settings.gd @@ -16,52 +16,17 @@ # extends Menu -const SETTINGS_ROW_SCENE = preload("res://menu/settings/settings_row.tscn") - -@onready var settings_tabs: TabContainer = $OuterGap/Panel/InnerGap/VBoxContainer/TabContainer +@onready var container = $OuterGap/Panel/InnerGap/VBoxContainer func _ready(): super() - update_rows() + Global.settings_tree._update_row() + container.add_child(Global.settings_tree.row) + container.move_child(Global.settings_tree.row, 1) func _on_back_pressed(): exit() func exit(): Global.save_settings() - Global.apply_settings() super() - -func update_rows(fix_focus = false): - for c in settings_tabs.get_children(): - c.queue_free() - - for category: SettingsCategory in Global.default_settings: - var category_settings = category.settings - var scroll := ScrollContainerCustom.new() - var options := VBoxContainer.new() - scroll.name = category.name - scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL - settings_tabs.add_child(scroll) - options.size_flags_horizontal = Control.SIZE_EXPAND_FILL - scroll.add_child(options) - - var category_presets = category.presets - if category_presets != null: - for i: Preset in category_presets: - var row: SettingsRow = SETTINGS_ROW_SCENE.instantiate() - options.add_child(row) - row.label.text = i.label - row.reset_button.visible = false - for b in i.buttons(): - row.value_parent.add_child(b) - - for k: String in category_settings.keys(): - var row: SettingsRow = Global.settings[k].get_row() - options.add_child(row) - - if fix_focus: - pass - # TODO: Not implemented! - # await get_tree().process_frame - # Global.focus_first(self) diff --git a/client/menu/settings.tscn b/client/menu/settings.tscn index 9f523f7c..0a55e222 100644 --- a/client/menu/settings.tscn +++ b/client/menu/settings.tscn @@ -1,12 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://8ic77jmadadj"] +[gd_scene load_steps=5 format=3 uid="uid://8ic77jmadadj"] [ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_foq3a"] [ext_resource type="Script" path="res://menu/settings.gd" id="2_3hgm8"] [ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/dark_blur_material.tres" id="3_8nykw"] [ext_resource type="Script" path="res://menu/blur_setup.gd" id="4_v6q3y"] -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_85urc"] - [node name="SettingsMenu" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -52,11 +50,6 @@ size_flags_horizontal = 0 theme_override_font_sizes/font_size = 36 text = "Settings" -[node name="TabContainer" type="TabContainer" parent="OuterGap/Panel/InnerGap/VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 -theme_override_styles/panel = SubResource("StyleBoxEmpty_85urc") - [node name="Back" type="Button" parent="OuterGap/Panel/InnerGap/VBoxContainer"] layout_mode = 2 size_flags_vertical = 8 diff --git a/client/menu/settings/dropdown_setting.gd b/client/menu/settings/dropdown_setting.gd index e57fc40f..62162320 100644 --- a/client/menu/settings/dropdown_setting.gd +++ b/client/menu/settings/dropdown_setting.gd @@ -18,23 +18,18 @@ extends GameSetting var options: Array -func _init(new_description: String, new_preset: int, new_options: Array): - assert(new_preset < new_options.size()) - super(new_description, new_preset) +func _init(new_id: String, new_default, new_options: Array): + super(new_id, new_default) options = new_options func _update_row(): super() row.value_node = OptionButton.new() for i in options: - row.value_node.add_item(i) - row.value_node.select(_value) + row.value_node.add_item(tr(nskey + "." + i)) + row.value_node.select(options.find(Global.get_setting(key))) + if not row.value_node.item_selected.is_connected(from_ui): + row.value_node.item_selected.connect(from_ui) -func fetch_setting(): - if row != null: - _value = row.value_node.selected - -func set_value(v): - super(v) - if row != null: - row.value_node.selected = _value +func from_ui(index): + Global.set_setting(key, options[index]) diff --git a/client/menu/settings/game_setting.gd b/client/menu/settings/game_setting.gd index afe1fe65..2846cbe3 100644 --- a/client/menu/settings/game_setting.gd +++ b/client/menu/settings/game_setting.gd @@ -16,39 +16,31 @@ class_name GameSetting extends Object -var preset -var _value -var description: String +var default +var key: String +var nskey: String -var row: SettingsRow +var row: Node -func _init(new_description: String, new_preset): - preset = new_preset - set_value(new_preset) - description = new_description +func _init(new_id: String, new_default = null): + default = new_default + key = new_id -func reset(): - set_value(preset) - -func get_row() -> SettingsRow: - _update_row() - return row +func set_parent(parent: GameSetting): + if parent != null: key = parent.key + "." + key + nskey = "c.settings." + key func _update_row(): - if row != null: - row.queue_free() - row = preload("res://menu/settings/settings_row.tscn").instantiate() - row.description = description - row.reset.connect(reset) + if row == null: row = preload("res://menu/settings/settings_row.tscn").instantiate() + row.description = tr(nskey) + if not row.reset.is_connected(reset): row.reset.connect(reset) -func fetch_setting(): - pass - -func get_value(): - return _value +func reset(): + Global.set_setting(key, default) -func set_value(v): - if v is Array: - _value = v.duplicate(true) - else: - _value = v +func check(): + if default != null: + if not key in Global.settings: + Global.set_setting_unchecked(key, default) + if typeof(default) != typeof(Global.settings[key]): + Global.set_setting_unchecked(key, default) diff --git a/client/menu/settings/input/input_manager.gd b/client/menu/settings/input/input_manager.gd index 96cdca09..784b4974 100644 --- a/client/menu/settings/input/input_manager.gd +++ b/client/menu/settings/input/input_manager.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 tpart +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -15,32 +16,6 @@ # extends Node -var action_descriptions = { - "forwards": tr("Move forwards"), - "backwards": tr("Move backwards"), - "left": tr("Move left"), - "right": tr("Move right"), - "rotate_left": tr("Rotate camera to the left"), - "rotate_right": tr("Rotate camera to the right"), - "rotate_up": tr("Rotate camera upwards"), - "rotate_down": tr("Rotate camera downwards"), - "interact": tr("Interact", "Interacting with items, etc."), - "boost": tr("Boost movement"), - "zoom_in": tr("Zoom in"), - "zoom_out": tr("Zoom out"), - "chat": tr("Toggle chat", "Toggle chat on or off"), - "reset": tr("Reset camera view"), - "fullscreen": tr("Toggle fullscreen"), - "previous": tr("Previous"), - "next": tr("Next"), - "start_game": tr("Start game"), - "join_spectate": tr("Join / Spectate"), - "zoom_in_discrete": tr("Zoom in (discrete)"), - "zoom_out_discrete": tr("Zoom out (discrete)"), - "scroll_down": tr("Scroll down"), - "scroll_up": tr("Scroll up"), -} - var default_input_map = {} var input_map @@ -56,12 +31,12 @@ func get_input_map() -> Dictionary: kb[a] = input_events return kb -func input_map_to_settings_dictionary(map: Dictionary) -> Dictionary: - var settings_dict := {} +func input_map_to_settings(map: Dictionary) -> Array: + var entries := [] for k in map.keys(): var events = map[k] - settings_dict[k] = InputSetting.new(action_descriptions[k] if action_descriptions.has(k) else k, events) - return settings_dict + entries.append(InputSetting.new(k, events)) + return entries func settings_dictionary_to_input_map(settings: Dictionary) -> Dictionary: var map := {} diff --git a/client/menu/settings/input/input_setting.gd b/client/menu/settings/input/input_setting.gd index eec68bdc..e32e800c 100644 --- a/client/menu/settings/input/input_setting.gd +++ b/client/menu/settings/input/input_setting.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 tpart +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -21,14 +22,9 @@ const INPUT_VALUE_NODE_SCENE = preload("res://menu/settings/input/input_value_no func _update_row(): super() row.value_node = INPUT_VALUE_NODE_SCENE.instantiate() - row.value_node.value = _value + row.value_node.value = Global.get_setting(key) + if not row.value_node.changed.is_connected(from_ui): + row.value_node.changed.connect(from_ui) -func fetch_setting(): - if row != null: - _value = row.value_node.value - -func set_value(v): - super(v) - if row != null: - row.value_node.value = _value - row.value_node.update() +func from_ui(): + Global.set_setting(key, row.value_node.value) diff --git a/client/menu/settings/input/input_value_node.gd b/client/menu/settings/input/input_value_node.gd index 125a946b..9f89416b 100644 --- a/client/menu/settings/input/input_value_node.gd +++ b/client/menu/settings/input/input_value_node.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 tpart +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -19,6 +20,8 @@ class_name InputValueNode var value: Array[InputEvent] = [] var listening := false +signal changed() + @onready var actions_container: VBoxContainer = $ActionsContainer @onready var add_button: Button = $Add @onready var add_text = add_button.text @@ -55,6 +58,7 @@ func update(fix_focus: bool = false): func erase_event(e: InputEvent): value.erase(e) update(true) + changed.emit() func _input(e: InputEvent): if listening: @@ -66,6 +70,7 @@ func _input(e: InputEvent): value.append(e) _on_add_pressed() update() + changed.emit() func events_equal(e1: InputEvent, e2: InputEvent) -> bool: if e1 is InputEventKey and e2 is InputEventKey: diff --git a/client/menu/settings/preset.gd b/client/menu/settings/preset_row.gd index bb13b570..808f6381 100644 --- a/client/menu/settings/preset.gd +++ b/client/menu/settings/preset_row.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -14,13 +15,13 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. # class_name Preset -extends Object +extends GameSetting -var label: String var options: Dictionary +var arr: Array[Button] -func _init(name_: String, options_: Dictionary): - label = name_ +func _init(id: String, options_: Dictionary): + super(id) options = options_ func apply(preset_name: String): @@ -29,11 +30,9 @@ func apply(preset_name: String): var setting_name: String = i Global.set_setting(setting_name, preset[setting_name]) -func buttons() -> Array[Button]: - var arr: Array[Button] = [] +func _update_row(): for i in options.keys(): var button := Button.new() button.pressed.connect(apply.bind(i)) button.text = i arr.push_back(button) - return arr diff --git a/client/menu/settings/range_setting.gd b/client/menu/settings/range_setting.gd index d13e2262..d8616d54 100644 --- a/client/menu/settings/range_setting.gd +++ b/client/menu/settings/range_setting.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -21,8 +22,8 @@ var max_value: float var tick_count var smooth: bool -func _init(new_description: String, new_preset: float, new_min_value: float, new_max_value: float, new_smooth: bool = true, new_tick_count = null): - super(new_description, new_preset) +func _init(new_id: String, new_default: float, new_min_value: float, new_max_value: float, new_smooth: bool = true, new_tick_count = null): + super(new_id, new_default) min_value = new_min_value max_value = new_max_value tick_count = new_tick_count @@ -35,13 +36,8 @@ func _update_row(): row.value_node.max_value = max_value row.value_node.tick_count = abs(max_value - min_value) if tick_count == null else tick_count row.value_node.step = 0 if smooth else (1 if tick_count == null else abs(max_value - min_value) / (tick_count - 1)) - row.value_node.value = _value + row.value_node.value = Global.get_setting(key) + if not row.value_node.value_changed.is_connected(from_ui): row.value_node.value_changed.connect(from_ui) -func fetch_setting(): - if row != null: - _value = row.value_node.value - -func set_value(v): - super(v) - if row != null: - row.value_node.value = _value +func from_ui(): + Global.set_setting(key, row.value_node.value) diff --git a/client/menu/settings/settings_category.gd b/client/menu/settings/settings_category.gd index c4601429..7425ea19 100644 --- a/client/menu/settings/settings_category.gd +++ b/client/menu/settings/settings_category.gd @@ -14,15 +14,48 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. # class_name SettingsCategory -extends Object +extends GameSetting -var name: String -var id: String -var settings: Dictionary # Dictionary[String, GameSetting] -var presets # Array[Preset] | null +var settings: Array # Dictionary[String, GameSetting] +var presets # Array[Preset] -func _init(new_name: String, new_id: String, new_settings: Dictionary, new_presets = null): - name = new_name - id = new_id +var options: VBoxContainer + +func _init(new_id: String, new_settings: Array, new_presets = []): + super(new_id) settings = new_settings - presets = new_presets + presets = new_presets + +func set_parent(parent: GameSetting): + super(parent) + for c in settings: + c.set_parent(self) + +func _update_row(): + if row == null: row = ScrollContainerCustom.new() + if options == null: options = VBoxContainer.new() + row.name = tr(nskey) + row.size_flags_horizontal = Control.SIZE_EXPAND_FILL + options.size_flags_horizontal = Control.SIZE_EXPAND_FILL + + if options.get_parent() != row: + row.add_child(options) + + if presets != null: + for i in presets: + var prow: SettingsRow = preload("res://menu/settings/settings_row.tscn").instantiate() + options.add_child(prow) + prow.label.text = i.label + prow.reset_button.visible = false + for b in i.buttons(): + prow.value_parent.add_child(b) + + for r in settings: + r._update_row() + if r.row.get_parent() != options: + print(r.row) + options.add_child(r.row) + +func check(): + for c in settings: + c.check() diff --git a/client/menu/settings/settings_root.gd b/client/menu/settings/settings_root.gd new file mode 100644 index 00000000..5acf7f11 --- /dev/null +++ b/client/menu/settings/settings_root.gd @@ -0,0 +1,36 @@ +# Hurry Curry! - a game about cooking +# Copyright 2024 metamuffin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +extends GameSetting +class_name SettingsRoot + +var children: Array +func _init(new_children: Array): + super("root") + children = new_children + for c in children: + c.set_parent(null) + +func _update_row(): + if row == null: row = TabContainer.new() + row.size_flags_vertical = Control.SIZE_EXPAND_FILL + for r in children: + r._update_row() + if r.row.get_parent() != row: + row.add_child(r.row) + +func check(): + for c in children: + c.check() diff --git a/client/menu/settings/settings_row.gd b/client/menu/settings/settings_row.gd index f5621d78..68340918 100644 --- a/client/menu/settings/settings_row.gd +++ b/client/menu/settings/settings_row.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by diff --git a/client/menu/settings/text_setting.gd b/client/menu/settings/text_setting.gd index faafa610..6fa6b1ef 100644 --- a/client/menu/settings/text_setting.gd +++ b/client/menu/settings/text_setting.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -18,21 +19,17 @@ extends GameSetting var placeholder: String -func _init(new_description: String, new_preset: String, new_placeholder: String = ""): - super(new_description, new_preset) +func _init(new_id: String, new_default: String, new_placeholder: String = ""): + super(new_id, new_default) placeholder = new_placeholder func _update_row(): super() row.value_node = LineEdit.new() - row.value_node.text = _value + row.value_node.text = Global.get_setting(key) row.value_node.placeholder_text = placeholder + if not row.value_node.text_changed.is_connected(from_ui): + row.value_node.text_changed.connect(from_ui) -func fetch_setting(): - if row != null: - _value = row.value_node.text - -func set_value(v): - super(v) - if row != null: - row.value_node.text = _value +func from_ui(text): + Global.set_setting(key, text) diff --git a/client/menu/settings/toggle_setting.gd b/client/menu/settings/toggle_setting.gd index 6d4150d4..45f08d9f 100644 --- a/client/menu/settings/toggle_setting.gd +++ b/client/menu/settings/toggle_setting.gd @@ -1,5 +1,6 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe +# Copyright 2024 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -16,19 +17,15 @@ class_name ToggleSetting extends GameSetting -func _init(new_description: String, new_preset: bool): - super(new_description, new_preset) - -func fetch_setting(): - if row != null: - _value = row.value_node.button_pressed +func _init(new_id: String, new_default: bool): + super(new_id, new_default) func _update_row(): super() row.value_node = CheckButton.new() - row.value_node.button_pressed = _value + row.value_node.button_pressed = Global.get_setting(key) + if not row.value_node.pressed.is_connected(from_ui): + row.value_node.pressed.connect(from_ui) -func set_value(v): - super(v) - if row != null: - row.value_node.button_pressed = _value +func from_ui(): + Global.set_setting(key, row.value_node.button_pressed) diff --git a/client/menu/setup.gd b/client/menu/setup.gd index 6c3c90cd..16944c7c 100644 --- a/client/menu/setup.gd +++ b/client/menu/setup.gd @@ -73,5 +73,5 @@ func _on_sign_pressed(): Global.set_profile("username", username.text) Global.set_profile("character", character) - Global.set_setting("setup_complete", true) + Global.set_setting("gameplay.setup_complete", true) replace_menu("res://menu/main.tscn") |