More contest code consolidation (#8889)

This commit is contained in:
Frank DeBlasio 2026-01-12 15:21:21 -05:00 committed by GitHub
parent 6dfcde7d48
commit 36119e45d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 86 deletions

View File

@ -309,6 +309,7 @@ struct ContestCategory
const u8 *generic;
const u8 *negativeTrait;
u8 palette;
u16 tile;
};
extern const struct ContestCategory gContestCategoryInfo[CONTEST_CATEGORIES_COUNT + 1];

View File

@ -399,15 +399,12 @@ extern const u8 gText_ThrewAwayVar2Var1s[];
extern const u8 gText_ConfirmTossItems[];
extern const u8 gText_MoveVar1Where[];
extern const u8 gText_ColorLightShadowDarkGray[];
extern const u8 gText_ColorBlue[];
extern const u8 gText_Friend[];
extern const u8 gText_FiveMarks[];
extern const u8 gText_TotalRecordWLD[];
extern const u8 gText_PlayersBattleResults[];
extern const u8 gText_WinLoseDraw[];
extern const u8 gText_ColorTransparent[];
extern const u8 gText_Slash[];
extern const u8 gText_HealthboxNickname[];
extern const u8 gText_HealthboxGender_None[];

View File

@ -360,11 +360,9 @@ EWRAM_DATA u8 gCurContestWinnerSaveIdx = 0;
// IWRAM common vars.
COMMON_DATA rng_value_t gContestRngValue = {0};
const u8 gText_LinkStandby4[] = COMPOUND_STRING("Link standby!");
extern const u8 gText_BDot[];
extern const u8 gText_CDot[];
//Text
const u8 gText_LinkStandby4[] = COMPOUND_STRING("Link standby!");
const u8 gText_AppealNumWhichMoveWillBePlayed[] = COMPOUND_STRING("Appeal no. {STR_VAR_1}!\nWhich move will be played?");
const u8 gText_AppealNumButItCantParticipate[] = COMPOUND_STRING("Appeal no. {STR_VAR_1}!\nBut it can't participate!");
const u8 gText_MonAppealedWithMove[] = COMPOUND_STRING("{STR_VAR_1} appealed with\n{STR_VAR_2}!");
@ -684,6 +682,7 @@ const struct ContestCategory gContestCategoryInfo[CONTEST_CATEGORIES_COUNT + 1]
.generic = COMPOUND_STRING("COOL Move"),
.negativeTrait = COMPOUND_STRING("shyness"),
.palette = 13,
.tile = 0x4040,
},
[CONTEST_CATEGORY_BEAUTY] =
@ -693,6 +692,7 @@ const struct ContestCategory gContestCategoryInfo[CONTEST_CATEGORIES_COUNT + 1]
.generic = COMPOUND_STRING("BEAUTY Move"),
.negativeTrait = COMPOUND_STRING("anxiety"),
.palette = 14,
.tile = 0x4045,
},
[CONTEST_CATEGORY_CUTE] =
@ -702,6 +702,7 @@ const struct ContestCategory gContestCategoryInfo[CONTEST_CATEGORIES_COUNT + 1]
.generic = COMPOUND_STRING("CUTE Move"),
.negativeTrait = COMPOUND_STRING("laziness"),
.palette = 14,
.tile = 0x404A,
},
[CONTEST_CATEGORY_SMART] =
@ -711,6 +712,7 @@ const struct ContestCategory gContestCategoryInfo[CONTEST_CATEGORIES_COUNT + 1]
.generic = COMPOUND_STRING("SMART Move"),
.negativeTrait = COMPOUND_STRING("hesitancy"),
.palette = 15,
.tile = 0x406A,
},
[CONTEST_CATEGORY_TOUGH] =
@ -720,6 +722,7 @@ const struct ContestCategory gContestCategoryInfo[CONTEST_CATEGORIES_COUNT + 1]
.generic = COMPOUND_STRING("TOUGH Move"),
.negativeTrait = COMPOUND_STRING("fear"),
.palette = 13,
.tile = 0x408A,
},
[CONTEST_CATEGORIES_COUNT] =
@ -1583,14 +1586,14 @@ static void Task_ShowMoveSelectScreen(u8 taskId)
&& eContestantStatus[gContestPlayerMonIndex].hasJudgesAttention)
{
// Highlight the text because it's a combo move
moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGray);
moveNameBuffer = StringCopy(moveName, COMPOUND_STRING("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}"));
}
else if (move != MOVE_NONE
&& eContestantStatus[gContestPlayerMonIndex].prevMove == move
&& GetMoveContestEffect(move) != CONTEST_EFFECT_REPETITION_NOT_BORING)
{
// Gray the text because it's a repeated move
moveNameBuffer = StringCopy(moveName, gText_ColorBlue);
moveNameBuffer = StringCopy(moveName, COMPOUND_STRING("{COLOR BLUE}"));
}
moveNameBuffer = StringCopy(moveNameBuffer, GetMoveName(move));
@ -3011,26 +3014,8 @@ u8 GetContestEntryEligibility(struct Pokemon *pkmn)
return CANT_ENTER_CONTEST_EGG;
if (GetMonData(pkmn, MON_DATA_HP) == 0)
return CANT_ENTER_CONTEST_FAINTED;
switch (gSpecialVar_ContestCategory)
{
case CONTEST_CATEGORY_COOL:
ribbon = GetMonData(pkmn, MON_DATA_COOL_RIBBON);
break;
case CONTEST_CATEGORY_BEAUTY:
ribbon = GetMonData(pkmn, MON_DATA_BEAUTY_RIBBON);
break;
case CONTEST_CATEGORY_CUTE:
ribbon = GetMonData(pkmn, MON_DATA_CUTE_RIBBON);
break;
case CONTEST_CATEGORY_SMART:
ribbon = GetMonData(pkmn, MON_DATA_SMART_RIBBON);
break;
case CONTEST_CATEGORY_TOUGH:
ribbon = GetMonData(pkmn, MON_DATA_TOUGH_RIBBON);
break;
default:
return CANT_ENTER_CONTEST;
}
ribbon = GetMonData(pkmn, MON_DATA_COOL_RIBBON + gSpecialVar_ContestCategory);
// Couldn't get this to match any other way.
// Returns 2, 1, or 0 respectively if ribbon's rank is above, equal, or below
@ -3058,7 +3043,7 @@ static void DrawContestantWindowText(void)
static u8 *Contest_CopyStringWithColor(const u8 *string, u8 color)
{
u8 *ptr = StringCopy(gDisplayedStringBattle, gText_ColorTransparent);
u8 *ptr = StringCopy(gDisplayedStringBattle, COMPOUND_STRING("{BACKGROUND TRANSPARENT}{ACCENT TRANSPARENT}{COLOR TRANSPARENT}"));
ptr[-1] = color; // Overwrites the "{COLOR TRANSPARENT}" part of the string.
ptr = StringCopy(ptr, string);
@ -3237,48 +3222,38 @@ static u16 GetMoveEffectSymbolTileOffset(enum Move move, u8 contestant)
static void PrintContestMoveDescription(enum Move move)
{
u8 category;
u16 categoryTile;
u8 numHearts;
struct ContestEffect contestEffect = gContestEffects[GetMoveContestEffect(move)];
// The contest category icon is implemented as a 5x2 group of tiles.
category = GetMoveContestCategory(move);
if (category == CONTEST_CATEGORY_COOL)
categoryTile = 0x4040;
else if (category == CONTEST_CATEGORY_BEAUTY)
categoryTile = 0x4045;
else if (category == CONTEST_CATEGORY_CUTE)
categoryTile = 0x404A;
else if (category == CONTEST_CATEGORY_SMART)
categoryTile = 0x406A;
else
categoryTile = 0x408A;
categoryTile = gContestCategoryInfo[GetMoveContestCategory(move)].tile;
ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01);
ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01);
// Appeal hearts
if (gContestEffects[GetMoveContestEffect(move)].appeal == 0xFF)
if (contestEffect.appeal == 0xFF)
numHearts = 0;
else
numHearts = gContestEffects[GetMoveContestEffect(move)].appeal / 10;
numHearts = contestEffect.appeal / 10;
if (numHearts > MAX_CONTEST_MOVE_HEARTS)
numHearts = MAX_CONTEST_MOVE_HEARTS;
ContestBG_FillBoxWithTile(0, TILE_EMPTY_APPEAL_HEART, 0x15, 0x1f, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
ContestBG_FillBoxWithTile(0, TILE_FILLED_APPEAL_HEART, 0x15, 0x1f, numHearts, 0x01, 0x11);
// Jam hearts
if (gContestEffects[GetMoveContestEffect(move)].jam == 0xFF)
if (contestEffect.jam == 0xFF)
numHearts = 0;
else
numHearts = gContestEffects[GetMoveContestEffect(move)].jam / 10;
numHearts = contestEffect.jam / 10;
if (numHearts > MAX_CONTEST_MOVE_HEARTS)
numHearts = MAX_CONTEST_MOVE_HEARTS;
ContestBG_FillBoxWithTile(0, TILE_EMPTY_JAM_HEART, 0x15, 0x20, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
ContestBG_FillBoxWithTile(0, TILE_FILLED_JAM_HEART, 0x15, 0x20, numHearts, 0x01, 0x11);
FillWindowPixelBuffer(WIN_MOVE_DESCRIPTION, PIXEL_FILL(0));
Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, gContestEffects[GetMoveContestEffect(move)].description);
Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, contestEffect.description);
Contest_PrintTextToBg0WindowStd(WIN_SLASH, gText_Slash);
}
@ -5579,24 +5554,7 @@ bool8 SaveContestWinner(u8 rank)
return FALSE;
// Adjust the random painting caption depending on the category
switch (gSpecialVar_ContestCategory)
{
case CONTEST_CATEGORY_COOL:
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_COOL;
break;
case CONTEST_CATEGORY_BEAUTY:
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_BEAUTY;
break;
case CONTEST_CATEGORY_CUTE:
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_CUTE;
break;
case CONTEST_CATEGORY_SMART:
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_SMART;
break;
case CONTEST_CATEGORY_TOUGH:
captionId += NUM_PAINTING_CAPTIONS * CONTEST_CATEGORY_TOUGH;
break;
}
captionId += NUM_PAINTING_CAPTIONS * gSpecialVar_ContestCategory;
if (rank != CONTEST_SAVE_FOR_ARTIST)
{
@ -5656,20 +5614,7 @@ u8 GetContestWinnerSaveIdx(u8 rank, bool8 shift)
default:
// case CONTEST_SAVE_FOR_MUSEUM:
// case CONTEST_SAVE_FOR_ARTIST:
switch (gSpecialVar_ContestCategory)
{
case CONTEST_CATEGORY_COOL:
return CONTEST_WINNER_MUSEUM_COOL - 1;
case CONTEST_CATEGORY_BEAUTY:
return CONTEST_WINNER_MUSEUM_BEAUTY - 1;
case CONTEST_CATEGORY_CUTE:
return CONTEST_WINNER_MUSEUM_CUTE - 1;
case CONTEST_CATEGORY_SMART:
return CONTEST_WINNER_MUSEUM_SMART - 1;
case CONTEST_CATEGORY_TOUGH:
default:
return CONTEST_WINNER_MUSEUM_TOUGH - 1;
}
return MUSEUM_CONTEST_WINNERS_START + gSpecialVar_ContestCategory;
}
}
@ -6016,7 +5961,7 @@ static void ContestDebugPrintBitStrings(void)
{
for (i = 0; i < CONTESTANT_COUNT; i++)
{
txtPtr = StringCopy(text1, gText_CDot);
txtPtr = StringCopy(text1, COMPOUND_STRING("C."));
Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1, 5, 1, FONT_NARROW);
bits = gContestResources->tv[i].winnerFlags;
for (j = 7; j > -1; j--) // Weird loop.
@ -6037,7 +5982,7 @@ static void ContestDebugPrintBitStrings(void)
{
for (i = 0; i < CONTESTANT_COUNT; i++)
{
StringCopy(text1, gText_BDot);
StringCopy(text1, COMPOUND_STRING("B."));
bits = gContestResources->tv[i].loserFlags;
txtPtr = &text1[2];
for (j = 7; j > -1; j--) // Weird loop.

View File

@ -736,11 +736,6 @@ ALIGNED(4) const u8 gText_Facility[] = _("{STR_VAR_1}");
const u8 gText_Give[] = _("Give");
const u8 gText_NoNeed[] = _("No need");
const u8 gText_ColorLightShadowDarkGray[] = _("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}");
const u8 gText_ColorBlue[] = _("{COLOR BLUE}");
const u8 gText_ColorTransparent[] = _("{BACKGROUND TRANSPARENT}{ACCENT TRANSPARENT}{COLOR TRANSPARENT}");
const u8 gText_CDot[] = _("C.");
const u8 gText_BDot[] = _("B.");
const u8 gText_AnnouncingResults[] = _("Announcing the results!");
const u8 gText_PreliminaryResults[] = _("The preliminary results!");
const u8 gText_Round2Results[] = _("Round 2 results!");