From c17013ac926168ebc2466ec154ba698c49dc479e Mon Sep 17 00:00:00 2001 From: Alex Page Date: Fri, 4 Feb 2022 19:55:21 -0500 Subject: [PATCH] Don't allow quitting on the web --- src/graphics/sidebar.rs | 4 +++- src/input/mod.rs | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/graphics/sidebar.rs b/src/graphics/sidebar.rs index 87fc854..3861aee 100644 --- a/src/graphics/sidebar.rs +++ b/src/graphics/sidebar.rs @@ -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"); diff --git a/src/input/mod.rs b/src/input/mod.rs index dae59fc..54f2519 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -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)) =