diff --git a/include/list_menu.h b/include/list_menu.h index e70a92bab..9299ede6c 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -7,12 +7,20 @@ #define LIST_CANCEL -2 #define LIST_HEADER -3 -#define LIST_NO_MULTIPLE_SCROLL 0 -#define LIST_MULTIPLE_SCROLL_DPAD 1 -#define LIST_MULTIPLE_SCROLL_L_R 2 +enum { + LIST_NO_MULTIPLE_SCROLL, + LIST_MULTIPLE_SCROLL_DPAD, + LIST_MULTIPLE_SCROLL_L_R, +}; -enum -{ +enum { + CURSOR_BLACK_ARROW, + CURSOR_INVISIBLE, + CURSOR_RED_OUTLINE, + CURSOR_RED_ARROW, +}; + +enum { SCROLL_ARROW_LEFT, SCROLL_ARROW_RIGHT, SCROLL_ARROW_UP, diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 67afaefe1..4f72a7463 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -160,7 +160,7 @@ static const struct ListMenuTemplate sListMenuTemplate = .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NARROW, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; enum { diff --git a/src/data/union_room.h b/src/data/union_room.h index a4e01bd53..533425fa8 100644 --- a/src/data/union_room.h +++ b/src/data/union_room.h @@ -719,7 +719,7 @@ static const struct ListMenuTemplate sListMenuTemplate_PossibleGroupMembers = { .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 1 + .cursorKind = CURSOR_INVISIBLE }; static const struct WindowTemplate sWindowTemplate_GroupList = { @@ -779,7 +779,7 @@ static const struct ListMenuTemplate sListMenuTemplate_UnionRoomGroups = { .itemVerticalPadding = 0, .scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct WindowTemplate sWindowTemplate_InviteToActivity = { @@ -817,7 +817,7 @@ static const struct ListMenuTemplate sListMenuTemplate_InviteToActivity = { .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct WindowTemplate sWindowTemplate_RegisterForTrade = { @@ -854,7 +854,7 @@ static const struct ListMenuTemplate sListMenuTemplate_RegisterForTrade = { .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct WindowTemplate sWindowTemplate_TradingBoardRequestType = { @@ -906,7 +906,7 @@ static const struct ListMenuTemplate sMenuTemplate_TradingBoardRequestType = { .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct WindowTemplate sWindowTemplate_TradingBoardHeader = { @@ -960,7 +960,7 @@ static const struct ListMenuTemplate sTradeBoardListMenuTemplate = { .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; // Unused @@ -1012,7 +1012,7 @@ static const struct ListMenuTemplate sEmptyListMenuTemplate = { .itemVerticalPadding = 0, .scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct RfuPlayerData sUnionRoomPlayer_DummyRfu = {0}; diff --git a/src/daycare.c b/src/daycare.c index 19d5edbb2..464be1475 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -78,7 +78,7 @@ static const struct ListMenuTemplate sDaycareListMenuLevelTemplate = .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const u8 *const sCompatibilityMessages[] = diff --git a/src/field_specials.c b/src/field_specials.c index 11ae04f55..22292cc4b 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -2536,9 +2536,9 @@ static void InitScrollableMultichoice(void) gScrollableMultichoice_ListMenuTemplate.cursorShadowPal = 3; gScrollableMultichoice_ListMenuTemplate.lettersSpacing = 0; gScrollableMultichoice_ListMenuTemplate.itemVerticalPadding = 0; - gScrollableMultichoice_ListMenuTemplate.scrollMultiple = 0; + gScrollableMultichoice_ListMenuTemplate.scrollMultiple = LIST_NO_MULTIPLE_SCROLL; gScrollableMultichoice_ListMenuTemplate.fontId = FONT_NORMAL; - gScrollableMultichoice_ListMenuTemplate.cursorKind = 0; + gScrollableMultichoice_ListMenuTemplate.cursorKind = CURSOR_BLACK_ARROW; } static void ScrollableMultichoice_MoveCursor(s32 itemIndex, bool8 onInit, struct ListMenu *list) diff --git a/src/item_menu.c b/src/item_menu.c index 9e7966528..4d3d365e5 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -259,9 +259,9 @@ static const struct ListMenuTemplate sItemListMenu = .cursorShadowPal = 3, .lettersSpacing = 0, .itemVerticalPadding = 0, - .scrollMultiple = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NARROW, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct MenuAction sItemMenuActions[] = { diff --git a/src/list_menu.c b/src/list_menu.c index 112fca753..35b777fd3 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -13,6 +13,10 @@ #include "sound.h" #include "constants/songs.h" +// Cursors after this point are created using a sprite with their own task. +// This allows them to have idle animations. Cursors prior to this are simply printed text. +#define CURSOR_OBJECT_START CURSOR_RED_OUTLINE + struct UnkIndicatorsStruct { u8 field_0; @@ -70,7 +74,7 @@ static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAn static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count); static void ListMenuDrawCursor(struct ListMenu *list); static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 onInit); -static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind); +static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorObjId); static void Task_ScrollIndicatorArrowPair(u8 taskId); static u8 ListMenuAddRedOutlineCursorObject(struct CursorStruct *cursor); static u8 ListMenuAddRedArrowCursorObject(struct CursorStruct *cursor); @@ -78,9 +82,9 @@ 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); +static u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorObjId); +static void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorObjId); +static void ListMenuRemoveCursorObject(u8 taskId, u32 cursorObjId); static void SpriteCallback_ScrollIndicatorArrow(struct Sprite *sprite); static void SpriteCallback_RedArrowCursor(struct Sprite *sprite); @@ -477,7 +481,7 @@ void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow) *selectedRow = list->selectedRow; if (list->taskId != TASK_NONE) - ListMenuRemoveCursorObject(list->taskId, list->template.cursorKind - 2); + ListMenuRemoveCursorObject(list->taskId, list->template.cursorKind - CURSOR_OBJECT_START); DestroyTask(listTaskId); } @@ -650,31 +654,33 @@ static void ListMenuDrawCursor(struct ListMenu *list) u8 y = list->selectedRow * yMultiplier + list->template.upText_Y; switch (list->template.cursorKind) { - case 0: + case CURSOR_BLACK_ARROW: ListMenuPrint(list, gText_SelectorArrow2, x, y); break; - case 1: + case CURSOR_INVISIBLE: break; - case 2: + case CURSOR_RED_OUTLINE: if (list->taskId == TASK_NONE) - list->taskId = ListMenuAddCursorObject(list, 0); + list->taskId = ListMenuAddCursorObject(list, CURSOR_RED_OUTLINE - CURSOR_OBJECT_START); ListMenuUpdateCursorObject(list->taskId, GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 - 1, - GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y - 1, 0); + GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y - 1, + CURSOR_RED_OUTLINE - CURSOR_OBJECT_START); break; - case 3: + case CURSOR_RED_ARROW: if (list->taskId == TASK_NONE) - list->taskId = ListMenuAddCursorObject(list, 1); + list->taskId = ListMenuAddCursorObject(list, CURSOR_RED_ARROW - CURSOR_OBJECT_START); ListMenuUpdateCursorObject(list->taskId, GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 + x, - GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y, 1); + GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y, + CURSOR_RED_ARROW - CURSOR_OBJECT_START); break; } } #undef TASK_NONE -static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind) +static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorObjId) { struct CursorStruct cursor; @@ -686,13 +692,13 @@ static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind) cursor.palTag = TAG_NONE; cursor.palNum = 15; - return ListMenuAddCursorObjectInternal(&cursor, cursorKind); + return ListMenuAddCursorObjectInternal(&cursor, cursorObjId); } static void ListMenuErasePrintedCursor(struct ListMenu *list, u16 selectedRow) { u8 cursorKind = list->template.cursorKind; - if (cursorKind == 0) + if (cursorKind == CURSOR_BLACK_ARROW) { u8 yMultiplier = GetFontAttribute(list->template.fontId, FONTATTR_MAX_LETTER_HEIGHT) + list->template.itemVerticalPadding; u8 width = GetMenuCursorDimensionByFont(list->template.fontId, 0); @@ -1190,39 +1196,39 @@ void RemoveScrollIndicatorArrowPair(u8 taskId) DestroyTask(taskId); } -static u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorKind) +static u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorObjId) { - switch (cursorKind) + switch (cursorObjId) { - case 0: + case CURSOR_RED_OUTLINE - CURSOR_OBJECT_START: default: return ListMenuAddRedOutlineCursorObject(cursor); - case 1: + case CURSOR_RED_ARROW - CURSOR_OBJECT_START: return ListMenuAddRedArrowCursorObject(cursor); } } -static void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorKind) +static void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorObjId) { - switch (cursorKind) + switch (cursorObjId) { - case 0: + case CURSOR_RED_OUTLINE - CURSOR_OBJECT_START: ListMenuUpdateRedOutlineCursorObject(taskId, x, y); break; - case 1: + case CURSOR_RED_ARROW - CURSOR_OBJECT_START: ListMenuUpdateRedArrowCursorObject(taskId, x, y); break; } } -static void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind) +static void ListMenuRemoveCursorObject(u8 taskId, u32 cursorObjId) { - switch (cursorKind) + switch (cursorObjId) { - case 0: + case CURSOR_RED_OUTLINE - CURSOR_OBJECT_START: ListMenuRemoveRedOutlineCursorObject(taskId); break; - case 1: + case CURSOR_RED_ARROW - CURSOR_OBJECT_START: ListMenuRemoveRedArrowCursorObject(taskId); break; } diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 42c80b5ee..50b8ff7e8 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -187,7 +187,7 @@ static const struct ListMenuTemplate sMoveRelearnerMovesListTemplate = .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; //-------------- @@ -284,7 +284,7 @@ u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page) gMultiuseListMenuTemplate.moveCursorFunc = MailboxMenu_MoveCursorFunc; gMultiuseListMenuTemplate.itemPrintFunc = MailboxMenu_ItemPrintFunc; gMultiuseListMenuTemplate.fontId = FONT_NORMAL; - gMultiuseListMenuTemplate.cursorKind = 0; + gMultiuseListMenuTemplate.cursorKind = CURSOR_BLACK_ARROW; gMultiuseListMenuTemplate.lettersSpacing = 0; gMultiuseListMenuTemplate.itemVerticalPadding = 0; gMultiuseListMenuTemplate.scrollMultiple = LIST_NO_MULTIPLE_SCROLL; diff --git a/src/mystery_gift_menu.c b/src/mystery_gift_menu.c index 4b81c81a3..ff7c97150 100644 --- a/src/mystery_gift_menu.c +++ b/src/mystery_gift_menu.c @@ -234,9 +234,9 @@ static const struct ListMenuTemplate sListMenuTemplate_ThreeOptions = { .cursorShadowPal = 3, .lettersSpacing = 0, .itemVerticalPadding = 0, - .scrollMultiple = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct ListMenuItem sListMenuItems_ReceiveSendToss[] = { @@ -279,9 +279,9 @@ static const struct ListMenuTemplate sListMenu_ReceiveSendToss = { .cursorShadowPal = 3, .lettersSpacing = 0, .itemVerticalPadding = 0, - .scrollMultiple = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct ListMenuTemplate sListMenu_ReceiveToss = { @@ -300,9 +300,9 @@ static const struct ListMenuTemplate sListMenu_ReceiveToss = { .cursorShadowPal = 3, .lettersSpacing = 0, .itemVerticalPadding = 0, - .scrollMultiple = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct ListMenuTemplate sListMenu_ReceiveSend = { @@ -321,9 +321,9 @@ static const struct ListMenuTemplate sListMenu_ReceiveSend = { .cursorShadowPal = 3, .lettersSpacing = 0, .itemVerticalPadding = 0, - .scrollMultiple = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct ListMenuTemplate sListMenu_Receive = { @@ -342,9 +342,9 @@ static const struct ListMenuTemplate sListMenu_Receive = { .cursorShadowPal = 3, .lettersSpacing = 0, .itemVerticalPadding = 0, - .scrollMultiple = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const u8 *const sUnusedMenuTexts[] = { diff --git a/src/pokeblock.c b/src/pokeblock.c index cf0513f80..481f84c4a 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -440,7 +440,7 @@ static const struct ListMenuTemplate sPokeblockListMenuTemplate = .itemVerticalPadding = 0, .scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD, .fontId = FONT_NORMAL, - .cursorKind = 1 + .cursorKind = CURSOR_INVISIBLE }; void OpenPokeblockCase(u8 caseId, void (*callback)(void)) diff --git a/src/secret_base.c b/src/secret_base.c index ea1999343..6344fb7ed 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -214,7 +214,7 @@ static const struct ListMenuTemplate sRegistryListMenuTemplate = .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NORMAL, - .cursorKind = 0, + .cursorKind = CURSOR_BLACK_ARROW, }; static void ClearSecretBase(struct SecretBase *secretBase) diff --git a/src/shop.c b/src/shop.c index b34bded84..d5e954635 100644 --- a/src/shop.c +++ b/src/shop.c @@ -216,7 +216,7 @@ static const struct ListMenuTemplate sShopBuyMenuListTemplate = .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .fontId = FONT_NARROW, - .cursorKind = 0 + .cursorKind = CURSOR_BLACK_ARROW }; static const struct BgTemplate sShopBuyMenuBgTemplates[] =