diff --git a/include/constants/scrcmd.h b/include/constants/scrcmd.h index 2e2756d66f..6625d4ccee 100644 --- a/include/constants/scrcmd.h +++ b/include/constants/scrcmd.h @@ -6,4 +6,11 @@ #define LOCALID_PLAYER 0xFF +#define LIST_MENU_ENTRY_NO_ALT_TEXT 0xff + +#define FIELD_MENU_ANCHOR_LEFT 0 +#define FIELD_MENU_ANCHOR_RIGHT 1 +#define FIELD_MENU_ANCHOR_TOP 0 +#define FIELD_MENU_ANCHOR_BOTTOM 1 + #endif // POKEPLATINUM_CONSTANTS_SCRCMD_H diff --git a/include/list_menu.h b/include/list_menu.h index 1f53d2f0f4..cc0d51b126 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -9,6 +9,8 @@ #define LIST_CANCEL -2 #define LIST_HEADER -3 +#define LIST_MENU_NO_SELECTION_YET 0xeeee // Only used outside of list_menu, as a placeholder for before the player makes a choice + enum ListMenuPagerMode { PAGER_MODE_NONE = 0, PAGER_MODE_LEFT_RIGHT_PAD, diff --git a/include/overlay005/field_menu.h b/include/overlay005/field_menu.h index 8caddf076d..aea7e5933b 100644 --- a/include/overlay005/field_menu.h +++ b/include/overlay005/field_menu.h @@ -12,15 +12,14 @@ #include "string_template.h" #include "sys_task.h" -#define GENERIC_MENU_ENTRIES_MAX 28 -#define NO_ALT_TEXT 0xff +#define FIELD_MENU_ENTRIES_MAX 28 typedef struct { FieldSystem *fieldSystem; SysTask *sysTask; Window menuWindow; Window *parentWindow; - Strbuf *choicesStringsBuffers[GENERIC_MENU_ENTRIES_MAX]; + Strbuf *choicesStringsBuffers[FIELD_MENU_ENTRIES_MAX]; MessageLoader *messageLoader; StringTemplate *stringTemplate; u8 sysTaskDelay; @@ -29,8 +28,8 @@ typedef struct { u8 canExitWithB : 1; u8 freeMsgLoaderOnDelete : 1; u8 unk_97_2 : 4; - u8 horizontalAnchor : 1; - u8 verticalAnchor : 1; + u8 anchorRight : 1; + u8 anchorBottom : 1; u8 anchorX; u8 anchorY; u8 unk_9A; @@ -41,13 +40,13 @@ typedef struct { u16 *listMenuCursorPosPtr; MenuTemplate menuTemplate; Menu *menu; - StringList menuChoicesStrings[GENERIC_MENU_ENTRIES_MAX]; + StringList menuChoicesStrings[FIELD_MENU_ENTRIES_MAX]; ListMenuTemplate listMenuTemplate; ListMenu *listMenu; u16 unk_1C0; u16 listMenuAltTextIndex; - StringList listMenuChoicesStrings[GENERIC_MENU_ENTRIES_MAX]; - u16 choicesAltTextStringIDs[GENERIC_MENU_ENTRIES_MAX]; + StringList listMenuChoicesStrings[FIELD_MENU_ENTRIES_MAX]; + u16 choicesAltTextStringIDs[FIELD_MENU_ENTRIES_MAX]; u16 cursorPos; } FieldMenuManager; diff --git a/src/overlay005/field_menu.c b/src/overlay005/field_menu.c index 5141213a2b..2671c9583a 100644 --- a/src/overlay005/field_menu.c +++ b/src/overlay005/field_menu.c @@ -4,6 +4,7 @@ #include #include "constants/narc.h" +#include "constants/scrcmd.h" #include "generated/map_headers.h" #include "generated/sdat.h" #include "generated/text_banks.h" @@ -34,6 +35,11 @@ #include "res/text/bank/common_strings_2.h" #include "res/text/bank/unk_0543.h" +#define LIST_MENU_MAX_DISPLAY 8 +#define MONEY_WINDOW_WIDTH 10 +#define COINS_BP_WINDOW_WIDTH 10 +#define SHARD_COST_WINDOW_WIDTH 10 + static void FieldMenuManager_Init(FieldSystem *fieldSystem, FieldMenuManager *menuManager, u8 anchorX, u8 anchorY, u8 initialCursorPos, u8 canExitWithB, u16 *selectedOptionPtr, StringTemplate *stringTemplate, Window *parentWindow, MessageLoader *messageLoader); static void FieldMenuManager_SetupMultiColumnMenu(FieldMenuManager *menuManager, u8 columnsCount, u8 rowsCount); static void _FieldMenuManager_AddMenuEntry(FieldMenuManager *menuManager, u32 entryID, u32 index); @@ -84,8 +90,8 @@ static void FieldMenuManager_Init(FieldSystem *fieldSystem, FieldMenuManager *me menuManager->listMenuCursorPosPtr = NULL; menuManager->canExitWithB = canExitWithB; menuManager->initialCursorPos = initialCursorPos; - menuManager->horizontalAnchor = FALSE; - menuManager->verticalAnchor = FALSE; + menuManager->anchorRight = FALSE; + menuManager->anchorBottom = FALSE; menuManager->anchorX = anchorX; menuManager->anchorY = anchorY; menuManager->optionsCount = 0; @@ -93,22 +99,22 @@ static void FieldMenuManager_Init(FieldSystem *fieldSystem, FieldMenuManager *me menuManager->sysTaskDelay = 3; menuManager->cursorPos = initialCursorPos; - for (i = 0; i < GENERIC_MENU_ENTRIES_MAX; i++) { + for (i = 0; i < FIELD_MENU_ENTRIES_MAX; i++) { menuManager->menuChoicesStrings[i].entry = NULL; menuManager->menuChoicesStrings[i].index = 0; } - for (i = 0; i < GENERIC_MENU_ENTRIES_MAX; i++) { + for (i = 0; i < FIELD_MENU_ENTRIES_MAX; i++) { menuManager->listMenuChoicesStrings[i].entry = NULL; menuManager->listMenuChoicesStrings[i].index = 0; - menuManager->choicesAltTextStringIDs[i] = NO_ALT_TEXT; + menuManager->choicesAltTextStringIDs[i] = LIST_MENU_ENTRY_NO_ALT_TEXT; } - for (i = 0; i < GENERIC_MENU_ENTRIES_MAX; i++) { + for (i = 0; i < FIELD_MENU_ENTRIES_MAX; i++) { menuManager->choicesStringsBuffers[i] = Strbuf_Init((40 * 2), HEAP_ID_FIELD); } - *menuManager->selectedOptionPtr = 0xeeee; + *menuManager->selectedOptionPtr = LIST_MENU_NO_SELECTION_YET; } FieldMenuManager *FieldMenuManager_New(FieldSystem *fieldSystem, u8 anchorX, u8 anchorY, u8 initialCursorPos, u8 canExitWithB, u16 *selectedOptionPtr, StringTemplate *stringTemplate, Window *parentWindow, MessageLoader *messageLoader) @@ -136,16 +142,16 @@ void FieldMenuManager_ShowSingleColumnMenu(FieldMenuManager *menuManager) menuWidth = PixelToTiles(menuWidth); - if (menuManager->horizontalAnchor) { + if (menuManager->anchorRight) { menuManager->anchorX -= menuWidth; } - if (menuManager->verticalAnchor) { + if (menuManager->anchorBottom) { menuManager->anchorY -= menuManager->optionsCount * 2; } - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, menuWidth, menuManager->optionsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); - LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, 4); + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, menuWidth, menuManager->optionsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); + LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, 4); Window_DrawStandardFrame(&menuManager->menuWindow, 1, 1024 - (18 + 12) - 9, 11); FieldMenuManager_SetupSingleColumnMenu(menuManager); @@ -244,7 +250,7 @@ void FieldMenuManager_DeleteWithMenu(FieldMenuManager *menuManager) Window_EraseStandardFrame(menuManager->menuTemplate.window, FALSE); Window_Remove(menuManager->menuTemplate.window); - for (int i = 0; i < GENERIC_MENU_ENTRIES_MAX; i++) { + for (int i = 0; i < FIELD_MENU_ENTRIES_MAX; i++) { Strbuf_Free(menuManager->choicesStringsBuffers[i]); } @@ -272,13 +278,13 @@ void FieldMenuManager_ShowListMenu(FieldMenuManager *menuManager) menuWidth = PixelToTiles(menuWidth); - if (menuManager->horizontalAnchor) { + if (menuManager->anchorRight) { menuManager->anchorX -= menuWidth; } - if (menuManager->verticalAnchor) { - if (menuManager->optionsCount > 8) { - menuManager->anchorY -= 8 * 2; + if (menuManager->anchorBottom) { + if (menuManager->optionsCount > LIST_MENU_MAX_DISPLAY) { + menuManager->anchorY -= LIST_MENU_MAX_DISPLAY * 2; } else { menuManager->anchorY -= menuManager->optionsCount * 2; } @@ -295,12 +301,12 @@ void FieldMenuManager_ShowListMenuWithWidth(FieldMenuManager *menuManager, u16 w static void _FieldMenuManager_ShowListMenuWithWidth(FieldMenuManager *menuManager, u32 windowWidth) { if (menuManager->optionsCount > 8) { - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, windowWidth, 8 * 2, 13, ((1 + (10 * 4)) + (10 * 2))); + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, windowWidth, 8 * 2, 13, ((1 + (10 * 4)) + (10 * 2))); } else { - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, windowWidth, menuManager->optionsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, windowWidth, menuManager->optionsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); } - LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); + LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); Window_DrawStandardFrame(&menuManager->menuWindow, TRUE, 1024 - (18 + 12) - 9, 11); FieldMenuManager_InitListMenuTemplate(menuManager); @@ -316,13 +322,13 @@ void FieldMenuManager_ShowListMenuWithCursorPosition(FieldMenuManager *menuManag menuWidth = PixelToTiles(menuWidth); - if (menuManager->optionsCount > 8) { - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, menuWidth, 8 * 2, 13, ((1 + (10 * 4)) + (10 * 2))); + if (menuManager->optionsCount > LIST_MENU_MAX_DISPLAY) { + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, menuWidth, LIST_MENU_MAX_DISPLAY * 2, 13, ((1 + (10 * 4)) + (10 * 2))); } else { - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, menuWidth, menuManager->optionsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, menuWidth, menuManager->optionsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); } - LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, 4); + LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, 4); Window_DrawStandardFrame(&menuManager->menuWindow, TRUE, 1024 - (18 + 12) - 9, 11); FieldMenuManager_InitListMenuTemplate(menuManager); @@ -385,7 +391,7 @@ static void FieldMenuManager_InitListMenuTemplate(FieldMenuManager *menuManager) menuManager->listMenuTemplate.printCallback = ListMenuPrintCallback; menuManager->listMenuTemplate.window = &menuManager->menuWindow; menuManager->listMenuTemplate.count = menuManager->optionsCount; - menuManager->listMenuTemplate.maxDisplay = 8; + menuManager->listMenuTemplate.maxDisplay = LIST_MENU_MAX_DISPLAY; menuManager->listMenuTemplate.headerXOffset = 1; menuManager->listMenuTemplate.textXOffset = 12; menuManager->listMenuTemplate.cursorXOffset = 2; @@ -475,7 +481,7 @@ static void FieldMenuManager_DeleteWithListMenu(FieldMenuManager *menuManager) Window_EraseStandardFrame(menuManager->listMenuTemplate.window, FALSE); Window_Remove(&menuManager->menuWindow); - for (int i = 0; i < GENERIC_MENU_ENTRIES_MAX; i++) { + for (int i = 0; i < FIELD_MENU_ENTRIES_MAX; i++) { Strbuf_Free(menuManager->choicesStringsBuffers[i]); } @@ -504,7 +510,7 @@ static void FieldMenuManager_UpdateListMenuAltText(FieldMenuManager *menuManager { ListMenu_CalcTrueCursorPos(menuManager->listMenu, &menuManager->listMenuAltTextIndex); - if (menuManager->choicesAltTextStringIDs[menuManager->listMenuAltTextIndex] != NO_ALT_TEXT) { + if (menuManager->choicesAltTextStringIDs[menuManager->listMenuAltTextIndex] != LIST_MENU_ENTRY_NO_ALT_TEXT) { FieldMenuManager_PrintListMenyAltText(menuManager, menuManager->choicesAltTextStringIDs[menuManager->listMenuAltTextIndex], 0); } } @@ -522,8 +528,8 @@ void FieldMenu_ShowCurrentFloorWindow(FieldSystem *fieldSystem, u8 tilemapLeft, width = (width / 8) + 1; } - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, width, 4, 13, ((1 + (10 * 4)) + (10 * 2)) + (16 * 10)); - LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, 4); + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, width, 4, 13, ((1 + (10 * 4)) + (10 * 2)) + (16 * 10)); + LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, 4); Window_DrawStandardFrame(&menuManager->menuWindow, TRUE, 1024 - (18 + 12) - 9, 11); Window_FillRectWithColor(&menuManager->menuWindow, 15, 0, 0, (width * 8), (4 * 8)); @@ -555,7 +561,7 @@ static void CurrentFloorWindowSystaskCallback(SysTask *sysTask, void *param) Window_EraseStandardFrame(menuManager->menuTemplate.window, FALSE); Window_Remove(menuManager->menuTemplate.window); - for (int i = 0; i < GENERIC_MENU_ENTRIES_MAX; i++) { + for (int i = 0; i < FIELD_MENU_ENTRIES_MAX; i++) { Strbuf_Free(menuManager->choicesStringsBuffers[i]); } @@ -646,8 +652,8 @@ void FieldMenuManager_ShowMultiColumnMenu(FieldMenuManager *menuManager, u8 colu rowsCount++; } - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, (menuWidth * columnsCount), rowsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); - LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, (menuWidth * columnsCount), rowsCount * 2, 13, ((1 + (10 * 4)) + (10 * 2))); + LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); Window_DrawStandardFrame(&menuManager->menuWindow, TRUE, 1024 - (18 + 12) - 9, 11); FieldMenuManager_SetupMultiColumnMenu(menuManager, columnsCount, rowsCount); @@ -667,12 +673,12 @@ static void FieldMenuManager_SetupMultiColumnMenu(FieldMenuManager *menuManager, menuManager->menuTemplate.suppressCursor = FALSE; } -Window *FieldMenu_CreateMoneyWindow(FieldSystem *fieldSystem, u8 tilemapTop, u8 tilemapLeft) // Create money window +Window *FieldMenu_CreateMoneyWindow(FieldSystem *fieldSystem, u8 tilemapTop, u8 tilemapLeft) { Window *window = Window_New(HEAP_ID_FIELD, 1); - Window_Add(fieldSystem->bgConfig, window, 3, tilemapTop, tilemapLeft, 10, 4, 13, 1); - LoadStandardWindowGraphics(fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); + Window_Add(fieldSystem->bgConfig, window, BG_LAYER_MAIN_3, tilemapTop, tilemapLeft, MONEY_WINDOW_WIDTH, 4, 13, 1); + LoadStandardWindowGraphics(fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); Window_DrawStandardFrame(window, TRUE, 1024 - (18 + 12) - 9, 11); Window_FillTilemap(window, 15); @@ -690,15 +696,15 @@ Window *FieldMenu_CreateMoneyWindow(FieldSystem *fieldSystem, u8 tilemapTop, u8 return window; } -void FieldMenu_DeleteMoneyWindow(Window *window) // Delete window. Used for the money window +void FieldMenu_DeleteMoneyWindow(Window *window) { Window_EraseStandardFrame(window, FALSE); Windows_Delete(window, 1); } -void FieldMenu_PrintMoneyToWindow(FieldSystem *fieldSystem, Window *window) // Print money to window +void FieldMenu_PrintMoneyToWindow(FieldSystem *fieldSystem, Window *window) { - Window_FillRectWithColor(window, 15, 0, 16, 10 * 8, 4 * 8 - 16); + Window_FillRectWithColor(window, 15, 0, 16, MONEY_WINDOW_WIDTH * 8, 4 * 8 - 16); MessageLoader *messageLoader = MessageLoader_Init(MESSAGE_LOADER_BANK_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_UNK_0543, HEAP_ID_FIELD); StringTemplate *stringTemplate = StringTemplate_Default(HEAP_ID_FIELD); @@ -709,7 +715,7 @@ void FieldMenu_PrintMoneyToWindow(FieldSystem *fieldSystem, Window *window) // P StringTemplate_SetNumber(stringTemplate, 0, money, 6, PADDING_MODE_SPACES, CHARSET_MODE_EN); StringTemplate_Format(stringTemplate, strbuf, fmtString); - u32 printerOffset = (10 * 8) - Font_CalcStrbufWidth(FONT_SYSTEM, strbuf, 0); + u32 printerOffset = (MONEY_WINDOW_WIDTH * 8) - Font_CalcStrbufWidth(FONT_SYSTEM, strbuf, 0); Text_AddPrinterWithParams(window, FONT_SYSTEM, strbuf, printerOffset, 16, TEXT_SPEED_NO_TRANSFER, NULL); Strbuf_Free(fmtString); @@ -719,12 +725,12 @@ void FieldMenu_PrintMoneyToWindow(FieldSystem *fieldSystem, Window *window) // P Window_ScheduleCopyToVRAM(window); } -Window *FieldMenu_CreateCoinsWindow(FieldSystem *fieldSystem, u8 tilemapLeft, u8 tilemapTop) // Create coins/BP window, show coins count +Window *FieldMenu_CreateCoinsWindow(FieldSystem *fieldSystem, u8 tilemapLeft, u8 tilemapTop) { Window *window = Window_New(HEAP_ID_FIELD, 1); - Window_Add(fieldSystem->bgConfig, window, 3, tilemapLeft, tilemapTop, 10, 2, 13, (1 + (10 * 4))); - LoadStandardWindowGraphics(fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); + Window_Add(fieldSystem->bgConfig, window, BG_LAYER_MAIN_3, tilemapLeft, tilemapTop, COINS_BP_WINDOW_WIDTH, 2, 13, (1 + (10 * 4))); + LoadStandardWindowGraphics(fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); Window_DrawStandardFrame(window, TRUE, 1024 - (18 + 12) - 9, 11); FieldMenu_PrintCoinsToWindow(fieldSystem, window); @@ -732,13 +738,13 @@ Window *FieldMenu_CreateCoinsWindow(FieldSystem *fieldSystem, u8 tilemapLeft, u8 return window; } -void FieldMenu_DeleteCoinsBPWindow(Window *window) // Delete window. Used for the coins & BP window +void FieldMenu_DeleteCoinsBPWindow(Window *window) { Window_EraseStandardFrame(window, FALSE); Windows_Delete(window, 1); } -void FieldMenu_PrintCoinsToWindow(FieldSystem *fieldSystem, Window *window) // Print coins count to window +void FieldMenu_PrintCoinsToWindow(FieldSystem *fieldSystem, Window *window) { Window_FillTilemap(window, 15); @@ -751,7 +757,7 @@ void FieldMenu_PrintCoinsToWindow(FieldSystem *fieldSystem, Window *window) // P StringTemplate_SetNumber(stringTemplate, 0, coins, 5, PADDING_MODE_SPACES, CHARSET_MODE_EN); StringTemplate_Format(stringTemplate, strbuf, fmtString); - u32 printerOffset = (10 * 8) - Font_CalcStrbufWidth(FONT_SYSTEM, strbuf, 0); + u32 printerOffset = (COINS_BP_WINDOW_WIDTH * 8) - Font_CalcStrbufWidth(FONT_SYSTEM, strbuf, 0); Text_AddPrinterWithParams(window, FONT_SYSTEM, strbuf, printerOffset, 0, TEXT_SPEED_NO_TRANSFER, NULL); Strbuf_Free(fmtString); @@ -761,12 +767,12 @@ void FieldMenu_PrintCoinsToWindow(FieldSystem *fieldSystem, Window *window) // P Window_ScheduleCopyToVRAM(window); } -Window *FieldMenu_CreateBPWindow(FieldSystem *fieldSystem, u8 tilemapLeft, u8 tilemapTop) // Create coins/BP window, show BP count +Window *FieldMenu_CreateBPWindow(FieldSystem *fieldSystem, u8 tilemapLeft, u8 tilemapTop) { Window *window = Window_New(HEAP_ID_FIELD, 1); - Window_Add(fieldSystem->bgConfig, window, 3, tilemapLeft, tilemapTop, 10, 2, 13, (1 + (10 * 4))); - LoadStandardWindowGraphics(fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); + Window_Add(fieldSystem->bgConfig, window, BG_LAYER_MAIN_3, tilemapLeft, tilemapTop, COINS_BP_WINDOW_WIDTH, 2, 13, (1 + (10 * 4))); + LoadStandardWindowGraphics(fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); Window_DrawStandardFrame(window, TRUE, 1024 - (18 + 12) - 9, 11); FieldMenu_PrintBPToWindow(fieldSystem, window); @@ -774,7 +780,7 @@ Window *FieldMenu_CreateBPWindow(FieldSystem *fieldSystem, u8 tilemapLeft, u8 ti return window; } -void FieldMenu_PrintBPToWindow(FieldSystem *fieldSystem, Window *window) // Print BP count to window +void FieldMenu_PrintBPToWindow(FieldSystem *fieldSystem, Window *window) { Window_FillTilemap(window, 15); @@ -787,7 +793,7 @@ void FieldMenu_PrintBPToWindow(FieldSystem *fieldSystem, Window *window) // Prin StringTemplate_SetNumber(stringTemplate, 0, battlePoints, 5, PADDING_MODE_SPACES, CHARSET_MODE_EN); StringTemplate_Format(stringTemplate, strbuf, fmtString); - u32 printerOffset = (10 * 8) - Font_CalcStrbufWidth(FONT_SYSTEM, strbuf, 0); + u32 printerOffset = (COINS_BP_WINDOW_WIDTH * 8) - Font_CalcStrbufWidth(FONT_SYSTEM, strbuf, 0); Text_AddPrinterWithParams(window, FONT_SYSTEM, strbuf, printerOffset, 0, TEXT_SPEED_NO_TRANSFER, NULL); Strbuf_Free(fmtString); @@ -801,10 +807,10 @@ FieldMenuManager *FieldMenuManager_NewMoveTutorCostWindow(FieldSystem *fieldSyst { FieldMenuManager *menuManager = FieldMenuManager_New(fieldSystem, anchorX, anchorY, 0, FALSE, selectedOptionPtr, stringTemplate, NULL, NULL); - Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, 3, menuManager->anchorX, menuManager->anchorY, 10, 16, 13, ((1 + (10 * 4)) + (10 * 2))); - LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, 3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); + Window_Add(menuManager->fieldSystem->bgConfig, &menuManager->menuWindow, BG_LAYER_MAIN_3, menuManager->anchorX, menuManager->anchorY, SHARD_COST_WINDOW_WIDTH, 16, 13, ((1 + (10 * 4)) + (10 * 2))); + LoadStandardWindowGraphics(menuManager->fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 0, HEAP_ID_FIELD); Window_DrawStandardFrame(&menuManager->menuWindow, TRUE, 1024 - (18 + 12) - 9, 11); - Window_FillRectWithColor(&menuManager->menuWindow, 15, 0, 0, (10 * 8), (16 * 8)); + Window_FillRectWithColor(&menuManager->menuWindow, 15, 0, 0, (SHARD_COST_WINDOW_WIDTH * 8), (16 * 8)); FieldMenuManager_PrintString(menuManager, pl_msg_00000361_00273, 0, 0); StringTemplate_SetNumber(stringTemplate, 0, redCost, 3, PADDING_MODE_SPACES, CHARSET_MODE_EN); @@ -833,7 +839,7 @@ void FieldMenuManager_DeleteMoveTutorCost(FieldMenuManager *menuManager) Window_EraseStandardFrame(menuManager->menuTemplate.window, FALSE); Window_Remove(menuManager->menuTemplate.window); - for (int i = 0; i < GENERIC_MENU_ENTRIES_MAX; i++) { + for (int i = 0; i < FIELD_MENU_ENTRIES_MAX; i++) { Strbuf_Free(menuManager->choicesStringsBuffers[i]); } @@ -846,10 +852,10 @@ void FieldMenuManager_DeleteMoveTutorCost(FieldMenuManager *menuManager) void FieldMenuManager_SetHorizontalAnchor(FieldMenuManager *menuManager, BOOL horizontalAnchor) { - menuManager->horizontalAnchor = horizontalAnchor; + menuManager->anchorRight = horizontalAnchor; } void FieldMenuManager_SetVerticalAnchor(FieldMenuManager *menuManager, BOOL verticalAnchor) { - menuManager->verticalAnchor = verticalAnchor; + menuManager->anchorBottom = verticalAnchor; } diff --git a/src/overlay005/scrcmd_move_tutor.c b/src/overlay005/scrcmd_move_tutor.c index 94ae2025b6..c700964680 100644 --- a/src/overlay005/scrcmd_move_tutor.c +++ b/src/overlay005/scrcmd_move_tutor.c @@ -41,8 +41,6 @@ #include "res/pokemon/species_learnsets_by_tutor.h" #include "res/text/bank/common_strings_2.h" -#define NO_SELECTION_YET 0xeeee - typedef struct { FieldSystem *fieldSystem; SysTask *sysTask; @@ -388,7 +386,7 @@ static BOOL ScriptContextShouldResume(ScriptContext *ctx) FieldSystem *fieldSystem = ctx->fieldSystem; u16 *selectedOptionPtr = FieldSystem_GetVarPointer(fieldSystem, ctx->data[0]); - if (*selectedOptionPtr == NO_SELECTION_YET) { + if (*selectedOptionPtr == LIST_MENU_NO_SELECTION_YET) { return FALSE; } @@ -428,7 +426,7 @@ static void MoveTutorManager_Init(FieldSystem *fieldSystem, MoveTutorManager *mo moveTutorManager->moveNames[moveIndex] = Strbuf_Init((40 * 2), HEAP_ID_FIELD); } - *moveTutorManager->selectedOptionPtr = NO_SELECTION_YET; + *moveTutorManager->selectedOptionPtr = LIST_MENU_NO_SELECTION_YET; } MoveTutorManager *MoveTutorManager_New(FieldSystem *fieldSystem, u8 tilemapLeft, u8 tilemapTop, u8 initialCursorPos, u8 canExitWithB, u16 *selectedOptionPtr, StringTemplate *stringTemplate, Window *window, MessageLoader *messageLoader) diff --git a/src/scrcmd.c b/src/scrcmd.c index 74ad03df50..81b2668fbc 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2782,7 +2782,7 @@ static BOOL sub_02040A50(ScriptContext *ctx) FieldSystem *fieldSystem = ctx->fieldSystem; u16 *v1 = FieldSystem_GetVarPointer(fieldSystem, ctx->data[0]); - if (*v1 == 0xeeee) { + if (*v1 == LIST_MENU_NO_SELECTION_YET) { return 0; } @@ -2806,7 +2806,7 @@ static BOOL sub_02040A9C(ScriptContext *ctx) u16 *v1 = FieldSystem_GetVarPointer(fieldSystem, ctx->data[0]); FieldMenuManager **v2 = FieldSystem_GetScriptMemberPtr(fieldSystem, 0); - if (*v1 == 0xeeee) { + if (*v1 == LIST_MENU_NO_SELECTION_YET) { if (sub_0205B9E8(fieldSystem->unk_7C)) { *v1 = 8; FieldMenuManager_DeleteWithMenu(*v2);