Skip to content

Commit

Permalink
Showing IVs/EVs in Summary Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
laserXdolphin committed Jul 1, 2024
1 parent 9dc2780 commit 9487c3e
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions src/pokemon_summary_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ static void DestroyMoveSelectorSprites(u8);
static void SetMainMoveSelectorColor(u8);
static void KeepMoveSelectorVisible(u8);
static void SummaryScreen_DestroyAnimDelayTask(void);
static void BufferIvOrEvStats(u8 mode);

static const struct BgTemplate sBgTemplates[] =
{
Expand Down Expand Up @@ -731,6 +732,7 @@ static void (*const sTextPrinterTasks[])(u8 taskId) =
static const u8 sMemoNatureTextColor[] = _("{COLOR LIGHT_RED}{SHADOW GREEN}");
static const u8 sMemoMiscTextColor[] = _("{COLOR WHITE}{SHADOW DARK_GRAY}"); // This is also affected by palettes, apparently
static const u8 sStatsLeftColumnLayout[] = _("{DYNAMIC 0}/{DYNAMIC 1}\n{DYNAMIC 2}\n{DYNAMIC 3}");
static const u8 sStatsLeftColumnLayoutIVEV[] = _("{DYNAMIC 0}\n{DYNAMIC 1}\n{DYNAMIC 2}");
static const u8 sStatsRightColumnLayout[] = _("{DYNAMIC 0}\n{DYNAMIC 1}\n{DYNAMIC 2}");
static const u8 sMovesPPLayout[] = _("{PP}{DYNAMIC 0}/{DYNAMIC 1}");

Expand Down Expand Up @@ -1633,6 +1635,28 @@ static void Task_HandleInput(u8 taskId)
PlaySE(SE_SELECT);
BeginCloseSummaryScreen(taskId);
}
// show IVs/EVs/stats on button presses
else if (JOY_NEW(R_BUTTON))
{
if (sMonSummaryScreen->currPageIndex == PSS_PAGE_SKILLS)
{
BufferIvOrEvStats(0);
}
}
else if (JOY_NEW(L_BUTTON))
{
if (sMonSummaryScreen->currPageIndex == PSS_PAGE_SKILLS)
{
BufferIvOrEvStats(1);
}
}
else if (JOY_NEW(START_BUTTON))
{
if (sMonSummaryScreen->currPageIndex == PSS_PAGE_SKILLS)
{
BufferIvOrEvStats(2);
}
}
#if DEBUG_POKEMON_MENU == TRUE
else if (JOY_NEW(SELECT_BUTTON) && !gMain.inBattle)
{
Expand Down Expand Up @@ -3475,6 +3499,84 @@ static void BufferStat(u8 *dst, s8 natureMod, u32 stat, u32 strId, u32 n)
DynamicPlaceholderTextUtil_SetPlaceholderPtr(strId, dst);
}

static void BufferIvOrEvStats(u8 mode)
{
u16 hp, hp2, atk, def, spA, spD, spe;
u8 *currHPString = Alloc(20);
const s8 *natureMod = gNatureStatTable[sMonSummaryScreen->summary.nature];

switch (mode)
{
case 0: // iv mode
hp = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_HP_IV);
atk = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_ATK_IV);
def = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_DEF_IV);

spA = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_SPATK_IV);
spD = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_SPDEF_IV);
spe = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_SPEED_IV);
break;
case 1: // ev mode
hp = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_HP_EV);
atk = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_ATK_EV);
def = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_DEF_EV);

spA = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_SPATK_EV);
spD = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_SPDEF_EV);
spe = GetMonData(&sMonSummaryScreen->currentMon, MON_DATA_SPEED_EV);
break;
case 2: // stats mode
default:
hp = sMonSummaryScreen->summary.currentHP;
hp2 = sMonSummaryScreen->summary.maxHP;
atk = sMonSummaryScreen->summary.atk;
def = sMonSummaryScreen->summary.def;

spA = sMonSummaryScreen->summary.spatk;
spD = sMonSummaryScreen->summary.spdef;
spe = sMonSummaryScreen->summary.speed;
break;
}

FillWindowPixelBuffer(sMonSummaryScreen->windowIds[PSS_DATA_WINDOW_SKILLS_STATS_LEFT], 0);
FillWindowPixelBuffer(sMonSummaryScreen->windowIds[PSS_DATA_WINDOW_SKILLS_STATS_RIGHT], 0);

switch (mode)
{
case 0:
case 1:
BufferStat(gStringVar1, 0, hp, 0, 7);
BufferStat(gStringVar2, 0, atk, 1, 7);
BufferStat(gStringVar3, 0, def, 2, 7);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sStatsLeftColumnLayoutIVEV);
PrintLeftColumnStats();

BufferStat(gStringVar1, 0, spA, 0, 3);
BufferStat(gStringVar2, 0, spD, 1, 3);
BufferStat(gStringVar3, 0, spe, 2, 3);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sStatsRightColumnLayout);
PrintRightColumnStats();
break;
case 2:
default:
BufferStat(currHPString, 0, hp, 0, 3);
BufferStat(gStringVar1, 0, hp2, 1, 3);
BufferStat(gStringVar2, natureMod[STAT_ATK - 1], atk, 2, 7);
BufferStat(gStringVar3, natureMod[STAT_DEF - 1], def, 3, 7);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sStatsLeftColumnLayout);
PrintLeftColumnStats();

BufferStat(gStringVar1, natureMod[STAT_SPATK - 1], spA, 0, 3);
BufferStat(gStringVar2, natureMod[STAT_SPDEF - 1], spD, 1, 3);
BufferStat(gStringVar3, natureMod[STAT_SPEED - 1], spe, 2, 3);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sStatsRightColumnLayout);
PrintRightColumnStats();
break;
}

Free(currHPString);
}

static void BufferLeftColumnStats(void)
{
u8 *currentHPString = Alloc(20);
Expand Down

0 comments on commit 9487c3e

Please sign in to comment.