aboutsummaryrefslogtreecommitdiff
path: root/client/menu/settings/input
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu/settings/input')
-rw-r--r--client/menu/settings/input/input_manager.gd35
-rw-r--r--client/menu/settings/input/input_setting.gd16
-rw-r--r--client/menu/settings/input/input_value_node.gd5
3 files changed, 16 insertions, 40 deletions
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: