wrap cursor in menu
This commit is contained in:
parent
8fb4ab4a18
commit
a0dd6d45a0
14
src/menu.rs
14
src/menu.rs
|
@ -431,6 +431,8 @@ pub fn handle_input(
|
||||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||||
mut ew_updatemenu: EventWriter<UpdateMenuEvent>,
|
mut ew_updatemenu: EventWriter<UpdateMenuEvent>,
|
||||||
) {
|
) {
|
||||||
|
let last_menu_entry = MENUDEF.len() - 1;
|
||||||
|
|
||||||
if keyboard_input.just_pressed(settings.key_menu)
|
if keyboard_input.just_pressed(settings.key_menu)
|
||||||
|| keyboard_input.just_pressed(settings.key_vehicle) && settings.menu_active
|
|| keyboard_input.just_pressed(settings.key_vehicle) && settings.menu_active
|
||||||
{
|
{
|
||||||
|
@ -443,7 +445,11 @@ pub fn handle_input(
|
||||||
|| keyboard_input.just_pressed(settings.key_mouseup)
|
|| keyboard_input.just_pressed(settings.key_mouseup)
|
||||||
|| keyboard_input.just_pressed(KeyCode::ArrowUp)
|
|| keyboard_input.just_pressed(KeyCode::ArrowUp)
|
||||||
{
|
{
|
||||||
menustate.cursor = menustate.cursor.saturating_sub(1);
|
menustate.cursor = if menustate.cursor == 0 {
|
||||||
|
last_menu_entry
|
||||||
|
} else {
|
||||||
|
menustate.cursor.saturating_sub(1)
|
||||||
|
};
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
|
||||||
ew_updatemenu.send(UpdateMenuEvent);
|
ew_updatemenu.send(UpdateMenuEvent);
|
||||||
}
|
}
|
||||||
|
@ -451,7 +457,11 @@ pub fn handle_input(
|
||||||
|| keyboard_input.just_pressed(settings.key_mousedown)
|
|| keyboard_input.just_pressed(settings.key_mousedown)
|
||||||
|| keyboard_input.just_pressed(KeyCode::ArrowDown)
|
|| keyboard_input.just_pressed(KeyCode::ArrowDown)
|
||||||
{
|
{
|
||||||
menustate.cursor = (menustate.cursor + 1).min(MENUDEF.len() - 1);
|
menustate.cursor = if menustate.cursor == last_menu_entry {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
menustate.cursor.saturating_add(1)
|
||||||
|
};
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
|
||||||
ew_updatemenu.send(UpdateMenuEvent);
|
ew_updatemenu.send(UpdateMenuEvent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue