mGUI: Wrap around menu cursor when navigating past end (closes #3356)

This commit is contained in:
Vicki Pfau 2025-01-09 00:37:54 -08:00
parent 838439dcef
commit 7643a044f4
2 changed files with 15 additions and 6 deletions

View File

@ -41,6 +41,7 @@ Misc:
- Libretro: Add Super Game Boy Color support (closes mgba.io/i/3188) - Libretro: Add Super Game Boy Color support (closes mgba.io/i/3188)
- mGUI: Enable auto-softpatching (closes mgba.io/i/2899) - mGUI: Enable auto-softpatching (closes mgba.io/i/2899)
- mGUI: Persist fast forwarding after closing menu (fixes mgba.io/i/2414) - mGUI: Persist fast forwarding after closing menu (fixes mgba.io/i/2414)
- mGUI: Wrap around menu cursor when navigating past end (closes mgba.io/i/3356)
- Qt: Handle multiple save game files for disparate games separately (fixes mgba.io/i/2887) - Qt: Handle multiple save game files for disparate games separately (fixes mgba.io/i/2887)
- Qt: Remove maligned double-click-to-fullscreen shortcut (closes mgba.io/i/2632) - Qt: Remove maligned double-click-to-fullscreen shortcut (closes mgba.io/i/2632)
- Qt: Pass logging context through to video proxy thread (fixes mgba.io/i/3095) - Qt: Pass logging context through to video proxy thread (fixes mgba.io/i/3095)

View File

@ -119,12 +119,6 @@ static enum GUIMenuExitReason GUIMenuPollInput(struct GUIParams* params, struct
state->cursor = GUIPollCursor(params, &state->cx, &state->cy); state->cursor = GUIPollCursor(params, &state->cx, &state->cy);
// Check for new direction presses // Check for new direction presses
if (newInput & (1 << GUI_INPUT_UP) && menu->index > 0) {
--menu->index;
}
if (newInput & (1 << GUI_INPUT_DOWN) && menu->index < GUIMenuItemListSize(&menu->items) - 1) {
++menu->index;
}
if (newInput & (1 << GUI_INPUT_LEFT)) { if (newInput & (1 << GUI_INPUT_LEFT)) {
struct GUIMenuItem* item = GUIMenuItemListGetPointer(&menu->items, menu->index); struct GUIMenuItem* item = GUIMenuItemListGetPointer(&menu->items, menu->index);
if (item->validStates && !item->readonly) { if (item->validStates && !item->readonly) {
@ -145,6 +139,20 @@ static enum GUIMenuExitReason GUIMenuPollInput(struct GUIParams* params, struct
menu->index = GUIMenuItemListSize(&menu->items) - 1; menu->index = GUIMenuItemListSize(&menu->items) - 1;
} }
} }
if (newInput & (1 << GUI_INPUT_UP)) {
if (menu->index > 0) {
--menu->index;
} else {
menu->index = GUIMenuItemListSize(&menu->items) - 1;
}
}
if (newInput & (1 << GUI_INPUT_DOWN)) {
if (menu->index < GUIMenuItemListSize(&menu->items) - 1) {
++menu->index;
} else {
menu->index = 0;
}
}
// Handle cursor movement // Handle cursor movement
if (state->cursor != GUI_CURSOR_NOT_PRESENT) { if (state->cursor != GUI_CURSOR_NOT_PRESENT) {