From 2cd07d80b8e60cc0b2660dea3df7d2f4295b69c8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 29 Sep 2022 13:31:01 -0400 Subject: [PATCH] Use window constants in wireless_communication_status_screen --- src/wireless_communication_status_screen.c | 62 ++++++++++++---------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c index 1fbd83fcda..5d40aefb7a 100644 --- a/src/wireless_communication_status_screen.c +++ b/src/wireless_communication_status_screen.c @@ -27,12 +27,20 @@ enum { COLORMODE_WHITE_DGRAY, }; -#define GROUPTYPE_TRADE 0 -#define GROUPTYPE_BATTLE 1 -#define GROUPTYPE_UNION 2 -#define GROUPTYPE_TOTAL 3 -#define GROUPTYPE_NONE -1 -#define NUM_GROUPTYPES 4 +enum { + WIN_TITLE, + WIN_GROUP_NAMES, + WIN_GROUP_COUNTS, +}; + +enum { + GROUPTYPE_NONE = -1, + GROUPTYPE_TRADE, + GROUPTYPE_BATTLE, + GROUPTYPE_UNION, + GROUPTYPE_TOTAL, + NUM_GROUPTYPES +}; struct WirelessCommunicationStatusScreen { @@ -70,7 +78,7 @@ static const struct BgTemplate sBgTemplates[] = { }; static const struct WindowTemplate sWindowTemplates[] = { - { + [WIN_TITLE] = { .bg = 0, .tilemapLeft = 3, .tilemapTop = 0, @@ -78,7 +86,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 3, .paletteNum = 15, .baseBlock = 0x0001 - }, { + }, + [WIN_GROUP_NAMES] = { .bg = 0, .tilemapLeft = 3, .tilemapTop = 4, @@ -86,7 +95,8 @@ static const struct WindowTemplate sWindowTemplates[] = { .height = 15, .paletteNum = 15, .baseBlock = 0x0049 - }, { + }, + [WIN_GROUP_COUNTS] = { .bg = 0, .tilemapLeft = 24, .tilemapTop = 4, @@ -233,19 +243,17 @@ static void WCSS_CyclePalette(s16 * counter, s16 * palIdx) static void PrintHeaderTexts(void) { s32 i; - FillWindowPixelBuffer(0, PIXEL_FILL(0)); - FillWindowPixelBuffer(1, PIXEL_FILL(0)); - FillWindowPixelBuffer(2, PIXEL_FILL(0)); - WCSS_AddTextPrinterParameterized(0, FONT_NORMAL, sHeaderTexts[0], GetStringCenterAlignXOffset(FONT_NORMAL, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN); + FillWindowPixelBuffer(WIN_TITLE, PIXEL_FILL(0)); + FillWindowPixelBuffer(WIN_GROUP_NAMES, PIXEL_FILL(0)); + FillWindowPixelBuffer(WIN_GROUP_COUNTS, PIXEL_FILL(0)); + WCSS_AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, sHeaderTexts[0], GetStringCenterAlignXOffset(FONT_NORMAL, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN); for (i = 0; i < (int)ARRAY_COUNT(*sHeaderTexts) - 1; i++) - { - WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY); - } - WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED); - PutWindowTilemap(0); - CopyWindowToVram(0, COPYWIN_GFX); - PutWindowTilemap(1); - CopyWindowToVram(1, COPYWIN_GFX); + WCSS_AddTextPrinterParameterized(WIN_GROUP_NAMES, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY); + WCSS_AddTextPrinterParameterized(WIN_GROUP_NAMES, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED); + PutWindowTilemap(WIN_TITLE); + CopyWindowToVram(WIN_TITLE, COPYWIN_GFX); + PutWindowTilemap(WIN_GROUP_NAMES); + CopyWindowToVram(WIN_GROUP_NAMES, COPYWIN_GFX); } #define tState data[0] @@ -268,24 +276,22 @@ static void Task_WirelessCommunicationScreen(u8 taskId) break; case 2: if (!gPaletteFade.active) - { gTasks[taskId].tState++; - } break; case 3: if (UpdateCommunicationCounts(sStatusScreen->groupCounts, sStatusScreen->prevGroupCounts, sStatusScreen->activities, sStatusScreen->rfuTaskId)) { - FillWindowPixelBuffer(2, PIXEL_FILL(0)); + FillWindowPixelBuffer(WIN_GROUP_COUNTS, PIXEL_FILL(0)); for (i = 0; i < NUM_GROUPTYPES; i++) { ConvertIntToDecimalStringN(gStringVar4, sStatusScreen->groupCounts[i], STR_CONV_MODE_RIGHT_ALIGN, 2); if (i != GROUPTYPE_TOTAL) - WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY); + WCSS_AddTextPrinterParameterized(WIN_GROUP_COUNTS, FONT_NORMAL, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY); else - WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 98, COLORMODE_RED); + WCSS_AddTextPrinterParameterized(WIN_GROUP_COUNTS, FONT_NORMAL, gStringVar4, 12, 98, COLORMODE_RED); } - PutWindowTilemap(2); - CopyWindowToVram(2, COPYWIN_FULL); + PutWindowTilemap(WIN_GROUP_COUNTS); + CopyWindowToVram(WIN_GROUP_COUNTS, COPYWIN_FULL); } if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) {