Fix: Hauptmenue-Buttons reagieren auf confirm (Enter + Controller)
Ursache: Die Aktivierung verliess sich auf Godots eingebautes ui_accept, das standardmaessig keinen Controller-Button enthaelt; die confirm-Action aus der Input-Map wurde nie gelesen. Fix: confirm aktiviert in _unhandled_input den fokussierten Button; Events, die auch ui_accept matchen (Enter), bleiben dem eingebauten Pfad ueberlassen, sonst gaebe es eine Doppel-Ausloesung (headless per Input-Sonde verifiziert: Enter = 1x, Joypad-Button 0 = 1x). grab_focus laeuft jetzt deferred, damit der Initial-Fokus auch nach Szenenwechseln sicher sitzt. Dazu: von Godot 4.7 erzeugte Script-UIDs der Phase-1a-Dateien. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
df795ef40d
commit
ec8e1fa665
4 changed files with 32 additions and 7 deletions
1
scripts/gameplay/npc_placeholder.gd.uid
Normal file
1
scripts/gameplay/npc_placeholder.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cmrgsx1tsswoh
|
||||||
1
scripts/gameplay/test_ground.gd.uid
Normal file
1
scripts/gameplay/test_ground.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://5a1troqr5458
|
||||||
|
|
@ -4,10 +4,11 @@ extends Control
|
||||||
## Start setzt den GameState auf ein neues Spiel zurück und lädt die
|
## Start setzt den GameState auf ein neues Spiel zurück und lädt die
|
||||||
## Greybox-Testszene. Fortsetzen ist nur sichtbar, wenn ein Spielstand
|
## Greybox-Testszene. Fortsetzen ist nur sichtbar, wenn ein Spielstand
|
||||||
## existiert, und lädt ihn über SaveSystem. Beenden schließt das Spiel.
|
## existiert, und lädt ihn über SaveSystem. Beenden schließt das Spiel.
|
||||||
## Vollständig fokus-navigierbar mit Tastatur und Controller: Die
|
## Vollständig fokus-navigierbar mit Tastatur und Controller:
|
||||||
## confirm-Belegung (Enter/Ⓐ/✕) deckt sich physisch mit Godots ui_accept,
|
## Pfeiltasten/D-Pad/linker Stick bewegen den Fokus, die confirm-Action
|
||||||
## Pfeiltasten/D-Pad/linker Stick bewegen den Fokus, cancel (Esc/Ⓑ/◯)
|
## (Enter/Ⓐ/✕) aktiviert den fokussierten Button, cancel (Esc/Ⓑ/◯) springt
|
||||||
## springt auf den Beenden-Button.
|
## auf den Beenden-Button. Die Aktivierung läuft explizit über die
|
||||||
|
## Input-Map-Action confirm und hängt nicht an Godots internem ui_accept.
|
||||||
|
|
||||||
const GAME_SCENE := "res://scenes/test_ground.tscn"
|
const GAME_SCENE := "res://scenes/test_ground.tscn"
|
||||||
|
|
||||||
|
|
@ -24,15 +25,36 @@ func _ready() -> void:
|
||||||
_start_button.pressed.connect(_on_start_pressed)
|
_start_button.pressed.connect(_on_start_pressed)
|
||||||
_continue_button.pressed.connect(_on_continue_pressed)
|
_continue_button.pressed.connect(_on_continue_pressed)
|
||||||
_quit_button.pressed.connect(_on_quit_pressed)
|
_quit_button.pressed.connect(_on_quit_pressed)
|
||||||
_start_button.grab_focus()
|
_start_button.grab_focus.call_deferred()
|
||||||
|
|
||||||
|
|
||||||
## Springt mit cancel auf den Beenden-Button.
|
## Aktiviert mit confirm den fokussierten Button und springt mit cancel auf
|
||||||
|
## den Beenden-Button.
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("cancel"):
|
if event.is_action_pressed("confirm"):
|
||||||
|
_handle_confirm(event)
|
||||||
|
elif event.is_action_pressed("cancel"):
|
||||||
_quit_button.grab_focus()
|
_quit_button.grab_focus()
|
||||||
|
|
||||||
|
|
||||||
|
## Löst den fokussierten Button für confirm-Events aus, die Godots
|
||||||
|
## eingebautes ui_accept NICHT abdeckt (z. B. Controller-Ⓐ/✕). Events, die
|
||||||
|
## auch ui_accept matchen (Enter), verarbeitet der fokussierte Button
|
||||||
|
## bereits selbst — sie hier erneut auszulösen wäre eine Doppel-Aktivierung
|
||||||
|
## (per Input-Sonde verifiziert). Hat kein Control den Fokus, wird er
|
||||||
|
## stattdessen auf den Start-Button zurückgesetzt.
|
||||||
|
func _handle_confirm(event: InputEvent) -> void:
|
||||||
|
var focused := get_viewport().gui_get_focus_owner()
|
||||||
|
if focused == null:
|
||||||
|
_start_button.grab_focus()
|
||||||
|
return
|
||||||
|
if event.is_action("ui_accept"):
|
||||||
|
return
|
||||||
|
var button := focused as BaseButton
|
||||||
|
if button != null and not button.disabled:
|
||||||
|
button.pressed.emit()
|
||||||
|
|
||||||
|
|
||||||
## Startet ein neues Spiel mit frisch zurückgesetztem GameState.
|
## Startet ein neues Spiel mit frisch zurückgesetztem GameState.
|
||||||
func _on_start_pressed() -> void:
|
func _on_start_pressed() -> void:
|
||||||
GameState.reset()
|
GameState.reset()
|
||||||
|
|
|
||||||
1
scripts/ui/main_menu.gd.uid
Normal file
1
scripts/ui/main_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dy1ia7kmpwymh
|
||||||
Loading…
Add table
Add a link
Reference in a new issue