feat: implement settings menu with video, audio, and input remapping support

This commit is contained in:
Yogi Wiguna
2026-03-30 16:19:18 +08:00
parent c5da49d872
commit 91dc34a7be
8 changed files with 557 additions and 39 deletions
-2
View File
@@ -48,8 +48,6 @@ func _process(delta):
# 3. Action inputs (momentary)
if Input.is_action_just_pressed("action_grab"):
player.grab_item(player.current_position)
elif Input.is_action_just_pressed("action_put"):
player.auto_put_item()
if move_vec != Vector2i.ZERO:
var target_position = player.current_position + move_vec
+8 -3
View File
@@ -44,8 +44,6 @@ var settings = {
# Actions
"grab": KEY_SPACE,
"grab_alt": KEY_J,
"put": KEY_R,
"put_alt": KEY_K,
"tekton_grab": KEY_G,
"tekton_grab_alt": KEY_L,
@@ -77,6 +75,14 @@ func load_settings():
print("[Settings] Loaded.")
else:
print("[Settings] Using defaults.")
# Remove deprecated keys that may persist in old saved configs
var deprecated_keys = ["put", "put_alt"]
for k in deprecated_keys:
if settings.controls.has(k):
settings.controls.erase(k)
print("[Settings] Removed deprecated control: ", k)
func save_settings():
var config = ConfigFile.new()
@@ -166,7 +172,6 @@ func apply_control_settings():
"move_left": "move_west",
"move_right": "move_east",
"grab": "action_grab",
"put": "action_put",
"use_powerup": "use_powerup",
"tekton_grab": "action_grab_tekton",
"attack_mode": "action_knock_tekton"
+3 -2
View File
@@ -189,7 +189,7 @@ func _create_touch_ui():
# Hide Put Button
if put_button:
put_button.visible = true
put_button.visible = false
# SettingsBtn signal is handled by main.gd (_toggle_pause_menu).
# We only grab the reference here in case touch_controls needs it in future,
@@ -494,6 +494,7 @@ func _apply_settings():
if grab_button:
grab_button.visible = true
grab_button.vertical_icon_alignment = VERTICAL_ALIGNMENT_TOP
grab_button.scale = Vector2(button_scale, button_scale)
grab_button.set_anchors_preset(Control.PRESET_BOTTOM_RIGHT)
grab_button.offset_left = button_positions.grab.x
@@ -502,7 +503,7 @@ func _apply_settings():
grab_button.offset_bottom = button_positions.grab.y + button_size
if put_button:
put_button.visible = true
put_button.visible = false
if attack_mode_button:
attack_mode_button.visible = true
+6 -1
View File
@@ -23,6 +23,9 @@ extends CanvasLayer
@onready var SettingsManager = get_node_or_null("/root/SettingsManager")
var listening_action: String = "" # Set when waiting for a keypress
# Keys removed from the game - skip them even if stale user config has them
const DEPRECATED_ACTIONS: Array = ["put", "put_alt"]
func _ready():
# Theme inheritance is broken by CanvasLayer root, no need for theme = null
_load_ui_values()
@@ -107,7 +110,7 @@ func _connect_signals():
# Connect remapping buttons
for action_name in SettingsManager.settings.controls.keys():
if action_name == "use_controller":
if action_name == "use_controller" or action_name in DEPRECATED_ACTIONS:
continue
# Check Primary Button
@@ -197,6 +200,8 @@ func _input(event):
func _update_all_key_labels():
for action_name in SettingsManager.settings.controls.keys():
if action_name in DEPRECATED_ACTIONS:
continue
_update_key_label(action_name)
func _update_key_label(action_name: String):