Let a gamepad drive the end-screen buttons (Play Again / Main Menu)

Nothing had focus by default when the outcome screen appeared, so a
gamepad's ui_accept/ui_left/ui_right (bound to Godot's built-in ui_*
actions) had no control to act on — same reason main_menu.gd grabs
focus on its own default button per panel. Grab it on whichever
button is visible (Play Again/Continue on a win, Retry on a loss);
Godot's geometry-based focus neighbors then let ui_left/ui_right reach
Main Menu from there. Verified headlessly: a synthetic ui_accept on
the focused button reloads the run, same as a real gamepad A press
would.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXBNaEBmrYDSMcv4NgUWtV
This commit is contained in:
2026-09-10 17:56:24 +03:00
parent a9440c6a43
commit d8d6b11508
+5
View File
@@ -590,6 +590,11 @@ func _present_outcome() -> void:
_over_continue.text = "Play Again (Enter)" if _is_final_boss else "Continue (Enter)" _over_continue.text = "Play Again (Enter)" if _is_final_boss else "Continue (Enter)"
_over_continue.visible = _result_win _over_continue.visible = _result_win
_over_again.visible = not _result_win _over_again.visible = not _result_win
# Nothing has focus by default when this screen appears, so a gamepad's ui_accept/ui_left/
# ui_right (bound to Godot's built-in ui_* actions) would have nothing to act on — grab it
# on the default button, same as main_menu.gd does for its own panels. Geometry-based focus
# neighbors (Godot's default) then let ui_left/ui_right reach Main Menu from here.
(_over_continue if _result_win else _over_again).grab_focus()
var path := _THANKYOU_VIDEO if _is_final_boss else (_WIN_VIDEO if _result_win else _LOSS_VIDEO) var path := _THANKYOU_VIDEO if _is_final_boss else (_WIN_VIDEO if _result_win else _LOSS_VIDEO)
if ResourceLoader.exists(path): if ResourceLoader.exists(path):