Fix main menu selection if there is no save file. Also remove redundant variables and returns
This commit is contained in:
parent
79d9c569d3
commit
32874bf9f5
74
src/gui.rs
74
src/gui.rs
@ -623,53 +623,49 @@ pub fn main_menu(gs: &mut State, ctx: &mut Rltk) -> MainMenuResult {
|
||||
ctx.print_color_centered(y, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK), "Quit");
|
||||
}
|
||||
|
||||
match ctx.key {
|
||||
None => {
|
||||
return MainMenuResult::NoSelection {
|
||||
return match ctx.key {
|
||||
None => MainMenuResult::NoSelection {
|
||||
selected: selection,
|
||||
}
|
||||
}
|
||||
},
|
||||
Some(key) => match key {
|
||||
VirtualKeyCode::Escape => {
|
||||
return MainMenuResult::NoSelection {
|
||||
VirtualKeyCode::Escape => MainMenuResult::NoSelection {
|
||||
selected: MainMenuSelection::Quit,
|
||||
}
|
||||
}
|
||||
VirtualKeyCode::Up => {
|
||||
let newselection;
|
||||
match selection {
|
||||
MainMenuSelection::NewGame => newselection = MainMenuSelection::Quit,
|
||||
MainMenuSelection::LoadGame => newselection = MainMenuSelection::NewGame,
|
||||
MainMenuSelection::Quit => newselection = MainMenuSelection::LoadGame,
|
||||
}
|
||||
return MainMenuResult::NoSelection {
|
||||
selected: newselection,
|
||||
};
|
||||
}
|
||||
VirtualKeyCode::Down => {
|
||||
let newselection;
|
||||
match selection {
|
||||
MainMenuSelection::NewGame => newselection = MainMenuSelection::LoadGame,
|
||||
MainMenuSelection::LoadGame => newselection = MainMenuSelection::Quit,
|
||||
MainMenuSelection::Quit => newselection = MainMenuSelection::NewGame,
|
||||
}
|
||||
return MainMenuResult::NoSelection {
|
||||
selected: newselection,
|
||||
};
|
||||
}
|
||||
VirtualKeyCode::Return => {
|
||||
return MainMenuResult::Selected {
|
||||
selected: selection,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return MainMenuResult::NoSelection {
|
||||
selected: selection,
|
||||
},
|
||||
VirtualKeyCode::Up => MainMenuResult::NoSelection {
|
||||
selected: match selection {
|
||||
MainMenuSelection::NewGame => MainMenuSelection::Quit,
|
||||
MainMenuSelection::LoadGame => MainMenuSelection::NewGame,
|
||||
MainMenuSelection::Quit => {
|
||||
if save_exists {
|
||||
MainMenuSelection::LoadGame
|
||||
} else {
|
||||
MainMenuSelection::NewGame
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
VirtualKeyCode::Down => MainMenuResult::NoSelection {
|
||||
selected: match selection {
|
||||
MainMenuSelection::NewGame => {
|
||||
if save_exists {
|
||||
MainMenuSelection::LoadGame
|
||||
} else {
|
||||
MainMenuSelection::Quit
|
||||
}
|
||||
}
|
||||
MainMenuSelection::LoadGame => MainMenuSelection::Quit,
|
||||
MainMenuSelection::Quit => MainMenuSelection::NewGame,
|
||||
},
|
||||
},
|
||||
VirtualKeyCode::Return => MainMenuResult::Selected {
|
||||
selected: selection,
|
||||
},
|
||||
_ => MainMenuResult::NoSelection {
|
||||
selected: selection,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
MainMenuResult::NoSelection {
|
||||
selected: MainMenuSelection::NewGame,
|
||||
|
Loading…
Reference in New Issue
Block a user