Use window constants for move relearner

This commit is contained in:
GriffinR
2022-09-29 11:57:30 -04:00
parent f254df9a1a
commit 16be1e8447
3 changed files with 76 additions and 90 deletions

View File

@@ -105,10 +105,9 @@ static const u8 sConditionToLineLength[MAX_CONDITION + 1] =
34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35
};
static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
{
{
[RELEARNERWIN_DESC_BATTLE] = {
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 1,
@@ -117,7 +116,7 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 0xF,
.baseBlock = 0xA
},
{
[RELEARNERWIN_DESC_CONTEST] = {
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 1,
@@ -126,7 +125,7 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 0xF,
.baseBlock = 0xCA
},
{
[RELEARNERWIN_MOVE_LIST] = {
.bg = 1,
.tilemapLeft = 19,
.tilemapTop = 1,
@@ -135,7 +134,7 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 0xF,
.baseBlock = 0x18A
},
{
[RELEARNERWIN_MSG] = {
.bg = 1,
.tilemapLeft = 4,
.tilemapTop = 15,
@@ -144,7 +143,8 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 0xF,
.baseBlock = 0x202
},
{
// Unused. Identical to sMoveRelearnerYesNoMenuTemplate
[RELEARNERWIN_YESNO] = {
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 8,
@@ -175,7 +175,7 @@ static const struct ListMenuTemplate sMoveRelearnerMovesListTemplate =
.itemPrintFunc = NULL,
.totalItems = 0,
.maxShowed = 0,
.windowId = 2,
.windowId = RELEARNERWIN_MOVE_LIST,
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@@ -701,7 +701,7 @@ void ConditionGraph_CalcPositions(u8 *conditions, struct UCoords16 *positions)
// Move relearner
//----------------
void InitMoveRelearnerWindows(bool8 useContextWindow)
void InitMoveRelearnerWindows(bool8 useContestWindow)
{
u8 i;
@@ -713,20 +713,20 @@ void InitMoveRelearnerWindows(bool8 useContextWindow)
for (i = 0; i < ARRAY_COUNT(sMoveRelearnerWindowTemplates) - 1; i++)
FillWindowPixelBuffer(i, PIXEL_FILL(1));
if (!useContextWindow)
if (!useContestWindow)
{
PutWindowTilemap(0);
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x1, 0xE);
PutWindowTilemap(RELEARNERWIN_DESC_BATTLE);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_DESC_BATTLE, FALSE, 0x1, 0xE);
}
else
{
PutWindowTilemap(1);
DrawStdFrameWithCustomTileAndPalette(1, FALSE, 1, 0xE);
PutWindowTilemap(RELEARNERWIN_DESC_CONTEST);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_DESC_CONTEST, FALSE, 1, 0xE);
}
PutWindowTilemap(2);
PutWindowTilemap(3);
DrawStdFrameWithCustomTileAndPalette(2, FALSE, 1, 0xE);
DrawStdFrameWithCustomTileAndPalette(3, FALSE, 1, 0xE);
PutWindowTilemap(RELEARNERWIN_MOVE_LIST);
PutWindowTilemap(RELEARNERWIN_MSG);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_MOVE_LIST, FALSE, 1, 0xE);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_MSG, FALSE, 1, 0xE);
MoveRelearnerDummy();
ScheduleBgCopyTilemapToVram(1);
}
@@ -757,33 +757,34 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
u8 buffer[32];
const u8 *str;
FillWindowPixelBuffer(0, PIXEL_FILL(1));
FillWindowPixelBuffer(RELEARNERWIN_DESC_BATTLE, PIXEL_FILL(1));
str = gText_MoveRelearnerBattleMoves;
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 0x80);
AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 128);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerPP;
AddTextPrinterParameterized(0, FONT_NORMAL, str, 4, 0x29, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 4, 41, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerPower;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x6A);
AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 0x19, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 106);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerAccuracy;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x6A);
AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 0x29, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 106);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, x, 41, TEXT_SKIP_DRAW, NULL);
if (chosenMove == LIST_CANCEL)
{
CopyWindowToVram(0, COPYWIN_GFX);
// On "Cancel", skip printing move data
CopyWindowToVram(RELEARNERWIN_DESC_BATTLE, COPYWIN_GFX);
return;
}
move = &gBattleMoves[chosenMove];
str = gTypeNames[move->type];
AddTextPrinterParameterized(0, FONT_NORMAL, str, 4, 0x19, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 4, 25, TEXT_SKIP_DRAW, NULL);
x = 4 + GetStringWidth(FONT_NORMAL, gText_MoveRelearnerPP, 0);
ConvertIntToDecimalStringN(buffer, move->pp, STR_CONV_MODE_LEFT_ALIGN, 2);
AddTextPrinterParameterized(0, FONT_NORMAL, buffer, x, 0x29, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, buffer, x, 41, TEXT_SKIP_DRAW, NULL);
if (move->power < 2)
{
@@ -794,7 +795,7 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
ConvertIntToDecimalStringN(buffer, move->power, STR_CONV_MODE_LEFT_ALIGN, 3);
str = buffer;
}
AddTextPrinterParameterized(0, FONT_NORMAL, str, 0x6A, 0x19, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 106, 25, TEXT_SKIP_DRAW, NULL);
if (move->accuracy == 0)
{
@@ -805,10 +806,10 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
ConvertIntToDecimalStringN(buffer, move->accuracy, STR_CONV_MODE_LEFT_ALIGN, 3);
str = buffer;
}
AddTextPrinterParameterized(0, FONT_NORMAL, str, 0x6A, 0x29, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 106, 41, TEXT_SKIP_DRAW, NULL);
str = gMoveDescriptionPointers[chosenMove - 1];
AddTextPrinterParameterized(0, FONT_NARROW, str, 0, 0x41, 0, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NARROW, str, 0, 65, 0, NULL);
}
static void MoveRelearnerMenuLoadContestMoveDescription(u32 chosenMove)
@@ -818,33 +819,33 @@ static void MoveRelearnerMenuLoadContestMoveDescription(u32 chosenMove)
const struct ContestMove *move;
MoveRelearnerShowHideHearts(chosenMove);
FillWindowPixelBuffer(1, PIXEL_FILL(1));
FillWindowPixelBuffer(RELEARNERWIN_DESC_CONTEST, PIXEL_FILL(1));
str = gText_MoveRelearnerContestMovesTitle;
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 0x80);
AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 128);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerAppeal;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x5C);
AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 0x19, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 92);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerJam;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x5C);
AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 0x29, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 92);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, x, 41, TEXT_SKIP_DRAW, NULL);
if (chosenMove == MENU_NOTHING_CHOSEN)
{
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(RELEARNERWIN_DESC_CONTEST, COPYWIN_GFX);
return;
}
move = &gContestMoves[chosenMove];
str = gContestMoveTypeTextPointers[move->contestCategory];
AddTextPrinterParameterized(1, FONT_NORMAL, str, 4, 0x19, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, 4, 25, TEXT_SKIP_DRAW, NULL);
str = gContestEffectDescriptionPointers[move->effect];
AddTextPrinterParameterized(1, FONT_NARROW, str, 0, 0x41, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NARROW, str, 0, 65, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(RELEARNERWIN_DESC_CONTEST, COPYWIN_GFX);
}
static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list)
@@ -855,20 +856,20 @@ static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct List
MoveRelearnerMenuLoadContestMoveDescription(itemIndex);
}
void MoveRelearnerPrintText(u8 *str)
void MoveRelearnerPrintMessage(u8 *str)
{
u8 speed;
FillWindowPixelBuffer(3, PIXEL_FILL(1));
FillWindowPixelBuffer(RELEARNERWIN_MSG, PIXEL_FILL(1));
gTextFlags.canABSpeedUpPrint = TRUE;
speed = GetPlayerTextSpeedDelay();
AddTextPrinterParameterized2(3, FONT_NORMAL, str, speed, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, 3);
AddTextPrinterParameterized2(RELEARNERWIN_MSG, FONT_NORMAL, str, speed, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, 3);
}
bool16 MoveRelearnerRunTextPrinters(void)
{
RunTextPrinters();
return IsTextPrinterActive(3);
return IsTextPrinterActive(RELEARNERWIN_MSG);
}
void MoveRelearnerCreateYesNoMenu(void)