pokeemerald/src/pokenav_conditions.c

631 lines
21 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"
2021-11-12 17:13:49 +01:00
#define CONDITION_MONS_LOADED 3
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu
2019-07-25 18:56:08 +02:00
{
2021-11-12 17:13:49 +01:00
u32 monPal[CONDITION_MONS_LOADED][0x20];
2019-07-25 18:56:08 +02:00
u8 fill[0x180];
2021-11-12 17:13:49 +01:00
u32 monPicGfx[CONDITION_MONS_LOADED][MON_PIC_SIZE];
2021-11-11 22:50:36 +01:00
bool8 inSearchMode;
s16 toLoadListIndex;
u32 (*callback)(struct Pokenav_ConditionMenu *);
u8 fill2[0x18];
2021-11-12 17:13:49 +01:00
u8 locationText[CONDITION_MONS_LOADED][24];
u8 nameText[CONDITION_MONS_LOADED][64];
2021-11-11 00:52:30 +01:00
struct ConditionGraph graph;
2021-11-12 17:13:49 +01:00
u8 numSparkles[CONDITION_MONS_LOADED];
u8 monMarks[CONDITION_MONS_LOADED];
2021-11-11 22:50:36 +01:00
s8 loadId;
s8 nextLoadIdDown;
s8 nextLoadIdUp;
s8 toLoadId;
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);
2021-11-11 22:50:36 +01:00
static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *);
static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *);
static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *);
static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *);
2021-11-10 02:02:12 +01:00
static u8 SwitchConditionSummaryIndex(bool8);
static void CopyMonNameGenderLocation(s16, u8);
static void GetMonConditionGraphData(s16, u8);
static void ConditionGraphDrawMonPic(s16, u8);
2021-11-11 22:50:36 +01:00
bool32 PokenavCallback_Init_ConditionGraph_Party(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu));
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
if (menu == NULL)
2019-07-25 18:56:08 +02:00
return FALSE;
2021-11-11 22:50:36 +01:00
ConditionGraph_Init(&menu->graph);
2020-10-11 00:17:34 +02:00
InitPartyConditionListParameters();
2019-07-25 18:56:08 +02:00
gKeyRepeatStartDelay = 20;
2021-11-11 22:50:36 +01:00
menu->callback = HandleConditionMenuInput;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2021-11-11 22:50:36 +01:00
bool32 PokenavCallback_Init_ConditionGraph_Search(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU, sizeof(struct Pokenav_ConditionMenu));
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
if (menu == NULL)
2019-07-25 18:56:08 +02:00
return FALSE;
2021-11-11 22:50:36 +01:00
ConditionGraph_Init(&menu->graph);
2021-11-10 02:02:12 +01:00
InitSearchResultsConditionList();
2019-07-25 18:56:08 +02:00
gKeyRepeatStartDelay = 20;
2021-11-11 22:50:36 +01:00
menu->callback = HandleConditionMenuInput;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2021-11-11 22:50:36 +01:00
u32 GetConditionGraphMenuCallback(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
return menu->callback(menu);
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
static u32 HandleConditionMenuInput(struct Pokenav_ConditionMenu *menu)
2019-07-25 18:56:08 +02:00
{
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2021-11-11 22:50:36 +01:00
u32 ret = ConditionGraphHandleDpadInput(menu);
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
if (ret == 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);
2021-11-11 22:50:36 +01:00
menu->callback = GetConditionReturnCallback;
ret = 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
{
2021-11-11 22:50:36 +01:00
if (!menu->inSearchMode)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
// In Party mode, pressing A only applies to the Cancel button
2020-10-11 00:17:34 +02:00
if (monListPtr->currIndex == monListPtr->listCount - 1)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
// Cancel
2019-07-25 18:56:08 +02:00
PlaySE(SE_SELECT);
2021-11-11 22:50:36 +01:00
menu->callback = GetConditionReturnCallback;
ret = CONDITION_FUNC_RETURN;
2019-07-25 18:56:08 +02:00
}
}
else
{
2021-11-11 22:50:36 +01:00
// In Search mode pressing A brings up the markings menu
2019-07-25 18:56:08 +02:00
PlaySE(SE_SELECT);
2021-11-11 22:50:36 +01:00
ret = CONDITION_FUNC_ADD_MARKINGS;
menu->callback = OpenMarkingsMenu;
2019-07-25 18:56:08 +02:00
}
}
}
return ret;
}
2021-11-11 22:50:36 +01:00
static u32 OpenMarkingsMenu(struct Pokenav_ConditionMenu *menu)
2019-07-25 18:56:08 +02:00
{
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr;
2019-07-25 18:56:08 +02:00
u8 markings;
2021-11-11 22:50:36 +01:00
u32 ret = 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
{
2021-11-11 22:50:36 +01:00
menu->monMarks[menu->loadId] = GetMonMarkingsData();
2020-10-11 00:17:34 +02:00
monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[monListPtr->currIndex].boxId;
monId = monListPtr->monData[monListPtr->currIndex].monId;
2021-11-11 22:50:36 +01:00
markings = menu->monMarks[menu->loadId];
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);
2021-11-11 22:50:36 +01:00
menu->callback = HandleConditionMenuInput;
ret = CONDITION_FUNC_CLOSE_MARKINGS;
2019-07-25 18:56:08 +02:00
}
return ret;
}
2021-11-11 22:50:36 +01:00
static u32 GetConditionReturnCallback(struct Pokenav_ConditionMenu *menu)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
if (!menu->inSearchMode)
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
}
2021-11-11 22:50:36 +01:00
void FreeConditionGraphMenuSubstruct1(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (!menu->inSearchMode)
2020-10-11 00:17:34 +02:00
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
static u8 ConditionGraphHandleDpadInput(struct Pokenav_ConditionMenu *menu)
2019-07-25 18:56:08 +02:00
{
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2021-11-11 22:50:36 +01:00
u8 ret = CONDITION_FUNC_NONE;
2019-07-25 18:56:08 +02:00
2020-09-05 03:11:55 +02:00
if (JOY_HELD(DPAD_UP))
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
// Prevent input wrapping in search mode
if (!menu->inSearchMode || 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
{
2021-11-11 22:50:36 +01:00
// Prevent input wrapping in search mode
if (!menu->inSearchMode || 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
{
2021-11-11 22:50:36 +01:00
u16 newLoadId;
2020-10-11 00:17:34 +02:00
bool8 wasNotLastMon, isNotLastMon;
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2020-10-11 00:17:34 +02:00
2021-11-11 22:50:36 +01:00
newLoadId = (moveUp) ? menu->nextLoadIdUp : menu->nextLoadIdDown;
ConditionGraph_SetNewPositions(&menu->graph, menu->graph.savedPositions[menu->loadId], menu->graph.savedPositions[newLoadId]);
wasNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1));
2020-10-11 00:17:34 +02:00
if (moveUp)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
menu->nextLoadIdUp = menu->nextLoadIdDown;
menu->nextLoadIdDown = menu->loadId;
menu->loadId = newLoadId;
menu->toLoadId = menu->nextLoadIdUp;
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
monListPtr->currIndex = (monListPtr->currIndex == 0) ? monListPtr->listCount - 1 : monListPtr->currIndex - 1;
2021-11-11 22:50:36 +01:00
menu->toLoadListIndex = (monListPtr->currIndex != 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1;
2019-07-25 18:56:08 +02:00
}
else
{
2021-11-11 22:50:36 +01:00
menu->nextLoadIdDown = menu->nextLoadIdUp;
menu->nextLoadIdUp = menu->loadId;
menu->loadId = newLoadId;
menu->toLoadId = menu->nextLoadIdDown;
2019-07-25 18:56:08 +02:00
2020-10-11 00:17:34 +02:00
monListPtr->currIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
2021-11-11 22:50:36 +01:00
menu->toLoadListIndex = (monListPtr->currIndex < monListPtr->listCount - 1) ? monListPtr->currIndex + 1 : 0;
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
isNotLastMon = (monListPtr->currIndex != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1));
2020-10-11 00:17:34 +02:00
if (!wasNotLastMon)
2021-11-11 22:50:36 +01:00
return CONDITION_FUNC_NO_TRANSITION;
2020-10-11 00:17:34 +02:00
else if (!isNotLastMon)
2021-11-11 22:50:36 +01:00
return CONDITION_FUNC_SLIDE_MON_OUT;
2019-07-25 18:56:08 +02:00
else
2021-11-11 22:50:36 +01:00
return CONDITION_FUNC_SLIDE_MON_IN;
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
bool32 LoadConditionGraphMenuGfx(void)
2019-07-25 18:56:08 +02:00
{
s32 var;
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
switch (menu->state)
2019-07-25 18:56:08 +02:00
{
case 0:
2021-11-12 17:13:49 +01:00
CopyMonNameGenderLocation(monListPtr->currIndex, 0);
2019-07-25 18:56:08 +02:00
break;
case 1:
2021-11-12 17:13:49 +01:00
GetMonConditionGraphData(monListPtr->currIndex, 0);
2019-07-25 18:56:08 +02:00
break;
case 2:
2021-11-12 17:13:49 +01:00
ConditionGraphDrawMonPic(monListPtr->currIndex, 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-12 17:13:49 +01:00
menu->loadId = 0;
menu->nextLoadIdDown = 0;
menu->nextLoadIdUp = 0;
2021-11-11 22:50:36 +01:00
menu->state = 0;
2019-07-25 18:56:08 +02:00
return TRUE;
}
else
{
2021-11-12 17:13:49 +01:00
menu->loadId = 0;
menu->nextLoadIdDown = 1;
menu->nextLoadIdUp = 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-12 17:13:49 +01:00
CopyMonNameGenderLocation(var, 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-12 17:13:49 +01:00
GetMonConditionGraphData(var, 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-12 17:13:49 +01:00
ConditionGraphDrawMonPic(var, 1);
2019-07-25 18:56:08 +02:00
break;
case 7:
2021-11-12 17:13:49 +01:00
CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
2019-07-25 18:56:08 +02:00
break;
case 8:
2021-11-12 17:13:49 +01:00
GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
2019-07-25 18:56:08 +02:00
break;
case 9:
2021-11-12 17:13:49 +01:00
ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2);
2021-11-11 22:50:36 +01:00
menu->state = 0;
2019-07-25 18:56:08 +02:00
return TRUE;
}
2021-11-11 22:50:36 +01:00
menu->state++;
2019-07-25 18:56:08 +02:00
return FALSE;
}
2021-11-11 22:50:36 +01:00
bool32 LoadNextConditionMenuMonData(u8 mode)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
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
{
2021-11-11 22:50:36 +01:00
case CONDITION_LOAD_MON_INFO:
CopyMonNameGenderLocation(menu->toLoadListIndex, menu->toLoadId);
2019-07-25 18:56:08 +02:00
break;
2021-11-11 22:50:36 +01:00
case CONDITION_LOAD_GRAPH:
GetMonConditionGraphData(menu->toLoadListIndex, menu->toLoadId);
2019-07-25 18:56:08 +02:00
break;
2021-11-11 22:50:36 +01:00
case CONDITION_LOAD_MON_PIC:
ConditionGraphDrawMonPic(menu->toLoadListIndex, menu->toLoadId);
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_;
2021-11-13 02:24:14 +01:00
struct PokenavMonList *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);
StringGet_Nickname(str);
2019-07-25 18:56:08 +02:00
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;
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
if (listId != (IsConditionMenuSearchMode() ? monListPtr->listCount : monListPtr->listCount - 1))
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
CopyConditionMonNameGender(menu->nameText[loadId], listId, FALSE);
2021-11-10 02:02:12 +01:00
boxId = monListPtr->monData[listId].boxId;
2021-11-11 22:50:36 +01:00
menu->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN;
menu->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
menu->locationText[loadId][2] = TEXT_COLOR_BLUE;
menu->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT;
menu->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE;
2019-07-25 18:56:08 +02:00
if (boxId == TOTAL_BOXES_COUNT)
2021-11-11 22:50:36 +01:00
CopyStringLeftAlignedToConditionData(&menu->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH);
2019-07-25 18:56:08 +02:00
else
2021-11-11 22:50:36 +01:00
CopyStringLeftAlignedToConditionData(&menu->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-11 22:50:36 +01:00
menu->nameText[loadId][i] = CHAR_SPACE;
menu->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++)
2021-11-11 22:50:36 +01:00
menu->locationText[loadId][i] = CHAR_SPACE;
menu->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;
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavMonList));
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
menu->inSearchMode = FALSE;
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;
2021-11-11 22:50:36 +01:00
menu->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
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
menu->inSearchMode = TRUE;
menu->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;
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
if (listId != (IsConditionMenuSearchMode() ? 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;
2021-11-11 22:50:36 +01:00
menu->graph.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
menu->graph.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
menu->graph.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
menu->graph.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
menu->graph.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
menu->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL));
menu->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
ConditionGraph_CalcPositions(menu->graph.conditions[loadId], menu->graph.savedPositions[loadId]);
2019-07-25 18:56:08 +02:00
}
else
{
2021-11-11 22:50:36 +01:00
// Set empty graph point
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-11 22:50:36 +01:00
menu->graph.conditions[loadId][i] = 0;
menu->graph.savedPositions[loadId][i].x = CONDITION_GRAPH_CENTER_X;
menu->graph.savedPositions[loadId][i].y = CONDITION_GRAPH_CENTER_Y;
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;
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2019-07-25 18:56:08 +02:00
2021-11-11 22:50:36 +01:00
if (listId == (IsConditionMenuSearchMode() ? 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-11 22:50:36 +01:00
LoadSpecialPokePic(&gMonFrontPicTable[species], menu->monPicGfx[loadId], species, personality, TRUE);
LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), menu->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
{
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2020-10-11 00:17:34 +02:00
return monListPtr->listCount;
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
u16 GetConditionGraphCurrentListIndex(void)
2019-07-25 18:56:08 +02:00
{
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2020-10-11 00:17:34 +02:00
return monListPtr->currIndex;
2019-07-25 18:56:08 +02:00
}
2021-11-11 00:52:30 +01:00
struct ConditionGraph *GetConditionGraphPtr(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return &menu->graph;
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
u8 GetConditionGraphMenuCurrentLoadIndex(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->loadId;
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
u8 GetConditionGraphMenuToLoadListIndex(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->toLoadListIndex;
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
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->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
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->monPal[loadId];
2019-07-25 18:56:08 +02:00
}
2021-11-11 22:50:36 +01:00
u8 GetConditionGraphMenuToLoadId(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->toLoadId;
2019-07-25 18:56:08 +02:00
}
2021-11-10 02:02:12 +01:00
u8 *GetConditionMonNameText(u8 loadId)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->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
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->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
{
2021-11-13 02:24:14 +01:00
struct PokenavMonList *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
2020-10-11 00:17:34 +02:00
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
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (menu->inSearchMode == TRUE)
2019-07-25 18:56:08 +02:00
return TRUE;
else
return FALSE;
}
2021-11-11 22:50:36 +01:00
// Markings are only shown in search mode
2020-10-11 00:17:34 +02:00
u8 TryGetMonMarkId(void)
2019-07-25 18:56:08 +02:00
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
if (menu->inSearchMode == TRUE)
return menu->monMarks[menu->loadId];
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
{
2021-11-11 22:50:36 +01:00
struct Pokenav_ConditionMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH_MENU);
return menu->numSparkles[menu->loadId];
2019-07-25 18:56:08 +02:00
}