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:
@@ -590,9 +590,15 @@ fn handle_restore_prompt(
|
|||||||
if screens.is_empty() {
|
if screens.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let key_continue = keys
|
// Esc maps to Continue rather than New Game so a stray dismiss
|
||||||
.as_ref()
|
// press preserves the saved game — the data-preserving default is
|
||||||
.is_some_and(|k| k.just_pressed(KeyCode::Enter) || k.just_pressed(KeyCode::KeyC));
|
// 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 key_new = keys.as_ref().is_some_and(|k| k.just_pressed(KeyCode::KeyN));
|
||||||
let click_continue = continue_buttons
|
let click_continue = continue_buttons
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -333,10 +333,16 @@ fn handle_home_card_click(
|
|||||||
|
|
||||||
fn handle_home_cancel_button(
|
fn handle_home_cancel_button(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
keys: Option<Res<ButtonInput<KeyCode>>>,
|
||||||
cancel_buttons: Query<&Interaction, (With<HomeCancelButton>, Changed<Interaction>)>,
|
cancel_buttons: Query<&Interaction, (With<HomeCancelButton>, Changed<Interaction>)>,
|
||||||
screens: Query<Entity, With<HomeScreen>>,
|
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;
|
return;
|
||||||
}
|
}
|
||||||
for entity in &screens {
|
for entity in &screens {
|
||||||
|
|||||||
Reference in New Issue
Block a user