Fix a display issue with B_SHOW_TYPES (#5201)

* Moved HandleInputChooseTarget and ShowEntireFieldTargets to non-static and added them as cases to ShouldHideTypeIcon

* Made ShouldHideTypeIcon easier to parse

* Made ShouldHideTypeIcon a for loop

* Fixed identation

* Made showTypesControllerFuncs a static const array per https://github.com/rh-hideout/pokeemerald-expansion/pull/5201\#discussion_r1730336265
This commit is contained in:
psf 2024-08-26 12:16:56 -07:00 committed by GitHub
parent 03e0472cbe
commit b6299ac4ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 9 deletions

View file

@ -313,6 +313,8 @@ void MoveSelectionDestroyCursorAt(u8 cursorPosition);
void PlayerHandleChooseMove(u32 battler);
void HandleInputChooseMove(u32 battler);
void HandleInputChooseTarget(u32 battler);
void HandleInputShowEntireFieldTargets(u32 battler);
void HandleInputShowTargets(u32 battler);
void HandleMoveSwitching(u32 battler);
void HandleChooseMoveAfterDma3(u32 battler);

View file

@ -593,7 +593,7 @@ static void HideShownTargets(u32 battler)
}
}
static void HandleInputShowEntireFieldTargets(u32 battler)
void HandleInputShowEntireFieldTargets(u32 battler)
{
if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
gPlayerDpadHoldFrames++;
@ -621,7 +621,7 @@ static void HandleInputShowEntireFieldTargets(u32 battler)
}
}
static void HandleInputShowTargets(u32 battler)
void HandleInputShowTargets(u32 battler)
{
if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
gPlayerDpadHoldFrames++;

View file

@ -471,15 +471,27 @@ static void FreeAllTypeIconResources(void)
}
}
static void (* const sShowTypesControllerFuncs[])(u32 battler) =
{
PlayerHandleChooseMove,
HandleChooseMoveAfterDma3,
HandleInputChooseTarget,
HandleInputShowTargets,
HandleInputShowEntireFieldTargets,
HandleMoveSwitching,
HandleInputChooseMove,
};
static bool32 ShouldHideTypeIcon(u32 battlerId)
{
return gBattlerControllerFuncs[battlerId] != PlayerHandleChooseMove
&& gBattlerControllerFuncs[battlerId] != HandleInputChooseMove
&& gBattlerControllerFuncs[battlerId] != HandleChooseMoveAfterDma3
&& gBattlerControllerFuncs[battlerId] != HandleInputChooseMove
&& gBattlerControllerFuncs[battlerId] != HandleInputChooseTarget
&& gBattlerControllerFuncs[battlerId] != HandleMoveSwitching
&& gBattlerControllerFuncs[battlerId] != HandleInputChooseMove;
u32 funcIndex;
for (funcIndex = 0; funcIndex < ARRAY_COUNT(sShowTypesControllerFuncs); funcIndex++)
if (gBattlerControllerFuncs[battlerId] == sShowTypesControllerFuncs[funcIndex])
return FALSE;
return TRUE;
}
static s32 GetTypeIconHideMovement(bool32 useDoubleBattleCoords, u32 position)