feat: gamepad/keyboard UI navigation on all menus

This commit is contained in:
2026-03-19 03:26:50 +01:00
parent 2bc0b76050
commit 3b18e328b2
5 changed files with 137 additions and 0 deletions

View File

@@ -13,8 +13,27 @@ public partial class GameOverScreen : Control
public override void _Ready()
{
RestartButton.FocusMode = Control.FocusModeEnum.All;
MainMenuButton.FocusMode = Control.FocusModeEnum.All;
RestartButton.Pressed += OnRestartClicked;
MainMenuButton.Pressed += OnMainMenuClicked;
if (InputDeviceManager.Instance != null)
InputDeviceManager.Instance.DeviceChanged += OnDeviceChanged;
}
public override void _ExitTree()
{
if (InputDeviceManager.Instance != null)
InputDeviceManager.Instance.DeviceChanged -= OnDeviceChanged;
}
private void OnDeviceChanged(int device)
{
var d = (InputDeviceManager.InputDevice)device;
if (d != InputDeviceManager.InputDevice.Mouse && GameOverPanel.IsVisibleInTree())
RestartButton.GrabFocus();
}
private void OnMainMenuClicked()
@@ -33,5 +52,7 @@ public partial class GameOverScreen : Control
if (GameStateStore.Instance?.Player.Lives != 0) return;
GameOverPanel.Show();
if (InputDeviceManager.Instance?.IsPointerless == true)
RestartButton.GrabFocus();
}
}