Don't allow quitting on the web
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alex Page 2022-02-04 19:55:21 -05:00
parent f08691a62e
commit c17013ac92
2 changed files with 13 additions and 5 deletions

View file

@ -88,7 +88,9 @@ pub fn draw(resources: &Resources, bterm: &mut BTerm) {
bterm.print(SIDEBAR_POS_X + 3, SIDEBAR_POS_Y + 19, "Whip");
bterm.print(SIDEBAR_POS_X + 3, SIDEBAR_POS_Y + 20, "Teleport");
bterm.print(SIDEBAR_POS_X + 3, SIDEBAR_POS_Y + 21, "Pause");
bterm.print(SIDEBAR_POS_X + 3, SIDEBAR_POS_Y + 22, "Quit");
if !cfg!(target_family = "wasm") {
bterm.print(SIDEBAR_POS_X + 3, SIDEBAR_POS_Y + 22, "Quit");
}
bterm.print(SIDEBAR_POS_X + 3, SIDEBAR_POS_Y + 23, "Save");
bterm.print(SIDEBAR_POS_X + 3, SIDEBAR_POS_Y + 24, "Restore");

View file

@ -71,10 +71,16 @@ pub fn handle(world: &mut World, resources: &mut Resources, bterm: &mut BTerm) {
resources.show_debug_info = !resources.show_debug_info;
}
VirtualKeyCode::Escape | VirtualKeyCode::Q => {
resources.flashing_message = Some(FlashingMessage::new(
" Are you sure you want to quit (Y/N)? ",
Some(FlashingMessageIntent::Quit),
));
if cfg!(not(target_family = "wasm")) {
resources.flashing_message = Some(FlashingMessage::new(
" Are you sure you want to quit (Y/N)? ",
Some(FlashingMessageIntent::Quit),
));
} else if let (Some(sound_effects), Some(sound_output)) =
(&mut resources.sound_effects, &mut resources.sound_output)
{
sound_output.play_sound(sound_effects.bad_key.clone());
}
}
VirtualKeyCode::P => {
if let (Some(sound_effects), Some(sound_output)) =