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
86
src/gui.rs
86
src/gui.rs
@ -623,52 +623,48 @@ 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 {
|
||||
selected: selection,
|
||||
}
|
||||
}
|
||||
Some(key) => match key {
|
||||
VirtualKeyCode::Escape => {
|
||||
return 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,
|
||||
}
|
||||
}
|
||||
return match ctx.key {
|
||||
None => MainMenuResult::NoSelection {
|
||||
selected: selection,
|
||||
},
|
||||
}
|
||||
Some(key) => match key {
|
||||
VirtualKeyCode::Escape => MainMenuResult::NoSelection {
|
||||
selected: MainMenuSelection::Quit,
|
||||
},
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user