feat: Introduce a settings manager and UI for configuring video, audio, and control keybinds.
This commit is contained in:
@@ -162,6 +162,30 @@ func _input(event):
|
||||
if listening_action != "" and event is InputEventKey and event.pressed:
|
||||
# Capture the key
|
||||
var keycode = event.keycode
|
||||
|
||||
# PREVENT DUPLICATES (User Request)
|
||||
var existing_action = SettingsManager.is_key_used(keycode)
|
||||
if existing_action != "" and existing_action != listening_action:
|
||||
# Visual Feedback for Error
|
||||
var error_btn = get_node_or_null("%" + listening_action.to_pascal_case() + "Btn")
|
||||
if error_btn:
|
||||
error_btn.text = "ALREADY USED!"
|
||||
error_btn.modulate = Color(1.0, 0.3, 0.3) # Red error
|
||||
|
||||
# Play sound if available
|
||||
var sfx = get_node_or_null("/root/SfxManager")
|
||||
if sfx and sfx.has_method("play_rpc"):
|
||||
sfx.rpc("play_rpc", "error") # Assumes an error sound exists
|
||||
|
||||
# Reset listening but keep text for briefly before reverting
|
||||
listening_action = ""
|
||||
await get_tree().create_timer(1.2).timeout
|
||||
_update_all_key_labels()
|
||||
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
|
||||
# Proceed with remapping if not a duplicate
|
||||
SettingsManager.set_control(listening_action, keycode)
|
||||
|
||||
# Feedback and Reset
|
||||
|
||||
Reference in New Issue
Block a user