From 57db1a88e48018ff5f96c1eee0f886327ab48d37 Mon Sep 17 00:00:00 2001 From: Naramo <62239403+SevenSpiders@users.noreply.github.com> Date: Mon, 19 May 2025 11:32:35 +0200 Subject: [PATCH 1/6] Add window constants --- include/bag.h | 20 ++++++++++++++++++ src/bag.c | 58 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/include/bag.h b/include/bag.h index fec9f67bf7e..910530b96ce 100644 --- a/include/bag.h +++ b/include/bag.h @@ -3,6 +3,26 @@ #include "menu_helpers.h" +#define BAG_WIN_ITEMS_ID 0 // central main list window +#define BAG_WIN_MSG_ID 1 // bottom MSG box +#define BAG_WIN_TITLE_ID 2 // top left pocket title + +// whichWindow indexes +#define BAG_WIN_CHOOSE_QUANTITY 0 // bottom right corner +#define BAG_WIN_BUY_QUANTITY 1 // popup when buying or selling quantities +#define BAG_WIN_MONEY 2 // top left corner +#define BAG_WIN_CHOOSE_QUANTITY2 3 // unused +#define BAG_WIN_4 4 // unused +#define BAG_WIN_MSG_W26 5 // whole MSG box +#define BAG_WIN_MSG_W14 6 // MSG box width 14 (spares icon bottom left corner) +#define BAG_WIN_MSG_W15 7 // MSG box width 15 +#define BAG_WIN_MSG_W16 8 // MSG box width 16 +#define BAG_WIN_MSG_W23 9 // MSG box width 23 +#define BAG_WIN_CONTEXT_H2 10 // conctext menu with 1 element +#define BAG_WIN_CONTEXT_H4 11 // conctext menu with 2 elements +#define BAG_WIN_CONTEXT_H6 12 // conctext menu with 3 elements +#define BAG_WIN_CONTEXT_H8 13 // conctext menu with 4 elements + void InitBagWindows(void); void BagPrintTextOnWindow(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx); void BagPrintTextOnWin1CenteredColor0(const u8 * str, u8 unused); diff --git a/src/bag.c b/src/bag.c index 9e76811438d..ed2fbe1dc9d 100644 --- a/src/bag.c +++ b/src/bag.c @@ -7,6 +7,7 @@ #include "menu.h" #include "money.h" #include "strings.h" +#include "bag.h" static const u16 sBagWindowPalF[] = INCBIN_U16("graphics/item_menu/bag_window_pal.gbapal"); @@ -18,7 +19,7 @@ static const u8 sTextColors[][3] = { }; static const struct WindowTemplate sDefaultBagWindowsStd[] = { - { + [BAG_WIN_ITEMS_ID] = { // central main list window .bg = 0, .tilemapLeft = 11, .tilemapTop = 1, @@ -26,7 +27,8 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = { .height = 12, .paletteNum = 15, .baseBlock = 0x008a - }, { + }, + [BAG_WIN_MSG_ID] = { // bottom MSG box .bg = 0, .tilemapLeft = 5, .tilemapTop = 14, @@ -34,7 +36,8 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = { .height = 6, .paletteNum = 15, .baseBlock = 0x0162 - }, { + }, + [BAG_WIN_TITLE_ID] = { // top left pocket title .bg = 0, .tilemapLeft = 1, .tilemapTop = 1, @@ -46,7 +49,7 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = { }; static const struct WindowTemplate sDefaultBagWindowsDeposit[] = { - { + [BAG_WIN_ITEMS_ID] = { // central main list window .bg = 0, .tilemapLeft = 11, .tilemapTop = 1, @@ -54,7 +57,8 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = { .height = 12, .paletteNum = 15, .baseBlock = 0x008a - }, { + }, + [BAG_WIN_MSG_ID] = { // bottom MSG box .bg = 0, .tilemapLeft = 5, .tilemapTop = 14, @@ -62,7 +66,8 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = { .height = 6, .paletteNum = 15, .baseBlock = 0x0162 - }, { + }, + [BAG_WIN_TITLE_ID] = { // top left pocket title .bg = 0, .tilemapLeft = 1, .tilemapTop = 1, @@ -74,7 +79,7 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = { }; static const struct WindowTemplate sWindowTemplates[] = { - { + [BAG_WIN_CHOOSE_QUANTITY] = { // bottom right corner .bg = 0, .tilemapLeft = 24, .tilemapTop = 15, @@ -82,7 +87,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 15, .baseBlock = 0x242 - }, { + }, + [BAG_WIN_BUY_QUANTITY] = { // popup when buying or selling quantities .bg = 0, .tilemapLeft = 17, .tilemapTop = 9, @@ -90,7 +96,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 15, .baseBlock = 0x242 - }, { + }, + [BAG_WIN_MONEY] = { // top left corner .bg = 0, .tilemapLeft = 1, .tilemapTop = 1, @@ -98,7 +105,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 3, .paletteNum = 12, .baseBlock = 0x272 - }, { + }, + [BAG_WIN_CHOOSE_QUANTITY2] = { // unused .bg = 0, .tilemapLeft = 23, .tilemapTop = 15, @@ -106,7 +114,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 15, .baseBlock = 0x28a - }, { + }, + [BAG_WIN_4] = { // unused .bg = 0, .tilemapLeft = 21, .tilemapTop = 9, @@ -114,7 +123,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 15, .baseBlock = 0x28a - }, { + }, + [BAG_WIN_MSG_W26] = { // whole MSG box .bg = 0, .tilemapLeft = 2, .tilemapTop = 15, @@ -122,7 +132,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 15, .baseBlock = 0x2a2 - }, { + }, + [BAG_WIN_MSG_W14] = { // MSG bodx width 14 (spares icon bottom left corner) .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -130,7 +141,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 12, .baseBlock = 0x2a2 - }, { + }, + [BAG_WIN_MSG_W15] = { // MSG bodx width 15 .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -138,7 +150,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 12, .baseBlock = 0x2da - }, { + }, + [BAG_WIN_MSG_W16] = { // MSG bodx width 16 .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -146,7 +159,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 12, .baseBlock = 0x316 - }, { + }, + [BAG_WIN_MSG_W23] = { // MSG bodx width 23 .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -154,7 +168,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 12, .baseBlock = 0x356 - }, { + }, + [BAG_WIN_CONTEXT_H2] = { // conctext menu with 1 element .bg = 0, .tilemapLeft = 22, .tilemapTop = 17, @@ -162,7 +177,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 2, .paletteNum = 15, .baseBlock = 0x20a - }, { + }, + [BAG_WIN_CONTEXT_H4] = { // conctext menu with 2 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 15, @@ -170,7 +186,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 4, .paletteNum = 15, .baseBlock = 0x20a - }, { + }, + [BAG_WIN_CONTEXT_H6] = { // conctext menu with 3 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 13, @@ -178,7 +195,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 6, .paletteNum = 15, .baseBlock = 0x20a - }, { + }, + [BAG_WIN_CONTEXT_H8] = { // conctext menu with 4 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 11, From f2965f89ed30b2e61a35ca4ba8736ee606d753d2 Mon Sep 17 00:00:00 2001 From: Naramo <62239403+SevenSpiders@users.noreply.github.com> Date: Mon, 19 May 2025 12:04:09 +0200 Subject: [PATCH 2/6] renaming part 1 --- include/bag.h | 16 ++------ src/bag.c | 30 +++++++------- src/item_menu.c | 106 ++++++++++++++++++++++++------------------------ 3 files changed, 71 insertions(+), 81 deletions(-) diff --git a/include/bag.h b/include/bag.h index 910530b96ce..43007c44faf 100644 --- a/include/bag.h +++ b/include/bag.h @@ -4,24 +4,14 @@ #include "menu_helpers.h" #define BAG_WIN_ITEMS_ID 0 // central main list window -#define BAG_WIN_MSG_ID 1 // bottom MSG box +#define BAG_WIN_MESSAGE_ID 1 // bottom MSG box #define BAG_WIN_TITLE_ID 2 // top left pocket title // whichWindow indexes #define BAG_WIN_CHOOSE_QUANTITY 0 // bottom right corner -#define BAG_WIN_BUY_QUANTITY 1 // popup when buying or selling quantities #define BAG_WIN_MONEY 2 // top left corner -#define BAG_WIN_CHOOSE_QUANTITY2 3 // unused -#define BAG_WIN_4 4 // unused -#define BAG_WIN_MSG_W26 5 // whole MSG box -#define BAG_WIN_MSG_W14 6 // MSG box width 14 (spares icon bottom left corner) -#define BAG_WIN_MSG_W15 7 // MSG box width 15 -#define BAG_WIN_MSG_W16 8 // MSG box width 16 -#define BAG_WIN_MSG_W23 9 // MSG box width 23 -#define BAG_WIN_CONTEXT_H2 10 // conctext menu with 1 element -#define BAG_WIN_CONTEXT_H4 11 // conctext menu with 2 elements -#define BAG_WIN_CONTEXT_H6 12 // conctext menu with 3 elements -#define BAG_WIN_CONTEXT_H8 13 // conctext menu with 4 elements +#define BAG_WIN_MSG 6 // MSG box width 14 (spares icon bottom left corner) +#define BAG_WIN_CONTEXT 10 // conctext menu with 1 element void InitBagWindows(void); void BagPrintTextOnWindow(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx); diff --git a/src/bag.c b/src/bag.c index ed2fbe1dc9d..8aa5419a320 100644 --- a/src/bag.c +++ b/src/bag.c @@ -28,7 +28,7 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = { .paletteNum = 15, .baseBlock = 0x008a }, - [BAG_WIN_MSG_ID] = { // bottom MSG box + [BAG_WIN_MESSAGE_ID] = { // bottom MSG box .bg = 0, .tilemapLeft = 5, .tilemapTop = 14, @@ -58,7 +58,7 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = { .paletteNum = 15, .baseBlock = 0x008a }, - [BAG_WIN_MSG_ID] = { // bottom MSG box + [BAG_WIN_MESSAGE_ID] = { // bottom MSG box .bg = 0, .tilemapLeft = 5, .tilemapTop = 14, @@ -88,7 +88,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x242 }, - [BAG_WIN_BUY_QUANTITY] = { // popup when buying or selling quantities + [BAG_WIN_CHOOSE_QUANTITY + 1] = { // popup when buying or selling quantities .bg = 0, .tilemapLeft = 17, .tilemapTop = 9, @@ -106,7 +106,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 12, .baseBlock = 0x272 }, - [BAG_WIN_CHOOSE_QUANTITY2] = { // unused + [3] = { // unused .bg = 0, .tilemapLeft = 23, .tilemapTop = 15, @@ -115,7 +115,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x28a }, - [BAG_WIN_4] = { // unused + [4] = { // unused .bg = 0, .tilemapLeft = 21, .tilemapTop = 9, @@ -124,7 +124,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x28a }, - [BAG_WIN_MSG_W26] = { // whole MSG box + [BAG_WIN_MSG - 1] = { // whole MSG box unused .bg = 0, .tilemapLeft = 2, .tilemapTop = 15, @@ -133,7 +133,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x2a2 }, - [BAG_WIN_MSG_W14] = { // MSG bodx width 14 (spares icon bottom left corner) + [BAG_WIN_MSG] = { // MSG box width 14 (spares icon bottom left corner) .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -142,7 +142,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 12, .baseBlock = 0x2a2 }, - [BAG_WIN_MSG_W15] = { // MSG bodx width 15 + [BAG_WIN_MSG + 1] = { // MSG box width 15 .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -151,7 +151,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 12, .baseBlock = 0x2da }, - [BAG_WIN_MSG_W16] = { // MSG bodx width 16 + [BAG_WIN_MSG + 2] = { // MSG box width 16 .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -160,7 +160,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 12, .baseBlock = 0x316 }, - [BAG_WIN_MSG_W23] = { // MSG bodx width 23 + [BAG_WIN_MSG + 3] = { // MSG box width 23 .bg = 0, .tilemapLeft = 6, .tilemapTop = 15, @@ -169,7 +169,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 12, .baseBlock = 0x356 }, - [BAG_WIN_CONTEXT_H2] = { // conctext menu with 1 element + [BAG_WIN_CONTEXT] = { // conctext menu with 1 element .bg = 0, .tilemapLeft = 22, .tilemapTop = 17, @@ -178,7 +178,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x20a }, - [BAG_WIN_CONTEXT_H4] = { // conctext menu with 2 elements + [BAG_WIN_CONTEXT + 1] = { // conctext menu with 2 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 15, @@ -187,7 +187,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x20a }, - [BAG_WIN_CONTEXT_H6] = { // conctext menu with 3 elements + [BAG_WIN_CONTEXT + 2] = { // conctext menu with 3 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 13, @@ -196,7 +196,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x20a }, - [BAG_WIN_CONTEXT_H8] = { // conctext menu with 4 elements + [BAG_WIN_CONTEXT + 3] = { // conctext menu with 4 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 11, @@ -321,7 +321,7 @@ void BagCreateYesNoMenuTopRight(u8 taskId, const struct YesNoFuncTable * ptrs) void BagPrintMoneyAmount(void) { - PrintMoneyAmountInMoneyBoxWithBorder(ShowBagWindow(2, 0), 0x081, 0x0C, GetMoney(&gSaveBlock1Ptr->money)); + PrintMoneyAmountInMoneyBoxWithBorder(ShowBagWindow(BAG_WIN_MONEY, 0), 0x081, 0x0C, GetMoney(&gSaveBlock1Ptr->money)); } void BagDrawTextBoxOnWindow(u8 windowId) diff --git a/src/item_menu.c b/src/item_menu.c index 8f52ead00ec..e18192b3ea7 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1307,15 +1307,15 @@ static void AbortMovingItemInPocket(u8 taskId, u32 itemIndex) static void InitQuantityToTossOrDeposit(u16 cursorPos, const u8 *str) { - u8 r4; - u8 r5 = ShowBagWindow(6, 2); + u8 bagQuantityWinId; + u8 bagMSGWinId = ShowBagWindow(BAG_WIN_MSG, 2); CopyItemName(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, cursorPos), gStringVar1); StringExpandPlaceholders(gStringVar4, str); - BagPrintTextOnWindow(r5, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); - r4 = ShowBagWindow(0, 0); + BagPrintTextOnWindow(bagMSGWinId, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); + bagQuantityWinId = ShowBagWindow(BAG_WIN_CHOOSE_QUANTITY, 0); ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 3); StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1); - BagPrintTextOnWindow(r4, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1); + BagPrintTextOnWindow(bagQuantityWinId, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1); CreateArrowPair_QuantitySelect(); } @@ -1337,8 +1337,8 @@ static void DrawItemListRow(u8 row) static void OpenContextMenu(u8 taskId) { - u8 r6; - u8 r4; + u8 bagContextWinId; + u8 bagMSGWinId; switch (gBagMenuState.location) { case ITEMMENULOCATION_BATTLE: @@ -1416,9 +1416,9 @@ static void OpenContextMenu(u8 taskId) } } } - r6 = ShowBagWindow(10, sContextMenuNumItems - 1); + bagContextWinId = ShowBagWindow(BAG_WIN_CONTEXT, sContextMenuNumItems - 1); AddItemMenuActionTextPrinters( - r6, + bagContextWinId, FONT_NORMAL, GetMenuCursorDimensionByFont(FONT_NORMAL, 0), 2, @@ -1428,11 +1428,11 @@ static void OpenContextMenu(u8 taskId) sItemMenuContextActions, sContextMenuItemsPtr ); - Menu_InitCursor(r6, FONT_NORMAL, 0, 2, GetFontAttribute(FONT_NORMAL, FONTATTR_MAX_LETTER_HEIGHT) + 2, sContextMenuNumItems, 0); - r4 = ShowBagWindow(6, 0); + Menu_InitCursor(bagContextWinId, FONT_NORMAL, 0, 2, GetFontAttribute(FONT_NORMAL, FONTATTR_MAX_LETTER_HEIGHT) + 2, sContextMenuNumItems, 0); + bagMSGWinId = ShowBagWindow(BAG_WIN_MSG, 0); CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected); - BagPrintTextOnWindow(r4, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); + BagPrintTextOnWindow(bagMSGWinId, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); } static void Task_ItemContext_FieldOrBattle(u8 taskId) @@ -1467,8 +1467,8 @@ static void Task_ItemMenuAction_Use(u8 taskId) { if (ItemId_GetFieldFunc(gSpecialVar_ItemId) != NULL) { - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(0); @@ -1484,8 +1484,8 @@ static void Task_ItemMenuAction_Toss(u8 taskId) s16 *data = gTasks[taskId].data; ClearWindowTilemap(GetBagWindow(10)); ClearWindowTilemap(GetBagWindow(6)); - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); data[8] = 1; if (data[2] == 1) @@ -1504,14 +1504,14 @@ static void Task_ConfirmTossItems(u8 taskId) s16 *data = gTasks[taskId].data; ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_ThrowAwayStrVar2OfThisItemQM); - BagPrintTextOnWindow(ShowBagWindow(6, 1), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); + BagPrintTextOnWindow(ShowBagWindow(BAG_WIN_MSG, 1), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); BagCreateYesNoMenuBottomRight(taskId, &sYesNoMenu_Toss); } static void Task_TossItem_No(u8 taskId) { s16 *data = gTasks[taskId].data; - HideBagWindow(6); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(0); bag_menu_print_cursor_(data[0], 1); @@ -1529,8 +1529,8 @@ static void Task_SelectQuantityToToss(u8 taskId) { PlaySE(SE_SELECT); ClearWindowTilemap(GetBagWindow(6)); - HideBagWindow(6); - HideBagWindow(0); + HideBagWindow(BAG_WIN_MSG); + HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); ScheduleBgCopyTilemapToVram(0); BagDestroyPocketScrollArrowPair(); Task_ConfirmTossItems(taskId); @@ -1538,8 +1538,8 @@ static void Task_SelectQuantityToToss(u8 taskId) else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - HideBagWindow(6); - HideBagWindow(0); + HideBagWindow(BAG_WIN_MSG); + HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); PutWindowTilemap(0); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(0); @@ -1552,11 +1552,11 @@ static void Task_SelectQuantityToToss(u8 taskId) static void Task_TossItem_Yes(u8 taskId) { s16 *data = gTasks[taskId].data; - HideBagWindow(6); + HideBagWindow(BAG_WIN_MSG); CopyItemName(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1]), gStringVar1); ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_ThrewAwayStrVar2StrVar1s); - BagPrintTextOnWindow(ShowBagWindow(6, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); + BagPrintTextOnWindow(ShowBagWindow(BAG_WIN_MSG, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); gTasks[taskId].func = Task_WaitAB_RedrawAndReturnToBag; } @@ -1567,7 +1567,7 @@ static void Task_WaitAB_RedrawAndReturnToBag(u8 taskId) { PlaySE(SE_SELECT); RemoveBagItem(gSpecialVar_ItemId, data[8]); - HideBagWindow(6); + HideBagWindow(BAG_WIN_MSG); DestroyListMenuTask(data[0], &gBagMenuState.cursorPos[gBagMenuState.pocket], &gBagMenuState.itemsAbove[gBagMenuState.pocket]); Pocket_CalculateNItemsAndMaxShowed(gBagMenuState.pocket); PocketCalculateInitialCursorPosAndItemsAbove(gBagMenuState.pocket); @@ -1601,8 +1601,8 @@ static void Task_ItemMenuAction_Give(u8 taskId) { s16 *data = gTasks[taskId].data; u16 itemId = BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1]); - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); CopyWindowToVram(0, COPYWIN_MAP); @@ -1674,8 +1674,8 @@ static void Task_UnusedReturnToBag(u8 taskId) static void Task_ItemMenuAction_Cancel(u8 taskId) { - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(0); @@ -1687,8 +1687,8 @@ static void Task_ItemMenuAction_BattleUse(u8 taskId) { if (ItemId_GetBattleFunc(gSpecialVar_ItemId) != NULL) { - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); CopyWindowToVram(0, COPYWIN_MAP); @@ -1853,7 +1853,7 @@ static void Task_ShowSellYesNoMenu(u8 taskId) static void Task_SellItem_No(u8 taskId) { s16 *data = gTasks[taskId].data; - HideBagWindow(2); + HideBagWindow(BAG_WIN_MONEY); CloseBagWindow(5); PutWindowTilemap(2); PutWindowTilemap(0); @@ -1866,10 +1866,10 @@ static void Task_SellItem_No(u8 taskId) static void Task_InitSaleQuantitySelectInterface(u8 taskId) { s16 *data = gTasks[taskId].data; - u8 r4 = ShowBagWindow(0, 1); + u8 bagQuantityWinId = ShowBagWindow(BAG_WIN_CHOOSE_QUANTITY, 1); ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1); - BagPrintTextOnWindow(r4, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0xFF, 1); + BagPrintTextOnWindow(bagQuantityWinId, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0xFF, 1); UpdateSalePriceDisplay(ItemId_GetPrice(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8]); BagPrintMoneyAmount(); CreatePocketScrollArrowPair_SellQuantity(); @@ -1892,7 +1892,7 @@ static void Task_SelectQuantityToSell(u8 taskId) else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); - HideBagWindow(0); + HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); PutWindowTilemap(0); ScheduleBgCopyTilemapToVram(0); BagDestroyPocketScrollArrowPair(); @@ -1901,8 +1901,8 @@ static void Task_SelectQuantityToSell(u8 taskId) else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - HideBagWindow(0); - HideBagWindow(2); + HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); + HideBagWindow(BAG_WIN_MONEY); CloseBagWindow(5); PutWindowTilemap(2); PutWindowTilemap(0); @@ -1949,7 +1949,7 @@ static void Task_WaitPressAB_AfterSell(u8 taskId) if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - HideBagWindow(2); + HideBagWindow(BAG_WIN_MONEY); PutWindowTilemap(2); sBagMenuDisplay->inhibitItemDescriptionPrint = FALSE; Task_ReturnToBagFromContextMenu(taskId); @@ -1982,8 +1982,8 @@ static void Task_SelectQuantityToDeposit(u8 taskId) { PlaySE(SE_SELECT); ClearWindowTilemap(GetBagWindow(6)); - HideBagWindow(6); - HideBagWindow(0); + HideBagWindow(BAG_WIN_MSG); + HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); ScheduleBgCopyTilemapToVram(0); BagDestroyPocketScrollArrowPair(); Task_TryDoItemDeposit(taskId); @@ -1991,8 +1991,8 @@ static void Task_SelectQuantityToDeposit(u8 taskId) else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); - HideBagWindow(6); - HideBagWindow(0); + HideBagWindow(BAG_WIN_MSG); + HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(0); bag_menu_print_cursor_(data[0], 1); @@ -2010,7 +2010,7 @@ static void Task_TryDoItemDeposit(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_DepositedStrVar2StrVar1s); - BagPrintTextOnWindow(ShowBagWindow(6, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); + BagPrintTextOnWindow(ShowBagWindow(BAG_WIN_MSG, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1); gTasks[taskId].func = Task_WaitAB_RedrawAndReturnToBag; } else @@ -2124,8 +2124,8 @@ static void Task_Bag_OldManTutorial(u8 taskId) break; case 408: PlaySE(SE_SELECT); - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); CopyWindowToVram(0, COPYWIN_MAP); @@ -2230,8 +2230,8 @@ static void Task_Bag_TeachyTvRegister(u8 taskId) case 408: PlaySE(SE_SELECT); gSaveBlock1Ptr->registeredItem = gSpecialVar_ItemId; - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); DestroyListMenuTask(data[0], &gBagMenuState.cursorPos[gBagMenuState.pocket], &gBagMenuState.itemsAbove[gBagMenuState.pocket]); @@ -2298,8 +2298,8 @@ static void Task_Bag_TeachyTvCatching(u8 taskId) break; case 816: PlaySE(SE_SELECT); - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); CopyWindowToVram(0, COPYWIN_MAP); @@ -2340,8 +2340,8 @@ static void Task_Bag_TeachyTvStatus(u8 taskId) break; case 306: PlaySE(SE_SELECT); - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); CopyWindowToVram(0, COPYWIN_MAP); @@ -2381,8 +2381,8 @@ static void Task_Bag_TeachyTvTMs(u8 taskId) break; case 408: PlaySE(SE_SELECT); - HideBagWindow(10); - HideBagWindow(6); + HideBagWindow(BAG_WIN_CONTEXT); + HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); PutWindowTilemap(1); CopyWindowToVram(0, COPYWIN_MAP); From 7d672f3bfae7c33015d4cb87db7e532a7220f553 Mon Sep 17 00:00:00 2001 From: Naramo <62239403+SevenSpiders@users.noreply.github.com> Date: Mon, 19 May 2025 12:14:27 +0200 Subject: [PATCH 3/6] renaming part 2 --- include/bag.h | 7 ++++--- src/bag.c | 6 +++--- src/item_menu.c | 28 ++++++++++++++-------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/bag.h b/include/bag.h index 43007c44faf..844dfb18258 100644 --- a/include/bag.h +++ b/include/bag.h @@ -4,14 +4,15 @@ #include "menu_helpers.h" #define BAG_WIN_ITEMS_ID 0 // central main list window -#define BAG_WIN_MESSAGE_ID 1 // bottom MSG box +#define BAG_WIN_MAIN_MSG_ID 1 // bottom MSG box #define BAG_WIN_TITLE_ID 2 // top left pocket title // whichWindow indexes #define BAG_WIN_CHOOSE_QUANTITY 0 // bottom right corner #define BAG_WIN_MONEY 2 // top left corner -#define BAG_WIN_MSG 6 // MSG box width 14 (spares icon bottom left corner) -#define BAG_WIN_CONTEXT 10 // conctext menu with 1 element +#define BAG_WIN_MSG_FULL 5 // full MSG box +#define BAG_WIN_MSG 6 // MSG box width 14 (spares icon bottom left corner) +#define BAG_WIN_CONTEXT 10 // conctext menu with 1 element void InitBagWindows(void); void BagPrintTextOnWindow(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx); diff --git a/src/bag.c b/src/bag.c index 8aa5419a320..20cafe19233 100644 --- a/src/bag.c +++ b/src/bag.c @@ -28,7 +28,7 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = { .paletteNum = 15, .baseBlock = 0x008a }, - [BAG_WIN_MESSAGE_ID] = { // bottom MSG box + [BAG_WIN_MAIN_MSG_ID] = { // bottom MSG box .bg = 0, .tilemapLeft = 5, .tilemapTop = 14, @@ -58,7 +58,7 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = { .paletteNum = 15, .baseBlock = 0x008a }, - [BAG_WIN_MESSAGE_ID] = { // bottom MSG box + [BAG_WIN_MAIN_MSG_ID] = { // bottom MSG box .bg = 0, .tilemapLeft = 5, .tilemapTop = 14, @@ -124,7 +124,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x28a }, - [BAG_WIN_MSG - 1] = { // whole MSG box unused + [BAG_WIN_MSG_FULL] = { // whole MSG box .bg = 0, .tilemapLeft = 2, .tilemapTop = 15, diff --git a/src/item_menu.c b/src/item_menu.c index e18192b3ea7..a87ee8b9940 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1018,7 +1018,7 @@ static void All_CalculateNItemsAndMaxShowed(void) void DisplayItemMessageInBag(u8 taskId, u8 fontId, const u8 * string, TaskFunc followUpFunc) { s16 *data = gTasks[taskId].data; - data[10] = OpenBagWindow(5); + data[10] = OpenBagWindow(BAG_WIN_MSG_FULL); FillWindowPixelBuffer(data[10], PIXEL_FILL(1)); DisplayMessageAndContinueTask(taskId, data[10], 0x06D, 0x0D, fontId, GetTextSpeedSetting(), string, followUpFunc); ScheduleBgCopyTilemapToVram(0); @@ -1321,11 +1321,11 @@ static void InitQuantityToTossOrDeposit(u16 cursorPos, const u8 *str) static void UpdateQuantityToTossOrDeposit(s16 value, u8 ndigits) { - u8 r6 = GetBagWindow(0); - FillWindowPixelBuffer(r6, PIXEL_FILL(1)); + u8 bagQuantityWinId = GetBagWindow(BAG_WIN_CHOOSE_QUANTITY); + FillWindowPixelBuffer(bagQuantityWinId, PIXEL_FILL(1)); ConvertIntToDecimalStringN(gStringVar1, value, STR_CONV_MODE_LEADING_ZEROS, ndigits); StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1); - BagPrintTextOnWindow(r6, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1); + BagPrintTextOnWindow(bagQuantityWinId, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1); } // row of 0 is the bottom row in the list, up to LIST_TILES_HEIGHT at the top @@ -1482,8 +1482,8 @@ static void Task_ItemMenuAction_Use(u8 taskId) static void Task_ItemMenuAction_Toss(u8 taskId) { s16 *data = gTasks[taskId].data; - ClearWindowTilemap(GetBagWindow(10)); - ClearWindowTilemap(GetBagWindow(6)); + ClearWindowTilemap(GetBagWindow(BAG_WIN_CONTEXT)); + ClearWindowTilemap(GetBagWindow(BAG_WIN_MSG)); HideBagWindow(BAG_WIN_CONTEXT); HideBagWindow(BAG_WIN_MSG); PutWindowTilemap(0); @@ -1528,7 +1528,7 @@ static void Task_SelectQuantityToToss(u8 taskId) else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); - ClearWindowTilemap(GetBagWindow(6)); + ClearWindowTilemap(GetBagWindow(BAG_WIN_MSG)); HideBagWindow(BAG_WIN_MSG); HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); ScheduleBgCopyTilemapToVram(0); @@ -1648,7 +1648,7 @@ static void Task_WaitAButtonAndCloseContextMenu(u8 taskId) void Task_ReturnToBagFromContextMenu(u8 taskId) { s16 *data = gTasks[taskId].data; - CloseBagWindow(5); + CloseBagWindow(BAG_WIN_MSG_FULL); DestroyListMenuTask(data[0], &gBagMenuState.cursorPos[gBagMenuState.pocket], &gBagMenuState.itemsAbove[gBagMenuState.pocket]); Pocket_CalculateNItemsAndMaxShowed(gBagMenuState.pocket); PocketCalculateInitialCursorPosAndItemsAbove(gBagMenuState.pocket); @@ -1854,7 +1854,7 @@ static void Task_SellItem_No(u8 taskId) { s16 *data = gTasks[taskId].data; HideBagWindow(BAG_WIN_MONEY); - CloseBagWindow(5); + CloseBagWindow(BAG_WIN_MSG_FULL); PutWindowTilemap(2); PutWindowTilemap(0); PutWindowTilemap(1); @@ -1878,7 +1878,7 @@ static void Task_InitSaleQuantitySelectInterface(u8 taskId) static void UpdateSalePriceDisplay(s32 amount) { - PrintMoneyAmount(GetBagWindow(0), 56, 10, amount, 0); + PrintMoneyAmount(GetBagWindow(BAG_WIN_CHOOSE_QUANTITY), 56, 10, amount, 0); } static void Task_SelectQuantityToSell(u8 taskId) @@ -1903,7 +1903,7 @@ static void Task_SelectQuantityToSell(u8 taskId) PlaySE(SE_SELECT); HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); HideBagWindow(BAG_WIN_MONEY); - CloseBagWindow(5); + CloseBagWindow(BAG_WIN_MSG_FULL); PutWindowTilemap(2); PutWindowTilemap(0); PutWindowTilemap(1); @@ -1939,8 +1939,8 @@ static void Task_FinalizeSaleToShop(u8 taskId) Bag_BuildListMenuTemplate(gBagMenuState.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gBagMenuState.cursorPos[gBagMenuState.pocket], gBagMenuState.itemsAbove[gBagMenuState.pocket]); bag_menu_print_cursor_(data[0], 2); - BagDrawTextBoxOnWindow(GetBagWindow(2)); - PrintMoneyAmountInMoneyBox(GetBagWindow(2), GetMoney(&gSaveBlock1Ptr->money), 0); + BagDrawTextBoxOnWindow(GetBagWindow(BAG_WIN_MONEY)); + PrintMoneyAmountInMoneyBox(GetBagWindow(BAG_WIN_MONEY), GetMoney(&gSaveBlock1Ptr->money), 0); gTasks[taskId].func = Task_WaitPressAB_AfterSell; } @@ -1981,7 +1981,7 @@ static void Task_SelectQuantityToDeposit(u8 taskId) else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); - ClearWindowTilemap(GetBagWindow(6)); + ClearWindowTilemap(GetBagWindow(BAG_WIN_MSG)); HideBagWindow(BAG_WIN_MSG); HideBagWindow(BAG_WIN_CHOOSE_QUANTITY); ScheduleBgCopyTilemapToVram(0); From 18d9d282415c2233644e6bf6c525833e90032777 Mon Sep 17 00:00:00 2001 From: Naramo <62239403+SevenSpiders@users.noreply.github.com> Date: Mon, 19 May 2025 12:21:14 +0200 Subject: [PATCH 4/6] renaming part 3 --- include/bag.h | 7 ++++--- src/item_menu.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/bag.h b/include/bag.h index 844dfb18258..0b68f068a64 100644 --- a/include/bag.h +++ b/include/bag.h @@ -3,14 +3,15 @@ #include "menu_helpers.h" +// windowIds #define BAG_WIN_ITEMS_ID 0 // central main list window -#define BAG_WIN_MAIN_MSG_ID 1 // bottom MSG box +#define BAG_WIN_MAIN_MSG_ID 1 // bottom MSG box #define BAG_WIN_TITLE_ID 2 // top left pocket title -// whichWindow indexes +// whichWindow #define BAG_WIN_CHOOSE_QUANTITY 0 // bottom right corner #define BAG_WIN_MONEY 2 // top left corner -#define BAG_WIN_MSG_FULL 5 // full MSG box +#define BAG_WIN_MSG_FULL 5 // full MSG box #define BAG_WIN_MSG 6 // MSG box width 14 (spares icon bottom left corner) #define BAG_WIN_CONTEXT 10 // conctext menu with 1 element diff --git a/src/item_menu.c b/src/item_menu.c index a87ee8b9940..56c6fc79721 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -735,7 +735,7 @@ static void bag_menu_print_cursor(u8 y, u8 colorIdx) } else { - BagPrintTextOnWindow(0, FONT_NORMAL, gText_SelectorArrow2, 1, y, 0, 0, 0, colorIdx); + BagPrintTextOnWindow(BAG_WIN_ITEMS_ID, FONT_NORMAL, gText_SelectorArrow2, 1, y, 0, 0, 0, colorIdx); } } @@ -753,7 +753,7 @@ static void PrintItemDescriptionOnMessageWindow(s32 itemIndex) else description = gText_CloseBag; FillWindowPixelBuffer(1, PIXEL_FILL(0)); - BagPrintTextOnWindow(1, FONT_NORMAL, description, 0, 3, 2, 0, 0, 0); + BagPrintTextOnWindow(BAG_WIN_MAIN_MSG_ID, FONT_NORMAL, description, 0, 3, 2, 0, 0, 0); } static void CreatePocketScrollArrowPair(void) @@ -1226,7 +1226,7 @@ static void BeginMovingItemInPocket(u8 taskId, s16 itemIndex) StringCopy(gStringVar1, ItemId_GetName(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1]))); StringExpandPlaceholders(gStringVar4, gOtherText_WhereShouldTheStrVar1BePlaced); FillWindowPixelBuffer(1, PIXEL_FILL(0)); - BagPrintTextOnWindow(1, FONT_NORMAL, gStringVar4, 0, 3, 2, 0, 0, 0); + BagPrintTextOnWindow(BAG_WIN_MAIN_MSG_ID, FONT_NORMAL, gStringVar4, 0, 3, 2, 0, 0, 0); UpdateSwapLinePos(0, ListMenuGetYCoordForPrintingArrowCursor(data[0])); SetSwapLineInvisibility(FALSE); BagDestroyPocketSwitchArrowPair(); From 59f285224c397863fc5d59194808decb7fa9f228 Mon Sep 17 00:00:00 2001 From: Naramo <62239403+SevenSpiders@users.noreply.github.com> Date: Mon, 19 May 2025 12:25:31 +0200 Subject: [PATCH 5/6] use WINDOW_NONE --- src/bag.c | 12 ++++++------ src/window.c | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/bag.c b/src/bag.c index 20cafe19233..b297efd9cc5 100644 --- a/src/bag.c +++ b/src/bag.c @@ -232,7 +232,7 @@ void InitBagWindows(void) ScheduleBgCopyTilemapToVram(0); for (i = 0; i < 11; i++) { - sOpenWindows[i] = 0xFF; + sOpenWindows[i] = WINDOW_NONE; } } @@ -257,7 +257,7 @@ void BagDrawDepositItemTextBox(void) u8 ShowBagWindow(u8 whichWindow, u8 nItems) { - if (sOpenWindows[whichWindow] == 0xFF) + if (sOpenWindows[whichWindow] == WINDOW_NONE) { sOpenWindows[whichWindow] = AddWindow(&sWindowTemplates[whichWindow + nItems]); if (whichWindow != 6) @@ -279,12 +279,12 @@ void HideBagWindow(u8 whichWindow) ClearWindowTilemap(sOpenWindows[whichWindow]); RemoveWindow(sOpenWindows[whichWindow]); ScheduleBgCopyTilemapToVram(0); - sOpenWindows[whichWindow] = 0xFF; + sOpenWindows[whichWindow] = WINDOW_NONE; } u8 OpenBagWindow(u8 whichWindow) { - if (sOpenWindows[whichWindow] == 0xFF) + if (sOpenWindows[whichWindow] == WINDOW_NONE) { sOpenWindows[whichWindow] = AddWindow(&sWindowTemplates[whichWindow]); } @@ -293,14 +293,14 @@ u8 OpenBagWindow(u8 whichWindow) void CloseBagWindow(u8 whichWindow) { - if (sOpenWindows[whichWindow] != 0xFF) + if (sOpenWindows[whichWindow] != WINDOW_NONE) { ClearDialogWindowAndFrameToTransparent(sOpenWindows[whichWindow], FALSE); ClearWindowTilemap(sOpenWindows[whichWindow]); RemoveWindow(sOpenWindows[whichWindow]); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(0); - sOpenWindows[whichWindow] = 0xFF; + sOpenWindows[whichWindow] = WINDOW_NONE; } } diff --git a/src/window.c b/src/window.c index 834f13a8c9f..d93d104547c 100644 --- a/src/window.c +++ b/src/window.c @@ -8,7 +8,7 @@ EWRAM_DATA struct Window gWindows[WINDOWS_MAX] = {0}; static u8 GetNumActiveWindowsOnBg(u8 bgId); -static const struct WindowTemplate sDummyWindowTemplate = {0xFF, 0, 0, 0, 0, 0, 0}; +static const struct WindowTemplate sDummyWindowTemplate = {WINDOW_NONE, 0, 0, 0, 0, 0, 0}; static void nullsub_8(void) { @@ -98,6 +98,7 @@ bool16 InitWindows(const struct WindowTemplate *templates) return TRUE; } +// returns windowId or WINDOW_NONE (0xFF) u16 AddWindow(const struct WindowTemplate *template) { u16 win; @@ -114,7 +115,7 @@ u16 AddWindow(const struct WindowTemplate *template) } if (win == WINDOWS_MAX) - return 0xFF; + return WINDOW_NONE; bgLayer = template->bg; allocatedBaseBlock = 0; @@ -124,7 +125,7 @@ u16 AddWindow(const struct WindowTemplate *template) allocatedBaseBlock = BgTileAllocOp(bgLayer, 0, template->width * template->height, BG_TILE_FIND_FREE_SPACE); if (allocatedBaseBlock == -1) - return 0xFF; + return WINDOW_NONE; } if (gWindowBgTilemapBuffers[bgLayer] == NULL) @@ -136,7 +137,7 @@ u16 AddWindow(const struct WindowTemplate *template) allocatedTilemapBuffer = Alloc(bgSize); if (allocatedTilemapBuffer == NULL) - return 0xFF; + return WINDOW_NONE; for (i = 0; i < bgSize; ++i) allocatedTilemapBuffer[i] = 0; @@ -155,7 +156,7 @@ u16 AddWindow(const struct WindowTemplate *template) Free(gWindowBgTilemapBuffers[bgLayer]); gWindowBgTilemapBuffers[bgLayer] = allocatedTilemapBuffer; } - return 0xFF; + return WINDOW_NONE; } gWindows[win].tileData = allocatedTilemapBuffer; From 46820ff292642b5479e432747a993997c85716ca Mon Sep 17 00:00:00 2001 From: Naramo <62239403+SevenSpiders@users.noreply.github.com> Date: Mon, 19 May 2025 12:37:56 +0200 Subject: [PATCH 6/6] spelling --- include/bag.h | 2 +- src/bag.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/bag.h b/include/bag.h index 0b68f068a64..1d03aee08f9 100644 --- a/include/bag.h +++ b/include/bag.h @@ -13,7 +13,7 @@ #define BAG_WIN_MONEY 2 // top left corner #define BAG_WIN_MSG_FULL 5 // full MSG box #define BAG_WIN_MSG 6 // MSG box width 14 (spares icon bottom left corner) -#define BAG_WIN_CONTEXT 10 // conctext menu with 1 element +#define BAG_WIN_CONTEXT 10 // context menu with 1 element void InitBagWindows(void); void BagPrintTextOnWindow(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx); diff --git a/src/bag.c b/src/bag.c index b297efd9cc5..78c523ee65c 100644 --- a/src/bag.c +++ b/src/bag.c @@ -169,7 +169,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 12, .baseBlock = 0x356 }, - [BAG_WIN_CONTEXT] = { // conctext menu with 1 element + [BAG_WIN_CONTEXT] = { // context menu with 1 element .bg = 0, .tilemapLeft = 22, .tilemapTop = 17, @@ -178,7 +178,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x20a }, - [BAG_WIN_CONTEXT + 1] = { // conctext menu with 2 elements + [BAG_WIN_CONTEXT + 1] = { // context menu with 2 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 15, @@ -187,7 +187,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x20a }, - [BAG_WIN_CONTEXT + 2] = { // conctext menu with 3 elements + [BAG_WIN_CONTEXT + 2] = { // context menu with 3 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 13, @@ -196,7 +196,7 @@ static const struct WindowTemplate sWindowTemplates[] = { .paletteNum = 15, .baseBlock = 0x20a }, - [BAG_WIN_CONTEXT + 3] = { // conctext menu with 4 elements + [BAG_WIN_CONTEXT + 3] = { // context menu with 4 elements .bg = 0, .tilemapLeft = 22, .tilemapTop = 11,