feat(engine): Esc dismisses Home / accepts default on Restore prompt

Home and Restore-prompt previously ignored Esc, which after the last
fix meant Esc just did nothing on those screens. Now both honor the
"Esc closes the modal" convention every other modal already follows.

- Home: Esc behaves like the Cancel button — despawns the modal so
  the player keeps the underlying default deal.
- Restore: Esc maps to Continue rather than New Game; a reflexive
  dismiss press preserves the saved game, matching how the primary
  action already advertises the Enter accelerator.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
funman300
2026-05-06 15:36:09 +00:00
parent 08b006ff30
commit d48b9489db
2 changed files with 16 additions and 4 deletions
+9 -3
View File
@@ -590,9 +590,15 @@ fn handle_restore_prompt(
if screens.is_empty() {
return;
}
let key_continue = keys
.as_ref()
.is_some_and(|k| k.just_pressed(KeyCode::Enter) || k.just_pressed(KeyCode::KeyC));
// Esc maps to Continue rather than New Game so a stray dismiss
// press preserves the saved game — the data-preserving default is
// the safer fallback when a player hits Esc reflexively to "close
// this dialog" without reading it.
let key_continue = keys.as_ref().is_some_and(|k| {
k.just_pressed(KeyCode::Enter)
|| k.just_pressed(KeyCode::KeyC)
|| k.just_pressed(KeyCode::Escape)
});
let key_new = keys.as_ref().is_some_and(|k| k.just_pressed(KeyCode::KeyN));
let click_continue = continue_buttons
.iter()
+7 -1
View File
@@ -333,10 +333,16 @@ fn handle_home_card_click(
fn handle_home_cancel_button(
mut commands: Commands,
keys: Option<Res<ButtonInput<KeyCode>>>,
cancel_buttons: Query<&Interaction, (With<HomeCancelButton>, Changed<Interaction>)>,
screens: Query<Entity, With<HomeScreen>>,
) {
if !cancel_buttons.iter().any(|i| *i == Interaction::Pressed) {
if screens.is_empty() {
return;
}
let click = cancel_buttons.iter().any(|i| *i == Interaction::Pressed);
let esc = keys.is_some_and(|k| k.just_pressed(KeyCode::Escape));
if !click && !esc {
return;
}
for entity in &screens {