From 304447ee2d35408c5d113a4540ae39017c5d7bad Mon Sep 17 00:00:00 2001 From: Ninjdai Date: Sat, 11 Nov 2023 00:24:25 +0100 Subject: [PATCH] Added X/Y-style wrapping summary screen --- src/pokemon_summary_screen.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 79ade7cdd..a8d7864b1 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1778,28 +1778,22 @@ static void Task_ChangeSummaryMon(u8 taskId) static s8 AdvanceMonIndex(s8 delta) { struct Pokemon *mon = sMonSummaryScreen->monList.mons; + u8 index = sMonSummaryScreen->curMonIndex; + u8 numMons = sMonSummaryScreen->maxMonIndex + 1; + delta += numMons; - if (sMonSummaryScreen->currPageIndex == PSS_PAGE_INFO) - { - if (delta == -1 && sMonSummaryScreen->curMonIndex == 0) - return -1; - else if (delta == 1 && sMonSummaryScreen->curMonIndex >= sMonSummaryScreen->maxMonIndex) - return -1; - else - return sMonSummaryScreen->curMonIndex + delta; - } + index = (index + delta) % numMons; + + // skip over any Eggs unless on the Info Page + if (sMonSummaryScreen->currPageIndex != PSS_PAGE_INFO) + while (GetMonData(&mon[index], MON_DATA_IS_EGG)) + index = (index + delta) % numMons; + + // to avoid "scrolling" to the same Pokemon + if (index == sMonSummaryScreen->curMonIndex) + return -1; else - { - s8 index = sMonSummaryScreen->curMonIndex; - - do - { - index += delta; - if (index < 0 || index > sMonSummaryScreen->maxMonIndex) - return -1; - } while (GetMonData(&mon[index], MON_DATA_IS_EGG)); return index; - } } static s8 AdvanceMultiBattleMonIndex(s8 delta)