pokeemerald/src/pokenav_conditions_1.c

622 lines
20 KiB
C
Raw Normal View History

2019-07-25 18:56:08 +02:00
#include "global.h"
#include "data.h"
#include "decompress.h"
#include "main.h"
#include "menu_specialized.h"
#include "mon_markings.h"
#include "pokenav.h"
#include "pokemon.h"
#include "pokemon_storage_system.h"
#include "sound.h"
#include "string_util.h"
#include "strings.h"
#include "text.h"
#include "constants/songs.h"
struct PokenavSub11
{
2021-11-10 02:02:12 +01:00
u32 monPal[NUM_CONDITION_MONS][0x20];
2019-07-25 18:56:08 +02:00
u8 fill[0x180];
2021-11-10 02:02:12 +01:00
u32 monPicGfx[NUM_CONDITION_MONS][MON_PIC_SIZE];
2020-10-11 00:17:34 +02:00
u8 searchMode;
s16 monIndex;
u32 (*callback)(struct PokenavSub11 *);
2019-07-25 18:56:08 +02:00
u8 fill2[0x6320 - 0x6308];
2021-11-10 02:02:12 +01:00
u8 locationText[NUM_CONDITION_MONS][24];
u8 nameText[NUM_CONDITION_MONS][64];
2020-10-11 00:17:34 +02:00
struct ConditionGraph conditionData;
2021-11-10 02:02:12 +01:00
u8 numSparkles[NUM_CONDITION_MONS];
u8 monMarks[NUM_CONDITION_MONS];
2020-10-11 00:17:34 +02:00
s8 mark;
2019-07-25 18:56:08 +02:00
s8 unk6787;
s8 unk6788;
s8 unk6789;
2020-10-11 00:17:34 +02:00
u8 state;
2019-07-25 18:56:08 +02:00
};
2021-11-10 02:02:12 +01:00
static void InitPartyConditionListParameters(void);
static void InitSearchResultsConditionList(void);
static u32 HandlePartyConditionInput(struct PokenavSub11 *);
static u32 GetConditionReturnCallback(struct PokenavSub11 *);
static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *);
static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *);
static u8 SwitchConditionSummaryIndex(bool8);
static void CopyMonNameGenderLocation(s16, u8);
static void GetMonConditionGraphData(s16, u8);
static void ConditionGraphDrawMonPic(s16, u8);
2020-10-11 00:17:34 +02:00
bool32 PokenavCallback_Init_PartyCondition(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11));
2019-07-25 18:56:08 +02:00
if (structPtr == NULL)
return FALSE;
2021-11-10 02:02:12 +01:00
ConditionGraph_Init(&structPtr->conditionData);
2020-10-11 00:17:34 +02:00
InitPartyConditionListParameters();
2019-07-25 18:56:08 +02:00
gKeyRepeatStartDelay = 20;
2020-10-11 00:17:34 +02:00
structPtr->callback = HandlePartyConditionInput;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2020-10-11 00:17:34 +02:00
bool32 PokenavCallback_Init_ConditionGraphFromSearch(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11));
2019-07-25 18:56:08 +02:00
if (structPtr == NULL)
return FALSE;
2021-11-10 02:02:12 +01:00
ConditionGraph_Init(&structPtr->conditionData);
InitSearchResultsConditionList();
2019-07-25 18:56:08 +02:00
gKeyRepeatStartDelay = 20;
2020-10-11 00:17:34 +02:00
structPtr->callback = HandlePartyConditionInput;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2020-10-11 00:17:34 +02:00
u32 GetPartyConditionCallback(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
return structPtr->callback(structPtr);
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
static u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u32 ret = ConditionGraphHandleDpadInput(structPtr);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
if (ret == PARTY_CONDITION_FUNC_NONE)
2019-07-25 18:56:08 +02:00
{
2020-09-05 03:11:55 +02:00
if (JOY_NEW(B_BUTTON))
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
structPtr->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN;
2019-07-25 18:56:08 +02:00
}
2020-09-05 03:11:55 +02:00
else if (JOY_NEW(A_BUTTON))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (monListPtr->currIndex == monListPtr->listCount - 1)
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
structPtr->callback = GetConditionReturnCallback;
ret = PARTY_CONDITION_FUNC_RETURN;
2019-07-25 18:56:08 +02:00
}
}
else
{
PlaySE(SE_SELECT);
2020-10-11 00:17:34 +02:00
ret = PARTY_CONDITION_FUNC_ADD_MARKINGS;
structPtr->callback = ConditionMenu_OpenMarkingsMenu;
2019-07-25 18:56:08 +02:00
}
}
}
return ret;
}
2021-11-10 02:02:12 +01:00
static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr;
2019-07-25 18:56:08 +02:00
u8 markings;
2020-10-11 00:17:34 +02:00
u32 ret = PARTY_CONDITION_FUNC_NONE, boxId, monId;
2019-07-25 18:56:08 +02:00
2021-02-28 23:22:26 +01:00
if (!HandleMonMarkingsMenuInput())
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
structPtr->monMarks[structPtr->mark] = GetMonMarkingsData();
monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[monListPtr->currIndex].boxId;
monId = monListPtr->monData[monListPtr->currIndex].monId;
markings = structPtr->monMarks[structPtr->mark];
2019-07-25 18:56:08 +02:00
if (boxId == TOTAL_BOXES_COUNT)
SetMonData(&gPlayerParty[monId], MON_DATA_MARKINGS, &markings);
else
SetBoxMonDataAt(boxId, monId, MON_DATA_MARKINGS, &markings);
2020-10-11 00:17:34 +02:00
structPtr->callback = HandlePartyConditionInput;
ret = PARTY_CONDITION_FUNC_CLOSE_MARKINGS;
2019-07-25 18:56:08 +02:00
}
return ret;
}
2021-11-10 02:02:12 +01:00
static u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0)
2020-02-05 08:47:32 +01:00
return POKENAV_CONDITION_MENU;
2019-07-25 18:56:08 +02:00
else
2020-10-11 00:17:34 +02:00
return POKENAV_RETURN_CONDITION_SEARCH;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
void FreePartyConditionSubstruct1(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 0)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
u8 ret = 0;
2020-09-05 03:11:55 +02:00
if (JOY_HELD(DPAD_UP))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0 || monListPtr->currIndex != 0)
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2021-11-10 02:02:12 +01:00
ret = SwitchConditionSummaryIndex(TRUE);
2019-07-25 18:56:08 +02:00
}
}
2020-09-05 03:11:55 +02:00
else if (JOY_HELD(DPAD_DOWN))
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1)
2019-07-25 18:56:08 +02:00
{
PlaySE(SE_SELECT);
2021-11-10 02:02:12 +01:00
ret = SwitchConditionSummaryIndex(FALSE);
2019-07-25 18:56:08 +02:00
}
}
return ret;
}
2021-11-10 02:02:12 +01:00
static u8 SwitchConditionSummaryIndex(u8 moveUp)
2019-07-25 18:56:08 +02:00
{
u16 r7;
2020-10-11 00:17:34 +02:00
bool8 wasNotLastMon, isNotLastMon;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
r7 = (moveUp) ? structPtr->unk6788 : structPtr->unk6787;
sub_81D1F84(&structPtr->conditionData, structPtr->conditionData.unk14[structPtr->mark], structPtr->conditionData.unk14[r7]);
wasNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
if (moveUp)
2019-07-25 18:56:08 +02:00
{
structPtr->unk6788 = structPtr->unk6787;
2020-10-11 00:17:34 +02:00
structPtr->unk6787 = structPtr->mark;
structPtr->mark = r7;
2019-07-25 18:56:08 +02:00
structPtr->unk6789 = structPtr->unk6788;
2020-10-11 00:17:34 +02:00
monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1;
structPtr->monIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1;
2019-07-25 18:56:08 +02:00
}
else
{
structPtr->unk6787 = structPtr->unk6788;
2020-10-11 00:17:34 +02:00
structPtr->unk6788 = structPtr->mark;
structPtr->mark = r7;
2019-07-25 18:56:08 +02:00
structPtr->unk6789 = structPtr->unk6787;
2020-10-11 00:17:34 +02:00
monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
structPtr->monIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
isNotLastMon = (monListPtr->currIndex != ((IsConditionMenuSearchMode() != 0) ? monListPtr->listCount : monListPtr->listCount - 1));
2020-10-11 00:17:34 +02:00
if (!wasNotLastMon)
return PARTY_CONDITION_FUNC_NO_TRANSITION;
else if (!isNotLastMon)
return PARTY_CONDITION_FUNC_SLIDE_MON_OUT;
2019-07-25 18:56:08 +02:00
else
2020-10-11 00:17:34 +02:00
return PARTY_CONDITION_FUNC_SLIDE_MON_IN;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
bool32 LoadPartyConditionMenuGfx(void)
2019-07-25 18:56:08 +02:00
{
s32 var;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
switch (structPtr->state)
2019-07-25 18:56:08 +02:00
{
case 0:
2021-11-10 02:02:12 +01:00
CopyMonNameGenderLocation(monListPtr->currIndex, CONDITION_MON_0);
2019-07-25 18:56:08 +02:00
break;
case 1:
2021-11-10 02:02:12 +01:00
GetMonConditionGraphData(monListPtr->currIndex, CONDITION_MON_0);
2019-07-25 18:56:08 +02:00
break;
case 2:
2021-11-10 02:02:12 +01:00
ConditionGraphDrawMonPic(monListPtr->currIndex, CONDITION_MON_0);
2019-07-25 18:56:08 +02:00
break;
case 3:
2020-10-11 00:17:34 +02:00
if (monListPtr->listCount == 1)
2019-07-25 18:56:08 +02:00
{
2021-11-10 02:02:12 +01:00
structPtr->mark = CONDITION_MON_0;
structPtr->unk6787 = CONDITION_MON_0;
structPtr->unk6788 = CONDITION_MON_0;
2020-10-11 00:17:34 +02:00
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
return TRUE;
}
else
{
2021-11-10 02:02:12 +01:00
structPtr->mark = CONDITION_MON_0;
structPtr->unk6787 = CONDITION_MON_1;
structPtr->unk6788 = CONDITION_MON_2;
2019-07-25 18:56:08 +02:00
}
break;
// These were probably ternaries just like cases 7-9, but couldn't match it any other way.
case 4:
2020-10-11 00:17:34 +02:00
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
2019-07-25 18:56:08 +02:00
var = 0;
2021-11-10 02:02:12 +01:00
CopyMonNameGenderLocation(var, CONDITION_MON_1);
2019-07-25 18:56:08 +02:00
break;
case 5:
2020-10-11 00:17:34 +02:00
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
2019-07-25 18:56:08 +02:00
var = 0;
2021-11-10 02:02:12 +01:00
GetMonConditionGraphData(var, CONDITION_MON_1);
2019-07-25 18:56:08 +02:00
break;
case 6:
2020-10-11 00:17:34 +02:00
var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount)
2019-07-25 18:56:08 +02:00
var = 0;
2021-11-10 02:02:12 +01:00
ConditionGraphDrawMonPic(var, CONDITION_MON_1);
2019-07-25 18:56:08 +02:00
break;
case 7:
2021-11-10 02:02:12 +01:00
CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2);
2019-07-25 18:56:08 +02:00
break;
case 8:
2021-11-10 02:02:12 +01:00
GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2);
2019-07-25 18:56:08 +02:00
break;
case 9:
2021-11-10 02:02:12 +01:00
ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2);
2020-10-11 00:17:34 +02:00
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2020-10-11 00:17:34 +02:00
structPtr->state++;
2019-07-25 18:56:08 +02:00
return FALSE;
}
2020-10-11 00:17:34 +02:00
bool32 SetConditionGraphData(u8 mode)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
switch (mode)
2019-07-25 18:56:08 +02:00
{
case 0:
2020-10-11 00:17:34 +02:00
CopyMonNameGenderLocation(structPtr->monIndex, structPtr->unk6789);
2019-07-25 18:56:08 +02:00
break;
case 1:
2020-10-11 00:17:34 +02:00
GetMonConditionGraphData(structPtr->monIndex, structPtr->unk6789);
2019-07-25 18:56:08 +02:00
break;
case 2:
2020-10-11 00:17:34 +02:00
ConditionGraphDrawMonPic(structPtr->monIndex, structPtr->unk6789);
2019-07-25 18:56:08 +02:00
return TRUE;
}
return FALSE;
}
2020-10-11 00:17:34 +02:00
u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n)
2019-07-25 18:56:08 +02:00
{
while (*src != EOS)
*dst++ = *src++, n--;
while (n-- > 0)
*dst++ = CHAR_SPACE;
*dst = EOS;
return dst;
}
2021-11-10 02:02:12 +01:00
static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3)
2019-07-25 18:56:08 +02:00
{
u16 boxId, monId, gender, species, level, lvlDigits;
struct BoxPokemon *boxMon;
u8 *txtPtr, *str_;
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-10 02:02:12 +01:00
boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[listId].monId;
2019-07-25 18:56:08 +02:00
*(str++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str++) = TEXT_COLOR_BLUE;
*(str++) = TEXT_COLOR_TRANSPARENT;
*(str++) = TEXT_COLOR_LIGHT_BLUE;
2019-07-25 18:56:08 +02:00
if (GetBoxOrPartyMonData(boxId, monId, MON_DATA_IS_EGG, NULL))
return StringCopyPadded(str, gText_EggNickname, CHAR_SPACE, 12);
GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, str);
StringGetEnd10(str);
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL);
if (boxId == TOTAL_BOXES_COUNT)
{
level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
gender = GetMonGender(&gPlayerParty[monId]);
}
else
{
boxMon = GetBoxedMonPtr(boxId, monId);
gender = GetBoxMonGender(boxMon);
level = GetLevelFromBoxMonExp(boxMon);
}
if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(str, gSpeciesNames[species]))
gender = MON_GENDERLESS;
str_ = str; // For some reason, a variable is needed to match.
while (*str_ != EOS)
2019-08-05 21:49:05 +02:00
(str_++);
2019-07-25 18:56:08 +02:00
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_SKIP;
*(str_++) = 60;
2019-07-25 18:56:08 +02:00
switch (gender)
{
default:
2021-10-17 23:51:35 +02:00
*(str_++) = CHAR_SPACER; // Genderless
2019-07-25 18:56:08 +02:00
break;
case MON_MALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
2020-08-11 05:50:49 +02:00
*(str_++) = TEXT_COLOR_RED;
2019-07-25 18:56:08 +02:00
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_RED;
2019-07-25 18:56:08 +02:00
*(str_++) = CHAR_MALE;
break;
case MON_FEMALE:
*(str_++) = EXT_CTRL_CODE_BEGIN;
*(str_++) = EXT_CTRL_CODE_COLOR;
2020-08-11 05:50:49 +02:00
*(str_++) = TEXT_COLOR_GREEN;
2019-07-25 18:56:08 +02:00
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_SHADOW;
*(str_++) = TEXT_COLOR_LIGHT_GREEN;
2019-07-25 18:56:08 +02:00
*(str_++) = CHAR_FEMALE;
break;
}
*(str_++) = EXT_CTRL_CODE_BEGIN;
2020-08-11 05:50:49 +02:00
*(str_++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str_++) = TEXT_COLOR_BLUE;
*(str_++) = TEXT_COLOR_TRANSPARENT;
*(str_++) = TEXT_COLOR_LIGHT_BLUE;
2019-07-25 18:56:08 +02:00
*(str_++) = CHAR_SLASH;
2020-08-11 05:50:49 +02:00
*(str_++) = CHAR_EXTRA_SYMBOL;
2020-02-01 06:25:50 +01:00
*(str_++) = CHAR_LV_2;
2019-07-25 18:56:08 +02:00
txtPtr = str_;
str_ = ConvertIntToDecimalStringN(str_, level, STR_CONV_MODE_LEFT_ALIGN, 3);
lvlDigits = str_ - txtPtr;
*(str_++) = CHAR_SPACE;
if (!arg3)
{
lvlDigits = 3 - lvlDigits;
while (lvlDigits-- != 0)
*(str_++) = CHAR_SPACE;
}
*str_ = EOS;
return str_;
}
2021-11-10 02:02:12 +01:00
static void CopyMonNameGenderLocation(s16 listId, u8 loadId)
2019-07-25 18:56:08 +02:00
{
u16 boxId, i;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-10 02:02:12 +01:00
if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
2019-07-25 18:56:08 +02:00
{
2021-11-10 02:02:12 +01:00
CopyConditionMonNameGender(structPtr->nameText[loadId], listId, FALSE);
boxId = monListPtr->monData[listId].boxId;
structPtr->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN;
structPtr->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
structPtr->locationText[loadId][2] = TEXT_COLOR_BLUE;
structPtr->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT;
structPtr->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE;
2019-07-25 18:56:08 +02:00
if (boxId == TOTAL_BOXES_COUNT)
2021-11-10 02:02:12 +01:00
CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH);
2019-07-25 18:56:08 +02:00
else
2021-11-10 02:02:12 +01:00
CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH);
2019-07-25 18:56:08 +02:00
}
else
{
for (i = 0; i < 12; i++)
2021-11-10 02:02:12 +01:00
structPtr->nameText[loadId][i] = CHAR_SPACE;
structPtr->nameText[loadId][i] = EOS;
2019-07-25 18:56:08 +02:00
2021-11-10 02:02:12 +01:00
for (i = 0; i < BOX_NAME_LENGTH; i++)
structPtr->locationText[loadId][i] = CHAR_SPACE;
structPtr->locationText[loadId][i] = EOS;
2019-07-25 18:56:08 +02:00
}
}
2021-11-10 02:02:12 +01:00
static void InitPartyConditionListParameters(void)
2019-07-25 18:56:08 +02:00
{
u16 i, count;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
structPtr->searchMode = 0;
2019-07-25 18:56:08 +02:00
for (i = 0, count = 0; i < CalculatePlayerPartyCount(); i++)
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
{
2020-10-11 00:17:34 +02:00
monListPtr->monData[count].boxId = TOTAL_BOXES_COUNT;
monListPtr->monData[count].monId = i;
monListPtr->monData[count].data = 0;
2019-07-25 18:56:08 +02:00
count++;
}
}
2020-10-11 00:17:34 +02:00
monListPtr->monData[count].boxId = 0;
monListPtr->monData[count].monId = 0;
monListPtr->monData[count].data = 0;
monListPtr->currIndex = 0;
monListPtr->listCount = count + 1;
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
static void InitSearchResultsConditionList(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
structPtr->searchMode = 1;
structPtr->state = 0;
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
static void GetMonConditionGraphData(s16 listId, u8 loadId)
2019-07-25 18:56:08 +02:00
{
u16 boxId, monId, i;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-10 02:02:12 +01:00
if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
2019-07-25 18:56:08 +02:00
{
2021-11-10 02:02:12 +01:00
boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[listId].monId;
structPtr->conditionData.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
structPtr->conditionData.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
structPtr->conditionData.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
structPtr->conditionData.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
structPtr->conditionData.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
structPtr->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL));
structPtr->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
sub_81D2754(structPtr->conditionData.conditions[loadId], structPtr->conditionData.unk14[loadId]);
2019-07-25 18:56:08 +02:00
}
else
{
2021-11-10 02:02:12 +01:00
for (i = 0; i < CONDITION_COUNT; i++)
2019-07-25 18:56:08 +02:00
{
2021-11-10 02:02:12 +01:00
structPtr->conditionData.conditions[loadId][i] = 0;
structPtr->conditionData.unk14[loadId][i].unk0 = CONDITION_GRAPH_CENTER_X;
structPtr->conditionData.unk14[loadId][i].unk2 = CONDITION_GRAPH_UNK;
2019-07-25 18:56:08 +02:00
}
}
}
2021-11-10 02:02:12 +01:00
static void ConditionGraphDrawMonPic(s16 listId, u8 loadId)
2019-07-25 18:56:08 +02:00
{
u16 boxId, monId, species;
u32 personality, tid;
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-10 02:02:12 +01:00
if (listId == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
2019-07-25 18:56:08 +02:00
return;
2021-11-10 02:02:12 +01:00
boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[listId].monId;
2019-07-25 18:56:08 +02:00
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL);
tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL);
personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL);
2021-11-10 02:02:12 +01:00
LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[loadId], species, personality, TRUE);
LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[loadId]);
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u16 GetMonListCount(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->listCount;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u16 GetConditionGraphCurrentMonIndex(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->currIndex;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
struct ConditionGraph *GetConditionGraphDataPtr(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return &structPtr->conditionData;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u8 GetMonMarkIndex(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->mark;
2019-07-25 18:56:08 +02:00
}
u8 sub_81CDC9C(void)
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->monIndex;
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
void *GetConditionMonPicGfx(u8 loadId)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2021-11-10 02:02:12 +01:00
return structPtr->monPicGfx[loadId];
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
void *GetConditionMonPal(u8 loadId)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2021-11-10 02:02:12 +01:00
return structPtr->monPal[loadId];
2019-07-25 18:56:08 +02:00
}
u8 sub_81CDCEC(void)
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2019-07-25 18:56:08 +02:00
return structPtr->unk6789;
}
2021-11-10 02:02:12 +01:00
u8 *GetConditionMonNameText(u8 loadId)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2021-11-10 02:02:12 +01:00
return structPtr->nameText[loadId];
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
u8 *GetConditionMonLocationText(u8 loadId)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2021-11-10 02:02:12 +01:00
return structPtr->locationText[loadId];
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
u16 GetConditionMonDataBuffer(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
return monListPtr->monData[monListPtr->currIndex].data;
2019-07-25 18:56:08 +02:00
}
2020-10-11 00:17:34 +02:00
bool32 IsConditionMenuSearchMode(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 1)
2019-07-25 18:56:08 +02:00
return TRUE;
else
return FALSE;
}
2020-10-11 00:17:34 +02:00
u8 TryGetMonMarkId(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
if (structPtr->searchMode == 1)
return structPtr->monMarks[structPtr->mark];
2019-07-25 18:56:08 +02:00
else
return 0;
}
2021-11-10 02:02:12 +01:00
u8 GetNumConditionMonSparkles(void)
2019-07-25 18:56:08 +02:00
{
2020-10-11 00:17:34 +02:00
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
2021-11-10 02:02:12 +01:00
return structPtr->numSparkles[structPtr->mark];
2019-07-25 18:56:08 +02:00
}