2019-04-07 20:40:35 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "pokenav.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "bg.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "decompress.h"
|
2021-11-01 23:06:15 +01:00
|
|
|
#include "international_string_util.h"
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
#define GFXTAG_ARROW 10
|
|
|
|
#define PALTAG_ARROW 20
|
2020-02-05 08:47:32 +01:00
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavListMenuWindow {
|
2019-04-07 20:40:35 +02:00
|
|
|
u8 bg;
|
2021-11-13 18:52:41 +01:00
|
|
|
u8 fillValue;
|
|
|
|
u8 x;
|
|
|
|
u8 y;
|
|
|
|
u8 width;
|
2019-04-07 20:40:35 +02:00
|
|
|
u8 fontId;
|
2021-11-13 18:52:41 +01:00
|
|
|
u16 tileOffset;
|
2019-04-07 20:40:35 +02:00
|
|
|
u16 windowId;
|
|
|
|
u16 unkA;
|
2021-11-13 18:52:41 +01:00
|
|
|
u16 numPrinted;
|
|
|
|
u16 numToPrint;
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState {
|
2019-04-07 20:40:35 +02:00
|
|
|
// The index of the element at the top of the window.
|
|
|
|
u16 windowTopIndex;
|
|
|
|
u16 listLength;
|
|
|
|
u16 unk4;
|
|
|
|
// The index of the cursor, relative to the top of the window.
|
|
|
|
u16 selectedIndexOffset;
|
|
|
|
u16 visibleEntries;
|
|
|
|
u16 unkA;
|
2021-11-13 18:52:41 +01:00
|
|
|
u32 listItemSize;
|
|
|
|
void * listPtr;
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
struct PokenavSub17Substruct
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavListMenuWindow listWindow;
|
2019-04-07 20:40:35 +02:00
|
|
|
u32 unk10;
|
2021-11-13 18:52:41 +01:00
|
|
|
u32 printIndex;
|
|
|
|
u32 itemSize;
|
|
|
|
void * listPtr;
|
|
|
|
s32 startBgY;
|
|
|
|
s32 endBgY;
|
2020-10-11 00:17:34 +02:00
|
|
|
u32 loopedTaskId;
|
2021-11-13 18:52:41 +01:00
|
|
|
s32 moveDelta;
|
|
|
|
u32 bgMoveType;
|
|
|
|
PokenavListBufferItemFunc bufferItemFunc;
|
|
|
|
void (*iconDrawFunc)(u16, u32, u32);
|
2019-04-07 20:40:35 +02:00
|
|
|
struct Sprite *rightArrow;
|
|
|
|
struct Sprite *upArrow;
|
|
|
|
struct Sprite *downArrow;
|
2021-11-13 18:52:41 +01:00
|
|
|
u8 itemTextBuffer[64];
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
struct PokenavSub17
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavSub17Substruct list;
|
2021-11-13 18:52:41 +01:00
|
|
|
u8 tilemapBuffer[BG_SCREEN_SIZE];
|
|
|
|
struct PokenavListWindowState windowState;
|
2019-08-04 19:09:12 +02:00
|
|
|
s32 unk89C;
|
2020-10-11 00:17:34 +02:00
|
|
|
u32 loopedTaskId;
|
2019-04-07 20:40:35 +02:00
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void InitPokenavListBg(struct PokenavSub17 *);
|
|
|
|
static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *, const struct BgTemplate *, struct PokenavListTemplate *, s32);
|
|
|
|
static void InitPokenavListWindowState(struct PokenavListWindowState *, struct PokenavListTemplate *);
|
|
|
|
static void SpriteCB_UpArrow(struct Sprite *);
|
|
|
|
static void SpriteCB_DownArrow(struct Sprite *);
|
|
|
|
static void SpriteCB_RightArrow(struct Sprite *);
|
|
|
|
static void ToggleListArrows(struct PokenavSub17Substruct *, u32);
|
|
|
|
static void DestroyListArrows(struct PokenavSub17Substruct *);
|
|
|
|
static void CreateListArrowSprites(struct PokenavListWindowState *, struct PokenavSub17Substruct *);
|
|
|
|
static void LoadListArrowGfx(void);
|
|
|
|
static void PrintMatchCallFlavorText(struct PokenavListWindowState *, struct PokenavSub17Substruct *, u32);
|
|
|
|
static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *, u32);
|
|
|
|
static void PrintMatchCallListTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *);
|
|
|
|
static void PrintCheckPageTrainerName(struct PokenavListWindowState *, struct PokenavSub17Substruct *);
|
|
|
|
static void sub_81C8B70(struct PokenavListMenuWindow *, s32, s32);
|
|
|
|
static void CreateMoveListWindowTask(s32, struct PokenavSub17Substruct *);
|
|
|
|
static void PrintListItems(void *, u32, u32, u32, u32, struct PokenavSub17Substruct *);
|
|
|
|
static void InitListItems(struct PokenavListWindowState *, struct PokenavSub17Substruct *);
|
|
|
|
static void InitPokenavListWindow(struct PokenavListMenuWindow *);
|
|
|
|
static u32 LoopedTask_CreatePokenavList(s32);
|
|
|
|
static bool32 IsPrintListItemsTaskActive(void);
|
|
|
|
static u32 LoopedTask_PrintListItems(s32);
|
|
|
|
static u32 LoopedTask_MoveListWindow(s32);
|
|
|
|
static u32 LoopedTask_sub_81C8870(s32);
|
|
|
|
static u32 LoopedTask_sub_81C8A28(s32);
|
|
|
|
static u32 LoopedTask_PrintCheckPageInfo(s32);
|
|
|
|
|
|
|
|
static const u16 sListArrow_Pal[] = INCBIN_U16("graphics/pokenav/list_arrows.gbapal");
|
|
|
|
static const u32 sListArrow_Gfx[] = INCBIN_U32("graphics/pokenav/list_arrows.4bpp.lz");
|
|
|
|
|
|
|
|
static EWRAM_DATA u32 gUnknown_0203CF44 = 0;
|
|
|
|
|
|
|
|
bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset)
|
|
|
|
{
|
|
|
|
struct PokenavSub17 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_LIST, sizeof(struct PokenavSub17));
|
2019-04-07 20:40:35 +02:00
|
|
|
if (structPtr == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
InitPokenavListWindowState(&structPtr->windowState, listTemplate);
|
|
|
|
if (!CopyPokenavListMenuTemplate(&structPtr->list, bgTemplate, listTemplate, tileOffset))
|
2019-04-07 20:40:35 +02:00
|
|
|
return FALSE;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
CreateLoopedTask(LoopedTask_CreatePokenavList, 6);
|
2019-04-07 20:40:35 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
bool32 IsCreatePokenavListTaskActive(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
return FuncIsActiveLoopedTask(LoopedTask_CreatePokenavList);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
void DestroyPokenavList(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
DestroyListArrows(&structPtr->list);
|
2020-10-11 00:17:34 +02:00
|
|
|
RemoveWindow(structPtr->list.listWindow.windowId);
|
2021-11-13 18:52:41 +01:00
|
|
|
FreePokenavSubstruct(POKENAV_SUBSTRUCT_LIST);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static u32 LoopedTask_CreatePokenavList(s32 state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
struct PokenavSub17 *structPtr;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
2020-10-11 00:17:34 +02:00
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2019-08-04 19:09:12 +02:00
|
|
|
|
|
|
|
switch (state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
case 0:
|
2021-11-13 18:52:41 +01:00
|
|
|
InitPokenavListBg(structPtr);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 1:
|
2021-11-13 18:52:41 +01:00
|
|
|
InitPokenavListWindow(&structPtr->list.listWindow);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 2:
|
2021-11-13 18:52:41 +01:00
|
|
|
InitListItems(&structPtr->windowState, &structPtr->list);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
case 3:
|
2021-11-13 18:52:41 +01:00
|
|
|
if (IsPrintListItemsTaskActive())
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
|
|
|
return LT_PAUSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
LoadListArrowGfx();
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_CONTINUE;
|
|
|
|
}
|
|
|
|
case 4:
|
2021-11-13 18:52:41 +01:00
|
|
|
CreateListArrowSprites(&structPtr->windowState, &structPtr->list);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
|
|
|
default:
|
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void InitPokenavListBg(struct PokenavSub17 *a0)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
u16 tileNum = (a0->list.listWindow.fillValue << 12) | a0->list.listWindow.tileOffset;
|
|
|
|
BgDmaFill(a0->list.listWindow.bg, PIXEL_FILL(1), a0->list.listWindow.tileOffset, 1);
|
|
|
|
BgDmaFill(a0->list.listWindow.bg, PIXEL_FILL(4), a0->list.listWindow.tileOffset + 1, 1);
|
|
|
|
SetBgTilemapBuffer(a0->list.listWindow.bg, a0->tilemapBuffer);
|
|
|
|
FillBgTilemapBufferRect_Palette0(a0->list.listWindow.bg, tileNum, 0, 0, 32, 32);
|
|
|
|
ChangeBgY(a0->list.listWindow.bg, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(a0->list.listWindow.bg, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(a0->list.listWindow.bg, a0->list.listWindow.y << 11, BG_COORD_SUB);
|
|
|
|
CopyBgTilemapBufferToVram(a0->list.listWindow.bg);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void InitPokenavListWindow(struct PokenavListMenuWindow *listWindow)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
FillWindowPixelBuffer(listWindow->windowId, PIXEL_FILL(1));
|
|
|
|
PutWindowTilemap(listWindow->windowId);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(listWindow->windowId, COPYWIN_MAP);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavSub17Substruct *a1)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
s32 numToPrint = windowState->listLength - windowState->windowTopIndex;
|
|
|
|
if (numToPrint > windowState->visibleEntries)
|
|
|
|
numToPrint = windowState->visibleEntries;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintListItems(windowState->listPtr, windowState->windowTopIndex, numToPrint, windowState->listItemSize, 0, a1);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemSize, u32 a4, struct PokenavSub17Substruct *list)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (numItems == 0)
|
2019-04-07 20:40:35 +02:00
|
|
|
return;
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
list->listPtr = listPtr + topIndex * itemSize;
|
|
|
|
list->itemSize = itemSize;
|
|
|
|
list->listWindow.numPrinted = 0;
|
|
|
|
list->listWindow.numToPrint = numItems;
|
|
|
|
list->printIndex = topIndex;
|
2020-10-11 00:17:34 +02:00
|
|
|
list->unk10 = a4;
|
2021-11-13 18:52:41 +01:00
|
|
|
CreateLoopedTask(LoopedTask_PrintListItems, 5);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static bool32 IsPrintListItemsTaskActive(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
return FuncIsActiveLoopedTask(LoopedTask_PrintListItems);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static u32 LoopedTask_PrintListItems(s32 state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
u32 v1;
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17Substruct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
switch (state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2021-11-13 18:52:41 +01:00
|
|
|
v1 = (structPtr->listWindow.unkA + structPtr->listWindow.numPrinted + structPtr->unk10) & 0xF;
|
|
|
|
structPtr->bufferItemFunc(structPtr->listPtr, structPtr->itemTextBuffer);
|
|
|
|
if (structPtr->iconDrawFunc != NULL)
|
|
|
|
structPtr->iconDrawFunc(structPtr->listWindow.windowId, structPtr->printIndex, v1);
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
AddTextPrinterParameterized(structPtr->listWindow.windowId, structPtr->listWindow.fontId, structPtr->itemTextBuffer, 8, (v1 << 4) + 1, 255, NULL);
|
|
|
|
if (++structPtr->listWindow.numPrinted >= structPtr->listWindow.numToPrint)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
// Finished printing items. If icons were being drawn, draw the
|
|
|
|
// window tilemap and graphics. Otherwise just do the graphics
|
|
|
|
if (structPtr->iconDrawFunc != NULL)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_FULL);
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_GFX);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
structPtr->listPtr += structPtr->itemSize;
|
|
|
|
structPtr->printIndex++;
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_CONTINUE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_PAUSE;
|
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool32 ShouldShowUpArrow(void)
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
return (structPtr->windowState.windowTopIndex != 0);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool32 ShouldShowDownArrow(void)
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
struct PokenavListWindowState *subPtr = &structPtr->windowState;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
|
|
|
return (subPtr->windowTopIndex + subPtr->visibleEntries < subPtr->listLength);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void MoveListWindow(s32 delta, bool32 a1)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
struct PokenavListWindowState *subPtr = &structPtr->windowState;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
if (delta < 0)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (subPtr->windowTopIndex + delta < 0)
|
|
|
|
delta = -1 * subPtr->windowTopIndex;
|
2019-04-07 20:40:35 +02:00
|
|
|
if (a1)
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintListItems(subPtr->listPtr, subPtr->windowTopIndex + delta, delta * -1, subPtr->listItemSize, delta, &structPtr->list);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
else if (a1)
|
|
|
|
{
|
2019-04-08 02:09:53 +02:00
|
|
|
s32 temp = gUnknown_0203CF44 = subPtr->windowTopIndex + subPtr->visibleEntries;
|
2021-11-13 18:52:41 +01:00
|
|
|
if (temp + delta >= subPtr->listLength)
|
|
|
|
delta = subPtr->listLength - temp;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintListItems(subPtr->listPtr, gUnknown_0203CF44, delta, subPtr->listItemSize, subPtr->visibleEntries, &structPtr->list);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
CreateMoveListWindowTask(delta, &structPtr->list);
|
|
|
|
subPtr->windowTopIndex += delta;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void CreateMoveListWindowTask(s32 delta, struct PokenavSub17Substruct *list)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
list->startBgY = GetBgY(list->listWindow.bg);
|
|
|
|
list->endBgY = list->startBgY + (delta << 12);
|
|
|
|
if (delta > 0)
|
|
|
|
list->bgMoveType = BG_COORD_ADD;
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2021-11-13 18:52:41 +01:00
|
|
|
list->bgMoveType = BG_COORD_SUB;
|
|
|
|
list->moveDelta = delta;
|
|
|
|
list->loopedTaskId = CreateLoopedTask(LoopedTask_MoveListWindow, 6);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static u32 LoopedTask_MoveListWindow(s32 state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
s32 oldY, newY;
|
|
|
|
bool32 finished;
|
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2020-10-11 00:17:34 +02:00
|
|
|
struct PokenavSub17Substruct *subPtr = &structPtr->list;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
|
|
|
switch (state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2021-11-13 18:52:41 +01:00
|
|
|
if (!IsPrintListItemsTaskActive())
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_CONTINUE;
|
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 1:
|
2021-11-13 18:52:41 +01:00
|
|
|
finished = FALSE;
|
|
|
|
oldY = GetBgY(subPtr->listWindow.bg);
|
|
|
|
newY = ChangeBgY(subPtr->listWindow.bg, 0x1000, subPtr->bgMoveType);
|
|
|
|
if (subPtr->bgMoveType == BG_COORD_SUB)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if ((oldY > subPtr->endBgY || oldY <= subPtr->startBgY) && newY <= subPtr->endBgY)
|
|
|
|
finished = TRUE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2021-11-04 04:02:06 +01:00
|
|
|
else // BG_COORD_ADD
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if ((oldY < subPtr->endBgY || oldY >= subPtr->startBgY) && newY >= subPtr->endBgY)
|
|
|
|
finished = TRUE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
if (finished)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
subPtr->listWindow.unkA = (subPtr->listWindow.unkA + subPtr->moveDelta) & 0xF;
|
|
|
|
ChangeBgY(subPtr->listWindow.bg, subPtr->endBgY, BG_COORD_SET);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
bool32 IsMovePokenavListWindowTaskActive(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2020-10-11 00:17:34 +02:00
|
|
|
return IsLoopedTaskActive(structPtr->list.loopedTaskId);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static struct PokenavListWindowState *GetPokenavListWindowState(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
return &structPtr->windowState;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
int PokenavList_MoveCursorUp(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState *structPtr = GetPokenavListWindowState();
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (structPtr->selectedIndexOffset != 0)
|
|
|
|
{
|
|
|
|
structPtr->selectedIndexOffset--;
|
|
|
|
return 1;
|
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
if (ShouldShowUpArrow())
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
MoveListWindow(-1, TRUE);
|
2019-08-04 19:09:12 +02:00
|
|
|
return 2;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return 0;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
int PokenavList_MoveCursorDown(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState *structPtr = GetPokenavListWindowState();
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
if (structPtr->windowTopIndex + structPtr->selectedIndexOffset >= structPtr->listLength - 1)
|
|
|
|
return 0;
|
|
|
|
if (structPtr->selectedIndexOffset < structPtr->visibleEntries - 1)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
structPtr->selectedIndexOffset++;
|
|
|
|
return 1;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
if (ShouldShowDownArrow())
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
MoveListWindow(1, TRUE);
|
2019-08-04 19:09:12 +02:00
|
|
|
return 2;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return 0;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
int PokenavList_PageUp(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
s32 scroll;
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState *structPtr = GetPokenavListWindowState();
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2019-04-07 20:40:35 +02:00
|
|
|
if (ShouldShowUpArrow())
|
|
|
|
{
|
|
|
|
if (structPtr->windowTopIndex >= structPtr->visibleEntries)
|
|
|
|
scroll = structPtr->visibleEntries;
|
|
|
|
else
|
|
|
|
scroll = structPtr->windowTopIndex;
|
2021-11-13 18:52:41 +01:00
|
|
|
MoveListWindow(scroll * -1, TRUE);
|
2019-04-07 20:40:35 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else if (structPtr->selectedIndexOffset != 0)
|
|
|
|
{
|
|
|
|
structPtr->selectedIndexOffset = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return 0;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
int PokenavList_PageDown(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState *structPtr = GetPokenavListWindowState();
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (ShouldShowDownArrow())
|
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
s32 windowBottomIndex = structPtr->windowTopIndex + structPtr->visibleEntries;
|
|
|
|
s32 scroll = structPtr->unk4 - structPtr->windowTopIndex;
|
|
|
|
|
2019-04-07 20:40:35 +02:00
|
|
|
if (windowBottomIndex <= structPtr->unk4)
|
|
|
|
scroll = structPtr->visibleEntries;
|
2021-11-13 18:52:41 +01:00
|
|
|
MoveListWindow(scroll, TRUE);
|
2019-04-07 20:40:35 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
s32 cursor, lastVisibleIndex;
|
2019-04-07 20:40:35 +02:00
|
|
|
if (structPtr->listLength >= structPtr->visibleEntries)
|
|
|
|
{
|
|
|
|
cursor = structPtr->selectedIndexOffset;
|
|
|
|
lastVisibleIndex = structPtr->visibleEntries;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cursor = structPtr->selectedIndexOffset;
|
|
|
|
lastVisibleIndex = structPtr->listLength;
|
|
|
|
}
|
|
|
|
lastVisibleIndex -= 1;
|
|
|
|
if (cursor >= lastVisibleIndex)
|
|
|
|
return 0;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
|
|
|
structPtr->selectedIndexOffset = lastVisibleIndex;
|
|
|
|
return 1;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
u32 GetSelectedPokenavListIndex(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState *structPtr = GetPokenavListWindowState();
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
return structPtr->windowTopIndex + structPtr->selectedIndexOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetMatchCallListTopIndex(void)
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState *structPtr = GetPokenavListWindowState();
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2019-04-07 20:40:35 +02:00
|
|
|
return structPtr->windowTopIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81C877C(void)
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2019-04-07 20:40:35 +02:00
|
|
|
structPtr->unk89C = 0;
|
2020-10-11 00:17:34 +02:00
|
|
|
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8870, 6);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-12 23:28:06 +01:00
|
|
|
void PrintCheckPageInfo(s16 delta)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
structPtr->windowState.windowTopIndex += delta;
|
2019-04-07 20:40:35 +02:00
|
|
|
structPtr->unk89C = 0;
|
2020-10-11 00:17:34 +02:00
|
|
|
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81C87F0(void)
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2019-04-07 20:40:35 +02:00
|
|
|
structPtr->unk89C = 0;
|
2020-10-11 00:17:34 +02:00
|
|
|
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C8A28, 6);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
bool32 IsMatchCallListTaskActive(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2020-10-11 00:17:34 +02:00
|
|
|
return IsLoopedTaskActive(structPtr->loopedTaskId);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
void PokenavList_DrawCurrentItemIcon(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
struct PokenavListWindowState *subPtr = &structPtr->windowState;
|
|
|
|
structPtr->list.iconDrawFunc(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(structPtr->list.listWindow.windowId, COPYWIN_MAP);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static u32 LoopedTask_sub_81C8870(s32 state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
switch (state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2021-11-13 18:52:41 +01:00
|
|
|
ToggleListArrows(&structPtr->list, 1);
|
2019-04-07 20:40:35 +02:00
|
|
|
// fall-through
|
|
|
|
case 1:
|
2021-11-13 18:52:41 +01:00
|
|
|
if (structPtr->unk89C != structPtr->windowState.selectedIndexOffset)
|
2020-10-11 00:17:34 +02:00
|
|
|
sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, 1);
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2019-04-07 20:40:35 +02:00
|
|
|
structPtr->unk89C++;
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 2:
|
2019-08-04 19:09:12 +02:00
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (structPtr->unk89C != structPtr->windowState.visibleEntries)
|
2019-08-04 19:09:12 +02:00
|
|
|
return 6;
|
2021-11-13 18:52:41 +01:00
|
|
|
if (structPtr->windowState.selectedIndexOffset != 0)
|
|
|
|
sub_81C8B70(&structPtr->list.listWindow, structPtr->unk89C, structPtr->windowState.selectedIndexOffset);
|
2019-08-04 19:09:12 +02:00
|
|
|
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
}
|
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 3:
|
2019-08-04 19:09:12 +02:00
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (structPtr->windowState.selectedIndexOffset != 0)
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
MoveListWindow(structPtr->windowState.selectedIndexOffset, FALSE);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
}
|
|
|
|
return LT_FINISH;
|
|
|
|
}
|
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 4:
|
2021-11-13 18:52:41 +01:00
|
|
|
if (IsMovePokenavListWindowTaskActive())
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
structPtr->windowState.selectedIndexOffset = 0;
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static u32 LoopedTask_PrintCheckPageInfo(s32 state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
2019-04-07 20:40:35 +02:00
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_PAUSE;
|
|
|
|
|
|
|
|
switch (state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintCheckPageTrainerName(&structPtr->windowState, &structPtr->list);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-10-11 00:17:34 +02:00
|
|
|
PrintMatchCallFieldNames(&structPtr->list, 0);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_STRATEGY);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-10-11 00:17:34 +02:00
|
|
|
PrintMatchCallFieldNames(&structPtr->list, 1);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_POKEMON);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-10-11 00:17:34 +02:00
|
|
|
PrintMatchCallFieldNames(&structPtr->list, 2);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_INTRO_1);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintMatchCallFlavorText(&structPtr->windowState, &structPtr->list, CHECK_PAGE_INTRO_2);
|
2019-04-07 20:40:35 +02:00
|
|
|
break;
|
|
|
|
default:
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static u32 LoopedTask_sub_81C8A28(s32 state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
struct PokenavSub17 *structPtr;
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavListWindowState *windowState;
|
2019-08-04 19:09:12 +02:00
|
|
|
struct PokenavSub17Substruct *subPtr0;
|
|
|
|
s32 r5, *ptr;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_PAUSE;
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
windowState = &structPtr->windowState;
|
2020-10-11 00:17:34 +02:00
|
|
|
subPtr0 = &structPtr->list;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
switch (state)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintMatchCallListTrainerName(windowState, subPtr0);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 1:
|
2019-08-04 19:09:12 +02:00
|
|
|
ptr = &structPtr->unk89C;
|
2021-11-13 18:52:41 +01:00
|
|
|
if (++(*ptr) < structPtr->windowState.visibleEntries)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
sub_81C8B70(&subPtr0->listWindow, *ptr, 1);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
*ptr = 0;
|
2021-11-13 18:52:41 +01:00
|
|
|
if (windowState->listLength <= windowState->visibleEntries)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (windowState->windowTopIndex != 0)
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
s32 r4 = windowState->windowTopIndex;
|
2019-08-04 19:09:12 +02:00
|
|
|
r5 = -r4;
|
2020-10-11 00:17:34 +02:00
|
|
|
sub_81C8B70(&subPtr0->listWindow, r5, r4);
|
2021-11-13 18:52:41 +01:00
|
|
|
windowState->selectedIndexOffset = r4;
|
2019-08-04 19:09:12 +02:00
|
|
|
*ptr = r5;
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
}
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (windowState->windowTopIndex + windowState->visibleEntries > windowState->listLength)
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
s32 r4 = windowState->windowTopIndex + windowState->visibleEntries - windowState->listLength;
|
2019-08-04 19:09:12 +02:00
|
|
|
r5 = -r4;
|
2020-10-11 00:17:34 +02:00
|
|
|
sub_81C8B70(&subPtr0->listWindow, r5, r4);
|
2021-11-13 18:52:41 +01:00
|
|
|
windowState->selectedIndexOffset = r4;
|
2019-08-04 19:09:12 +02:00
|
|
|
*ptr = r5;
|
|
|
|
return LT_INC_AND_PAUSE;
|
|
|
|
}
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
return 9;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 2:
|
2021-11-13 18:52:41 +01:00
|
|
|
MoveListWindow(structPtr->unk89C, FALSE);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 3:
|
2021-11-13 18:52:41 +01:00
|
|
|
if (!IsMovePokenavListWindowTaskActive())
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
|
|
|
structPtr->unk89C = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 2;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 4:
|
2021-11-13 18:52:41 +01:00
|
|
|
PrintListItems(windowState->listPtr, windowState->windowTopIndex + structPtr->unk89C, 1, windowState->listItemSize, structPtr->unk89C, &structPtr->list);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_PAUSE;
|
2019-04-07 20:40:35 +02:00
|
|
|
case 5:
|
2021-11-13 18:52:41 +01:00
|
|
|
if (IsPrintListItemsTaskActive())
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_PAUSE;
|
2021-11-13 18:52:41 +01:00
|
|
|
if (++structPtr->unk89C >= windowState->listLength || structPtr->unk89C >= windowState->visibleEntries)
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_INC_AND_CONTINUE;
|
2019-04-07 20:40:35 +02:00
|
|
|
return 9;
|
|
|
|
case 6:
|
2021-11-13 18:52:41 +01:00
|
|
|
ToggleListArrows(subPtr0, 0);
|
2019-08-04 19:09:12 +02:00
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2019-08-04 19:09:12 +02:00
|
|
|
|
|
|
|
return LT_FINISH;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
u8 *tileData = (u8*)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA);
|
|
|
|
u32 v2 = listWindow->width * 64;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
a1 = (listWindow->unkA + a1) & 0xF;
|
2019-08-04 19:09:12 +02:00
|
|
|
if (a1 + a2 <= 16)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
CpuFastFill8(PIXEL_FILL(1), tileData + a1 * v2, a2 * v2);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(listWindow->windowId, COPYWIN_GFX);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
u32 v3 = 16 - a1;
|
|
|
|
u32 v4 = a2 - v3;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
CpuFastFill8(PIXEL_FILL(1), tileData + a1 * v2, v3 * v2);
|
|
|
|
CpuFastFill8(PIXEL_FILL(1), tileData, v4 * v2);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(listWindow->windowId, COPYWIN_GFX);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
for (a2--; a2 != -1; a1 = (a1 + 1) & 0xF, a2--)
|
2020-10-11 00:17:34 +02:00
|
|
|
ClearRematchPokeballIcon(listWindow->windowId, a1);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(listWindow->windowId, COPYWIN_MAP);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
void sub_81C8C64(struct PokenavListMenuWindow *listWindow, u32 a1)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
u16 var;
|
2020-10-11 00:17:34 +02:00
|
|
|
u16 *v1 = (u16*)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG));
|
2021-11-13 18:52:41 +01:00
|
|
|
v1 += ((listWindow->unkA << 6) + listWindow->x) - 1;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
|
|
|
if (a1 != 0)
|
2021-11-13 18:52:41 +01:00
|
|
|
var = (listWindow->fillValue << 12) | (listWindow->tileOffset + 1);
|
2019-04-07 20:40:35 +02:00
|
|
|
else
|
2021-11-13 18:52:41 +01:00
|
|
|
var = (listWindow->fillValue << 12) | (listWindow->tileOffset);
|
2019-08-04 19:09:12 +02:00
|
|
|
|
|
|
|
v1[0] = var;
|
|
|
|
v1[0x20] = var;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
// Print the trainer's name and title at the top of their check page
|
|
|
|
static void PrintCheckPageTrainerName(struct PokenavListWindowState *state, struct PokenavSub17Substruct *list)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-04-10 04:39:34 +02:00
|
|
|
u8 colors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_RED};
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
list->bufferItemFunc(state->listPtr + state->listItemSize * state->windowTopIndex, list->itemTextBuffer);
|
|
|
|
list->iconDrawFunc(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA);
|
|
|
|
FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.width * 8, 16);
|
|
|
|
AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SKIP_DRAW, list->itemTextBuffer);
|
2020-10-11 00:17:34 +02:00
|
|
|
sub_81C8C64(&list->listWindow, 1);
|
2021-11-13 18:52:41 +01:00
|
|
|
CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_FULL, 0, list->listWindow.unkA * 2, list->listWindow.width, 2);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
// Print the trainer's name and title for the list (to replace the check page name and title, which has a red background)
|
|
|
|
static void PrintMatchCallListTrainerName(struct PokenavListWindowState *state, struct PokenavSub17Substruct *list)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
list->bufferItemFunc(state->listPtr + state->listItemSize * state->windowTopIndex, list->itemTextBuffer);
|
|
|
|
FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.width * 8, 16);
|
|
|
|
AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->itemTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SKIP_DRAW, NULL);
|
2020-10-11 00:17:34 +02:00
|
|
|
sub_81C8C64(&list->listWindow, 0);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(list->listWindow.windowId, COPYWIN_FULL);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
const u8 *fieldNames[] = {
|
|
|
|
gText_PokenavMatchCall_Strategy,
|
|
|
|
gText_PokenavMatchCall_TrainerPokemon,
|
|
|
|
gText_PokenavMatchCall_SelfIntroduction
|
|
|
|
};
|
2019-12-05 21:33:36 +01:00
|
|
|
u8 colors[3] = {TEXT_COLOR_WHITE, TEXT_COLOR_RED, TEXT_COLOR_LIGHT_RED};
|
2020-10-11 00:17:34 +02:00
|
|
|
u32 top = (list->listWindow.unkA + 1 + (fieldId * 2)) & 0xF;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.width, 16);
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinterParameterized3(list->listWindow.windowId, FONT_NARROW, 2, (top << 4) + 1, colors, TEXT_SKIP_DRAW, fieldNames[fieldId]);
|
2021-11-13 18:52:41 +01:00
|
|
|
CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, top << 1, list->listWindow.width, 2);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void PrintMatchCallFlavorText(struct PokenavListWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-12-05 21:33:36 +01:00
|
|
|
// lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames
|
2021-08-25 00:59:32 +02:00
|
|
|
static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] =
|
2019-12-05 21:33:36 +01:00
|
|
|
{
|
2021-08-25 00:59:32 +02:00
|
|
|
[CHECK_PAGE_STRATEGY] = 2,
|
|
|
|
[CHECK_PAGE_POKEMON] = 4,
|
|
|
|
[CHECK_PAGE_INTRO_1] = 6,
|
2019-12-05 21:33:36 +01:00
|
|
|
[CHECK_PAGE_INTRO_2] = 7
|
|
|
|
};
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
u32 r6 = (list->listWindow.unkA + lineOffsets[checkPageEntry]) & 0xF;
|
2019-12-05 21:33:36 +01:00
|
|
|
const u8 *str = GetMatchCallFlavorText(a0->windowTopIndex, checkPageEntry);
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2019-08-04 19:09:12 +02:00
|
|
|
if (str != NULL)
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
FillWindowTilesByRow(list->listWindow.windowId, 1, r6 * 2, list->listWindow.width - 1, 2);
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinterParameterized(list->listWindow.windowId, FONT_NARROW, str, 2, (r6 << 4) + 1, TEXT_SKIP_DRAW, NULL);
|
2021-11-13 18:52:41 +01:00
|
|
|
CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, r6 * 2, list->listWindow.width, 2);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static const struct CompressedSpriteSheet sListArrowSpriteSheets[] =
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
.data = sListArrow_Gfx,
|
2019-08-04 19:09:12 +02:00
|
|
|
.size = 192,
|
2021-11-13 18:52:41 +01:00
|
|
|
.tag = GFXTAG_ARROW
|
2019-08-04 19:09:12 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static const struct SpritePalette sListArrowPalettes[] =
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
.data = sListArrow_Pal,
|
|
|
|
.tag = PALTAG_ARROW
|
2019-08-04 19:09:12 +02:00
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static const struct OamData sOamData_RightArrow =
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
|
|
|
.shape = SPRITE_SHAPE(8x16),
|
|
|
|
.x = 0,
|
|
|
|
.size = SPRITE_SIZE(8x16),
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.paletteNum = 0
|
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_RightArrow =
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
.tileTag = GFXTAG_ARROW,
|
|
|
|
.paletteTag = PALTAG_ARROW,
|
|
|
|
.oam = &sOamData_RightArrow,
|
2019-08-04 19:09:12 +02:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2021-11-13 18:52:41 +01:00
|
|
|
.callback = SpriteCB_RightArrow
|
2019-08-04 19:09:12 +02:00
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static const struct OamData sOamData_UpDownArrow =
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
|
|
|
.shape = SPRITE_SHAPE(16x8),
|
|
|
|
.x = 0,
|
|
|
|
.size = SPRITE_SIZE(16x8),
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.paletteNum = 0
|
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_UpDownArrow =
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
.tileTag = GFXTAG_ARROW,
|
|
|
|
.paletteTag = PALTAG_ARROW,
|
|
|
|
.oam = &sOamData_UpDownArrow,
|
2019-08-04 19:09:12 +02:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void LoadListArrowGfx(void)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
const struct CompressedSpriteSheet *ptr;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
for (i = 0, ptr = sListArrowSpriteSheets; i < ARRAY_COUNT(sListArrowSpriteSheets); ptr++, i++)
|
2019-04-07 20:40:35 +02:00
|
|
|
LoadCompressedSpriteSheet(ptr);
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
Pokenav_AllocAndLoadPalettes(sListArrowPalettes);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void CreateListArrowSprites(struct PokenavListWindowState *windowState, struct PokenavSub17Substruct *list)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2019-08-04 19:09:12 +02:00
|
|
|
u32 spriteId;
|
|
|
|
s16 x;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_RightArrow, list->listWindow.x * 8 + 3, (list->listWindow.y + 1) * 8, 7);
|
2020-10-11 00:17:34 +02:00
|
|
|
list->rightArrow = &gSprites[spriteId];
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
x = list->listWindow.x * 8 + (list->listWindow.width - 1) * 4;
|
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_UpDownArrow, x, list->listWindow.y * 8 + windowState->visibleEntries * 16, 7);
|
2020-10-11 00:17:34 +02:00
|
|
|
list->downArrow = &gSprites[spriteId];
|
|
|
|
list->downArrow->oam.tileNum += 2;
|
2021-11-13 18:52:41 +01:00
|
|
|
list->downArrow->callback = SpriteCB_DownArrow;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_UpDownArrow, x, list->listWindow.y * 8, 7);
|
2020-10-11 00:17:34 +02:00
|
|
|
list->upArrow = &gSprites[spriteId];
|
|
|
|
list->upArrow->oam.tileNum += 4;
|
2021-11-13 18:52:41 +01:00
|
|
|
list->upArrow->callback = SpriteCB_UpArrow;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void DestroyListArrows(struct PokenavSub17Substruct *list)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
DestroySprite(list->rightArrow);
|
|
|
|
DestroySprite(list->upArrow);
|
|
|
|
DestroySprite(list->downArrow);
|
2021-11-13 18:52:41 +01:00
|
|
|
FreeSpriteTilesByTag(GFXTAG_ARROW);
|
|
|
|
FreeSpritePaletteByTag(PALTAG_ARROW);
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void ToggleListArrows(struct PokenavSub17Substruct *list, bool32 invisible)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (invisible)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
list->rightArrow->callback = SpriteCallbackDummy;
|
|
|
|
list->upArrow->callback = SpriteCallbackDummy;
|
|
|
|
list->downArrow->callback = SpriteCallbackDummy;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
list->rightArrow->callback = SpriteCB_RightArrow;
|
|
|
|
list->upArrow->callback = SpriteCB_UpArrow;
|
|
|
|
list->downArrow->callback = SpriteCB_DownArrow;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
2021-11-13 18:52:41 +01:00
|
|
|
list->rightArrow->invisible = invisible;
|
|
|
|
list->upArrow->invisible = invisible;
|
|
|
|
list->downArrow->invisible = invisible;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void SpriteCB_RightArrow(struct Sprite *sprite)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
sprite->y2 = structPtr->windowState.selectedIndexOffset << 4;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
#define sTimer data[0]
|
|
|
|
#define sOffset data[1]
|
|
|
|
#define sInvisible data[7]
|
|
|
|
|
|
|
|
static void SpriteCB_DownArrow(struct Sprite *sprite)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (!sprite->sInvisible && ShouldShowDownArrow())
|
2019-04-07 20:40:35 +02:00
|
|
|
sprite->invisible = FALSE;
|
|
|
|
else
|
|
|
|
sprite->invisible = TRUE;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
if (++sprite->sTimer > 3)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
s16 offset;
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
sprite->sTimer = 0;
|
|
|
|
offset = (sprite->sOffset + 1) & 7;
|
|
|
|
sprite->sOffset = offset;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = offset;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static void SpriteCB_UpArrow(struct Sprite *sprite)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
if (!sprite->sInvisible && ShouldShowUpArrow())
|
2019-04-07 20:40:35 +02:00
|
|
|
sprite->invisible = FALSE;
|
|
|
|
else
|
|
|
|
sprite->invisible = TRUE;
|
2019-08-04 19:09:12 +02:00
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
if (++sprite->sTimer > 3)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
s16 offset;
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
sprite->sTimer = 0;
|
|
|
|
offset = (sprite->sOffset + 1) & 7;
|
|
|
|
sprite->sOffset = offset;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = -1 * offset;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
void PokenavList_ToggleVerticalArrows(bool32 invisible)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
|
|
|
|
structPtr->list.upArrow->sInvisible = invisible;
|
|
|
|
structPtr->list.downArrow->sInvisible = invisible;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
#undef sTimer
|
|
|
|
#undef sOffset
|
|
|
|
#undef sInvisible
|
|
|
|
|
|
|
|
static void InitPokenavListWindowState(struct PokenavListWindowState *dst, struct PokenavListTemplate *template)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2021-11-13 18:52:41 +01:00
|
|
|
dst->listPtr = template->list;
|
|
|
|
dst->windowTopIndex = template->startIndex;
|
2020-10-11 00:17:34 +02:00
|
|
|
dst->listLength = template->count;
|
2021-11-13 18:52:41 +01:00
|
|
|
dst->listItemSize = template->itemSize;
|
2020-10-11 00:17:34 +02:00
|
|
|
dst->visibleEntries = template->maxShowed;
|
|
|
|
if (dst->visibleEntries >= dst->listLength)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
dst->windowTopIndex = 0;
|
|
|
|
dst->unk4 = 0;
|
2021-11-13 18:52:41 +01:00
|
|
|
dst->selectedIndexOffset = template->startIndex;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
dst->unk4 = dst->listLength - dst->visibleEntries;
|
|
|
|
if (dst->windowTopIndex + dst->visibleEntries > dst->listLength)
|
2019-08-04 19:09:12 +02:00
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
dst->selectedIndexOffset = dst->windowTopIndex + dst->visibleEntries - dst->listLength;
|
2021-11-13 18:52:41 +01:00
|
|
|
dst->windowTopIndex = template->startIndex - dst->selectedIndexOffset;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-11 00:17:34 +02:00
|
|
|
dst->selectedIndexOffset = 0;
|
2019-04-07 20:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 18:52:41 +01:00
|
|
|
static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 tileOffset)
|
2019-04-07 20:40:35 +02:00
|
|
|
{
|
|
|
|
struct WindowTemplate window;
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
dest->listWindow.bg = bgTemplate->bg;
|
2021-11-13 18:52:41 +01:00
|
|
|
dest->listWindow.tileOffset = tileOffset;
|
|
|
|
dest->bufferItemFunc = template->bufferItemFunc;
|
|
|
|
dest->iconDrawFunc = template->iconDrawFunc;
|
|
|
|
dest->listWindow.fillValue = template->fillValue;
|
|
|
|
dest->listWindow.x = template->item_X;
|
|
|
|
dest->listWindow.y = template->listTop;
|
|
|
|
dest->listWindow.width = template->windowWidth;
|
2020-10-11 00:17:34 +02:00
|
|
|
dest->listWindow.fontId = template->fontId;
|
|
|
|
|
|
|
|
window.bg = bgTemplate->bg;
|
|
|
|
window.tilemapLeft = template->item_X;
|
2019-04-07 20:40:35 +02:00
|
|
|
window.tilemapTop = 0;
|
2020-10-11 00:17:34 +02:00
|
|
|
window.width = template->windowWidth;
|
2019-04-07 20:40:35 +02:00
|
|
|
window.height = 32;
|
2020-10-11 00:17:34 +02:00
|
|
|
window.paletteNum = template->fillValue;
|
2021-11-13 18:52:41 +01:00
|
|
|
window.baseBlock = tileOffset + 2;
|
2019-04-07 20:40:35 +02:00
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
dest->listWindow.windowId = AddWindow(&window);
|
2021-02-20 00:36:48 +01:00
|
|
|
if (dest->listWindow.windowId == WINDOW_NONE)
|
2019-08-04 19:09:12 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2020-10-11 00:17:34 +02:00
|
|
|
dest->listWindow.unkA = 0;
|
|
|
|
dest->rightArrow = NULL;
|
|
|
|
dest->upArrow = NULL;
|
|
|
|
dest->downArrow = NULL;
|
2019-08-04 19:09:12 +02:00
|
|
|
return 1;
|
2019-05-14 16:49:07 +02:00
|
|
|
}
|