Skip to content

Commit

Permalink
Move Relearner now displays move category (#5081)
Browse files Browse the repository at this point in the history
* Move relearner now displays move category

* Update move_relearner.c

* Update move_relearner.c

* Address reviews
  • Loading branch information
kittenchilly authored Aug 6, 2024
1 parent db3bb40 commit e4f09c8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
#define B_FAST_HP_DRAIN TRUE // If set to TRUE, HP bars will move faster.
#define B_FAST_EXP_GROW TRUE // If set to TRUE, EXP bars will move faster.
#define B_SHOW_TARGETS TRUE // If set to TRUE, all available targets, for moves hitting 2 or 3 Pokémon, will be shown before selecting a move.
#define B_SHOW_CATEGORY_ICON TRUE // If set to TRUE, it will show an icon in the summary showing the move's category.
#define B_SHOW_CATEGORY_ICON TRUE // If set to TRUE, it will show an icon in the summary and move relearner showing the move's category.
#define B_HIDE_HEALTHBOX_IN_ANIMS TRUE // If set to TRUE, hides healthboxes during move animations.
#define B_EXPANDED_MOVE_NAMES TRUE // If set to FALSE, move names are decreased from 16 characters to 12 characters.
#define B_WAIT_TIME_MULTIPLIER 16 // This determines how long text pauses in battle last. Vanilla is 16. Lower values result in faster battles.
Expand Down
1 change: 1 addition & 0 deletions include/move_relearner.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

void TeachMoveRelearnerMove(void);
void MoveRelearnerShowHideHearts(s32);
void MoveRelearnerShowHideCategoryIcon(s32);

#endif //GUARD_MOVE_RELEARNER_H
3 changes: 3 additions & 0 deletions src/menu_specialized.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
u8 buffer[32];
const u8 *str;

if (B_SHOW_CATEGORY_ICON == TRUE)
MoveRelearnerShowHideCategoryIcon(chosenMove);

FillWindowPixelBuffer(RELEARNERWIN_DESC_BATTLE, PIXEL_FILL(1));
str = gText_MoveRelearnerBattleMoves;
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 128);
Expand Down
30 changes: 30 additions & 0 deletions src/move_relearner.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "global.h"
#include "main.h"
#include "battle.h"
#include "battle_util.h"
#include "bg.h"
#include "contest_effect.h"
#include "data.h"
#include "decompress.h"
#include "event_data.h"
#include "field_screen_effect.h"
#include "gpu_regs.h"
Expand Down Expand Up @@ -173,6 +175,7 @@ static EWRAM_DATA struct
u8 moveListScrollArrowTask; /*0x113*/
u8 moveDisplayArrowTask; /*0x114*/
u16 scrollOffset; /*0x116*/
u8 categoryIconSpriteId; /*0x117*/
} *sMoveRelearnerStruct = {0};

static EWRAM_DATA struct {
Expand Down Expand Up @@ -803,6 +806,9 @@ static void HandleInput(bool8 showContest)

ScheduleBgCopyTilemapToVram(1);
MoveRelearnerShowHideHearts(GetCurrentSelectedMove());
if (B_SHOW_CATEGORY_ICON == TRUE)
MoveRelearnerShowHideCategoryIcon(GetCurrentSelectedMove());

break;
case LIST_CANCEL:
PlaySE(SE_SELECT);
Expand Down Expand Up @@ -851,6 +857,10 @@ static void CreateUISprites(void)
sMoveRelearnerStruct->moveListScrollArrowTask = TASK_NONE;
AddScrollArrows();

sMoveRelearnerStruct->categoryIconSpriteId = 0xFF;
LoadCompressedSpriteSheet(&gSpriteSheet_CategoryIcons);
LoadSpritePalette(&gSpritePal_CategoryIcons);

// These are the appeal hearts.
for (i = 0; i < 8; i++)
sMoveRelearnerStruct->heartSpriteIds[i] = CreateSprite(&sConstestMoveHeartSprite, (i - (i / 4) * 4) * 8 + 104, (i / 4) * 8 + 36, 0);
Expand Down Expand Up @@ -957,3 +967,23 @@ void MoveRelearnerShowHideHearts(s32 moveId)
}
}
}

void MoveRelearnerShowHideCategoryIcon(s32 moveId)
{
if (sMoveRelearnerMenuSate.showContestInfo || moveId == LIST_CANCEL)
{
if (sMoveRelearnerStruct->categoryIconSpriteId != 0xFF)
DestroySprite(&gSprites[sMoveRelearnerStruct->categoryIconSpriteId]);

sMoveRelearnerStruct->categoryIconSpriteId = 0xFF;
gSprites[sMoveRelearnerStruct->categoryIconSpriteId].invisible = TRUE;
}
else
{
if (sMoveRelearnerStruct->categoryIconSpriteId == 0xFF)
sMoveRelearnerStruct->categoryIconSpriteId = CreateSprite(&gSpriteTemplate_CategoryIcons, 66, 40, 0);

gSprites[sMoveRelearnerStruct->categoryIconSpriteId].invisible = FALSE;
StartSpriteAnim(&gSprites[sMoveRelearnerStruct->categoryIconSpriteId], GetBattleMoveCategory(moveId));
}
}

0 comments on commit e4f09c8

Please sign in to comment.