Skip to content

Commit

Permalink
Adds configable nature colors (#3582)
Browse files Browse the repository at this point in the history
* Colored stats depending on nature

* Fix bug

* Update colors and add config

---------

Co-authored-by: DizzyEggg <[email protected]>
  • Loading branch information
AsparagusEduardo and DizzyEggg committed Nov 20, 2023
2 parents 341bbb3 + 59a7d2c commit 13a65a2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
5 changes: 3 additions & 2 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
#define GEN_LATEST GEN_9

// General settings
#define EXPANSION_INTRO TRUE // If TRUE, a custom RHH intro will play after the vanilla copyright screen.
#define POKEDEX_PLUS_HGSS FALSE // If TRUE, enables the custom HGSS style Pokedex.
#define EXPANSION_INTRO TRUE // If TRUE, a custom RHH intro will play after the vanilla copyright screen.
#define POKEDEX_PLUS_HGSS FALSE // If TRUE, enables the custom HGSS style Pokedex.
#define SUMMARY_SCREEN_NATURE_COLORS TRUE // If TRUE, nature-based stat boosts and reductions will be red and blue in the summary screen.

#endif // GUARD_CONFIG_H
50 changes: 31 additions & 19 deletions src/pokemon_summary_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3471,23 +3471,37 @@ static void PrintRibbonCount(void)
PrintTextOnWindow(AddWindowFromTemplateList(sPageSkillsTemplate, PSS_DATA_WINDOW_SKILLS_RIBBON_COUNT), text, x, 1, 0, 0);
}

static void BufferLeftColumnStats(void)
static void BufferStat(u8 *dst, s8 natureMod, u32 stat, u32 strId, u32 n)
{
u8 *currentHPString = Alloc(8);
u8 *maxHPString = Alloc(8);
u8 *attackString = Alloc(8);
u8 *defenseString = Alloc(8);
static const u8 sTextNatureDown[] = _("{COLOR}{08}");
static const u8 sTextNatureUp[] = _("{COLOR}{05}");
static const u8 sTextNatureNeutral[] = _("{COLOR}{01}");
u8 *txtPtr;

if (natureMod == 0 || !SUMMARY_SCREEN_NATURE_COLORS)
txtPtr = StringCopy(dst, sTextNatureNeutral);
else if (natureMod > 0)
txtPtr = StringCopy(dst, sTextNatureUp);
else
txtPtr = StringCopy(dst, sTextNatureDown);

ConvertIntToDecimalStringN(currentHPString, sMonSummaryScreen->summary.currentHP, STR_CONV_MODE_RIGHT_ALIGN, 3);
ConvertIntToDecimalStringN(maxHPString, sMonSummaryScreen->summary.maxHP, STR_CONV_MODE_RIGHT_ALIGN, 3);
ConvertIntToDecimalStringN(attackString, sMonSummaryScreen->summary.atk, STR_CONV_MODE_RIGHT_ALIGN, 7);
ConvertIntToDecimalStringN(defenseString, sMonSummaryScreen->summary.def, STR_CONV_MODE_RIGHT_ALIGN, 7);
ConvertIntToDecimalStringN(txtPtr, stat, STR_CONV_MODE_RIGHT_ALIGN, n);
DynamicPlaceholderTextUtil_SetPlaceholderPtr(strId, dst);
}

static void BufferLeftColumnStats(void)
{
u8 *currentHPString = Alloc(20);
u8 *maxHPString = Alloc(20);
u8 *attackString = Alloc(20);
u8 *defenseString = Alloc(20);
const s8 *natureMod = gNatureStatTable[sMonSummaryScreen->summary.nature];

DynamicPlaceholderTextUtil_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, currentHPString);
DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, maxHPString);
DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, attackString);
DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, defenseString);
BufferStat(currentHPString, 0, sMonSummaryScreen->summary.currentHP, 0, 3);
BufferStat(maxHPString, 0, sMonSummaryScreen->summary.maxHP, 1, 3);
BufferStat(attackString, natureMod[STAT_ATK - 1], sMonSummaryScreen->summary.atk, 2, 7);
BufferStat(defenseString, natureMod[STAT_DEF - 1], sMonSummaryScreen->summary.def, 3, 7);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sStatsLeftColumnLayout);

Free(currentHPString);
Expand All @@ -3503,14 +3517,12 @@ static void PrintLeftColumnStats(void)

static void BufferRightColumnStats(void)
{
ConvertIntToDecimalStringN(gStringVar1, sMonSummaryScreen->summary.spatk, STR_CONV_MODE_RIGHT_ALIGN, 3);
ConvertIntToDecimalStringN(gStringVar2, sMonSummaryScreen->summary.spdef, STR_CONV_MODE_RIGHT_ALIGN, 3);
ConvertIntToDecimalStringN(gStringVar3, sMonSummaryScreen->summary.speed, STR_CONV_MODE_RIGHT_ALIGN, 3);
const s8 *natureMod = gNatureStatTable[sMonSummaryScreen->summary.nature];

DynamicPlaceholderTextUtil_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gStringVar2);
DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, gStringVar3);
BufferStat(gStringVar1, natureMod[STAT_SPATK - 1], sMonSummaryScreen->summary.spatk, 0, 3);
BufferStat(gStringVar2, natureMod[STAT_SPDEF - 1], sMonSummaryScreen->summary.spdef, 1, 3);
BufferStat(gStringVar3, natureMod[STAT_SPEED - 1], sMonSummaryScreen->summary.speed, 2, 3);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sStatsRightColumnLayout);
}

Expand Down

0 comments on commit 13a65a2

Please sign in to comment.