Use window constants in trainer_card

This commit is contained in:
GriffinR 2022-09-29 12:30:10 -04:00
parent dd5daa3208
commit 9f5704b05a

View File

@ -33,6 +33,12 @@
#include "constants/trainers.h" #include "constants/trainers.h"
#include "constants/union_room.h" #include "constants/union_room.h"
enum {
WIN_MSG,
WIN_CARD_TEXT,
WIN_TRAINER_PIC,
};
struct TrainerCardData struct TrainerCardData
{ {
u8 mainState; u8 mainState;
@ -226,7 +232,7 @@ static const struct BgTemplate sTrainerCardBgTemplates[4] =
static const struct WindowTemplate sTrainerCardWindowTemplates[] = static const struct WindowTemplate sTrainerCardWindowTemplates[] =
{ {
{ [WIN_MSG] = {
.bg = 1, .bg = 1,
.tilemapLeft = 2, .tilemapLeft = 2,
.tilemapTop = 15, .tilemapTop = 15,
@ -235,7 +241,7 @@ static const struct WindowTemplate sTrainerCardWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x253, .baseBlock = 0x253,
}, },
{ [WIN_CARD_TEXT] = {
.bg = 1, .bg = 1,
.tilemapLeft = 1, .tilemapLeft = 1,
.tilemapTop = 1, .tilemapTop = 1,
@ -244,7 +250,7 @@ static const struct WindowTemplate sTrainerCardWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x1, .baseBlock = 0x1,
}, },
{ [WIN_TRAINER_PIC] = {
.bg = 3, .bg = 3,
.tilemapLeft = 19, .tilemapLeft = 19,
.tilemapTop = 5, .tilemapTop = 5,
@ -376,7 +382,7 @@ static void Task_TrainerCard(u8 taskId)
case 0: case 0:
if (!IsDma3ManagerBusyWithBgCopy()) if (!IsDma3ManagerBusyWithBgCopy())
{ {
FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(WIN_CARD_TEXT, PIXEL_FILL(0));
sData->mainState++; sData->mainState++;
} }
break; break;
@ -385,13 +391,13 @@ static void Task_TrainerCard(u8 taskId)
sData->mainState++; sData->mainState++;
break; break;
case 2: case 2:
DrawTrainerCardWindow(1); DrawTrainerCardWindow(WIN_CARD_TEXT);
sData->mainState++; sData->mainState++;
break; break;
case 3: case 3:
FillWindowPixelBuffer(2, PIXEL_FILL(0)); FillWindowPixelBuffer(WIN_TRAINER_PIC, PIXEL_FILL(0));
CreateTrainerCardTrainerPic(); CreateTrainerCardTrainerPic();
DrawTrainerCardWindow(2); DrawTrainerCardWindow(WIN_TRAINER_PIC);
sData->mainState++; sData->mainState++;
break; break;
case 4: case 4:
@ -411,7 +417,7 @@ static void Task_TrainerCard(u8 taskId)
if (gWirelessCommType == 1 && gReceivedRemoteLinkPlayers == TRUE) if (gWirelessCommType == 1 && gReceivedRemoteLinkPlayers == TRUE)
{ {
LoadWirelessStatusIndicatorSpriteGfx(); LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(230, 150); CreateWirelessStatusIndicatorSprite(DISPLAY_WIDTH - 10, DISPLAY_HEIGHT - 10);
} }
BlendPalettes(PALETTES_ALL, 16, sData->blendColor); BlendPalettes(PALETTES_ALL, 16, sData->blendColor);
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, sData->blendColor); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, sData->blendColor);
@ -434,7 +440,7 @@ static void Task_TrainerCard(u8 taskId)
if (!gReceivedRemoteLinkPlayers && sData->timeColonNeedDraw) if (!gReceivedRemoteLinkPlayers && sData->timeColonNeedDraw)
{ {
PrintTimeOnCard(); PrintTimeOnCard();
DrawTrainerCardWindow(1); DrawTrainerCardWindow(WIN_CARD_TEXT);
sData->timeColonNeedDraw = FALSE; sData->timeColonNeedDraw = FALSE;
} }
if (JOY_NEW(A_BUTTON)) if (JOY_NEW(A_BUTTON))
@ -497,9 +503,9 @@ static void Task_TrainerCard(u8 taskId)
break; break;
case STATE_WAIT_LINK_PARTNER: case STATE_WAIT_LINK_PARTNER:
SetCloseLinkCallback(); SetCloseLinkCallback();
DrawDialogueFrame(0, TRUE); DrawDialogueFrame(WIN_MSG, TRUE);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_WaitingTrainerFinishReading, 0, 1, 255, 0); AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, gText_WaitingTrainerFinishReading, 0, 1, 255, 0);
CopyWindowToVram(0, COPYWIN_FULL); CopyWindowToVram(WIN_MSG, COPYWIN_FULL);
sData->mainState = STATE_CLOSE_CARD_LINK; sData->mainState = STATE_CLOSE_CARD_LINK;
break; break;
case STATE_CLOSE_CARD_LINK: case STATE_CLOSE_CARD_LINK:
@ -1002,9 +1008,9 @@ static void PrintNameOnCardFront(void)
StringCopy(txtPtr, sData->trainerCard.playerName); StringCopy(txtPtr, sData->trainerCard.playerName);
ConvertInternationalString(txtPtr, sData->language); ConvertInternationalString(txtPtr, sData->language);
if (sData->cardType == CARD_TYPE_FRLG) if (sData->cardType == CARD_TYPE_FRLG)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 28, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 28, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
else else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
} }
static void PrintIdOnCard(void) static void PrintIdOnCard(void)
@ -1026,7 +1032,7 @@ static void PrintIdOnCard(void)
top = 9; top = 9;
} }
AddTextPrinterParameterized3(1, FONT_NORMAL, xPos, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xPos, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
} }
static void PrintMoneyOnCard(void) static void PrintMoneyOnCard(void)
@ -1035,9 +1041,9 @@ static void PrintMoneyOnCard(void)
u8 top; u8 top;
if (!sData->isHoenn) if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 56, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 56, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
else else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 57, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 57, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
ConvertIntToDecimalStringN(gStringVar1, sData->trainerCard.money, STR_CONV_MODE_LEFT_ALIGN, 6); ConvertIntToDecimalStringN(gStringVar1, sData->trainerCard.money, STR_CONV_MODE_LEFT_ALIGN, 6);
StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1); StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1);
@ -1051,7 +1057,7 @@ static void PrintMoneyOnCard(void)
xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128); xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128);
top = 57; top = 57;
} }
AddTextPrinterParameterized3(1, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
} }
static u16 GetCaughtMonsCount(void) static u16 GetCaughtMonsCount(void)
@ -1069,9 +1075,9 @@ static void PrintPokedexOnCard(void)
if (FlagGet(FLAG_SYS_POKEDEX_GET)) if (FlagGet(FLAG_SYS_POKEDEX_GET))
{ {
if (!sData->isHoenn) if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 72, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 72, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex);
else else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 73, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 73, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex);
StringCopy(ConvertIntToDecimalStringN(gStringVar4, sData->trainerCard.caughtMonsCount, STR_CONV_MODE_LEFT_ALIGN, 3), gText_EmptyString6); StringCopy(ConvertIntToDecimalStringN(gStringVar4, sData->trainerCard.caughtMonsCount, STR_CONV_MODE_LEFT_ALIGN, 3), gText_EmptyString6);
if (!sData->isHoenn) if (!sData->isHoenn)
{ {
@ -1083,7 +1089,7 @@ static void PrintPokedexOnCard(void)
xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128); xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128);
top = 73; top = 73;
} }
AddTextPrinterParameterized3(1, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
} }
} }
@ -1097,9 +1103,9 @@ static void PrintTimeOnCard(void)
u32 x, y, totalWidth; u32 x, y, totalWidth;
if (!sData->isHoenn) if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 88, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 88, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime);
else else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 89, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 89, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime);
if (sData->isLink) if (sData->isLink)
{ {
@ -1131,14 +1137,14 @@ static void PrintTimeOnCard(void)
totalWidth = width + 30; totalWidth = width + 30;
x -= totalWidth; x -= totalWidth;
FillWindowPixelRect(1, PIXEL_FILL(0), x, y, totalWidth, 15); FillWindowPixelRect(WIN_CARD_TEXT, PIXEL_FILL(0), x, y, totalWidth, 15);
ConvertIntToDecimalStringN(gStringVar4, hours, STR_CONV_MODE_RIGHT_ALIGN, 3); ConvertIntToDecimalStringN(gStringVar4, hours, STR_CONV_MODE_RIGHT_ALIGN, 3);
AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
x += 18; x += 18;
AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTimeColonTextColors[sData->timeColonInvisible], TEXT_SKIP_DRAW, gText_Colon2); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, x, y, sTimeColonTextColors[sData->timeColonInvisible], TEXT_SKIP_DRAW, gText_Colon2);
x += width; x += width;
ConvertIntToDecimalStringN(gStringVar4, minutes, STR_CONV_MODE_LEADING_ZEROS, 2); ConvertIntToDecimalStringN(gStringVar4, minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
} }
static void PrintProfilePhraseOnCard(void) static void PrintProfilePhraseOnCard(void)
@ -1148,10 +1154,10 @@ static void PrintProfilePhraseOnCard(void)
if (sData->isLink) if (sData->isLink)
{ {
AddTextPrinterParameterized3(1, FONT_NORMAL, 8, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[0]); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 8, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[0]);
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[0], 0) + 14, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[1]); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[0], 0) + 14, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[1]);
AddTextPrinterParameterized3(1, FONT_NORMAL, 8, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[2]); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 8, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[2]);
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[2], 0) + 14, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[3]); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[2], 0) + 14, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[3]);
} }
} }
@ -1169,9 +1175,9 @@ static void BufferNameForCardBack(void)
static void PrintNameOnCardBack(void) static void PrintNameOnCardBack(void)
{ {
if (!sData->isHoenn) if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 136, 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 136, 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard);
else else
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, sData->textPlayersCard, 216), 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, sData->textPlayersCard, 216), 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard);
} }
static const u8 sText_HofTime[] = _("{STR_VAR_1}:{STR_VAR_2}:{STR_VAR_3}"); static const u8 sText_HofTime[] = _("{STR_VAR_1}:{STR_VAR_2}:{STR_VAR_3}");
@ -1192,8 +1198,8 @@ static void PrintStatOnBackOfCard(u8 top, const u8 *statName, u8 *stat, const u8
static const u8 xOffsets[] = {8, 16}; static const u8 xOffsets[] = {8, 16};
static const u8 widths[] = {216, 216}; static const u8 widths[] = {216, 216};
AddTextPrinterParameterized3(1, FONT_NORMAL, xOffsets[sData->isHoenn], top * 16 + 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, statName); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xOffsets[sData->isHoenn], top * 16 + 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, statName);
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, stat, widths[sData->isHoenn]), top * 16 + 33, color, TEXT_SKIP_DRAW, stat); AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, stat, widths[sData->isHoenn]), top * 16 + 33, color, TEXT_SKIP_DRAW, stat);
} }
static void PrintHofDebutTimeOnCard(void) static void PrintHofDebutTimeOnCard(void)
@ -1672,7 +1678,7 @@ static bool8 Task_DrawFlippedCardSide(struct Task *task)
switch (sData->flipDrawState) switch (sData->flipDrawState)
{ {
case 0: case 0:
FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(WIN_CARD_TEXT, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 0x20, 0x20); FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 0x20, 0x20);
break; break;
case 1: case 1:
@ -1691,13 +1697,13 @@ static bool8 Task_DrawFlippedCardSide(struct Task *task)
if (!sData->onBack) if (!sData->onBack)
DrawCardFrontOrBack(sData->backTilemap); DrawCardFrontOrBack(sData->backTilemap);
else else
DrawTrainerCardWindow(1); DrawTrainerCardWindow(WIN_CARD_TEXT);
break; break;
case 3: case 3:
if (!sData->onBack) if (!sData->onBack)
DrawCardBackStats(); DrawCardBackStats();
else else
FillWindowPixelBuffer(2, PIXEL_FILL(0)); FillWindowPixelBuffer(WIN_TRAINER_PIC, PIXEL_FILL(0));
break; break;
case 4: case 4:
if (sData->onBack) if (sData->onBack)
@ -1722,12 +1728,12 @@ static bool8 Task_SetCardFlipped(struct Task *task)
// If on back of card, draw front of card because its being flipped // If on back of card, draw front of card because its being flipped
if (sData->onBack) if (sData->onBack)
{ {
DrawTrainerCardWindow(2); DrawTrainerCardWindow(WIN_TRAINER_PIC);
DrawCardScreenBackground(sData->bgTilemap); DrawCardScreenBackground(sData->bgTilemap);
DrawCardFrontOrBack(sData->frontTilemap); DrawCardFrontOrBack(sData->frontTilemap);
DrawStarsAndBadgesOnCard(); DrawStarsAndBadgesOnCard();
} }
DrawTrainerCardWindow(1); DrawTrainerCardWindow(WIN_CARD_TEXT);
sData->onBack ^= 1; sData->onBack ^= 1;
task->tFlipState++; task->tFlipState++;
sData->allowDMACopy = TRUE; sData->allowDMACopy = TRUE;
@ -1882,7 +1888,7 @@ static void CreateTrainerCardTrainerPic(void)
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][0], sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][0],
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][1], sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][1],
8, 8,
2); WIN_TRAINER_PIC);
} }
else else
{ {
@ -1891,6 +1897,6 @@ static void CreateTrainerCardTrainerPic(void)
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][0], sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][0],
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][1], sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][1],
8, 8,
2); WIN_TRAINER_PIC);
} }
} }