pokeemerald/src/pokenav_list.c

1012 lines
32 KiB
C
Raw Normal View History

#include "global.h"
#include "pokenav.h"
#include "window.h"
#include "strings.h"
#include "text.h"
#include "bg.h"
#include "menu.h"
#include "decompress.h"
#include "international_string_util.h"
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 {
u8 bg;
2021-11-13 18:52:41 +01:00
u8 fillValue;
u8 x;
u8 y;
u8 width;
u8 fontId;
2021-11-13 18:52:41 +01:00
u16 tileOffset;
u16 windowId;
u16 unkA;
2021-11-13 18:52:41 +01:00
u16 numPrinted;
u16 numToPrint;
};
2021-11-13 18:52:41 +01:00
struct PokenavListWindowState {
// The index of the element at the top of the window.
u16 windowTopIndex;
u16 listLength;
2021-11-15 04:21:50 +01:00
u16 entriesOffscreen;
// The index of the cursor, relative to the top of the window.
u16 selectedIndexOffset;
2021-11-15 04:21:50 +01:00
u16 entriesOnscreen;
2021-11-13 18:52:41 +01:00
u32 listItemSize;
void * listPtr;
};
2021-11-15 06:21:40 +01:00
struct PokenavListSub
{
2020-10-11 00:17:34 +02:00
struct PokenavListMenuWindow listWindow;
2022-06-01 18:41:57 +02:00
u32 printStart;
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);
struct Sprite *rightArrow;
struct Sprite *upArrow;
struct Sprite *downArrow;
2021-11-13 18:52:41 +01:00
u8 itemTextBuffer[64];
};
2021-11-15 06:21:40 +01:00
struct PokenavList
{
2022-06-01 18:41:57 +02:00
struct PokenavListSub sub;
2021-11-13 18:52:41 +01:00
u8 tilemapBuffer[BG_SCREEN_SIZE];
struct PokenavListWindowState windowState;
2021-11-15 04:21:50 +01:00
s32 eraseIndex;
2020-10-11 00:17:34 +02:00
u32 loopedTaskId;
};
2021-11-15 06:21:40 +01:00
static void InitPokenavListBg(struct PokenavList *);
static bool32 CopyPokenavListMenuTemplate(struct PokenavListSub *, const struct BgTemplate *, struct PokenavListTemplate *, s32);
2021-11-13 18:52:41 +01:00
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 *);
2022-07-25 20:59:14 +02:00
static void ToggleListArrows(struct PokenavListSub *, bool32);
2021-11-15 06:21:40 +01:00
static void DestroyListArrows(struct PokenavListSub *);
static void CreateListArrowSprites(struct PokenavListWindowState *, struct PokenavListSub *);
2021-11-13 18:52:41 +01:00
static void LoadListArrowGfx(void);
2021-11-15 06:21:40 +01:00
static void PrintMatchCallFlavorText(struct PokenavListWindowState *, struct PokenavListSub *, u32);
static void PrintMatchCallFieldNames(struct PokenavListSub *, u32);
static void PrintMatchCallListTrainerName(struct PokenavListWindowState *, struct PokenavListSub *);
static void PrintCheckPageTrainerName(struct PokenavListWindowState *, struct PokenavListSub *);
2021-11-15 04:21:50 +01:00
static void EraseListEntry(struct PokenavListMenuWindow *, s32, s32);
2021-11-15 06:21:40 +01:00
static void CreateMoveListWindowTask(s32, struct PokenavListSub *);
static void PrintListItems(void *, u32, u32, u32, u32, struct PokenavListSub *);
static void InitListItems(struct PokenavListWindowState *, struct PokenavListSub *);
2021-11-13 18:52:41 +01:00
static void InitPokenavListWindow(struct PokenavListMenuWindow *);
static u32 LoopedTask_CreatePokenavList(s32);
static bool32 IsPrintListItemsTaskActive(void);
static u32 LoopedTask_PrintListItems(s32);
static u32 LoopedTask_MoveListWindow(s32);
2021-11-15 04:21:50 +01:00
static u32 LoopedTask_EraseListForCheckPage(s32);
static u32 LoopedTask_ReshowListFromCheckPage(s32);
2021-11-13 18:52:41 +01:00
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");
2021-11-15 04:21:50 +01:00
static EWRAM_DATA u32 sMoveWindowDownIndex = 0; // Read, but pointlessly
2021-11-13 18:52:41 +01:00
bool32 CreatePokenavList(const struct BgTemplate *bgTemplate, struct PokenavListTemplate *listTemplate, s32 tileOffset)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = AllocSubstruct(POKENAV_SUBSTRUCT_LIST, sizeof(struct PokenavList));
if (list == NULL)
return FALSE;
2022-06-01 18:41:57 +02:00
InitPokenavListWindowState(&list->windowState, listTemplate);
if (!CopyPokenavListMenuTemplate(&list->sub, bgTemplate, listTemplate, tileOffset))
return FALSE;
2021-11-13 18:52:41 +01:00
CreateLoopedTask(LoopedTask_CreatePokenavList, 6);
return TRUE;
}
2021-11-13 18:52:41 +01:00
bool32 IsCreatePokenavListTaskActive(void)
{
2021-11-13 18:52:41 +01:00
return FuncIsActiveLoopedTask(LoopedTask_CreatePokenavList);
}
2021-11-13 18:52:41 +01:00
void DestroyPokenavList(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
DestroyListArrows(&list->sub);
RemoveWindow(list->sub.listWindow.windowId);
2021-11-13 18:52:41 +01:00
FreePokenavSubstruct(POKENAV_SUBSTRUCT_LIST);
}
2021-11-13 18:52:41 +01:00
static u32 LoopedTask_CreatePokenavList(s32 state)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list;
if (IsDma3ManagerBusyWithBgCopy())
2020-10-11 00:17:34 +02:00
return LT_PAUSE;
2022-06-01 18:41:57 +02:00
list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
switch (state)
{
case 0:
2022-06-01 18:41:57 +02:00
InitPokenavListBg(list);
return LT_INC_AND_PAUSE;
case 1:
2022-06-01 18:41:57 +02:00
InitPokenavListWindow(&list->sub.listWindow);
return LT_INC_AND_PAUSE;
case 2:
2022-06-01 18:41:57 +02:00
InitListItems(&list->windowState, &list->sub);
return LT_INC_AND_PAUSE;
case 3:
2021-11-13 18:52:41 +01:00
if (IsPrintListItemsTaskActive())
{
return LT_PAUSE;
}
else
{
2021-11-13 18:52:41 +01:00
LoadListArrowGfx();
return LT_INC_AND_CONTINUE;
}
case 4:
2022-06-01 18:41:57 +02:00
CreateListArrowSprites(&list->windowState, &list->sub);
return LT_FINISH;
default:
return LT_FINISH;
}
}
2022-06-01 18:41:57 +02:00
static void InitPokenavListBg(struct PokenavList *list)
{
2022-06-01 18:41:57 +02:00
u16 tileNum = (list->sub.listWindow.fillValue << 12) | list->sub.listWindow.tileOffset;
BgDmaFill(list->sub.listWindow.bg, PIXEL_FILL(1), list->sub.listWindow.tileOffset, 1);
BgDmaFill(list->sub.listWindow.bg, PIXEL_FILL(4), list->sub.listWindow.tileOffset + 1, 1);
SetBgTilemapBuffer(list->sub.listWindow.bg, list->tilemapBuffer);
FillBgTilemapBufferRect_Palette0(list->sub.listWindow.bg, tileNum, 0, 0, 32, 32);
ChangeBgY(list->sub.listWindow.bg, 0, BG_COORD_SET);
ChangeBgX(list->sub.listWindow.bg, 0, BG_COORD_SET);
ChangeBgY(list->sub.listWindow.bg, list->sub.listWindow.y << 11, BG_COORD_SUB);
CopyBgTilemapBufferToVram(list->sub.listWindow.bg);
}
2021-11-13 18:52:41 +01:00
static void InitPokenavListWindow(struct PokenavListMenuWindow *listWindow)
{
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);
}
2022-06-01 18:41:57 +02:00
static void InitListItems(struct PokenavListWindowState *windowState, struct PokenavListSub *subPtr)
{
2021-11-13 18:52:41 +01:00
s32 numToPrint = windowState->listLength - windowState->windowTopIndex;
2021-11-15 04:21:50 +01:00
if (numToPrint > windowState->entriesOnscreen)
numToPrint = windowState->entriesOnscreen;
2022-06-01 18:41:57 +02:00
PrintListItems(windowState->listPtr, windowState->windowTopIndex, numToPrint, windowState->listItemSize, 0, subPtr);
}
2022-06-01 18:41:57 +02:00
static void PrintListItems(void * listPtr, u32 topIndex, u32 numItems, u32 itemSize, u32 printStart, struct PokenavListSub *list)
{
2021-11-13 18:52:41 +01:00
if (numItems == 0)
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;
2022-06-01 18:41:57 +02:00
list->printStart = printStart;
2021-11-13 18:52:41 +01:00
CreateLoopedTask(LoopedTask_PrintListItems, 5);
}
2021-11-13 18:52:41 +01:00
static bool32 IsPrintListItemsTaskActive(void)
{
2021-11-13 18:52:41 +01:00
return FuncIsActiveLoopedTask(LoopedTask_PrintListItems);
}
2021-11-13 18:52:41 +01:00
static u32 LoopedTask_PrintListItems(s32 state)
{
2021-11-15 04:21:50 +01:00
u32 row;
2022-06-01 18:41:57 +02:00
struct PokenavListSub *listSub = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
switch (state)
{
case 0:
2022-06-01 18:41:57 +02:00
row = (listSub->listWindow.unkA + listSub->listWindow.numPrinted + listSub->printStart) & 0xF;
listSub->bufferItemFunc(listSub->listPtr, listSub->itemTextBuffer);
if (listSub->iconDrawFunc != NULL)
listSub->iconDrawFunc(listSub->listWindow.windowId, listSub->printIndex, row);
2022-06-01 18:41:57 +02:00
AddTextPrinterParameterized(listSub->listWindow.windowId, listSub->listWindow.fontId, listSub->itemTextBuffer, 8, (row << 4) + 1, TEXT_SKIP_DRAW, NULL);
if (++listSub->listWindow.numPrinted >= listSub->listWindow.numToPrint)
{
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
2022-06-01 18:41:57 +02:00
if (listSub->iconDrawFunc != NULL)
CopyWindowToVram(listSub->listWindow.windowId, COPYWIN_FULL);
else
2022-06-01 18:41:57 +02:00
CopyWindowToVram(listSub->listWindow.windowId, COPYWIN_GFX);
return LT_INC_AND_PAUSE;
}
else
{
2022-06-01 18:41:57 +02:00
listSub->listPtr += listSub->itemSize;
listSub->printIndex++;
return LT_CONTINUE;
}
case 1:
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
return LT_FINISH;
}
return LT_FINISH;
}
2021-11-15 04:21:50 +01:00
static bool32 ShouldShowUpArrow(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
2022-06-01 18:41:57 +02:00
return (list->windowState.windowTopIndex != 0);
}
2021-11-15 04:21:50 +01:00
static bool32 ShouldShowDownArrow(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
struct PokenavListWindowState *windowState = &list->windowState;
2022-06-01 18:41:57 +02:00
return (windowState->windowTopIndex + windowState->entriesOnscreen < windowState->listLength);
}
2021-11-15 04:21:50 +01:00
static void MoveListWindow(s32 delta, bool32 printItems)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
struct PokenavListWindowState *windowState = &list->windowState;
2021-11-13 18:52:41 +01:00
if (delta < 0)
{
2022-06-01 18:41:57 +02:00
if (windowState->windowTopIndex + delta < 0)
delta = -1 * windowState->windowTopIndex;
2021-11-15 04:21:50 +01:00
if (printItems)
2022-06-01 18:41:57 +02:00
PrintListItems(windowState->listPtr, windowState->windowTopIndex + delta, delta * -1, windowState->listItemSize, delta, &list->sub);
}
2021-11-15 04:21:50 +01:00
else if (printItems)
{
2022-06-01 18:41:57 +02:00
s32 index = sMoveWindowDownIndex = windowState->windowTopIndex + windowState->entriesOnscreen;
if (index + delta >= windowState->listLength)
delta = windowState->listLength - index;
2022-06-01 18:41:57 +02:00
PrintListItems(windowState->listPtr, index, delta, windowState->listItemSize, windowState->entriesOnscreen, &list->sub);
}
2022-06-01 18:41:57 +02:00
CreateMoveListWindowTask(delta, &list->sub);
windowState->windowTopIndex += delta;
}
2021-11-15 06:21:40 +01:00
static void CreateMoveListWindowTask(s32 delta, struct PokenavListSub *list)
{
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;
else
2021-11-13 18:52:41 +01:00
list->bgMoveType = BG_COORD_SUB;
list->moveDelta = delta;
list->loopedTaskId = CreateLoopedTask(LoopedTask_MoveListWindow, 6);
}
2021-11-13 18:52:41 +01:00
static u32 LoopedTask_MoveListWindow(s32 state)
{
2021-11-13 18:52:41 +01:00
s32 oldY, newY;
bool32 finished;
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
struct PokenavListSub *subPtr = &list->sub;
switch (state)
{
case 0:
2021-11-13 18:52:41 +01:00
if (!IsPrintListItemsTaskActive())
return LT_INC_AND_CONTINUE;
return LT_PAUSE;
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)
{
2021-11-13 18:52:41 +01:00
if ((oldY > subPtr->endBgY || oldY <= subPtr->startBgY) && newY <= subPtr->endBgY)
finished = TRUE;
}
2021-11-04 04:02:06 +01:00
else // BG_COORD_ADD
{
2021-11-13 18:52:41 +01:00
if ((oldY < subPtr->endBgY || oldY >= subPtr->startBgY) && newY >= subPtr->endBgY)
finished = TRUE;
}
2021-11-13 18:52:41 +01:00
if (finished)
{
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);
return LT_FINISH;
}
return LT_PAUSE;
}
return LT_FINISH;
}
2021-11-15 04:21:50 +01:00
bool32 PokenavList_IsMoveWindowTaskActive(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
return IsLoopedTaskActive(list->sub.loopedTaskId);
}
2021-11-13 18:52:41 +01:00
static struct PokenavListWindowState *GetPokenavListWindowState(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
return &list->windowState;
}
2021-11-13 18:52:41 +01:00
int PokenavList_MoveCursorUp(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavListWindowState *windowState = GetPokenavListWindowState();
2022-06-01 18:41:57 +02:00
if (windowState->selectedIndexOffset != 0)
{
2022-06-01 18:41:57 +02:00
windowState->selectedIndexOffset--;
return 1;
}
if (ShouldShowUpArrow())
{
2021-11-13 18:52:41 +01:00
MoveListWindow(-1, TRUE);
return 2;
}
return 0;
}
2021-11-13 18:52:41 +01:00
int PokenavList_MoveCursorDown(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavListWindowState *windowState = GetPokenavListWindowState();
2022-06-01 18:41:57 +02:00
if (windowState->windowTopIndex + windowState->selectedIndexOffset >= windowState->listLength - 1)
return 0;
2022-06-01 18:41:57 +02:00
if (windowState->selectedIndexOffset < windowState->entriesOnscreen - 1)
{
2022-06-01 18:41:57 +02:00
windowState->selectedIndexOffset++;
return 1;
}
if (ShouldShowDownArrow())
{
2021-11-13 18:52:41 +01:00
MoveListWindow(1, TRUE);
return 2;
}
return 0;
}
2021-11-13 18:52:41 +01:00
int PokenavList_PageUp(void)
{
s32 scroll;
2022-06-01 18:41:57 +02:00
struct PokenavListWindowState *windowState = GetPokenavListWindowState();
if (ShouldShowUpArrow())
{
2022-06-01 18:41:57 +02:00
if (windowState->windowTopIndex >= windowState->entriesOnscreen)
scroll = windowState->entriesOnscreen;
else
2022-06-01 18:41:57 +02:00
scroll = windowState->windowTopIndex;
2021-11-13 18:52:41 +01:00
MoveListWindow(scroll * -1, TRUE);
return 2;
}
2022-06-01 18:41:57 +02:00
else if (windowState->selectedIndexOffset != 0)
{
2022-06-01 18:41:57 +02:00
windowState->selectedIndexOffset = 0;
return 1;
}
return 0;
}
2021-11-13 18:52:41 +01:00
int PokenavList_PageDown(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavListWindowState *windowState = GetPokenavListWindowState();
if (ShouldShowDownArrow())
{
2022-06-01 18:41:57 +02:00
s32 windowBottomIndex = windowState->windowTopIndex + windowState->entriesOnscreen;
s32 scroll = windowState->entriesOffscreen - windowState->windowTopIndex;
2022-06-01 18:41:57 +02:00
if (windowBottomIndex <= windowState->entriesOffscreen)
scroll = windowState->entriesOnscreen;
2021-11-13 18:52:41 +01:00
MoveListWindow(scroll, TRUE);
return 2;
}
else
{
s32 cursor, lastVisibleIndex;
2022-06-01 18:41:57 +02:00
if (windowState->listLength >= windowState->entriesOnscreen)
{
2022-06-01 18:41:57 +02:00
cursor = windowState->selectedIndexOffset;
lastVisibleIndex = windowState->entriesOnscreen;
}
else
{
2022-06-01 18:41:57 +02:00
cursor = windowState->selectedIndexOffset;
lastVisibleIndex = windowState->listLength;
}
lastVisibleIndex -= 1;
if (cursor >= lastVisibleIndex)
return 0;
2022-06-01 18:41:57 +02:00
windowState->selectedIndexOffset = lastVisibleIndex;
return 1;
}
}
2021-11-15 04:21:50 +01:00
u32 PokenavList_GetSelectedIndex(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavListWindowState *windowState = GetPokenavListWindowState();
2022-06-01 18:41:57 +02:00
return windowState->windowTopIndex + windowState->selectedIndexOffset;
}
2021-11-15 04:21:50 +01:00
u32 PokenavList_GetTopIndex(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavListWindowState *windowState = GetPokenavListWindowState();
2022-06-01 18:41:57 +02:00
return windowState->windowTopIndex;
}
2021-11-15 04:21:50 +01:00
void PokenavList_EraseListForCheckPage(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
list->eraseIndex = 0;
list->loopedTaskId = CreateLoopedTask(LoopedTask_EraseListForCheckPage, 6);
}
2021-11-12 23:28:06 +01:00
void PrintCheckPageInfo(s16 delta)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
list->windowState.windowTopIndex += delta;
list->eraseIndex = 0;
list->loopedTaskId = CreateLoopedTask(LoopedTask_PrintCheckPageInfo, 6);
}
2021-11-15 04:21:50 +01:00
void PokenavList_ReshowListFromCheckPage(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
list->eraseIndex = 0;
list->loopedTaskId = CreateLoopedTask(LoopedTask_ReshowListFromCheckPage, 6);
}
2021-11-15 04:21:50 +01:00
bool32 PokenavList_IsTaskActive(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
return IsLoopedTaskActive(list->loopedTaskId);
}
2021-11-13 18:52:41 +01:00
void PokenavList_DrawCurrentItemIcon(void)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
struct PokenavListWindowState *windowState = &list->windowState;
list->sub.iconDrawFunc(list->sub.listWindow.windowId, windowState->windowTopIndex + windowState->selectedIndexOffset, (list->sub.listWindow.unkA + windowState->selectedIndexOffset) & 0xF);
CopyWindowToVram(list->sub.listWindow.windowId, COPYWIN_MAP);
}
2021-11-15 04:21:50 +01:00
static u32 LoopedTask_EraseListForCheckPage(s32 state)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
switch (state)
{
case 0:
2022-07-25 20:59:14 +02:00
ToggleListArrows(&list->sub, TRUE);
// fall-through
case 1:
2022-06-01 18:41:57 +02:00
if (list->eraseIndex != list->windowState.selectedIndexOffset)
EraseListEntry(&list->sub.listWindow, list->eraseIndex, 1);
2022-06-01 18:41:57 +02:00
list->eraseIndex++;
return LT_INC_AND_PAUSE;
case 2:
if (!IsDma3ManagerBusyWithBgCopy())
{
2022-06-01 18:41:57 +02:00
if (list->eraseIndex != list->windowState.entriesOnscreen)
2021-11-15 04:21:50 +01:00
return LT_SET_STATE(1);
2022-06-01 18:41:57 +02:00
if (list->windowState.selectedIndexOffset != 0)
EraseListEntry(&list->sub.listWindow, list->eraseIndex, list->windowState.selectedIndexOffset);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 3:
if (!IsDma3ManagerBusyWithBgCopy())
{
2022-06-01 18:41:57 +02:00
if (list->windowState.selectedIndexOffset != 0)
{
2022-06-01 18:41:57 +02:00
MoveListWindow(list->windowState.selectedIndexOffset, FALSE);
return LT_INC_AND_PAUSE;
}
return LT_FINISH;
}
return LT_PAUSE;
case 4:
2021-11-15 04:21:50 +01:00
if (PokenavList_IsMoveWindowTaskActive())
return LT_PAUSE;
2022-06-01 18:41:57 +02:00
list->windowState.selectedIndexOffset = 0;
return LT_FINISH;
}
return LT_FINISH;
}
2021-11-13 18:52:41 +01:00
static u32 LoopedTask_PrintCheckPageInfo(s32 state)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
switch (state)
{
case 0:
2022-06-01 18:41:57 +02:00
PrintCheckPageTrainerName(&list->windowState, &list->sub);
break;
case 1:
2022-06-01 18:41:57 +02:00
PrintMatchCallFieldNames(&list->sub, 0);
break;
case 2:
2022-06-01 18:41:57 +02:00
PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_STRATEGY);
break;
case 3:
2022-06-01 18:41:57 +02:00
PrintMatchCallFieldNames(&list->sub, 1);
break;
case 4:
2022-06-01 18:41:57 +02:00
PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_POKEMON);
break;
case 5:
2022-06-01 18:41:57 +02:00
PrintMatchCallFieldNames(&list->sub, 2);
break;
case 6:
2022-06-01 18:41:57 +02:00
PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_INTRO_1);
break;
case 7:
2022-06-01 18:41:57 +02:00
PrintMatchCallFlavorText(&list->windowState, &list->sub, CHECK_PAGE_INTRO_2);
break;
default:
return LT_FINISH;
}
return LT_INC_AND_PAUSE;
}
2021-11-15 04:21:50 +01:00
static u32 LoopedTask_ReshowListFromCheckPage(s32 state)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list;
2021-11-13 18:52:41 +01:00
struct PokenavListWindowState *windowState;
2022-06-01 18:41:57 +02:00
struct PokenavListSub *subPtr;
s32 r5, *ptr;
if (IsDma3ManagerBusyWithBgCopy())
return LT_PAUSE;
2022-06-01 18:41:57 +02:00
list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
windowState = &list->windowState;
subPtr = &list->sub;
switch (state)
{
case 0:
2021-11-15 04:21:50 +01:00
// Rewrite the name of the trainer whose check page was just being viewed.
// This is done to erase the red background it had.
2022-06-01 18:41:57 +02:00
PrintMatchCallListTrainerName(windowState, subPtr);
return LT_INC_AND_PAUSE;
case 1:
2022-06-01 18:41:57 +02:00
ptr = &list->eraseIndex;
if (++(*ptr) < list->windowState.entriesOnscreen)
{
2022-06-01 18:41:57 +02:00
EraseListEntry(&subPtr->listWindow, *ptr, 1);
return LT_PAUSE;
}
*ptr = 0;
2021-11-15 04:21:50 +01:00
if (windowState->listLength <= windowState->entriesOnscreen)
{
2021-11-13 18:52:41 +01:00
if (windowState->windowTopIndex != 0)
{
2021-11-13 18:52:41 +01:00
s32 r4 = windowState->windowTopIndex;
r5 = -r4;
2022-06-01 18:41:57 +02:00
EraseListEntry(&subPtr->listWindow, r5, r4);
2021-11-13 18:52:41 +01:00
windowState->selectedIndexOffset = r4;
*ptr = r5;
return LT_INC_AND_PAUSE;
}
}
else
{
2021-11-15 04:21:50 +01:00
if (windowState->windowTopIndex + windowState->entriesOnscreen > windowState->listLength)
{
2021-11-15 04:21:50 +01:00
s32 r4 = windowState->windowTopIndex + windowState->entriesOnscreen - windowState->listLength;
r5 = -r4;
2022-06-01 18:41:57 +02:00
EraseListEntry(&subPtr->listWindow, r5, r4);
2021-11-13 18:52:41 +01:00
windowState->selectedIndexOffset = r4;
*ptr = r5;
return LT_INC_AND_PAUSE;
}
}
2021-11-15 04:21:50 +01:00
return LT_SET_STATE(4);
case 2:
2022-06-01 18:41:57 +02:00
MoveListWindow(list->eraseIndex, FALSE);
return LT_INC_AND_PAUSE;
case 3:
2021-11-15 04:21:50 +01:00
if (!PokenavList_IsMoveWindowTaskActive())
{
2022-06-01 18:41:57 +02:00
list->eraseIndex = 0;
2021-11-15 04:21:50 +01:00
return LT_INC_AND_CONTINUE;
}
2021-11-15 04:21:50 +01:00
return LT_PAUSE;
case 4:
2022-06-01 18:41:57 +02:00
PrintListItems(windowState->listPtr, windowState->windowTopIndex + list->eraseIndex, 1, windowState->listItemSize, list->eraseIndex, &list->sub);
return LT_INC_AND_PAUSE;
case 5:
2021-11-13 18:52:41 +01:00
if (IsPrintListItemsTaskActive())
return LT_PAUSE;
2022-06-01 18:41:57 +02:00
if (++list->eraseIndex >= windowState->listLength || list->eraseIndex >= windowState->entriesOnscreen)
return LT_INC_AND_CONTINUE;
2021-11-15 04:21:50 +01:00
return LT_SET_STATE(4);
case 6:
2022-07-25 20:59:14 +02:00
ToggleListArrows(subPtr, FALSE);
return LT_FINISH;
}
return LT_FINISH;
}
2022-06-01 18:41:57 +02:00
static void EraseListEntry(struct PokenavListMenuWindow *listWindow, s32 offset, s32 entries)
{
u8 *tileData = (u8 *)GetWindowAttribute(listWindow->windowId, WINDOW_TILE_DATA);
2021-11-15 04:21:50 +01:00
u32 width = listWindow->width * 64;
2022-06-01 18:41:57 +02:00
offset = (listWindow->unkA + offset) & 0xF;
if (offset + entries <= 16)
{
2022-06-01 18:41:57 +02:00
CpuFastFill8(PIXEL_FILL(1), tileData + offset * width, entries * width);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(listWindow->windowId, COPYWIN_GFX);
}
else
{
2022-06-01 18:41:57 +02:00
u32 v3 = 16 - offset;
u32 v4 = entries - v3;
2022-06-01 18:41:57 +02:00
CpuFastFill8(PIXEL_FILL(1), tileData + offset * width, v3 * width);
2021-11-15 04:21:50 +01:00
CpuFastFill8(PIXEL_FILL(1), tileData, v4 * width);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(listWindow->windowId, COPYWIN_GFX);
}
2022-06-01 18:41:57 +02:00
for (entries--; entries != -1; offset = (offset + 1) & 0xF, entries--)
ClearRematchPokeballIcon(listWindow->windowId, offset);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(listWindow->windowId, COPYWIN_MAP);
}
2021-11-15 04:21:50 +01:00
// Pointless
static void SetListMarginTile(struct PokenavListMenuWindow *listWindow, bool32 draw)
{
u16 var;
u16 *tilemapBuffer = (u16 *)GetBgTilemapBuffer(GetWindowAttribute(listWindow->windowId, WINDOW_BG));
2021-11-15 04:21:50 +01:00
tilemapBuffer += (listWindow->unkA << 6) + listWindow->x - 1;
2021-11-15 04:21:50 +01:00
if (draw)
2021-11-13 18:52:41 +01:00
var = (listWindow->fillValue << 12) | (listWindow->tileOffset + 1);
else
2021-11-13 18:52:41 +01:00
var = (listWindow->fillValue << 12) | (listWindow->tileOffset);
2021-11-15 04:21:50 +01:00
tilemapBuffer[0] = var;
tilemapBuffer[0x20] = var;
}
2021-11-13 18:52:41 +01:00
// Print the trainer's name and title at the top of their check page
2021-11-15 06:21:40 +01:00
static void PrintCheckPageTrainerName(struct PokenavListWindowState *state, struct PokenavListSub *list)
{
2021-04-10 04:39:34 +02:00
u8 colors[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_RED};
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);
2021-11-15 04:21:50 +01:00
SetListMarginTile(&list->listWindow, TRUE);
2021-11-13 18:52:41 +01:00
CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_FULL, 0, list->listWindow.unkA * 2, list->listWindow.width, 2);
}
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)
2021-11-15 06:21:40 +01:00
static void PrintMatchCallListTrainerName(struct PokenavListWindowState *state, struct PokenavListSub *list)
{
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);
2021-11-15 04:21:50 +01:00
SetListMarginTile(&list->listWindow, FALSE);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(list->listWindow.windowId, COPYWIN_FULL);
}
2021-11-15 06:21:40 +01:00
static void PrintMatchCallFieldNames(struct PokenavListSub *list, u32 fieldId)
{
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;
2021-11-13 18:52:41 +01:00
FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.width, 16);
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);
}
2022-06-01 18:41:57 +02:00
static void PrintMatchCallFlavorText(struct PokenavListWindowState *windowState, struct PokenavListSub *list, u32 checkPageEntry)
{
2019-12-05 21:33:36 +01:00
// lines 1, 3, and 5 are the field names printed by PrintMatchCallFieldNames
2021-11-15 04:21:50 +01:00
static const u8 lineOffsets[CHECK_PAGE_ENTRY_COUNT] = {
[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;
2022-06-01 18:41:57 +02:00
const u8 *str = GetMatchCallFlavorText(windowState->windowTopIndex, checkPageEntry);
if (str != NULL)
{
2021-11-13 18:52:41 +01:00
FillWindowTilesByRow(list->listWindow.windowId, 1, r6 * 2, list->listWindow.width - 1, 2);
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);
}
}
2021-11-13 18:52:41 +01:00
static const struct CompressedSpriteSheet sListArrowSpriteSheets[] =
{
{
2021-11-13 18:52:41 +01:00
.data = sListArrow_Gfx,
2021-11-15 04:21:50 +01:00
.size = 0xC0,
2021-11-13 18:52:41 +01:00
.tag = GFXTAG_ARROW
}
};
2021-11-13 18:52:41 +01:00
static const struct SpritePalette sListArrowPalettes[] =
{
{
2021-11-13 18:52:41 +01:00
.data = sListArrow_Pal,
.tag = PALTAG_ARROW
},
{}
};
2021-11-13 18:52:41 +01:00
static const struct OamData sOamData_RightArrow =
{
.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 =
{
2021-11-13 18:52:41 +01:00
.tileTag = GFXTAG_ARROW,
.paletteTag = PALTAG_ARROW,
.oam = &sOamData_RightArrow,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2021-11-13 18:52:41 +01:00
.callback = SpriteCB_RightArrow
};
2021-11-13 18:52:41 +01:00
static const struct OamData sOamData_UpDownArrow =
{
.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 =
{
2021-11-13 18:52:41 +01:00
.tileTag = GFXTAG_ARROW,
.paletteTag = PALTAG_ARROW,
.oam = &sOamData_UpDownArrow,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
2021-11-13 18:52:41 +01:00
static void LoadListArrowGfx(void)
{
u32 i;
const struct CompressedSpriteSheet *ptr;
2021-11-13 18:52:41 +01:00
for (i = 0, ptr = sListArrowSpriteSheets; i < ARRAY_COUNT(sListArrowSpriteSheets); ptr++, i++)
LoadCompressedSpriteSheet(ptr);
2021-11-13 18:52:41 +01:00
Pokenav_AllocAndLoadPalettes(sListArrowPalettes);
}
2021-11-15 06:21:40 +01:00
static void CreateListArrowSprites(struct PokenavListWindowState *windowState, struct PokenavListSub *list)
{
u32 spriteId;
s16 x;
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];
2021-11-13 18:52:41 +01:00
x = list->listWindow.x * 8 + (list->listWindow.width - 1) * 4;
2021-11-15 04:21:50 +01:00
spriteId = CreateSprite(&sSpriteTemplate_UpDownArrow, x, list->listWindow.y * 8 + windowState->entriesOnscreen * 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;
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;
}
2021-11-15 06:21:40 +01:00
static void DestroyListArrows(struct PokenavListSub *list)
{
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);
}
2021-11-15 06:21:40 +01:00
static void ToggleListArrows(struct PokenavListSub *list, bool32 invisible)
{
2021-11-13 18:52:41 +01:00
if (invisible)
{
2020-10-11 00:17:34 +02:00
list->rightArrow->callback = SpriteCallbackDummy;
list->upArrow->callback = SpriteCallbackDummy;
list->downArrow->callback = SpriteCallbackDummy;
}
else
{
2021-11-13 18:52:41 +01:00
list->rightArrow->callback = SpriteCB_RightArrow;
list->upArrow->callback = SpriteCB_UpArrow;
list->downArrow->callback = SpriteCB_DownArrow;
}
2021-11-13 18:52:41 +01:00
list->rightArrow->invisible = invisible;
list->upArrow->invisible = invisible;
list->downArrow->invisible = invisible;
}
2021-11-13 18:52:41 +01:00
static void SpriteCB_RightArrow(struct Sprite *sprite)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
sprite->y2 = list->windowState.selectedIndexOffset << 4;
}
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)
{
2021-11-13 18:52:41 +01:00
if (!sprite->sInvisible && ShouldShowDownArrow())
sprite->invisible = FALSE;
else
sprite->invisible = TRUE;
2021-11-13 18:52:41 +01:00
if (++sprite->sTimer > 3)
{
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;
}
}
2021-11-13 18:52:41 +01:00
static void SpriteCB_UpArrow(struct Sprite *sprite)
{
2021-11-13 18:52:41 +01:00
if (!sprite->sInvisible && ShouldShowUpArrow())
sprite->invisible = FALSE;
else
sprite->invisible = TRUE;
2021-11-13 18:52:41 +01:00
if (++sprite->sTimer > 3)
{
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;
}
}
2021-11-13 18:52:41 +01:00
void PokenavList_ToggleVerticalArrows(bool32 invisible)
{
2022-06-01 18:41:57 +02:00
struct PokenavList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_LIST);
list->sub.upArrow->sInvisible = invisible;
list->sub.downArrow->sInvisible = invisible;
}
2021-11-13 18:52:41 +01:00
#undef sTimer
#undef sOffset
#undef sInvisible
static void InitPokenavListWindowState(struct PokenavListWindowState *dst, struct PokenavListTemplate *template)
{
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;
2021-11-15 04:21:50 +01:00
dst->entriesOnscreen = template->maxShowed;
if (dst->entriesOnscreen >= dst->listLength)
{
2020-10-11 00:17:34 +02:00
dst->windowTopIndex = 0;
2021-11-15 04:21:50 +01:00
dst->entriesOffscreen = 0;
2021-11-13 18:52:41 +01:00
dst->selectedIndexOffset = template->startIndex;
}
else
{
2021-11-15 04:21:50 +01:00
dst->entriesOffscreen = dst->listLength - dst->entriesOnscreen;
if (dst->windowTopIndex + dst->entriesOnscreen > dst->listLength)
{
2021-11-15 04:21:50 +01:00
dst->selectedIndexOffset = dst->windowTopIndex + dst->entriesOnscreen - dst->listLength;
2021-11-13 18:52:41 +01:00
dst->windowTopIndex = template->startIndex - dst->selectedIndexOffset;
}
else
{
2020-10-11 00:17:34 +02:00
dst->selectedIndexOffset = 0;
}
}
}
2021-11-15 06:21:40 +01:00
static bool32 CopyPokenavListMenuTemplate(struct PokenavListSub *dest, const struct BgTemplate *bgTemplate, struct PokenavListTemplate *template, s32 tileOffset)
{
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;
window.tilemapTop = 0;
2020-10-11 00:17:34 +02:00
window.width = template->windowWidth;
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;
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)
return FALSE;
2020-10-11 00:17:34 +02:00
dest->listWindow.unkA = 0;
dest->rightArrow = NULL;
dest->upArrow = NULL;
dest->downArrow = NULL;
return 1;
}