diff --git a/src/gui.rs b/src/gui.rs index b2e0263..8e823e9 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -477,7 +477,7 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult { Some(key) => match key { VirtualKeyCode::Escape => { return MainMenuResult::NoSelection { - selected: selection, + selected: MainMenuSelection::Quit, } } VirtualKeyCode::Up => { diff --git a/src/main.rs b/src/main.rs index b9251f8..5ceaa56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,24 +110,7 @@ impl GameState for State { ctx.cls(); match newrunstate { - RunState::MainMenu { .. } => match gui::main_menu(self, ctx) { - gui::MainMenuResult::NoSelection { selected } => { - newrunstate = RunState::MainMenu { - menu_selection: selected, - } - } - gui::MainMenuResult::Selected { selected } => match selected { - gui::MainMenuSelection::NewGame => newrunstate = RunState::PreRun, - gui::MainMenuSelection::LoadGame => { - saveload_system::load_game(&mut self.ecs); - newrunstate = RunState::AwaitingInput; - saveload_system::delete_save(); - } - gui::MainMenuSelection::Quit => { - ::std::process::exit(0); - } - }, - }, + RunState::MainMenu { .. } => {} _ => { // Draw the UI draw_map(&self.ecs, ctx); @@ -244,23 +227,24 @@ impl GameState for State { } } } - RunState::MainMenu { .. } => { - let result = gui::main_menu(self, ctx); - match result { - gui::MainMenuResult::NoSelection { selected } => { - newrunstate = RunState::MainMenu { - menu_selection: selected, - } + RunState::MainMenu { .. } => match gui::main_menu(self, ctx) { + gui::MainMenuResult::NoSelection { selected } => { + newrunstate = RunState::MainMenu { + menu_selection: selected, } - gui::MainMenuResult::Selected { selected } => match selected { - gui::MainMenuSelection::NewGame => newrunstate = RunState::PreRun, - gui::MainMenuSelection::LoadGame => newrunstate = RunState::PreRun, - gui::MainMenuSelection::Quit => { - ::std::process::exit(0); - } - }, } - } + gui::MainMenuResult::Selected { selected } => match selected { + gui::MainMenuSelection::NewGame => newrunstate = RunState::PreRun, + gui::MainMenuSelection::LoadGame => { + saveload_system::load_game(&mut self.ecs); + newrunstate = RunState::AwaitingInput; + saveload_system::delete_save(); + } + gui::MainMenuSelection::Quit => { + ::std::process::exit(0); + } + }, + }, RunState::SaveGame => { saveload_system::save_game(&mut self.ecs);