From 36e5d5e759d32e4987ffbbac70f84978e1893d16 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 27 Feb 2022 13:47:50 -0500 Subject: [PATCH] Add missing menu array counts --- src/main_menu.c | 2 +- src/menu.c | 8 ++++---- src/player_pc.c | 4 ++-- src/secret_base.c | 2 +- src/trade.c | 2 +- src/trader.c | 18 +++++++----------- src/union_room_chat.c | 2 +- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/main_menu.c b/src/main_menu.c index 54a4f6891..ed6158a9c 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -2090,7 +2090,7 @@ static void NewGameBirchSpeech_ShowGenderMenu(void) DrawMainMenuWindowBorder(&gNewGameBirchSpeechTextWindows[1], 0xF3); FillWindowPixelBuffer(1, PIXEL_FILL(1)); PrintMenuTable(1, ARRAY_COUNT(sMenuActions_Gender), sMenuActions_Gender); - InitMenuInUpperLeftCornerNormal(1, 2, 0); + InitMenuInUpperLeftCornerNormal(1, ARRAY_COUNT(sMenuActions_Gender), 0); PutWindowTilemap(1); CopyWindowToVram(1, COPYWIN_FULL); } diff --git a/src/menu.c b/src/menu.c index 6b915f9ce..49baddded 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1542,25 +1542,25 @@ static s8 Menu_ProcessGridInputRepeat(void) { return MENU_B_PRESSED; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP) { if (oldPos != ChangeGridMenuCursorPosition(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN) { if (oldPos != ChangeGridMenuCursorPosition(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { if (oldPos != ChangeGridMenuCursorPosition(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { if (oldPos != ChangeGridMenuCursorPosition(1, 0)) PlaySE(SE_SELECT); diff --git a/src/player_pc.c b/src/player_pc.c index 06f58fdeb..bf8479ce1 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -511,7 +511,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var) tWindowId = AddWindow(&windowTemplate); SetStandardWindowBorderStyle(tWindowId, 0); PrintMenuTable(tWindowId, ARRAY_COUNT(sItemStorage_MenuActions), sItemStorage_MenuActions); - InitMenuInUpperLeftCornerNormal(tWindowId, 4, var); + InitMenuInUpperLeftCornerNormal(tWindowId, ARRAY_COUNT(sItemStorage_MenuActions), var); ScheduleBgCopyTilemapToVram(0); ItemStorageMenuPrint(sItemStorage_OptionDescriptions[var]); } @@ -753,7 +753,7 @@ static void Mailbox_PrintMailOptions(u8 taskId) { u8 windowId = MailboxMenu_AddWindow(MAILBOXWIN_OPTIONS); PrintMenuTable(windowId, ARRAY_COUNT(gMailboxMailOptions), gMailboxMailOptions); - InitMenuInUpperLeftCornerNormal(windowId, 4, 0); + InitMenuInUpperLeftCornerNormal(windowId, ARRAY_COUNT(gMailboxMailOptions), 0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = Mailbox_MailOptionsProcessInput; } diff --git a/src/secret_base.c b/src/secret_base.c index 9398c4bb2..fa424889e 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1027,7 +1027,7 @@ static void ShowRegistryMenuActions(u8 taskId) tActionWindowId = AddWindow(&template); SetStandardWindowBorderStyle(tActionWindowId, 0); PrintMenuTable(tActionWindowId, ARRAY_COUNT(sRegistryMenuActions), sRegistryMenuActions); - InitMenuInUpperLeftCornerNormal(tActionWindowId, 2, 0); + InitMenuInUpperLeftCornerNormal(tActionWindowId, ARRAY_COUNT(sRegistryMenuActions), 0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = HandleRegistryMenuActionsInput; } diff --git a/src/trade.c b/src/trade.c index b48d1abf5..dd0851bbd 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1394,7 +1394,7 @@ static void TradeMenuProcessInput(void) DrawTextBorderOuter(1, 1, 14); FillWindowPixelBuffer(1, PIXEL_FILL(1)); PrintMenuTable(1, ARRAY_COUNT(sSelectTradeMonActions), sSelectTradeMonActions); - InitMenuInUpperLeftCornerNormal(1, 2, 0); + InitMenuInUpperLeftCornerNormal(1, ARRAY_COUNT(sSelectTradeMonActions), 0); PutWindowTilemap(1); CopyWindowToVram(1, COPYWIN_FULL); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SELECTED_MON; diff --git a/src/trader.c b/src/trader.c index abe581db3..b89ad6043 100644 --- a/src/trader.c +++ b/src/trader.c @@ -15,7 +15,7 @@ #include "task.h" #include "script_menu.h" -static const u8 * const sDefaultTraderNames[] = +static const u8 * const sDefaultTraderNames[NUM_TRADER_ITEMS] = { gText_Tristan, gText_Philip, @@ -23,7 +23,7 @@ static const u8 * const sDefaultTraderNames[] = gText_Roberto, }; -static const u8 sDefaultTraderDecorations[] = +static const u8 sDefaultTraderDecorations[NUM_TRADER_ITEMS] = { DECOR_DUSKULL_DOLL, DECOR_BALL_CUSHION, @@ -39,7 +39,7 @@ void TraderSetup(void) trader->id = MAUVILLE_MAN_TRADER; trader->alreadyTraded = FALSE; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { StringCopy(trader->playerNames[i], sDefaultTraderNames[i]); trader->decorations[i] = sDefaultTraderDecorations[i]; @@ -61,7 +61,7 @@ void CreateAvailableDecorationsMenu(u8 taskId) struct WindowTemplate windowTemplate = {0, 1, 1, 10, 10, 15, 1}; s32 windowWidth = GetStringWidth(FONT_NORMAL, gText_Exit, 0); s32 fiveMarksWidth = GetStringWidth(FONT_NORMAL, gText_FiveMarks, 0); - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { s32 curWidth; if (trader->decorations[i] > NUM_DECORATIONS) @@ -74,7 +74,7 @@ void CreateAvailableDecorationsMenu(u8 taskId) windowTemplate.width = ConvertPixelWidthToTileWidth(windowWidth); data[3] = AddWindow(&windowTemplate); DrawStdFrameWithCustomTileAndPalette(data[3], FALSE, 0x214, 14); - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { if (trader->decorations[i] > NUM_DECORATIONS) AddTextPrinterParameterized(data[3], FONT_NORMAL, gText_FiveMarks, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL); @@ -82,7 +82,7 @@ void CreateAvailableDecorationsMenu(u8 taskId) AddTextPrinterParameterized(data[3], FONT_NORMAL, gDecorations[trader->decorations[i]].name, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL); } AddTextPrinterParameterized(data[3], FONT_NORMAL, gText_Exit, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL); - InitMenuInUpperLeftCornerNormal(data[3], 5, 0); + InitMenuInUpperLeftCornerNormal(data[3], NUM_TRADER_ITEMS + 1, 0); ScheduleBgCopyTilemapToVram(0); } @@ -90,13 +90,9 @@ void Task_BufferDecorSelectionAndCloseWindow(u8 taskId, u8 decorationId) { s16 * data = gTasks[taskId].data; if (decorationId > NUM_DECORATIONS) - { gSpecialVar_0x8004 = 0xFFFF; - } else - { gSpecialVar_0x8004 = decorationId; - } ClearStdWindowAndFrameToTransparent(data[3], FALSE); ClearWindowTilemap(data[3]); @@ -116,7 +112,7 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) case MENU_NOTHING_CHOSEN: break; case MENU_B_PRESSED: - case 4: + case NUM_TRADER_ITEMS: PlaySE(SE_SELECT); Task_BufferDecorSelectionAndCloseWindow(taskId, 0); break; diff --git a/src/union_room_chat.c b/src/union_room_chat.c index 22268ef4a..9890bc1f8 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -2987,7 +2987,7 @@ static void ShowKeyboardSwapMenu(void) { FillWindowPixelBuffer(3, PIXEL_FILL(1)); DrawTextBorderOuter(3, 1, 13); - PrintMenuActionTextsAtPos(3, FONT_SHORT, 8, 1, 14, 5, sKeyboardPageTitleTexts); + PrintMenuActionTextsAtPos(3, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts); InitMenuNormal(3, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage()); PutWindowTilemap(3); }