2018-03-02 16:34:31 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "list_menu.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "text_window.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "task.h"
|
2018-05-19 11:36:31 +02:00
|
|
|
#include "trig.h"
|
|
|
|
#include "decompress.h"
|
|
|
|
#include "palette.h"
|
2018-11-29 12:24:28 +01:00
|
|
|
#include "alloc.h"
|
2018-03-03 14:58:41 +01:00
|
|
|
#include "strings.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "constants/songs.h"
|
2018-03-02 16:34:31 +01:00
|
|
|
|
2018-05-19 11:36:31 +02:00
|
|
|
struct UnkIndicatorsStruct
|
|
|
|
{
|
|
|
|
u8 field_0;
|
|
|
|
u16 *field_4;
|
|
|
|
u16 field_8;
|
|
|
|
u16 field_A;
|
|
|
|
u16 field_C;
|
|
|
|
u16 field_E;
|
|
|
|
u8 field_10;
|
|
|
|
u8 field_11;
|
|
|
|
u8 field_12;
|
|
|
|
u8 field_13;
|
|
|
|
u8 field_14_0:4;
|
|
|
|
u8 field_14_1:4;
|
|
|
|
u8 field_15_0:4;
|
|
|
|
u8 field_15_1:4;
|
|
|
|
u8 field_16_0:3;
|
|
|
|
u8 field_16_1:3;
|
|
|
|
u8 field_16_2:2;
|
|
|
|
u8 field_17_0:6;
|
|
|
|
u8 field_17_1:2;
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
struct ScrollIndicatorPair
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
u8 field_0;
|
2018-07-25 06:18:23 +02:00
|
|
|
u16 *scrollOffset;
|
2018-07-15 13:23:38 +02:00
|
|
|
u16 fullyUpThreshold;
|
|
|
|
u16 fullyDownThreshold;
|
|
|
|
u8 topSpriteId;
|
|
|
|
u8 bottomSpriteId;
|
2018-05-19 11:36:31 +02:00
|
|
|
u16 tileTag;
|
|
|
|
u16 palTag;
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedOutlineCursor
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
struct SubspriteTable subspriteTable;
|
|
|
|
struct Subsprite *subspritesPtr; // not a const pointer
|
|
|
|
u8 spriteId;
|
|
|
|
u16 tileTag;
|
|
|
|
u16 palTag;
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedArrowCursor
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 spriteId;
|
2018-05-19 11:36:31 +02:00
|
|
|
u16 tileTag;
|
|
|
|
u16 palTag;
|
|
|
|
};
|
|
|
|
|
2018-03-02 16:34:31 +01:00
|
|
|
// this file's functions
|
2018-03-03 14:58:41 +01:00
|
|
|
static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow);
|
|
|
|
static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown);
|
|
|
|
static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count);
|
|
|
|
static void ListMenuDrawCursor(struct ListMenu *list);
|
2018-07-15 13:23:38 +02:00
|
|
|
static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 onInit);
|
2018-03-03 14:58:41 +01:00
|
|
|
static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind);
|
2018-05-19 11:36:31 +02:00
|
|
|
static void Task_ScrollIndicatorArrowPair(u8 taskId);
|
|
|
|
static u8 ListMenuAddRedOutlineCursorObject(struct CursorStruct *cursor);
|
|
|
|
static u8 ListMenuAddRedArrowCursorObject(struct CursorStruct *cursor);
|
|
|
|
static void ListMenuUpdateRedOutlineCursorObject(u8 taskId, u16 x, u16 y);
|
|
|
|
static void ListMenuUpdateRedArrowCursorObject(u8 taskId, u16 x, u16 y);
|
|
|
|
static void ListMenuRemoveRedOutlineCursorObject(u8 taskId);
|
|
|
|
static void ListMenuRemoveRedArrowCursorObject(u8 taskId);
|
|
|
|
static u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorKind);
|
|
|
|
static void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorKind);
|
|
|
|
static void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind);
|
2018-07-15 13:23:38 +02:00
|
|
|
static void SpriteCallback_ScrollIndicatorArrow(struct Sprite *sprite);
|
|
|
|
static void SpriteCallback_RedArrowCursor(struct Sprite *sprite);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
|
|
|
// EWRAM vars
|
2018-07-15 13:23:38 +02:00
|
|
|
static EWRAM_DATA struct {
|
|
|
|
s32 currItemId;
|
|
|
|
u8 state;
|
|
|
|
u8 windowId;
|
|
|
|
u8 listTaskId;
|
|
|
|
} sMysteryGiftLinkMenu = {0};
|
|
|
|
|
|
|
|
EWRAM_DATA struct ScrollArrowsTemplate gTempScrollArrowTemplate = {0};
|
2018-03-03 14:58:41 +01:00
|
|
|
|
|
|
|
// IWRAM common
|
2018-07-15 13:23:38 +02:00
|
|
|
struct {
|
|
|
|
u8 cursorPal:4;
|
|
|
|
u8 fillValue:4;
|
|
|
|
u8 cursorShadowPal:4;
|
|
|
|
u8 lettersSpacing:6;
|
|
|
|
u8 field_2_2:6; // unused
|
|
|
|
u8 fontId:7;
|
|
|
|
bool8 enabled:1;
|
|
|
|
} gListMenuOverride;
|
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
struct ListMenuTemplate gMultiuseListMenuTemplate;
|
2018-03-02 16:34:31 +01:00
|
|
|
|
2018-05-19 11:36:31 +02:00
|
|
|
// const rom data
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
u8 animNum:4;
|
|
|
|
u8 bounceDir:4;
|
|
|
|
u8 multiplier;
|
|
|
|
u16 frequency;
|
|
|
|
} sScrollIndicatorTemplates[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
{0, 0, 2, 8},
|
|
|
|
{1, 0, 2, -8},
|
|
|
|
{2, 1, 2, 8},
|
|
|
|
{3, 1, 2, -8},
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct OamData sOamData_ScrollArrowIndicator =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = 0,
|
|
|
|
.objMode = 0,
|
|
|
|
.mosaic = 0,
|
|
|
|
.bpp = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
|
|
|
.size = 1,
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const union AnimCmd sSpriteAnim_ScrollArrowIndicator0[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 30),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const union AnimCmd sSpriteAnim_ScrollArrowIndicator1[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 30, 1, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const union AnimCmd sSpriteAnim_ScrollArrowIndicator2[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(4, 30),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const union AnimCmd sSpriteAnim_ScrollArrowIndicator3[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(4, 30, 0, 1),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const union AnimCmd *const sSpriteAnimTable_ScrollArrowIndicator[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
sSpriteAnim_ScrollArrowIndicator0,
|
|
|
|
sSpriteAnim_ScrollArrowIndicator1,
|
|
|
|
sSpriteAnim_ScrollArrowIndicator2,
|
|
|
|
sSpriteAnim_ScrollArrowIndicator3
|
2018-05-19 11:36:31 +02:00
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_ScrollArrowIndicator =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.tileTag = 0,
|
|
|
|
.paletteTag = 0,
|
2018-07-15 13:23:38 +02:00
|
|
|
.oam = &sOamData_ScrollArrowIndicator,
|
|
|
|
.anims = sSpriteAnimTable_ScrollArrowIndicator,
|
2018-05-19 11:36:31 +02:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2018-07-15 13:23:38 +02:00
|
|
|
.callback = SpriteCallback_ScrollIndicatorArrow,
|
2018-05-19 11:36:31 +02:00
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline1 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 0,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline2 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 1,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline3 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 2,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline4 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 3,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline5 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 4,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline6 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 5,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline7 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 6,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct Subsprite sSubsprite_RedOutline8 =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.size = 0,
|
|
|
|
.tileOffset = 7,
|
|
|
|
.priority = 0,
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct OamData sOamData_RedArrowCursor =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = 0,
|
|
|
|
.objMode = 0,
|
|
|
|
.mosaic = 0,
|
|
|
|
.bpp = 0,
|
|
|
|
.shape = 0,
|
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
|
|
|
.size = 1,
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const union AnimCmd sSpriteAnim_RedArrowCursor[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 30),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const union AnimCmd *const sSpriteAnimTable_RedArrowCursor[] =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
sSpriteAnim_RedArrowCursor
|
2018-05-19 11:36:31 +02:00
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_RedArrowCursor =
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
.tileTag = 0,
|
|
|
|
.paletteTag = 0,
|
2018-07-15 13:23:38 +02:00
|
|
|
.oam = &sOamData_RedArrowCursor,
|
|
|
|
.anims = sSpriteAnimTable_RedArrowCursor,
|
2018-05-19 11:36:31 +02:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2018-07-15 13:23:38 +02:00
|
|
|
.callback = SpriteCallback_RedArrowCursor,
|
2018-05-19 11:36:31 +02:00
|
|
|
};
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static const u16 sRedArrowPal[] = INCBIN_U16("graphics/interface/red_arrow.gbapal");
|
2018-10-21 09:24:57 +02:00
|
|
|
static const u32 sRedArrowOtherGfx[] = INCBIN_U32("graphics/interface/red_arrow_other.4bpp.lz");
|
|
|
|
static const u32 sSelectorOutlineGfx[] = INCBIN_U32("graphics/interface/selector_outline.4bpp.lz");
|
|
|
|
static const u32 sRedArrowGfx[] = INCBIN_U32("graphics/interface/red_arrow.4bpp.lz");
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-03-02 16:34:31 +01:00
|
|
|
// code
|
2018-03-03 14:58:41 +01:00
|
|
|
static void ListMenuDummyTask(u8 taskId)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
switch (sMysteryGiftLinkMenu.state)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
2018-07-15 13:23:38 +02:00
|
|
|
sMysteryGiftLinkMenu.windowId = AddWindow(windowTemplate);
|
2018-03-02 16:34:31 +01:00
|
|
|
switch (arg2)
|
|
|
|
{
|
|
|
|
case 2:
|
2018-07-15 13:23:38 +02:00
|
|
|
LoadUserWindowBorderGfx(sMysteryGiftLinkMenu.windowId, tileNum, palNum);
|
2018-03-02 16:34:31 +01:00
|
|
|
case 1:
|
2018-07-15 13:23:38 +02:00
|
|
|
sub_8098858(sMysteryGiftLinkMenu.windowId, tileNum, palNum / 16);
|
2018-03-02 16:34:31 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
gMultiuseListMenuTemplate = *listMenuTemplate;
|
2018-07-15 13:23:38 +02:00
|
|
|
gMultiuseListMenuTemplate.windowId = sMysteryGiftLinkMenu.windowId;
|
|
|
|
sMysteryGiftLinkMenu.listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
|
|
|
|
CopyWindowToVram(sMysteryGiftLinkMenu.windowId, 1);
|
|
|
|
sMysteryGiftLinkMenu.state = 1;
|
2018-03-02 16:34:31 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2019-02-02 11:04:38 +01:00
|
|
|
sMysteryGiftLinkMenu.currItemId = ListMenu_ProcessInput(sMysteryGiftLinkMenu.listTaskId);
|
2018-03-02 16:34:31 +01:00
|
|
|
if (gMain.newKeys & A_BUTTON)
|
2018-03-09 22:18:58 +01:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
sMysteryGiftLinkMenu.state = 2;
|
2018-03-09 22:18:58 +01:00
|
|
|
}
|
2018-03-02 16:34:31 +01:00
|
|
|
if (gMain.newKeys & B_BUTTON)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
sMysteryGiftLinkMenu.currItemId = LIST_B_PRESSED;
|
|
|
|
sMysteryGiftLinkMenu.state = 2;
|
2018-03-02 16:34:31 +01:00
|
|
|
}
|
2018-07-15 13:23:38 +02:00
|
|
|
if (sMysteryGiftLinkMenu.state == 2)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
if (arg2 == 0)
|
2018-03-09 22:18:58 +01:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
ClearWindowTilemap(sMysteryGiftLinkMenu.windowId);
|
2018-03-09 22:18:58 +01:00
|
|
|
}
|
2018-03-02 16:34:31 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (arg2)
|
|
|
|
{
|
|
|
|
case 0: // can never be reached, because of the if statement above
|
2018-07-15 13:23:38 +02:00
|
|
|
sub_819746C(sMysteryGiftLinkMenu.windowId, FALSE);
|
2018-03-02 16:34:31 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 1:
|
2018-07-15 13:23:38 +02:00
|
|
|
sub_819746C(sMysteryGiftLinkMenu.windowId, FALSE);
|
2018-03-02 16:34:31 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
CopyWindowToVram(sMysteryGiftLinkMenu.windowId, 1);
|
2018-03-02 16:34:31 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-07-15 13:23:38 +02:00
|
|
|
DestroyListMenuTask(sMysteryGiftLinkMenu.listTaskId, NULL, NULL);
|
|
|
|
RemoveWindow(sMysteryGiftLinkMenu.windowId);
|
|
|
|
sMysteryGiftLinkMenu.state = 0;
|
|
|
|
return sMysteryGiftLinkMenu.currItemId;
|
2018-03-02 16:34:31 +01:00
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
return LIST_NOTHING_CHOSEN;
|
2018-03-02 16:34:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow)
|
|
|
|
{
|
|
|
|
u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow);
|
|
|
|
PutWindowTilemap(listMenuTemplate->windowId);
|
|
|
|
CopyWindowToVram(listMenuTemplate->windowId, 2);
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// unused
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenuWindowRect *rect, u16 scrollOffset, u16 selectedRow)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow);
|
2018-12-05 15:31:01 +01:00
|
|
|
for (i = 0; rect[i].palNum != 0xFF; i++)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
PutWindowRectTilemapOverridePalette(listMenuTemplate->windowId,
|
2018-07-15 13:23:38 +02:00
|
|
|
rect[i].x,
|
|
|
|
rect[i].y,
|
|
|
|
rect[i].width,
|
|
|
|
rect[i].height,
|
|
|
|
rect[i].palNum);
|
2018-03-02 16:34:31 +01:00
|
|
|
}
|
|
|
|
CopyWindowToVram(listMenuTemplate->windowId, 2);
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
2019-02-02 11:04:38 +01:00
|
|
|
s32 ListMenu_ProcessInput(u8 listTaskId)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
|
|
|
if (gMain.newKeys & A_BUTTON)
|
|
|
|
{
|
|
|
|
return list->template.items[list->scrollOffset + list->selectedRow].id;
|
|
|
|
}
|
|
|
|
else if (gMain.newKeys & B_BUTTON)
|
|
|
|
{
|
|
|
|
return LIST_B_PRESSED;
|
|
|
|
}
|
|
|
|
else if (gMain.newAndRepeatedKeys & DPAD_UP)
|
|
|
|
{
|
|
|
|
ListMenuChangeSelection(list, TRUE, 1, FALSE);
|
|
|
|
return LIST_NOTHING_CHOSEN;
|
|
|
|
}
|
|
|
|
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
|
|
|
|
{
|
|
|
|
ListMenuChangeSelection(list, TRUE, 1, TRUE);
|
|
|
|
return LIST_NOTHING_CHOSEN;
|
|
|
|
}
|
|
|
|
else // try to move by one window scroll
|
|
|
|
{
|
|
|
|
bool16 rightButton, leftButton;
|
|
|
|
switch (list->template.scrollMultiple)
|
|
|
|
{
|
|
|
|
case LIST_NO_MULTIPLE_SCROLL:
|
|
|
|
default:
|
|
|
|
leftButton = FALSE;
|
|
|
|
rightButton = FALSE;
|
|
|
|
break;
|
|
|
|
case LIST_MULTIPLE_SCROLL_DPAD:
|
|
|
|
leftButton = gMain.newAndRepeatedKeys & DPAD_LEFT;
|
|
|
|
rightButton = gMain.newAndRepeatedKeys & DPAD_RIGHT;
|
|
|
|
break;
|
|
|
|
case LIST_MULTIPLE_SCROLL_L_R:
|
|
|
|
leftButton = gMain.newAndRepeatedKeys & L_BUTTON;
|
|
|
|
rightButton = gMain.newAndRepeatedKeys & R_BUTTON;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (leftButton)
|
|
|
|
{
|
|
|
|
ListMenuChangeSelection(list, TRUE, list->template.maxShowed, FALSE);
|
|
|
|
return LIST_NOTHING_CHOSEN;
|
|
|
|
}
|
|
|
|
else if (rightButton)
|
|
|
|
{
|
|
|
|
ListMenuChangeSelection(list, TRUE, list->template.maxShowed, TRUE);
|
|
|
|
return LIST_NOTHING_CHOSEN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return LIST_NOTHING_CHOSEN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-05 15:31:01 +01:00
|
|
|
#define TASK_NONE 0xFF
|
2018-07-15 13:23:38 +02:00
|
|
|
|
2018-03-02 16:34:31 +01:00
|
|
|
void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow)
|
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
|
|
|
if (scrollOffset != NULL)
|
|
|
|
*scrollOffset = list->scrollOffset;
|
|
|
|
if (selectedRow != NULL)
|
|
|
|
*selectedRow = list->selectedRow;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->taskId != TASK_NONE)
|
|
|
|
ListMenuRemoveCursorObject(list->taskId, list->template.cursorKind - 2);
|
2018-03-02 16:34:31 +01:00
|
|
|
|
|
|
|
DestroyTask(listTaskId);
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
void RedrawListMenu(u8 listTaskId)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
|
2018-03-02 16:34:31 +01:00
|
|
|
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
|
|
|
|
ListMenuDrawCursor(list);
|
|
|
|
CopyWindowToVram(list->template.windowId, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// unused
|
2018-03-03 14:58:41 +01:00
|
|
|
void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
|
|
|
list->template.cursorPal = cursorPal;
|
2018-03-03 14:58:41 +01:00
|
|
|
list->template.fillValue = fillValue;
|
2018-03-02 16:34:31 +01:00
|
|
|
list->template.cursorShadowPal = cursorShadowPal;
|
|
|
|
}
|
|
|
|
|
|
|
|
// unused
|
|
|
|
void ChangeListMenuCoords(u8 listTaskId, u8 x, u8 y)
|
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
|
|
|
SetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT, x);
|
|
|
|
SetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// unused
|
|
|
|
s32 ListMenuTestInput(struct ListMenuTemplate *template, u32 scrollOffset, u32 selectedRow, u16 keys, u16 *newScrollOffset, u16 *newSelectedRow)
|
|
|
|
{
|
|
|
|
struct ListMenu list;
|
|
|
|
|
|
|
|
list.template = *template;
|
|
|
|
list.scrollOffset = scrollOffset;
|
|
|
|
list.selectedRow = selectedRow;
|
|
|
|
list.unk_1C = 0;
|
|
|
|
list.unk_1D = 0;
|
|
|
|
|
|
|
|
if (keys == DPAD_UP)
|
|
|
|
ListMenuChangeSelection(&list, FALSE, 1, FALSE);
|
|
|
|
if (keys == DPAD_DOWN)
|
|
|
|
ListMenuChangeSelection(&list, FALSE, 1, TRUE);
|
|
|
|
|
|
|
|
if (newScrollOffset != NULL)
|
|
|
|
*newScrollOffset = list.scrollOffset;
|
|
|
|
if (newSelectedRow != NULL)
|
|
|
|
*newSelectedRow = list.selectedRow;
|
|
|
|
|
|
|
|
return LIST_NOTHING_CHOSEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ListMenuGetCurrentItemArrayId(u8 listTaskId, u16 *arrayId)
|
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
|
|
|
if (arrayId != NULL)
|
|
|
|
*arrayId = list->scrollOffset + list->selectedRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow)
|
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
|
|
|
if (scrollOffset != NULL)
|
|
|
|
*scrollOffset = list->scrollOffset;
|
|
|
|
if (selectedRow != NULL)
|
|
|
|
*selectedRow = list->selectedRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId)
|
|
|
|
{
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 yMultiplier = GetFontAttribute(list->template.fontId, FONTATTR_MAX_LETTER_HEIGHT) + list->template.itemVerticalPadding;
|
2018-03-02 16:34:31 +01:00
|
|
|
|
|
|
|
return list->selectedRow * yMultiplier + list->template.upText_Y;
|
|
|
|
}
|
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
u8 listTaskId = CreateTask(ListMenuDummyTask, 0);
|
|
|
|
struct ListMenu *list = (void*) gTasks[listTaskId].data;
|
|
|
|
|
|
|
|
list->template = *listMenuTemplate;
|
|
|
|
list->scrollOffset = scrollOffset;
|
|
|
|
list->selectedRow = selectedRow;
|
|
|
|
list->unk_1C = 0;
|
|
|
|
list->unk_1D = 0;
|
2018-07-15 13:23:38 +02:00
|
|
|
list->taskId = TASK_NONE;
|
2018-03-02 16:34:31 +01:00
|
|
|
list->unk_1F = 0;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
gListMenuOverride.cursorPal = list->template.cursorPal;
|
|
|
|
gListMenuOverride.fillValue = list->template.fillValue;
|
|
|
|
gListMenuOverride.cursorShadowPal = list->template.cursorShadowPal;
|
|
|
|
gListMenuOverride.lettersSpacing = list->template.lettersSpacing;
|
|
|
|
gListMenuOverride.fontId = list->template.fontId;
|
|
|
|
gListMenuOverride.enabled = FALSE;
|
2018-03-02 16:34:31 +01:00
|
|
|
|
|
|
|
if (list->template.totalItems < list->template.maxShowed)
|
|
|
|
list->template.maxShowed = list->template.totalItems;
|
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
|
2018-03-02 16:34:31 +01:00
|
|
|
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
|
|
|
|
ListMenuDrawCursor(list);
|
2018-07-15 13:23:38 +02:00
|
|
|
ListMenuCallSelectionChangedCallback(list, TRUE);
|
2018-03-02 16:34:31 +01:00
|
|
|
|
|
|
|
return listTaskId;
|
|
|
|
}
|
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
u8 colors[3];
|
2018-07-15 13:23:38 +02:00
|
|
|
if (gListMenuOverride.enabled)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
colors[0] = gListMenuOverride.fillValue;
|
|
|
|
colors[1] = gListMenuOverride.cursorPal;
|
|
|
|
colors[2] = gListMenuOverride.cursorShadowPal;
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized4(list->template.windowId,
|
2018-07-15 13:23:38 +02:00
|
|
|
gListMenuOverride.fontId,
|
2018-03-02 16:34:31 +01:00
|
|
|
x, y,
|
2018-07-15 13:23:38 +02:00
|
|
|
gListMenuOverride.lettersSpacing,
|
2018-03-02 16:34:31 +01:00
|
|
|
0, colors, TEXT_SPEED_FF, str);
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
gListMenuOverride.enabled = FALSE;
|
2018-03-02 16:34:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-03 14:58:41 +01:00
|
|
|
colors[0] = list->template.fillValue;
|
2018-03-02 16:34:31 +01:00
|
|
|
colors[1] = list->template.cursorPal;
|
|
|
|
colors[2] = list->template.cursorShadowPal;
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized4(list->template.windowId,
|
2018-03-02 16:34:31 +01:00
|
|
|
list->template.fontId,
|
|
|
|
x, y,
|
|
|
|
list->template.lettersSpacing,
|
|
|
|
0, colors, TEXT_SPEED_FF, str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count)
|
2018-03-02 16:34:31 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u8 x, y;
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 yMultiplier = GetFontAttribute(list->template.fontId, FONTATTR_MAX_LETTER_HEIGHT) + list->template.itemVerticalPadding;
|
2018-03-02 16:34:31 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->template.items[startIndex].id != LIST_HEADER)
|
|
|
|
x = list->template.item_X;
|
2018-03-02 16:34:31 +01:00
|
|
|
else
|
2018-07-15 13:23:38 +02:00
|
|
|
x = list->template.header_X;
|
2018-03-02 16:34:31 +01:00
|
|
|
|
|
|
|
y = (yOffset + i) * yMultiplier + list->template.upText_Y;
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->template.itemPrintFunc != NULL)
|
|
|
|
list->template.itemPrintFunc(list->template.windowId, list->template.items[startIndex].id, y);
|
2018-03-02 16:34:31 +01:00
|
|
|
|
|
|
|
ListMenuPrint(list, list->template.items[startIndex].name, x, y);
|
|
|
|
startIndex++;
|
|
|
|
}
|
|
|
|
}
|
2018-03-03 01:02:07 +01:00
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
static void ListMenuDrawCursor(struct ListMenu *list)
|
2018-03-03 01:02:07 +01:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 yMultiplier = GetFontAttribute(list->template.fontId, FONTATTR_MAX_LETTER_HEIGHT) + list->template.itemVerticalPadding;
|
2018-03-03 14:58:41 +01:00
|
|
|
u8 x = list->template.cursor_X;
|
2018-03-03 01:02:07 +01:00
|
|
|
u8 y = list->selectedRow * yMultiplier + list->template.upText_Y;
|
|
|
|
switch (list->template.cursorKind)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ListMenuPrint(list, gText_SelectorArrow2, x, y);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->taskId == TASK_NONE)
|
|
|
|
list->taskId = ListMenuAddCursorObject(list, 0);
|
|
|
|
ListMenuUpdateCursorObject(list->taskId,
|
2018-03-03 01:02:07 +01:00
|
|
|
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 - 1,
|
|
|
|
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y - 1, 0);
|
|
|
|
break;
|
|
|
|
case 3:
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->taskId == TASK_NONE)
|
|
|
|
list->taskId = ListMenuAddCursorObject(list, 1);
|
|
|
|
ListMenuUpdateCursorObject(list->taskId,
|
2018-03-03 01:02:07 +01:00
|
|
|
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 + x,
|
|
|
|
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
#undef TASK_NONE
|
|
|
|
|
2018-03-03 14:58:41 +01:00
|
|
|
static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind)
|
2018-03-03 01:02:07 +01:00
|
|
|
{
|
|
|
|
struct CursorStruct cursor;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
cursor.left = 0;
|
|
|
|
cursor.top = 160;
|
|
|
|
cursor.rowWidth = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8 + 2;
|
|
|
|
cursor.rowHeight = GetFontAttribute(list->template.fontId, FONTATTR_MAX_LETTER_HEIGHT) + 2;
|
2018-05-19 11:36:31 +02:00
|
|
|
cursor.tileTag = 0x4000;
|
2018-07-15 13:23:38 +02:00
|
|
|
cursor.palTag = SPRITE_INVALID_TAG;
|
|
|
|
cursor.palNum = 15;
|
2018-03-03 01:02:07 +01:00
|
|
|
|
|
|
|
return ListMenuAddCursorObjectInternal(&cursor, cursorKind);
|
|
|
|
}
|
2018-03-03 14:58:41 +01:00
|
|
|
|
|
|
|
static void ListMenuErasePrintedCursor(struct ListMenu *list, u16 selectedRow)
|
|
|
|
{
|
|
|
|
u8 cursorKind = list->template.cursorKind;
|
|
|
|
if (cursorKind == 0)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 yMultiplier = GetFontAttribute(list->template.fontId, FONTATTR_MAX_LETTER_HEIGHT) + list->template.itemVerticalPadding;
|
2018-03-03 14:58:41 +01:00
|
|
|
u8 width = GetMenuCursorDimensionByFont(list->template.fontId, 0);
|
|
|
|
u8 height = GetMenuCursorDimensionByFont(list->template.fontId, 1);
|
|
|
|
FillWindowPixelRect(list->template.windowId,
|
|
|
|
(list->template.fillValue << 4) | (list->template.fillValue),
|
|
|
|
list->template.cursor_X,
|
|
|
|
selectedRow * yMultiplier + list->template.upText_Y,
|
|
|
|
width,
|
|
|
|
height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, bool8 movingDown)
|
|
|
|
{
|
|
|
|
u16 selectedRow = list->selectedRow;
|
|
|
|
u16 scrollOffset = list->scrollOffset;
|
|
|
|
u16 newRow;
|
|
|
|
u32 newScroll;
|
|
|
|
|
|
|
|
if (!movingDown)
|
|
|
|
{
|
|
|
|
if (list->template.maxShowed == 1)
|
|
|
|
newRow = 0;
|
|
|
|
else
|
|
|
|
newRow = list->template.maxShowed - ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)) - 1;
|
|
|
|
|
|
|
|
if (scrollOffset == 0)
|
|
|
|
{
|
|
|
|
while (selectedRow != 0)
|
|
|
|
{
|
|
|
|
selectedRow--;
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->template.items[scrollOffset + selectedRow].id != LIST_HEADER)
|
2018-03-03 14:58:41 +01:00
|
|
|
{
|
|
|
|
list->selectedRow = selectedRow;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (selectedRow > newRow)
|
|
|
|
{
|
|
|
|
selectedRow--;
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->template.items[scrollOffset + selectedRow].id != LIST_HEADER)
|
2018-03-03 14:58:41 +01:00
|
|
|
{
|
|
|
|
list->selectedRow = selectedRow;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
newScroll = scrollOffset - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (list->template.maxShowed == 1)
|
|
|
|
newRow = 0;
|
|
|
|
else
|
|
|
|
newRow = ((list->template.maxShowed / 2) + (list->template.maxShowed % 2));
|
|
|
|
|
|
|
|
if (scrollOffset == list->template.totalItems - list->template.maxShowed)
|
|
|
|
{
|
|
|
|
while (selectedRow < list->template.maxShowed - 1)
|
|
|
|
{
|
|
|
|
selectedRow++;
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->template.items[scrollOffset + selectedRow].id != LIST_HEADER)
|
2018-03-03 14:58:41 +01:00
|
|
|
{
|
|
|
|
list->selectedRow = selectedRow;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (selectedRow < newRow)
|
|
|
|
{
|
|
|
|
selectedRow++;
|
2018-07-15 13:23:38 +02:00
|
|
|
if (list->template.items[scrollOffset + selectedRow].id != LIST_HEADER)
|
2018-03-03 14:58:41 +01:00
|
|
|
{
|
|
|
|
list->selectedRow = selectedRow;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
newScroll = scrollOffset + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
list->selectedRow = newRow;
|
|
|
|
list->scrollOffset = newScroll;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ListMenuScroll(struct ListMenu *list, u8 count, bool8 movingDown)
|
|
|
|
{
|
|
|
|
if (count >= list->template.maxShowed)
|
|
|
|
{
|
|
|
|
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
|
|
|
|
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 yMultiplier = GetFontAttribute(list->template.fontId, FONTATTR_MAX_LETTER_HEIGHT) + list->template.itemVerticalPadding;
|
2018-03-03 14:58:41 +01:00
|
|
|
|
|
|
|
if (!movingDown)
|
|
|
|
{
|
|
|
|
u16 y, width, height;
|
|
|
|
|
|
|
|
ScrollWindow(list->template.windowId, 1, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
|
|
|
|
ListMenuPrintEntries(list, list->scrollOffset, 0, count);
|
|
|
|
|
|
|
|
y = (list->template.maxShowed * yMultiplier) + list->template.upText_Y;
|
|
|
|
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
|
|
|
|
height = (GetWindowAttribute(list->template.windowId, WINDOW_HEIGHT) * 8) - y;
|
|
|
|
FillWindowPixelRect(list->template.windowId,
|
|
|
|
(list->template.fillValue << 4) | (list->template.fillValue),
|
|
|
|
0, y, width, height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u16 width;
|
|
|
|
|
|
|
|
ScrollWindow(list->template.windowId, 0, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
|
|
|
|
ListMenuPrintEntries(list, list->scrollOffset + (list->template.maxShowed - count), list->template.maxShowed - count, count);
|
|
|
|
|
|
|
|
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
|
|
|
|
FillWindowPixelRect(list->template.windowId,
|
|
|
|
(list->template.fillValue << 4) | (list->template.fillValue),
|
|
|
|
0, 0, width, list->template.upText_Y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown)
|
|
|
|
{
|
|
|
|
u16 oldSelectedRow;
|
|
|
|
u8 selectionChange, i, cursorCount;
|
|
|
|
|
|
|
|
oldSelectedRow = list->selectedRow;
|
|
|
|
cursorCount = 0;
|
|
|
|
selectionChange = 0;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
u8 ret = ListMenuUpdateSelectedRowIndexAndScrollOffset(list, movingDown);
|
|
|
|
selectionChange |= ret;
|
|
|
|
if (ret != 2)
|
|
|
|
break;
|
|
|
|
cursorCount++;
|
2018-07-15 13:23:38 +02:00
|
|
|
} while (list->template.items[list->scrollOffset + list->selectedRow].id == LIST_HEADER);
|
2018-03-03 14:58:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (updateCursorAndCallCallback)
|
|
|
|
{
|
|
|
|
switch (selectionChange)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return TRUE;
|
|
|
|
case 1:
|
|
|
|
ListMenuErasePrintedCursor(list, oldSelectedRow);
|
|
|
|
ListMenuDrawCursor(list);
|
2018-07-15 13:23:38 +02:00
|
|
|
ListMenuCallSelectionChangedCallback(list, FALSE);
|
2018-03-03 14:58:41 +01:00
|
|
|
CopyWindowToVram(list->template.windowId, 2);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
ListMenuErasePrintedCursor(list, oldSelectedRow);
|
|
|
|
ListMenuScroll(list, cursorCount, movingDown);
|
|
|
|
ListMenuDrawCursor(list);
|
2018-07-15 13:23:38 +02:00
|
|
|
ListMenuCallSelectionChangedCallback(list, FALSE);
|
2018-03-03 14:58:41 +01:00
|
|
|
CopyWindowToVram(list->template.windowId, 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 onInit)
|
2018-03-03 14:58:41 +01:00
|
|
|
{
|
|
|
|
if (list->template.moveCursorFunc != NULL)
|
2018-07-15 13:23:38 +02:00
|
|
|
list->template.moveCursorFunc(list->template.items[list->scrollOffset + list->selectedRow].id, onInit, list);
|
2018-03-03 14:58:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// unused
|
2018-07-15 13:23:38 +02:00
|
|
|
void ListMenuOverrideSetColors(u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
|
2018-03-03 14:58:41 +01:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
gListMenuOverride.cursorPal = cursorPal;
|
|
|
|
gListMenuOverride.fillValue = fillValue;
|
|
|
|
gListMenuOverride.cursorShadowPal = cursorShadowPal;
|
|
|
|
gListMenuOverride.enabled = TRUE;
|
2018-03-03 14:58:41 +01:00
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
void ListMenuDefaultCursorMoveFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list)
|
2018-03-03 14:58:41 +01:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
if (!onInit)
|
2018-03-03 14:58:41 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
}
|
2018-05-19 11:36:31 +02:00
|
|
|
|
|
|
|
// unused
|
2018-07-15 13:23:38 +02:00
|
|
|
s32 ListMenuGetUnkIndicatorsStructFields(u8 taskId, u8 field)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
struct UnkIndicatorsStruct *data = (void*) gTasks[taskId].data;
|
|
|
|
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
return (s32)(data->field_4);
|
|
|
|
case 2:
|
|
|
|
return data->field_C;
|
|
|
|
case 3:
|
|
|
|
return data->field_E;
|
|
|
|
case 4:
|
|
|
|
return data->field_10;
|
|
|
|
case 5:
|
|
|
|
return data->field_11;
|
|
|
|
case 6:
|
|
|
|
return data->field_12;
|
|
|
|
case 7:
|
|
|
|
return data->field_13;
|
|
|
|
case 8:
|
|
|
|
return data->field_14_0;
|
|
|
|
case 9:
|
|
|
|
return data->field_14_1;
|
|
|
|
case 10:
|
|
|
|
return data->field_15_0;
|
|
|
|
case 11:
|
|
|
|
return data->field_15_1;
|
|
|
|
case 12:
|
|
|
|
return data->field_16_0;
|
|
|
|
case 13:
|
|
|
|
return data->field_16_1;
|
|
|
|
case 14:
|
|
|
|
return data->field_16_2;
|
|
|
|
case 15:
|
|
|
|
return data->field_17_0;
|
|
|
|
case 16:
|
|
|
|
return data->field_17_1;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
void ListMenuSetUnkIndicatorsStructField(u8 taskId, u8 field, s32 value)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
struct UnkIndicatorsStruct *data = (void*) &gTasks[taskId].data;
|
|
|
|
|
|
|
|
switch (field)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
data->field_4 = (void*)(value);
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 2:
|
|
|
|
data->field_C = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 3:
|
|
|
|
data->field_E = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 4:
|
|
|
|
data->field_10 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 5:
|
|
|
|
data->field_11 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 6:
|
|
|
|
data->field_12 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 7:
|
|
|
|
data->field_13 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 8:
|
|
|
|
data->field_14_0 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 9:
|
|
|
|
data->field_14_1 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 10:
|
|
|
|
data->field_15_0 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 11:
|
|
|
|
data->field_15_1 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 12:
|
|
|
|
data->field_16_0 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 13:
|
|
|
|
data->field_16_1 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 14:
|
|
|
|
data->field_16_2 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 15:
|
|
|
|
data->field_17_0 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
case 16:
|
|
|
|
data->field_17_1 = value;
|
2018-12-05 15:31:01 +01:00
|
|
|
break;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
#define tState data[0]
|
|
|
|
#define tAnimNum data[1]
|
|
|
|
#define tBounceDir data[2]
|
|
|
|
#define tMultiplier data[3]
|
|
|
|
#define tFrequency data[4]
|
|
|
|
#define tSinePos data[5]
|
|
|
|
|
|
|
|
static void SpriteCallback_ScrollIndicatorArrow(struct Sprite *sprite)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
s32 multiplier;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
switch (sprite->tState)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2018-07-15 13:23:38 +02:00
|
|
|
StartSpriteAnim(sprite, sprite->tAnimNum);
|
|
|
|
sprite->tState++;
|
2018-05-19 11:36:31 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-07-15 13:23:38 +02:00
|
|
|
switch (sprite->tBounceDir)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2018-07-15 13:23:38 +02:00
|
|
|
multiplier = sprite->tMultiplier;
|
|
|
|
sprite->pos2.x = (gSineTable[(u8)(sprite->tSinePos)] * multiplier) / 256;
|
2018-05-19 11:36:31 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-07-15 13:23:38 +02:00
|
|
|
multiplier = sprite->tMultiplier;
|
|
|
|
sprite->pos2.y = (gSineTable[(u8)(sprite->tSinePos)] * multiplier) / 256;
|
2018-05-19 11:36:31 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-07-15 13:23:38 +02:00
|
|
|
sprite->tSinePos += sprite->tFrequency;
|
2018-05-19 11:36:31 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static u8 AddScrollIndicatorArrowObject(u8 arrowDir, u8 x, u8 y, u16 tileTag, u16 palTag)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
spriteTemplate = sSpriteTemplate_ScrollArrowIndicator;
|
2018-05-19 11:36:31 +02:00
|
|
|
spriteTemplate.tileTag = tileTag;
|
|
|
|
spriteTemplate.paletteTag = palTag;
|
|
|
|
|
|
|
|
spriteId = CreateSprite(&spriteTemplate, x, y, 0);
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[spriteId].invisible = TRUE;
|
|
|
|
gSprites[spriteId].tState = 0;
|
|
|
|
gSprites[spriteId].tAnimNum = sScrollIndicatorTemplates[arrowDir].animNum;
|
|
|
|
gSprites[spriteId].tBounceDir = sScrollIndicatorTemplates[arrowDir].bounceDir;
|
|
|
|
gSprites[spriteId].tMultiplier = sScrollIndicatorTemplates[arrowDir].multiplier;
|
|
|
|
gSprites[spriteId].tFrequency = sScrollIndicatorTemplates[arrowDir].frequency;
|
|
|
|
gSprites[spriteId].tSinePos = 0;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
#undef tState
|
|
|
|
#undef tAnimNum
|
|
|
|
#undef tBounceDir
|
|
|
|
#undef tMultiplier
|
|
|
|
#undef tFrequency
|
|
|
|
#undef tSinePos
|
|
|
|
|
2018-07-25 06:18:23 +02:00
|
|
|
u8 AddScrollIndicatorArrowPair(const struct ScrollArrowsTemplate *arrowInfo, u16 *scrollOffset)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
struct CompressedSpriteSheet spriteSheet;
|
|
|
|
struct SpritePalette spritePal;
|
2018-07-15 13:23:38 +02:00
|
|
|
struct ScrollIndicatorPair *data;
|
2018-05-19 11:36:31 +02:00
|
|
|
u8 taskId;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
spriteSheet.data = sRedArrowOtherGfx;
|
2018-05-19 11:36:31 +02:00
|
|
|
spriteSheet.size = 0x100;
|
|
|
|
spriteSheet.tag = arrowInfo->tileTag;
|
2018-12-17 23:00:08 +01:00
|
|
|
LoadCompressedSpriteSheet(&spriteSheet);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (arrowInfo->palTag == SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
LoadPalette(sRedArrowPal, (16 * arrowInfo->palNum) + 0x100, 0x20);
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
spritePal.data = sRedArrowPal;
|
2018-05-19 11:36:31 +02:00
|
|
|
spritePal.tag = arrowInfo->palTag;
|
|
|
|
LoadSpritePalette(&spritePal);
|
|
|
|
}
|
|
|
|
|
|
|
|
taskId = CreateTask(Task_ScrollIndicatorArrowPair, 0);
|
|
|
|
data = (void*) gTasks[taskId].data;
|
|
|
|
|
|
|
|
data->field_0 = 0;
|
2018-07-25 06:18:23 +02:00
|
|
|
data->scrollOffset = scrollOffset;
|
2018-07-15 13:23:38 +02:00
|
|
|
data->fullyUpThreshold = arrowInfo->fullyUpThreshold;
|
|
|
|
data->fullyDownThreshold = arrowInfo->fullyDownThreshold;
|
2018-05-19 11:36:31 +02:00
|
|
|
data->tileTag = arrowInfo->tileTag;
|
|
|
|
data->palTag = arrowInfo->palTag;
|
2018-07-15 13:23:38 +02:00
|
|
|
data->topSpriteId = AddScrollIndicatorArrowObject(arrowInfo->firstArrowType, arrowInfo->firstX, arrowInfo->firstY, arrowInfo->tileTag, arrowInfo->palTag);
|
|
|
|
data->bottomSpriteId = AddScrollIndicatorArrowObject(arrowInfo->secondArrowType, arrowInfo->secondX, arrowInfo->secondY, arrowInfo->tileTag, arrowInfo->palTag);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (arrowInfo->palTag == SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[data->topSpriteId].oam.paletteNum = arrowInfo->palNum;
|
|
|
|
gSprites[data->bottomSpriteId].oam.paletteNum = arrowInfo->palNum;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
2018-07-25 06:18:23 +02:00
|
|
|
u8 AddScrollIndicatorArrowPairParameterized(u32 arrowType, s32 commonPos, s32 firstPos, s32 secondPos, s32 fullyDownThreshold, s32 tileTag, s32 palTag, u16 *scrollOffset)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
if (arrowType == SCROLL_ARROW_UP || arrowType == SCROLL_ARROW_DOWN)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
gTempScrollArrowTemplate.firstArrowType = SCROLL_ARROW_UP;
|
|
|
|
gTempScrollArrowTemplate.firstX = commonPos;
|
|
|
|
gTempScrollArrowTemplate.firstY = firstPos;
|
|
|
|
gTempScrollArrowTemplate.secondArrowType = SCROLL_ARROW_DOWN;
|
|
|
|
gTempScrollArrowTemplate.secondX = commonPos;
|
|
|
|
gTempScrollArrowTemplate.secondY = secondPos;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
gTempScrollArrowTemplate.firstArrowType = SCROLL_ARROW_LEFT;
|
|
|
|
gTempScrollArrowTemplate.firstX = firstPos;
|
|
|
|
gTempScrollArrowTemplate.firstY = commonPos;
|
|
|
|
gTempScrollArrowTemplate.secondArrowType = SCROLL_ARROW_RIGHT;
|
|
|
|
gTempScrollArrowTemplate.secondX = secondPos;
|
|
|
|
gTempScrollArrowTemplate.secondY = commonPos;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
gTempScrollArrowTemplate.fullyUpThreshold = 0;
|
|
|
|
gTempScrollArrowTemplate.fullyDownThreshold = fullyDownThreshold;
|
|
|
|
gTempScrollArrowTemplate.tileTag = tileTag;
|
|
|
|
gTempScrollArrowTemplate.palTag = palTag;
|
|
|
|
gTempScrollArrowTemplate.palNum = 0;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-25 06:18:23 +02:00
|
|
|
return AddScrollIndicatorArrowPair(&gTempScrollArrowTemplate, scrollOffset);
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Task_ScrollIndicatorArrowPair(u8 taskId)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
struct ScrollIndicatorPair *data = (void*) gTasks[taskId].data;
|
2018-07-25 06:18:23 +02:00
|
|
|
u16 currItem = (*data->scrollOffset);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-12-05 15:31:01 +01:00
|
|
|
if (currItem == data->fullyUpThreshold && currItem != 0xFFFF)
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[data->topSpriteId].invisible = TRUE;
|
2018-05-19 11:36:31 +02:00
|
|
|
else
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[data->topSpriteId].invisible = FALSE;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (currItem == data->fullyDownThreshold)
|
|
|
|
gSprites[data->bottomSpriteId].invisible = TRUE;
|
2018-05-19 11:36:31 +02:00
|
|
|
else
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[data->bottomSpriteId].invisible = FALSE;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
#define tIsScrolled data[15]
|
|
|
|
|
2018-05-19 11:36:31 +02:00
|
|
|
void Task_ScrollIndicatorArrowPairOnMainMenu(u8 taskId)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
struct ScrollIndicatorPair *scrollData = (void*) data;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (tIsScrolled)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[scrollData->topSpriteId].invisible = FALSE;
|
|
|
|
gSprites[scrollData->bottomSpriteId].invisible = TRUE;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[scrollData->topSpriteId].invisible = TRUE;
|
|
|
|
gSprites[scrollData->bottomSpriteId].invisible = FALSE;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
#undef tIsScrolled
|
|
|
|
|
2018-05-19 11:36:31 +02:00
|
|
|
void RemoveScrollIndicatorArrowPair(u8 taskId)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
struct ScrollIndicatorPair *data = (void*) gTasks[taskId].data;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (data->tileTag != SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
FreeSpriteTilesByTag(data->tileTag);
|
2018-07-15 13:23:38 +02:00
|
|
|
if (data->palTag != SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
FreeSpritePaletteByTag(data->palTag);
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
DestroySprite(&gSprites[data->topSpriteId]);
|
|
|
|
DestroySprite(&gSprites[data->bottomSpriteId]);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorKind)
|
|
|
|
{
|
|
|
|
switch (cursorKind)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return ListMenuAddRedOutlineCursorObject(cursor);
|
|
|
|
case 1:
|
|
|
|
return ListMenuAddRedArrowCursorObject(cursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorKind)
|
|
|
|
{
|
|
|
|
switch (cursorKind)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ListMenuUpdateRedOutlineCursorObject(taskId, x, y);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ListMenuUpdateRedArrowCursorObject(taskId, x, y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind)
|
|
|
|
{
|
|
|
|
switch (cursorKind)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ListMenuRemoveRedOutlineCursorObject(taskId);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ListMenuRemoveRedArrowCursorObject(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Task_RedOutlineCursor(u8 taskId)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
u8 ListMenuGetRedOutlineCursorSpriteCount(u16 rowWidth, u16 rowHeight)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
s32 count = 4;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (rowWidth > 16)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
for (i = 8; i < (rowWidth - 8); i += 8)
|
2018-05-19 11:36:31 +02:00
|
|
|
count += 2;
|
|
|
|
}
|
2018-07-15 13:23:38 +02:00
|
|
|
if (rowHeight > 16)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
for (i = 8; i < (rowHeight - 8); i += 8)
|
2018-05-19 11:36:31 +02:00
|
|
|
count += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
void ListMenuSetUpRedOutlineCursorSpriteOamTable(u16 rowWidth, u16 rowHeight, struct Subsprite *subsprites)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
s32 i, j, id = 0;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline1;
|
2018-05-19 11:36:31 +02:00
|
|
|
subsprites[id].x = 136;
|
|
|
|
subsprites[id].y = 136;
|
|
|
|
id++;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline2;
|
|
|
|
subsprites[id].x = rowWidth + 128;
|
2018-05-19 11:36:31 +02:00
|
|
|
subsprites[id].y = 136;
|
|
|
|
id++;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline7;
|
2018-05-19 11:36:31 +02:00
|
|
|
subsprites[id].x = 136;
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id].y = rowHeight + 128;
|
2018-05-19 11:36:31 +02:00
|
|
|
id++;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline8;
|
|
|
|
subsprites[id].x = rowWidth + 128;
|
|
|
|
subsprites[id].y = rowHeight + 128;
|
2018-05-19 11:36:31 +02:00
|
|
|
id++;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (rowWidth > 16)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
for (i = 8; i < rowWidth - 8; i += 8)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline3;
|
2018-05-19 11:36:31 +02:00
|
|
|
subsprites[id].x = i - 120;
|
|
|
|
subsprites[id].y = 136;
|
|
|
|
id++;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline6;
|
2018-05-19 11:36:31 +02:00
|
|
|
subsprites[id].x = i - 120;
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id].y = rowHeight + 128;
|
2018-05-19 11:36:31 +02:00
|
|
|
id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (rowHeight > 16)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
for (j = 8; j < rowHeight - 8; j += 8)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline4;
|
2018-05-19 11:36:31 +02:00
|
|
|
subsprites[id].x = 136;
|
|
|
|
subsprites[id].y = j - 120;
|
|
|
|
id++;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
subsprites[id] = sSubsprite_RedOutline5;
|
|
|
|
subsprites[id].x = rowWidth + 128;
|
2018-05-19 11:36:31 +02:00
|
|
|
subsprites[id].y = j - 120;
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 ListMenuAddRedOutlineCursorObject(struct CursorStruct *cursor)
|
|
|
|
{
|
|
|
|
struct CompressedSpriteSheet spriteSheet;
|
|
|
|
struct SpritePalette spritePal;
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedOutlineCursor *data;
|
2018-05-19 11:36:31 +02:00
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
u8 taskId;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
spriteSheet.data = sSelectorOutlineGfx;
|
2018-05-19 11:36:31 +02:00
|
|
|
spriteSheet.size = 0x100;
|
|
|
|
spriteSheet.tag = cursor->tileTag;
|
2018-12-17 23:00:08 +01:00
|
|
|
LoadCompressedSpriteSheet(&spriteSheet);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (cursor->palTag == SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
LoadPalette(sRedArrowPal, (16 * cursor->palNum) + 0x100, 0x20);
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
spritePal.data = sRedArrowPal;
|
2018-05-19 11:36:31 +02:00
|
|
|
spritePal.tag = cursor->palTag;
|
|
|
|
LoadSpritePalette(&spritePal);
|
|
|
|
}
|
|
|
|
|
|
|
|
taskId = CreateTask(Task_RedOutlineCursor, 0);
|
|
|
|
data = (void*) gTasks[taskId].data;
|
|
|
|
|
|
|
|
data->tileTag = cursor->tileTag;
|
|
|
|
data->palTag = cursor->palTag;
|
2018-07-15 13:23:38 +02:00
|
|
|
data->subspriteTable.subspriteCount = ListMenuGetRedOutlineCursorSpriteCount(cursor->rowWidth, cursor->rowHeight);
|
2018-05-19 11:36:31 +02:00
|
|
|
data->subspriteTable.subsprites = data->subspritesPtr = Alloc(data->subspriteTable.subspriteCount * 4);
|
2018-07-15 13:23:38 +02:00
|
|
|
ListMenuSetUpRedOutlineCursorSpriteOamTable(cursor->rowWidth, cursor->rowHeight, data->subspritesPtr);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
|
|
|
spriteTemplate = gDummySpriteTemplate;
|
|
|
|
spriteTemplate.tileTag = cursor->tileTag;
|
|
|
|
spriteTemplate.paletteTag = cursor->palTag;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
data->spriteId = CreateSprite(&spriteTemplate, cursor->left + 120, cursor->top + 120, 0);
|
2018-05-19 11:36:31 +02:00
|
|
|
SetSubspriteTables(&gSprites[data->spriteId], &data->subspriteTable);
|
|
|
|
gSprites[data->spriteId].oam.priority = 0;
|
|
|
|
gSprites[data->spriteId].subpriority = 0;
|
|
|
|
gSprites[data->spriteId].subspriteTableNum = 0;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (cursor->palTag == SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
gSprites[data->spriteId].oam.paletteNum = cursor->palNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ListMenuUpdateRedOutlineCursorObject(u8 taskId, u16 x, u16 y)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedOutlineCursor *data = (void*) gTasks[taskId].data;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
|
|
|
gSprites[data->spriteId].pos1.x = x + 120;
|
|
|
|
gSprites[data->spriteId].pos1.y = y + 120;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ListMenuRemoveRedOutlineCursorObject(u8 taskId)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedOutlineCursor *data = (void*) gTasks[taskId].data;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
|
|
|
Free(data->subspritesPtr);
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (data->tileTag != SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
FreeSpriteTilesByTag(data->tileTag);
|
2018-07-15 13:23:38 +02:00
|
|
|
if (data->palTag != SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
FreeSpritePaletteByTag(data->palTag);
|
|
|
|
|
|
|
|
DestroySprite(&gSprites[data->spriteId]);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
static void SpriteCallback_RedArrowCursor(struct Sprite *sprite)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
|
|
|
sprite->pos2.x = gSineTable[(u8)(sprite->data[0])] / 64;
|
|
|
|
sprite->data[0] += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Task_RedArrowCursor(u8 taskId)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 ListMenuAddRedArrowCursorObject(struct CursorStruct *cursor)
|
|
|
|
{
|
|
|
|
struct CompressedSpriteSheet spriteSheet;
|
|
|
|
struct SpritePalette spritePal;
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedArrowCursor *data;
|
2018-05-19 11:36:31 +02:00
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
u8 taskId;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
spriteSheet.data = sRedArrowGfx;
|
2018-05-19 11:36:31 +02:00
|
|
|
spriteSheet.size = 0x80;
|
|
|
|
spriteSheet.tag = cursor->tileTag;
|
2018-12-17 23:00:08 +01:00
|
|
|
LoadCompressedSpriteSheet(&spriteSheet);
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (cursor->palTag == SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
LoadPalette(sRedArrowPal, (16 * cursor->palNum) + 0x100, 0x20);
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
spritePal.data = sRedArrowPal;
|
2018-05-19 11:36:31 +02:00
|
|
|
spritePal.tag = cursor->palTag;
|
|
|
|
LoadSpritePalette(&spritePal);
|
|
|
|
}
|
|
|
|
|
|
|
|
taskId = CreateTask(Task_RedArrowCursor, 0);
|
|
|
|
data = (void*) gTasks[taskId].data;
|
|
|
|
|
|
|
|
data->tileTag = cursor->tileTag;
|
|
|
|
data->palTag = cursor->palTag;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
spriteTemplate = sSpriteTemplate_RedArrowCursor;
|
2018-05-19 11:36:31 +02:00
|
|
|
spriteTemplate.tileTag = cursor->tileTag;
|
|
|
|
spriteTemplate.paletteTag = cursor->palTag;
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
data->spriteId = CreateSprite(&spriteTemplate, cursor->left, cursor->top, 0);
|
|
|
|
gSprites[data->spriteId].pos2.x = 8;
|
|
|
|
gSprites[data->spriteId].pos2.y = 8;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (cursor->palTag == SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[data->spriteId].oam.paletteNum = cursor->palNum;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ListMenuUpdateRedArrowCursorObject(u8 taskId, u16 x, u16 y)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedArrowCursor *data = (void*) gTasks[taskId].data;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
gSprites[data->spriteId].pos1.x = x;
|
|
|
|
gSprites[data->spriteId].pos1.y = y;
|
2018-05-19 11:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ListMenuRemoveRedArrowCursorObject(u8 taskId)
|
|
|
|
{
|
2018-07-15 13:23:38 +02:00
|
|
|
struct RedArrowCursor *data = (void*) gTasks[taskId].data;
|
2018-05-19 11:36:31 +02:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
if (data->tileTag != SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
FreeSpriteTilesByTag(data->tileTag);
|
2018-07-15 13:23:38 +02:00
|
|
|
if (data->palTag != SPRITE_INVALID_TAG)
|
2018-05-19 11:36:31 +02:00
|
|
|
FreeSpritePaletteByTag(data->palTag);
|
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
DestroySprite(&gSprites[data->spriteId]);
|
2018-05-19 11:36:31 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|