Fix some main menu-related code
This commit is contained in:
parent
a307521d64
commit
1330386b52
@ -477,7 +477,7 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
|
|||||||
Some(key) => match key {
|
Some(key) => match key {
|
||||||
VirtualKeyCode::Escape => {
|
VirtualKeyCode::Escape => {
|
||||||
return MainMenuResult::NoSelection {
|
return MainMenuResult::NoSelection {
|
||||||
selected: selection,
|
selected: MainMenuSelection::Quit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VirtualKeyCode::Up => {
|
VirtualKeyCode::Up => {
|
||||||
|
50
src/main.rs
50
src/main.rs
@ -110,24 +110,7 @@ impl GameState for State {
|
|||||||
ctx.cls();
|
ctx.cls();
|
||||||
|
|
||||||
match newrunstate {
|
match newrunstate {
|
||||||
RunState::MainMenu { .. } => match gui::main_menu(self, ctx) {
|
RunState::MainMenu { .. } => {}
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
_ => {
|
_ => {
|
||||||
// Draw the UI
|
// Draw the UI
|
||||||
draw_map(&self.ecs, ctx);
|
draw_map(&self.ecs, ctx);
|
||||||
@ -244,23 +227,24 @@ impl GameState for State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RunState::MainMenu { .. } => {
|
RunState::MainMenu { .. } => match gui::main_menu(self, ctx) {
|
||||||
let result = gui::main_menu(self, ctx);
|
gui::MainMenuResult::NoSelection { selected } => {
|
||||||
match result {
|
newrunstate = RunState::MainMenu {
|
||||||
gui::MainMenuResult::NoSelection { selected } => {
|
menu_selection: 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 => {
|
RunState::SaveGame => {
|
||||||
saveload_system::save_game(&mut self.ecs);
|
saveload_system::save_game(&mut self.ecs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user