Skip to content

Commit

Permalink
Add Stat Viewer to Player PC
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseurae committed Oct 16, 2024
1 parent 071c333 commit d9acec2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions scripts/stats_viewer.asm
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
.string "A device which lets\nyou see your\nPOKeMON's stats."
.endautoregion

.org 0x84062F0
.halfword ITEM_STATS_VIEWER

.endif
12 changes: 8 additions & 4 deletions src/stats_viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static void StatsViewer_PrintPokemonInfo(void)
ptr = StringCopy(ptr, gSpeciesNames[species]);
*(ptr++) = EXT_CTRL_CODE_BEGIN;
*(ptr++) = EXT_CTRL_CODE_CLEAR_TO;
*(ptr++) = POKEMON_NAME_LENGTH * 6;
*(ptr++) = (POKEMON_NAME_LENGTH + 1) * 6;
*(ptr++) = EOS;

Menu_PrintText(gStringVar4, 1, 3);
Expand Down Expand Up @@ -241,7 +241,7 @@ static void StatsViewer_PrintPokemonInfo(void)
}
else
{
Menu_BlankWindowRect(1, 3, 6, 6);
Menu_BlankWindowRect(1, 3, 10, 6);
StatsViewer_PrintPokemonEmpty(20);
StatsViewer_PrintPokemonEmpty(24);
StatsViewer_PrintPokemonEmpty(28);
Expand Down Expand Up @@ -358,20 +358,24 @@ static void Task_StatsViewer_Close(u8 taskId)

static void Task_StatsViewer_HandleInput(u8 taskId)
{
u8 lastSelectedMon = sStatsViewer.selectedMon;

if (gPaletteFade.active)
return;
if (gMain.newKeys & DPAD_DOWN)
{
sStatsViewer.selectedMon =
(sStatsViewer.selectedMon + 1) > (gPlayerPartyCount - 1) ? 0 : sStatsViewer.selectedMon + 1;
StatsViewer_ChangePokemon(taskId);
if (sStatsViewer.selectedMon != lastSelectedMon)
StatsViewer_ChangePokemon(taskId);
PlaySE(SE_SELECT);
}
else if (gMain.newKeys & DPAD_UP)
{
sStatsViewer.selectedMon =
(sStatsViewer.selectedMon - 1) < 0 ? (gPlayerPartyCount - 1) : sStatsViewer.selectedMon - 1;
StatsViewer_ChangePokemon(taskId);
if (sStatsViewer.selectedMon != lastSelectedMon)
StatsViewer_ChangePokemon(taskId);
PlaySE(SE_SELECT);
}
else if (gMain.newKeys & B_BUTTON)
Expand Down

0 comments on commit d9acec2

Please sign in to comment.