Clean up pokenav ribbons

This commit is contained in:
GriffinR 2021-11-09 12:50:35 -05:00
parent 1c82571fa0
commit 43e942c3af
6 changed files with 369 additions and 369 deletions

View File

@ -459,18 +459,18 @@ void CreateSearchResultsLoopedTask(s32);
u32 IsSearchResultLoopedTaskActive(void);
void FreeSearchResultSubstruct2(void);
// pokenav_ribbons_1.c
// pokenav_ribbons_list.c
u32 PokenavCallback_Init_MonRibbonList(void);
u32 PokenavCallback_Init_RibbonsMonListFromSummary(void);
u32 GetRibbonsMonListCallback(void);
void FreeRibbonsMonList1(void);
void FreeRibbonsMonList(void);
bool32 OpenRibbonsMonList(void);
bool32 OpenRibbonsMonListFromRibbonsSummary(void);
void CreateRibbonsMonListLoopedTask(s32);
u32 IsRibbonsMonListLoopedTaskActive(void);
void FreeRibbonsMonList2(void);
void FreeRibbonsMonMenu(void);
// pokenav_ribbons_2.c
// pokenav_ribbons_summary.c
u32 PokenavCallback_Init_RibbonsSummaryMenu(void);
u32 GetRibbonsSummaryMenuCallback(void);
void FreeRibbonsSummaryScreen1(void);

View File

@ -319,8 +319,8 @@ SECTIONS {
src/pokenav_conditions_1.o(.text);
src/pokenav_conditions_2.o(.text);
src/pokenav_conditions_3.o(.text);
src/pokenav_ribbons_1.o(.text);
src/pokenav_ribbons_2.o(.text);
src/pokenav_ribbons_list.o(.text);
src/pokenav_ribbons_summary.o(.text);
src/pokenav_match_call_data.o(.text);
src/menu_specialized.o(.text);
src/ereader_helpers.o(.text);
@ -673,8 +673,8 @@ SECTIONS {
src/pokenav_region_map.o(.rodata);
src/pokenav_conditions_2.o(.rodata);
src/pokenav_conditions_3.o(.rodata);
src/pokenav_ribbons_1.o(.rodata);
src/pokenav_ribbons_2.o(.rodata);
src/pokenav_ribbons_list.o(.rodata);
src/pokenav_ribbons_summary.o(.rodata);
src/pokenav_match_call_data.o(.rodata);
src/menu_specialized.o(.rodata);
src/ereader_helpers.o(.rodata);

View File

@ -179,8 +179,8 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.open = OpenRibbonsMonList,
.createLoopTask = CreateRibbonsMonListLoopedTask,
.isLoopTaskActive = IsRibbonsMonListLoopedTaskActive,
.free1 = FreeRibbonsMonList1,
.free2 = FreeRibbonsMonList2,
.free1 = FreeRibbonsMonList,
.free2 = FreeRibbonsMonMenu,
},
[POKENAV_RIBBONS_SUMMARY_SCREEN - POKENAV_MENU_IDS_START] =
{
@ -199,8 +199,8 @@ const struct PokenavCallbacks PokenavMenuCallbacks[15] =
.open = OpenRibbonsMonListFromRibbonsSummary,
.createLoopTask = CreateRibbonsMonListLoopedTask,
.isLoopTaskActive = IsRibbonsMonListLoopedTaskActive,
.free1 = FreeRibbonsMonList1,
.free2 = FreeRibbonsMonList2,
.free1 = FreeRibbonsMonList,
.free2 = FreeRibbonsMonMenu,
},
};

View File

@ -20,9 +20,9 @@ enum
};
struct PokenavSub9
struct Pokenav_RibbonsMonList
{
u32 (*callback)(struct PokenavSub9*);
u32 (*callback)(struct Pokenav_RibbonsMonList*);
u32 loopedTaskId;
u16 winid;
s32 boxId;
@ -32,35 +32,35 @@ struct PokenavSub9
struct PokenavSub18 *monList;
};
struct PokenavSub10
struct Pokenav_RibbonsMonMenu
{
bool32 (*callback)(void);
u32 ltid;
u32 loopedTaskId;
u16 winid;
bool32 fromSummary;
u8 buff[BG_SCREEN_SIZE];
};
static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr);
static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr);
static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr);
static u32 RibbonsMonMenu_ToSummaryScreen(struct PokenavSub9 *structPtr);
static u32 BuildPartyMonRibbonList(s32 state);
static u32 InitBoxMonRibbonList(s32 state);
static u32 BuildBoxMonRibbonList(s32 state);
static u32 GetMonRibbonListLoopTaskFunc(s32 state);
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item);
static u32 LoopedTask_OpenRibbonsMonList(s32 state);
static u32 HandleRibbonsMonListInput_WaitListInit(struct Pokenav_RibbonsMonList *);
static u32 HandleRibbonsMonListInput(struct Pokenav_RibbonsMonList *);
static u32 RibbonsMonMenu_ReturnToMainMenu(struct Pokenav_RibbonsMonList *);
static u32 RibbonsMonMenu_ToSummaryScreen(struct Pokenav_RibbonsMonList *);
static u32 BuildPartyMonRibbonList(s32);
static u32 InitBoxMonRibbonList(s32);
static u32 BuildBoxMonRibbonList(s32);
static u32 GetMonRibbonListLoopTaskFunc(s32);
static void InsertMonListItem(struct Pokenav_RibbonsMonList *, struct PokenavMonList *);
static u32 LoopedTask_OpenRibbonsMonList(s32);
static bool32 GetRibbonsMonCurrentLoopedTaskActive(void);
static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state);
static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state);
static u32 LoopedTask_RibbonsListMovePageUp(s32 state);
static u32 LoopedTask_RibbonsListMovePageDown(s32 state);
static u32 LoopedTask_RibbonsListReturnToMainMenu(s32 state);
static u32 LoopedTask_RibbonsListOpenSummary(s32 state);
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2);
static void AddRibbonsMonListWindow(struct PokenavSub10 *ptr);
static void sub_81D0288(struct PokenavSub10 *ptr);
static u32 LoopedTask_RibbonsListMoveCursorUp(s32);
static u32 LoopedTask_RibbonsListMoveCursorDown(s32);
static u32 LoopedTask_RibbonsListMovePageUp(s32);
static u32 LoopedTask_RibbonsListMovePageDown(s32);
static u32 LoopedTask_RibbonsListReturnToMainMenu(s32);
static u32 LoopedTask_RibbonsListOpenSummary(s32);
static void DrawListIndexNumber(s32, s32, s32);
static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *);
static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *);
static void InitMonRibbonPokenavListMenuTemplate(void);
static void BufferRibbonMonInfoText(struct PokenavMonList *, u8 *);
@ -125,54 +125,54 @@ static const u8 sText_NoGenderSymbol[] = _("{UNK_SPACER}");
bool32 PokenavCallback_Init_MonRibbonList(void)
{
struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9));
if (structPtr == NULL)
struct Pokenav_RibbonsMonList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct Pokenav_RibbonsMonList));
if (list == NULL)
return FALSE;
structPtr->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
if (structPtr->monList == NULL)
list->monList = AllocSubstruct(POKENAV_SUBSTRUCT_MON_LIST, sizeof(struct PokenavSub18));
if (list->monList == NULL)
return FALSE;
structPtr->callback = HandleRibbonsMonListInput_WaitListInit;
structPtr->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1);
structPtr->changeBgs = 0;
list->callback = HandleRibbonsMonListInput_WaitListInit;
list->loopedTaskId = CreateLoopedTask(GetMonRibbonListLoopTaskFunc, 1);
list->changeBgs = 0;
return TRUE;
}
bool32 PokenavCallback_Init_RibbonsMonListFromSummary(void)
{
struct PokenavSub9 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct PokenavSub9));
if (structPtr == NULL)
struct Pokenav_RibbonsMonList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST, sizeof(struct Pokenav_RibbonsMonList));
if (list == NULL)
return FALSE;
structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
structPtr->callback = HandleRibbonsMonListInput;
structPtr->changeBgs = 1;
list->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
list->callback = HandleRibbonsMonListInput;
list->changeBgs = 1;
return TRUE;
}
u32 GetRibbonsMonListCallback(void)
{
struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return structPtr->callback(structPtr);
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->callback(list);
}
void FreeRibbonsMonList1(void)
void FreeRibbonsMonList(void)
{
struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
if (!structPtr->saveMonList)
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
if (!list->saveMonList)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_MON_LIST);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
}
static u32 HandleRibbonsMonListInput_WaitListInit(struct PokenavSub9 *structPtr)
static u32 HandleRibbonsMonListInput_WaitListInit(struct Pokenav_RibbonsMonList *list)
{
if (!IsLoopedTaskActive(structPtr->loopedTaskId))
structPtr->callback = HandleRibbonsMonListInput;
if (!IsLoopedTaskActive(list->loopedTaskId))
list->callback = HandleRibbonsMonListInput;
return 0;
}
static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr)
static u32 HandleRibbonsMonListInput(struct Pokenav_RibbonsMonList *list)
{
if (JOY_REPEAT(DPAD_UP))
return RIBBONS_MON_LIST_FUNC_MOVE_UP;
@ -184,60 +184,60 @@ static u32 HandleRibbonsMonListInput(struct PokenavSub9 *structPtr)
return RIBBONS_MON_LIST_FUNC_PAGE_DOWN;
if (JOY_NEW(B_BUTTON))
{
structPtr->saveMonList = 0;
structPtr->callback = RibbonsMonMenu_ReturnToMainMenu;
list->saveMonList = 0;
list->callback = RibbonsMonMenu_ReturnToMainMenu;
return RIBBONS_MON_LIST_FUNC_EXIT;
}
if (JOY_NEW(A_BUTTON))
{
structPtr->monList->currIndex = GetSelectedPokenavListIndex();
structPtr->saveMonList = 1;
structPtr->callback = RibbonsMonMenu_ToSummaryScreen;
list->monList->currIndex = GetSelectedPokenavListIndex();
list->saveMonList = 1;
list->callback = RibbonsMonMenu_ToSummaryScreen;
return RIBBONS_MON_LIST_FUNC_OPEN_RIBBONS_SUMMARY;
}
return RIBBONS_MON_LIST_FUNC_NONE;
}
static u32 RibbonsMonMenu_ReturnToMainMenu(struct PokenavSub9 *structPtr)
static u32 RibbonsMonMenu_ReturnToMainMenu(struct Pokenav_RibbonsMonList *list)
{
return POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS;
}
static u32 RibbonsMonMenu_ToSummaryScreen(struct PokenavSub9 *structPtr)
static u32 RibbonsMonMenu_ToSummaryScreen(struct Pokenav_RibbonsMonList *list)
{
return POKENAV_RIBBONS_SUMMARY_SCREEN;
}
static u32 UpdateMonListBgs(void)
{
struct PokenavSub9 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return structPtr->changeBgs;
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->changeBgs;
}
static struct PokenavMonList *GetMonRibbonMonListData(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->monList->monData;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->monList->monData;
}
static s32 GetRibbonsMonListCount(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->monList->listCount;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->monList->listCount;
}
//unused
static s32 GetMonRibbonSelectedMonData(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 idx = GetSelectedPokenavListIndex();
return ptr->monList->monData[idx].data;
return list->monList->monData[idx].data;
}
static s32 GetRibbonListMenuCurrIndex(void)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return ptr->monList->currIndex;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
return list->monList->currIndex;
}
static u32 GetMonRibbonListLoopTaskFunc(s32 state)
@ -249,10 +249,10 @@ static u32 BuildPartyMonRibbonList(s32 state)
{
s32 i;
struct PokenavMonList item;
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
ptr->monList->listCount = 0;
ptr->monList->currIndex = 0;
list->monList->listCount = 0;
list->monList->currIndex = 0;
item.boxId = TOTAL_BOXES_COUNT;
for (i = 0; i < PARTY_SIZE; i++)
{
@ -266,7 +266,7 @@ static u32 BuildPartyMonRibbonList(s32 state)
{
item.monId = i;
item.data = ribbonCount;
sub_81CFCEC(ptr, &item);
InsertMonListItem(list, &item);
}
}
}
@ -276,17 +276,17 @@ static u32 BuildPartyMonRibbonList(s32 state)
static u32 InitBoxMonRibbonList(s32 state)
{
struct PokenavSub9 *ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
ptr->monId = 0;
ptr->boxId = 0;
struct Pokenav_RibbonsMonList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
list->monId = 0;
list->boxId = 0;
return LT_INC_AND_CONTINUE;
}
static u32 BuildBoxMonRibbonList(s32 state)
{
struct PokenavSub9 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 boxId = ptr->boxId;
s32 monId = ptr->monId;
struct Pokenav_RibbonsMonList * list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_LIST);
s32 boxId = list->boxId;
s32 monId = list->monId;
s32 boxCount = 0;
struct PokenavMonList item;
@ -302,15 +302,15 @@ static u32 BuildBoxMonRibbonList(s32 state)
item.boxId = boxId;
item.monId = monId;
item.data = ribbonCount;
sub_81CFCEC(ptr, &item);
InsertMonListItem(list, &item);
}
}
boxCount++;
monId++;
if (boxCount > TOTAL_BOXES_COUNT)
{
ptr->boxId = boxId;
ptr->monId = monId;
list->boxId = boxId;
list->monId = monId;
return LT_CONTINUE;
}
}
@ -318,28 +318,28 @@ static u32 BuildBoxMonRibbonList(s32 state)
boxId++;
}
ptr->changeBgs = 1;
list->changeBgs = 1;
return LT_FINISH;
}
static void sub_81CFCEC(struct PokenavSub9 *structPtr, struct PokenavMonList *item)
static void InsertMonListItem(struct Pokenav_RibbonsMonList *list, struct PokenavMonList *item)
{
u32 left = 0;
u32 right = structPtr->monList->listCount;
u32 right = list->monList->listCount;
u32 insertionIdx = left + (right - left) / 2;
while (right != insertionIdx)
{
if (item->data > structPtr->monList->monData[insertionIdx].data)
if (item->data > list->monList->monData[insertionIdx].data)
right = insertionIdx;
else
left = insertionIdx + 1;
insertionIdx = left + (right - left) / 2;
}
for (right = structPtr->monList->listCount; right > insertionIdx; right--)
structPtr->monList->monData[right] = structPtr->monList->monData[right - 1];
structPtr->monList->monData[insertionIdx] = *item;
structPtr->monList->listCount++;
for (right = list->monList->listCount; right > insertionIdx; right--)
list->monList->monData[right] = list->monList->monData[right - 1];
list->monList->monData[insertionIdx] = *item;
list->monList->listCount++;
}
// Unused
@ -374,62 +374,62 @@ static bool32 PlayerHasRibbonsMon(void)
bool32 OpenRibbonsMonList(void)
{
struct PokenavSub10 *ptr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10));
if (ptr == NULL)
struct Pokenav_RibbonsMonMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct Pokenav_RibbonsMonMenu));
if (menu == NULL)
return FALSE;
ptr->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
ptr->callback = GetRibbonsMonCurrentLoopedTaskActive;
ptr->fromSummary = FALSE;
menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
menu->callback = GetRibbonsMonCurrentLoopedTaskActive;
menu->fromSummary = FALSE;
return TRUE;
}
bool32 OpenRibbonsMonListFromRibbonsSummary(void)
{
struct PokenavSub10 *monMenu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct PokenavSub10));
if (monMenu == NULL)
struct Pokenav_RibbonsMonMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU, sizeof(struct Pokenav_RibbonsMonMenu));
if (menu == NULL)
return FALSE;
monMenu->ltid = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive;
monMenu->fromSummary = TRUE;
menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsMonList, 1);
menu->callback = GetRibbonsMonCurrentLoopedTaskActive;
menu->fromSummary = TRUE;
return TRUE;
}
void CreateRibbonsMonListLoopedTask(s32 idx)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
monMenu->ltid = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1);
monMenu->callback = GetRibbonsMonCurrentLoopedTaskActive;
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
menu->loopedTaskId = CreateLoopedTask(sRibbonsMonMenuLoopTaskFuncs[idx], 1);
menu->callback = GetRibbonsMonCurrentLoopedTaskActive;
}
bool32 IsRibbonsMonListLoopedTaskActive(void)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return monMenu->callback();
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return menu->callback();
}
bool32 GetRibbonsMonCurrentLoopedTaskActive(void)
{
struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return IsLoopedTaskActive(ptr->ltid);
struct Pokenav_RibbonsMonMenu * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
return IsLoopedTaskActive(menu->loopedTaskId);
}
void FreeRibbonsMonList2(void)
void FreeRibbonsMonMenu(void)
{
struct PokenavSub10 * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu * menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
sub_81C8234();
RemoveWindow(ptr->winid);
RemoveWindow(menu->winid);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
}
static u32 LoopedTask_OpenRibbonsMonList(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
InitBgTemplates(sMonRibbonListBgTemplates, ARRAY_COUNT(sMonRibbonListBgTemplates));
DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0);
SetBgTilemapBuffer(1, monMenu->buff);
SetBgTilemapBuffer(1, menu->buff);
CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0);
CopyPaletteIntoBufferUnfaded(sMonRibbonListFramePal, 0x10, 0x20);
CopyBgTilemapBufferToVram(1);
@ -452,7 +452,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state)
case 3:
if (sub_81C8224())
return LT_PAUSE;
AddRibbonsMonListWindow(monMenu);
AddRibbonsMonListWindow(menu);
return LT_INC_AND_PAUSE;
case 4:
if (FreeTempTileDataBuffersIfPossible())
@ -461,7 +461,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state)
HideBg(3);
PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST);
PokenavFadeScreen(1);
if (!monMenu->fromSummary)
if (!menu->fromSummary)
{
LoadLeftHeaderGfxForIndex(POKENAV_GFX_RIBBONS_MENU);
ShowLeftHeaderGfx(POKENAV_GFX_RIBBONS_MENU, 1, 0);
@ -479,7 +479,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state)
static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
@ -500,7 +500,7 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state)
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -512,7 +512,7 @@ static u32 LoopedTask_RibbonsListMoveCursorUp(s32 state)
static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
@ -533,7 +533,7 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state)
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -545,7 +545,7 @@ static u32 LoopedTask_RibbonsListMoveCursorDown(s32 state)
static u32 LoopedTask_RibbonsListMovePageUp(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
@ -566,7 +566,7 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state)
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -578,7 +578,7 @@ static u32 LoopedTask_RibbonsListMovePageUp(s32 state)
static u32 LoopedTask_RibbonsListMovePageDown(s32 state)
{
struct PokenavSub10 *monMenu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
struct Pokenav_RibbonsMonMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_MON_MENU);
switch (state)
{
case 0:
@ -599,7 +599,7 @@ static u32 LoopedTask_RibbonsListMovePageDown(s32 state)
return LT_PAUSE;
// fallthrough
case 2:
sub_81D0288(monMenu);
UpdateIndexNumberDisplay(menu);
return LT_INC_AND_PAUSE;
case 3:
if (IsDma3ManagerBusyWithBgCopy())
@ -645,34 +645,34 @@ static u32 LoopedTask_RibbonsListOpenSummary(s32 state)
return LT_FINISH;
}
static void AddRibbonsMonListWindow(struct PokenavSub10 *monMenu)
static void AddRibbonsMonListWindow(struct Pokenav_RibbonsMonMenu *menu)
{
s32 r2;
monMenu->winid = AddWindow(&sRibbonsMonListWindowTemplate);
PutWindowTilemap(monMenu->winid);
r2 = GetRibbonsMonListCount();
sub_81D02B0(monMenu->winid, 0, r2);
CopyWindowToVram(monMenu->winid, COPYWIN_MAP);
sub_81D0288(monMenu);
s32 listCount;
menu->winid = AddWindow(&sRibbonsMonListWindowTemplate);
PutWindowTilemap(menu->winid);
listCount = GetRibbonsMonListCount();
DrawListIndexNumber(menu->winid, 0, listCount);
CopyWindowToVram(menu->winid, COPYWIN_MAP);
UpdateIndexNumberDisplay(menu);
}
static void sub_81D0288(struct PokenavSub10 *monMenu)
static void UpdateIndexNumberDisplay(struct Pokenav_RibbonsMonMenu *menu)
{
s32 r4 = GetSelectedPokenavListIndex();
s32 r2 = GetRibbonsMonListCount();
sub_81D02B0(monMenu->winid, r4 + 1, r2);
CopyWindowToVram(monMenu->winid, COPYWIN_GFX);
s32 listIndex = GetSelectedPokenavListIndex();
s32 listCount = GetRibbonsMonListCount();
DrawListIndexNumber(menu->winid, listIndex + 1, listCount);
CopyWindowToVram(menu->winid, COPYWIN_GFX);
}
static void sub_81D02B0(s32 windowId, s32 val1, s32 val2)
static void DrawListIndexNumber(s32 windowId, s32 index, s32 max)
{
u8 strbuf[16];
u32 x;
u8 * ptr = strbuf;
ptr = ConvertIntToDecimalStringN(ptr, val1, STR_CONV_MODE_RIGHT_ALIGN, 3);
ptr = ConvertIntToDecimalStringN(ptr, index, STR_CONV_MODE_RIGHT_ALIGN, 3);
*ptr++ = CHAR_SLASH;
ConvertIntToDecimalStringN(ptr, val2, STR_CONV_MODE_RIGHT_ALIGN, 3);
ConvertIntToDecimalStringN(ptr, max, STR_CONV_MODE_RIGHT_ALIGN, 3);
x = GetStringCenterAlignXOffset(FONT_NORMAL, strbuf, 56);
AddTextPrinterParameterized(windowId, FONT_NORMAL, strbuf, x, 1, TEXT_SKIP_DRAW, NULL);
}

View File

@ -39,7 +39,7 @@ enum
#define MON_SPRITE_X_OFF -32
#define MON_SPRITE_Y 104
struct PokenavSub13
struct Pokenav_RibbonsSummaryList
{
u8 unused1[8];
struct PokenavSub18 *monList;
@ -50,10 +50,10 @@ struct PokenavSub13
u32 ribbonIds[FIRST_GIFT_RIBBON];
u32 giftRibbonIds[NUM_GIFT_RIBBONS];
u32 unused2;
u32 (*callback)(struct PokenavSub13 *);
u32 (*callback)(struct Pokenav_RibbonsSummaryList *);
};
struct PokenavSub14
struct Pokenav_RibbonsSummaryMenu
{
u32 (*callback)(void);
u32 loopedTaskId;
@ -71,31 +71,31 @@ struct PokenavSub14
static u32 sRibbonDraw_Total;
static u32 sRibbonDraw_Current;
static void PrintCurrentMonRibbonCount(struct PokenavSub14 *);
static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *);
static void PrintRibbonsMonListIndex(struct PokenavSub14 *);
static void ZoomOutSelectedRibbon(struct PokenavSub14 *);
static void UpdateAndZoomInSelectedRibbon(struct PokenavSub14 *);
static void PrintRibbonNameAndDescription(struct PokenavSub14 *);
static void ResetSpritesAndDrawMonFrontPic(struct PokenavSub14 *);
static void AddRibbonListIndexWindow(struct PokenavSub14 *);
static void DestroyRibbonsMonFrontPic(struct PokenavSub14 *);
static void SlideMonSpriteOff(struct PokenavSub14 *);
static void SlideMonSpriteOn(struct PokenavSub14 *);
static void AddRibbonCountWindow(struct PokenavSub14 *);
static void CreateBigRibbonSprite(struct PokenavSub14 *);
static void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *);
static void DrawAllRibbonsSmall(struct PokenavSub14 *);
static bool32 IsRibbonAnimating(struct PokenavSub14 *);
static bool32 IsMonSpriteAnimating(struct PokenavSub14 *);
static void GetMonRibbons(struct PokenavSub13 *);
static u32 HandleExpandedRibbonInput(struct PokenavSub13 *);
static u32 RibbonsSummaryHandleInput(struct PokenavSub13 *);
static u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *);
static bool32 TrySelectRibbonUp(struct PokenavSub13 *);
static bool32 TrySelectRibbonRight(struct PokenavSub13 *);
static bool32 TrySelectRibbonLeft(struct PokenavSub13 *);
static bool32 TrySelectRibbonDown(struct PokenavSub13 *);
static void PrintCurrentMonRibbonCount(struct Pokenav_RibbonsSummaryMenu *);
static void PrintRibbbonsSummaryMonInfo(struct Pokenav_RibbonsSummaryMenu *);
static void PrintRibbonsMonListIndex(struct Pokenav_RibbonsSummaryMenu *);
static void ZoomOutSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *);
static void UpdateAndZoomInSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *);
static void PrintRibbonNameAndDescription(struct Pokenav_RibbonsSummaryMenu *);
static void ResetSpritesAndDrawMonFrontPic(struct Pokenav_RibbonsSummaryMenu *);
static void AddRibbonListIndexWindow(struct Pokenav_RibbonsSummaryMenu *);
static void DestroyRibbonsMonFrontPic(struct Pokenav_RibbonsSummaryMenu *);
static void SlideMonSpriteOff(struct Pokenav_RibbonsSummaryMenu *);
static void SlideMonSpriteOn(struct Pokenav_RibbonsSummaryMenu *);
static void AddRibbonCountWindow(struct Pokenav_RibbonsSummaryMenu *);
static void CreateBigRibbonSprite(struct Pokenav_RibbonsSummaryMenu *);
static void AddRibbonSummaryMonNameWindow(struct Pokenav_RibbonsSummaryMenu *);
static void DrawAllRibbonsSmall(struct Pokenav_RibbonsSummaryMenu *);
static bool32 IsRibbonAnimating(struct Pokenav_RibbonsSummaryMenu *);
static bool32 IsMonSpriteAnimating(struct Pokenav_RibbonsSummaryMenu *);
static void GetMonRibbons(struct Pokenav_RibbonsSummaryList *);
static u32 HandleExpandedRibbonInput(struct Pokenav_RibbonsSummaryList *);
static u32 RibbonsSummaryHandleInput(struct Pokenav_RibbonsSummaryList *);
static u32 ReturnToRibbonsListFromSummary(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonUp(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonRight(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonLeft(struct Pokenav_RibbonsSummaryList *);
static bool32 TrySelectRibbonDown(struct Pokenav_RibbonsSummaryList *);
static bool32 GetCurrentLoopedTaskActive(void);
static u32 GetRibbonsSummaryCurrentIndex(void);
static u32 GetRibbonsSummaryMonListCount(void);
@ -186,16 +186,16 @@ static const LoopedTask sRibbonsSummaryMenuLoopTaskFuncs[] =
bool32 PokenavCallback_Init_RibbonsSummaryMenu(void)
{
struct PokenavSub13 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, sizeof(struct PokenavSub13));
if (structPtr == NULL)
struct Pokenav_RibbonsSummaryList *list = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST, sizeof(struct Pokenav_RibbonsSummaryList));
if (list == NULL)
return FALSE;
structPtr->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (structPtr->monList == NULL)
list->monList = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (list->monList == NULL)
return FALSE;
GetMonRibbons(structPtr);
structPtr->callback = RibbonsSummaryHandleInput;
GetMonRibbons(list);
list->callback = RibbonsSummaryHandleInput;
gKeyRepeatContinueDelay = 3;
gKeyRepeatStartDelay = 10;
return TRUE;
@ -203,8 +203,8 @@ bool32 PokenavCallback_Init_RibbonsSummaryMenu(void)
u32 GetRibbonsSummaryMenuCallback(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->callback(structPtr);
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->callback(list);
}
void FreeRibbonsSummaryScreen1(void)
@ -213,150 +213,150 @@ void FreeRibbonsSummaryScreen1(void)
}
// Handles input when a specific ribbon is not currently selected
static u32 RibbonsSummaryHandleInput(struct PokenavSub13 *structPtr)
static u32 RibbonsSummaryHandleInput(struct Pokenav_RibbonsSummaryList *list)
{
// Handle Up/Down movement to select a new Pokémon to show ribbons for
if (JOY_REPEAT(DPAD_UP) && structPtr->monList->currIndex != 0)
if (JOY_REPEAT(DPAD_UP) && list->monList->currIndex != 0)
{
structPtr->monList->currIndex--;
structPtr->selectedPos = 0;
GetMonRibbons(structPtr);
list->monList->currIndex--;
list->selectedPos = 0;
GetMonRibbons(list);
return RIBBONS_SUMMARY_FUNC_SWITCH_MONS;
}
if (JOY_REPEAT(DPAD_DOWN) && structPtr->monList->currIndex < structPtr->monList->listCount - 1)
if (JOY_REPEAT(DPAD_DOWN) && list->monList->currIndex < list->monList->listCount - 1)
{
structPtr->monList->currIndex++;
structPtr->selectedPos = 0;
GetMonRibbons(structPtr);
list->monList->currIndex++;
list->selectedPos = 0;
GetMonRibbons(list);
return RIBBONS_SUMMARY_FUNC_SWITCH_MONS;
}
if (JOY_NEW(A_BUTTON))
{
// Enter ribbon selection
structPtr->callback = HandleExpandedRibbonInput;
list->callback = HandleExpandedRibbonInput;
return RIBBONS_SUMMARY_FUNC_SELECT_RIBBON;
}
if (JOY_NEW(B_BUTTON))
{
// Exit ribbon summary menu
structPtr->callback = ReturnToRibbonsListFromSummary;
list->callback = ReturnToRibbonsListFromSummary;
return RIBBONS_SUMMARY_FUNC_EXIT;
}
return RIBBONS_SUMMARY_FUNC_NONE;
}
// Handles input when a ribbon is selected
static u32 HandleExpandedRibbonInput(struct PokenavSub13 *structPtr)
static u32 HandleExpandedRibbonInput(struct Pokenav_RibbonsSummaryList *list)
{
// Handle movement while a ribbon is selected
if (JOY_REPEAT(DPAD_UP) && TrySelectRibbonUp(structPtr))
if (JOY_REPEAT(DPAD_UP) && TrySelectRibbonUp(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_REPEAT(DPAD_DOWN) && TrySelectRibbonDown(structPtr))
if (JOY_REPEAT(DPAD_DOWN) && TrySelectRibbonDown(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_REPEAT(DPAD_LEFT) && TrySelectRibbonLeft(structPtr))
if (JOY_REPEAT(DPAD_LEFT) && TrySelectRibbonLeft(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_REPEAT(DPAD_RIGHT) && TrySelectRibbonRight(structPtr))
if (JOY_REPEAT(DPAD_RIGHT) && TrySelectRibbonRight(list))
return RIBBONS_SUMMARY_FUNC_EXPANDED_CURSOR_MOVE;
if (JOY_NEW(B_BUTTON))
{
// Exit ribbon selection
structPtr->callback = RibbonsSummaryHandleInput;
list->callback = RibbonsSummaryHandleInput;
return RIBBONS_SUMMARY_FUNC_EXPANDED_CANCEL;
}
return RIBBONS_SUMMARY_FUNC_NONE;
}
static u32 ReturnToRibbonsListFromSummary(struct PokenavSub13 *structPtr)
static u32 ReturnToRibbonsListFromSummary(struct Pokenav_RibbonsSummaryList *list)
{
return POKENAV_RIBBONS_RETURN_TO_MON_LIST;
}
static bool32 TrySelectRibbonUp(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonUp(struct Pokenav_RibbonsSummaryList *list)
{
if (structPtr->selectedPos < FIRST_GIFT_RIBBON)
if (list->selectedPos < FIRST_GIFT_RIBBON)
{
// In normal ribbons, try to move up a row
if (structPtr->selectedPos < RIBBONS_PER_ROW)
if (list->selectedPos < RIBBONS_PER_ROW)
return FALSE;
structPtr->selectedPos -= RIBBONS_PER_ROW;
list->selectedPos -= RIBBONS_PER_ROW;
return TRUE;
}
if (structPtr->numNormalRibbons != 0)
if (list->numNormalRibbons != 0)
{
// In gift ribbons, try to move up into normal ribbons
// If there's > 1 row of gift ribbons (not normally possible)
// it's impossible to move up between them
u32 ribbonPos = structPtr->selectedPos - GIFT_RIBBON_START_POS;
structPtr->selectedPos = ribbonPos + structPtr->normalRibbonLastRowStart;
if (structPtr->selectedPos >= structPtr->numNormalRibbons)
structPtr->selectedPos = structPtr->numNormalRibbons - 1;
u32 ribbonPos = list->selectedPos - GIFT_RIBBON_START_POS;
list->selectedPos = ribbonPos + list->normalRibbonLastRowStart;
if (list->selectedPos >= list->numNormalRibbons)
list->selectedPos = list->numNormalRibbons - 1;
return TRUE;
}
return FALSE;
}
static bool32 TrySelectRibbonDown(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonDown(struct Pokenav_RibbonsSummaryList *list)
{
if (structPtr->selectedPos >= FIRST_GIFT_RIBBON)
if (list->selectedPos >= FIRST_GIFT_RIBBON)
return FALSE;
if (structPtr->selectedPos < structPtr->normalRibbonLastRowStart)
if (list->selectedPos < list->normalRibbonLastRowStart)
{
// Not in last row of normal ribbons, advance to next row
structPtr->selectedPos += RIBBONS_PER_ROW;
if (structPtr->selectedPos >= structPtr->numNormalRibbons)
structPtr->selectedPos = structPtr->numNormalRibbons - 1;
list->selectedPos += RIBBONS_PER_ROW;
if (list->selectedPos >= list->numNormalRibbons)
list->selectedPos = list->numNormalRibbons - 1;
return TRUE;
}
if (structPtr->numGiftRibbons != 0)
if (list->numGiftRibbons != 0)
{
// In/beyond last of row of normal ribbons and gift ribbons present, move down to gift ribbon row
int ribbonPos = structPtr->selectedPos - structPtr->normalRibbonLastRowStart;
if (ribbonPos >= structPtr->numGiftRibbons)
ribbonPos = structPtr->numGiftRibbons - 1;
int ribbonPos = list->selectedPos - list->normalRibbonLastRowStart;
if (ribbonPos >= list->numGiftRibbons)
ribbonPos = list->numGiftRibbons - 1;
structPtr->selectedPos = ribbonPos + GIFT_RIBBON_START_POS;
list->selectedPos = ribbonPos + GIFT_RIBBON_START_POS;
return TRUE;
}
return FALSE;
}
static bool32 TrySelectRibbonLeft(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonLeft(struct Pokenav_RibbonsSummaryList *list)
{
u16 column = structPtr->selectedPos % RIBBONS_PER_ROW;
u16 column = list->selectedPos % RIBBONS_PER_ROW;
if (column != 0)
{
structPtr->selectedPos--;
list->selectedPos--;
return TRUE;
}
return FALSE;
}
static bool32 TrySelectRibbonRight(struct PokenavSub13 *structPtr)
static bool32 TrySelectRibbonRight(struct Pokenav_RibbonsSummaryList *list)
{
int column = structPtr->selectedPos % RIBBONS_PER_ROW;
int column = list->selectedPos % RIBBONS_PER_ROW;
if (column >= RIBBONS_PER_ROW - 1)
return FALSE;
if (structPtr->selectedPos < GIFT_RIBBON_START_POS)
if (list->selectedPos < GIFT_RIBBON_START_POS)
{
// Move right in normal ribbon row
if (structPtr->selectedPos < structPtr->numNormalRibbons - 1)
if (list->selectedPos < list->numNormalRibbons - 1)
{
structPtr->selectedPos++;
list->selectedPos++;
return TRUE;
}
}
else
{
// Move right in gift ribbon row
if (column < structPtr->numGiftRibbons - 1)
if (column < list->numGiftRibbons - 1)
{
structPtr->selectedPos++;
list->selectedPos++;
return TRUE;
}
}
@ -365,20 +365,20 @@ static bool32 TrySelectRibbonRight(struct PokenavSub13 *structPtr)
static u32 GetRibbonsSummaryCurrentIndex(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->monList->currIndex;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->monList->currIndex;
}
static u32 GetRibbonsSummaryMonListCount(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->monList->listCount;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->monList->listCount;
}
static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->monList;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = list->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
@ -402,8 +402,8 @@ static void GetMonNicknameLevelGender(u8 *nick, u8 *level, u8 *gender)
static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *otId)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->monList;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = list->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
@ -426,8 +426,8 @@ static void GetMonSpeciesPersonalityOtId(u16 *species, u32 *personality, u32 *ot
static u32 GetCurrMonRibbonCount(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = structPtr->monList;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
struct PokenavSub18 *mons = list->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
@ -436,11 +436,11 @@ static u32 GetCurrMonRibbonCount(void)
return GetBoxMonDataAt(monInfo->boxId, monInfo->monId, MON_DATA_RIBBON_COUNT);
}
static void GetMonRibbons(struct PokenavSub13 *structPtr)
static void GetMonRibbons(struct Pokenav_RibbonsSummaryList *list)
{
u32 ribbonFlags;
s32 i, j;
struct PokenavSub18 *mons = structPtr->monList;
struct PokenavSub18 *mons = list->monList;
struct PokenavMonList *monInfo = &mons->monData[mons->currIndex];
if (monInfo->boxId == TOTAL_BOXES_COUNT)
@ -448,8 +448,8 @@ static void GetMonRibbons(struct PokenavSub13 *structPtr)
else
ribbonFlags = GetBoxMonDataAt(monInfo->boxId, monInfo->monId, MON_DATA_RIBBONS);
structPtr->numNormalRibbons = 0;
structPtr->numGiftRibbons = 0;
list->numNormalRibbons = 0;
list->numGiftRibbons = 0;
for (i = 0; i < ARRAY_COUNT(sRibbonData); i++)
{
// For all non-contest ribbons, numRibbons will be 1 if they have it, 0 if they don't
@ -458,119 +458,119 @@ static void GetMonRibbons(struct PokenavSub13 *structPtr)
if (!sRibbonData[i].isGiftRibbon)
{
for (j = 0; j < numRibbons; j++)
structPtr->ribbonIds[structPtr->numNormalRibbons++] = sRibbonData[i].ribbonId + j;
list->ribbonIds[list->numNormalRibbons++] = sRibbonData[i].ribbonId + j;
}
else
{
for (j = 0; j < numRibbons; j++)
structPtr->giftRibbonIds[structPtr->numGiftRibbons++] = sRibbonData[i].ribbonId + j;
list->giftRibbonIds[list->numGiftRibbons++] = sRibbonData[i].ribbonId + j;
}
ribbonFlags >>= sRibbonData[i].numBits;
}
if (structPtr->numNormalRibbons != 0)
if (list->numNormalRibbons != 0)
{
structPtr->normalRibbonLastRowStart = ((structPtr->numNormalRibbons - 1) / RIBBONS_PER_ROW) * RIBBONS_PER_ROW;
structPtr->selectedPos = 0;
list->normalRibbonLastRowStart = ((list->numNormalRibbons - 1) / RIBBONS_PER_ROW) * RIBBONS_PER_ROW;
list->selectedPos = 0;
}
else
{
// There are no normal ribbons, move cursor to first gift ribbon
structPtr->normalRibbonLastRowStart = 0;
structPtr->selectedPos = GIFT_RIBBON_START_POS;
list->normalRibbonLastRowStart = 0;
list->selectedPos = GIFT_RIBBON_START_POS;
}
}
static u32 *GetNormalRibbonIds(u32 *size)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = structPtr->numNormalRibbons;
return structPtr->ribbonIds;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = list->numNormalRibbons;
return list->ribbonIds;
}
static u32 *GetGiftRibbonIds(u32 *size)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = structPtr->numGiftRibbons;
return structPtr->giftRibbonIds;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
*size = list->numGiftRibbons;
return list->giftRibbonIds;
}
static u16 GetSelectedPosition(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return structPtr->selectedPos;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
return list->selectedPos;
}
static u32 GetRibbonId(void)
{
struct PokenavSub13 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
int ribbonPos = structPtr->selectedPos;
struct Pokenav_RibbonsSummaryList *list = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_LIST);
int ribbonPos = list->selectedPos;
if (ribbonPos < FIRST_GIFT_RIBBON)
return structPtr->ribbonIds[ribbonPos];
return list->ribbonIds[ribbonPos];
else
return structPtr->giftRibbonIds[ribbonPos - GIFT_RIBBON_START_POS];
return list->giftRibbonIds[ribbonPos - GIFT_RIBBON_START_POS];
}
bool32 OpenRibbonsSummaryMenu(void)
{
struct PokenavSub14 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, sizeof(struct PokenavSub14));
if (structPtr == NULL)
struct Pokenav_RibbonsSummaryMenu *menu = AllocSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU, sizeof(struct Pokenav_RibbonsSummaryMenu));
if (menu == NULL)
return FALSE;
structPtr->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1);
structPtr->callback = GetCurrentLoopedTaskActive;
menu->loopedTaskId = CreateLoopedTask(LoopedTask_OpenRibbonsSummaryMenu, 1);
menu->callback = GetCurrentLoopedTaskActive;
return TRUE;
}
void CreateRibbonsSummaryLoopedTask(s32 id)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
structPtr->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1);
structPtr->callback = GetCurrentLoopedTaskActive;
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
menu->loopedTaskId = CreateLoopedTask(sRibbonsSummaryMenuLoopTaskFuncs[id], 1);
menu->callback = GetCurrentLoopedTaskActive;
}
u32 IsRibbonsSummaryLoopedTaskActive(void)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return structPtr->callback();
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return menu->callback();
}
void FreeRibbonsSummaryScreen2(void)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
RemoveWindow(structPtr->ribbonCountWindowId);
RemoveWindow(structPtr->nameWindowId);
RemoveWindow(structPtr->listIdxWindowId);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
RemoveWindow(menu->ribbonCountWindowId);
RemoveWindow(menu->nameWindowId);
RemoveWindow(menu->listIdxWindowId);
#ifndef BUGFIX
RemoveWindow(structPtr->unusedWindowId); // Removing window, but window id is never set
RemoveWindow(menu->unusedWindowId); // Removing window, but window id is never set
#endif
DestroyRibbonsMonFrontPic(structPtr);
DestroyRibbonsMonFrontPic(menu);
FreeSpriteTilesByTag(GFXTAG_RIBBON_ICONS_BIG);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_1);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_2);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_3);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_4);
FreeSpritePaletteByTag(PALTAG_RIBBON_ICONS_5);
FreeSpriteOamMatrix(structPtr->bigRibbonSprite);
DestroySprite(structPtr->bigRibbonSprite);
FreeSpriteOamMatrix(menu->bigRibbonSprite);
DestroySprite(menu->bigRibbonSprite);
FreePokenavSubstruct(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
}
static bool32 GetCurrentLoopedTaskActive(void)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return IsLoopedTaskActive(structPtr->loopedTaskId);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
return IsLoopedTaskActive(menu->loopedTaskId);
}
static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
InitBgTemplates(sBgTemplates, ARRAY_COUNT(sBgTemplates));
DecompressAndCopyTileDataToVram(2, gPokenavRibbonsSummaryBg_Gfx, 0, 0, 0);
SetBgTilemapBuffer(2, structPtr->tilemapBuffers[0]);
SetBgTilemapBuffer(2, menu->tilemapBuffers[0]);
CopyToBgTilemapBuffer(2, gPokenavRibbonsSummaryBg_Tilemap, 0, 0);
CopyPaletteIntoBufferUnfaded(gPokenavRibbonsSummaryBg_Pal, 0x10, 0x20);
CopyBgTilemapBufferToVram(2);
@ -580,7 +580,7 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
{
BgDmaFill(1, 0, 0, 1);
DecompressAndCopyTileDataToVram(1, sRibbonIconsSmall_Gfx, 0, 1, 0);
SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]);
SetBgTilemapBuffer(1, menu->tilemapBuffers[1]);
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 32, 20);
CopyPaletteIntoBufferUnfaded(sRibbonIcons1_Pal, 0x20, 0xA0);
CopyPaletteIntoBufferUnfaded(sMonInfo_Pal, 0xA0, 0x20);
@ -591,21 +591,21 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
case 2:
if (!FreeTempTileDataBuffersIfPossible())
{
AddRibbonCountWindow(structPtr);
AddRibbonCountWindow(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 3:
if (!FreeTempTileDataBuffersIfPossible())
{
AddRibbonSummaryMonNameWindow(structPtr);
AddRibbonSummaryMonNameWindow(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 4:
if (!FreeTempTileDataBuffersIfPossible())
{
AddRibbonListIndexWindow(structPtr);
AddRibbonListIndexWindow(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
@ -619,18 +619,18 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state)
case 6:
if (!IsDma3ManagerBusyWithBgCopy())
{
ResetSpritesAndDrawMonFrontPic(structPtr);
ResetSpritesAndDrawMonFrontPic(menu);
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
case 7:
DrawAllRibbonsSmall(structPtr);
DrawAllRibbonsSmall(menu);
PrintHelpBarText(HELPBAR_RIBBONS_LIST);
return LT_INC_AND_PAUSE;
case 8:
if (!IsDma3ManagerBusyWithBgCopy())
{
CreateBigRibbonSprite(structPtr);
CreateBigRibbonSprite(menu);
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(2, 0, BG_COORD_SET);
@ -667,38 +667,38 @@ static u32 LoopedTask_ExitRibbonsSummaryMenu(s32 state)
static u32 LoopedTask_SwitchRibbonsSummaryMon(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
SlideMonSpriteOff(structPtr);
SlideMonSpriteOff(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsMonSpriteAnimating(structPtr))
if (!IsMonSpriteAnimating(menu))
{
PrintRibbbonsSummaryMonInfo(structPtr);
PrintRibbbonsSummaryMonInfo(menu);
return LT_INC_AND_CONTINUE;
}
return LT_PAUSE;
case 2:
DrawAllRibbonsSmall(structPtr);
DrawAllRibbonsSmall(menu);
return LT_INC_AND_CONTINUE;
case 3:
PrintRibbonsMonListIndex(structPtr);
PrintRibbonsMonListIndex(menu);
return LT_INC_AND_CONTINUE;
case 4:
PrintCurrentMonRibbonCount(structPtr);
PrintCurrentMonRibbonCount(menu);
return LT_INC_AND_CONTINUE;
case 5:
if (!IsDma3ManagerBusyWithBgCopy())
{
SlideMonSpriteOn(structPtr);
SlideMonSpriteOn(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 6:
if (IsMonSpriteAnimating(structPtr))
if (IsMonSpriteAnimating(menu))
return LT_PAUSE;
}
return LT_FINISH;
@ -706,17 +706,17 @@ static u32 LoopedTask_SwitchRibbonsSummaryMon(s32 state)
static u32 LoopedTask_ExpandSelectedRibbon(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
UpdateAndZoomInSelectedRibbon(structPtr);
UpdateAndZoomInSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
PrintRibbonNameAndDescription(structPtr);
PrintRibbonNameAndDescription(menu);
PrintHelpBarText(HELPBAR_RIBBONS_CHECK);
return LT_INC_AND_PAUSE;
}
@ -730,24 +730,24 @@ static u32 LoopedTask_ExpandSelectedRibbon(s32 state)
static u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
ZoomOutSelectedRibbon(structPtr);
ZoomOutSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
UpdateAndZoomInSelectedRibbon(structPtr);
UpdateAndZoomInSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
case 2:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
PrintRibbonNameAndDescription(structPtr);
PrintRibbonNameAndDescription(menu);
return LT_INC_AND_PAUSE;
}
return LT_PAUSE;
@ -760,17 +760,17 @@ static u32 LoopedTask_MoveRibbonsCursorExpanded(s32 state)
static u32 LoopedTask_ShrinkExpandedRibbon(s32 state)
{
struct PokenavSub14 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
struct Pokenav_RibbonsSummaryMenu *menu = GetSubstructPtr(POKENAV_SUBSTRUCT_RIBBONS_SUMMARY_MENU);
switch (state)
{
case 0:
PlaySE(SE_SELECT);
ZoomOutSelectedRibbon(structPtr);
ZoomOutSelectedRibbon(menu);
return LT_INC_AND_PAUSE;
case 1:
if (!IsRibbonAnimating(structPtr))
if (!IsRibbonAnimating(menu))
{
PrintCurrentMonRibbonCount(structPtr);
PrintCurrentMonRibbonCount(menu);
PrintHelpBarText(HELPBAR_RIBBONS_LIST);
return LT_INC_AND_PAUSE;
}
@ -793,14 +793,14 @@ static const struct WindowTemplate sRibbonCountWindowTemplate =
.baseBlock = 0x14,
};
static void AddRibbonCountWindow(struct PokenavSub14 *structPtr)
static void AddRibbonCountWindow(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate);
PutWindowTilemap(structPtr->ribbonCountWindowId);
PrintCurrentMonRibbonCount(structPtr);
menu->ribbonCountWindowId = AddWindow(&sRibbonCountWindowTemplate);
PutWindowTilemap(menu->ribbonCountWindowId);
PrintCurrentMonRibbonCount(menu);
}
static void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr)
static void PrintCurrentMonRibbonCount(struct Pokenav_RibbonsSummaryMenu *menu)
{
u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY};
@ -808,23 +808,23 @@ static void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr)
DynamicPlaceholderTextUtil_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1);
DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_RibbonsF700);
FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4));
AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, 1, color, TEXT_SKIP_DRAW, gStringVar4);
CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX);
FillWindowPixelBuffer(menu->ribbonCountWindowId, PIXEL_FILL(4));
AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, 1, color, TEXT_SKIP_DRAW, gStringVar4);
CopyWindowToVram(menu->ribbonCountWindowId, COPYWIN_GFX);
}
static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr)
static void PrintRibbonNameAndDescription(struct Pokenav_RibbonsSummaryMenu *menu)
{
s32 i;
u32 ribbonId = GetRibbonId();
u8 color[] = {TEXT_COLOR_RED, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY};
FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4));
FillWindowPixelBuffer(menu->ribbonCountWindowId, PIXEL_FILL(4));
if (ribbonId < FIRST_GIFT_RIBBON)
{
// Print normal ribbon name/description
for (i = 0; i < 2; i++)
AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gRibbonDescriptionPointers[ribbonId][i]);
AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gRibbonDescriptionPointers[ribbonId][i]);
}
else
{
@ -840,10 +840,10 @@ static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr)
// Print gift ribbon name/description
ribbonId--;
for (i = 0; i < 2; i++)
AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gGiftRibbonDescriptionPointers[ribbonId][i]);
AddTextPrinterParameterized3(menu->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gGiftRibbonDescriptionPointers[ribbonId][i]);
}
CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX);
CopyWindowToVram(menu->ribbonCountWindowId, COPYWIN_GFX);
}
static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate =
@ -857,23 +857,23 @@ static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate =
.baseBlock = 0x54,
};
static void AddRibbonSummaryMonNameWindow(struct PokenavSub14 *structPtr)
static void AddRibbonSummaryMonNameWindow(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate);
PutWindowTilemap(structPtr->nameWindowId);
PrintRibbbonsSummaryMonInfo(structPtr);
menu->nameWindowId = AddWindow(&sRibbonSummaryMonNameWindowTemplate);
PutWindowTilemap(menu->nameWindowId);
PrintRibbbonsSummaryMonInfo(menu);
}
static const u8 sMaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_RED}{WHITE}{GREEN}♂{COLOR_HIGHLIGHT_SHADOW}{DARK_GRAY}{WHITE}{LIGHT_GRAY}");
static const u8 sFemaleIconString[] = _("{COLOR_HIGHLIGHT_SHADOW}{LIGHT_GREEN}{WHITE}{BLUE}♀{COLOR_HIGHLIGHT_SHADOW}{DARK_GRAY}{WHITE}{LIGHT_GRAY}");
static const u8 sGenderlessIconString[] = _("{UNK_SPACER}");
static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr)
static void PrintRibbbonsSummaryMonInfo(struct Pokenav_RibbonsSummaryMenu *menu)
{
const u8 *genderTxt;
u8 *txtPtr;
u8 level, gender;
u16 windowId = structPtr->nameWindowId;
u16 windowId = menu->nameWindowId;
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
GetMonNicknameLevelGender(gStringVar3, &level, &gender);
@ -914,15 +914,15 @@ static const struct WindowTemplate sRibbonMonListIndexWindowTemplate[] =
{},
};
static void AddRibbonListIndexWindow(struct PokenavSub14 *structPtr)
static void AddRibbonListIndexWindow(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate);
FillWindowPixelBuffer(structPtr->listIdxWindowId, PIXEL_FILL(1));
PutWindowTilemap(structPtr->listIdxWindowId);
PrintRibbonsMonListIndex(structPtr);
menu->listIdxWindowId = AddWindow(sRibbonMonListIndexWindowTemplate);
FillWindowPixelBuffer(menu->listIdxWindowId, PIXEL_FILL(1));
PutWindowTilemap(menu->listIdxWindowId);
PrintRibbonsMonListIndex(menu);
}
static void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr)
static void PrintRibbonsMonListIndex(struct Pokenav_RibbonsSummaryMenu *menu)
{
s32 x;
u8 *txtPtr;
@ -933,24 +933,24 @@ static void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr)
*(txtPtr++) = CHAR_SLASH;
ConvertIntToDecimalStringN(txtPtr, count, STR_CONV_MODE_RIGHT_ALIGN, 3);
x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar1, 56);
AddTextPrinterParameterized(structPtr->listIdxWindowId, FONT_NORMAL, gStringVar1, x, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(structPtr->listIdxWindowId, COPYWIN_GFX);
AddTextPrinterParameterized(menu->listIdxWindowId, FONT_NORMAL, gStringVar1, x, 1, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(menu->listIdxWindowId, COPYWIN_GFX);
}
static void ResetSpritesAndDrawMonFrontPic(struct PokenavSub14 *structPtr)
static void ResetSpritesAndDrawMonFrontPic(struct Pokenav_RibbonsSummaryMenu *menu)
{
u16 species;
u32 personality, otId;
GetMonSpeciesPersonalityOtId(&species, &personality, &otId);
ResetAllPicSprites();
structPtr->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_ON, MON_SPRITE_Y);
menu->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_ON, MON_SPRITE_Y);
PokenavFillPalette(15, 0);
}
static void DestroyRibbonsMonFrontPic(struct PokenavSub14 *structPtr)
static void DestroyRibbonsMonFrontPic(struct Pokenav_RibbonsSummaryMenu *menu)
{
FreeAndDestroyMonPicSprite(structPtr->monSpriteId);
FreeAndDestroyMonPicSprite(menu->monSpriteId);
}
// x and y arguments are ignored
@ -967,25 +967,25 @@ static u16 DrawRibbonsMonFrontPic(s32 x, s32 y)
return spriteId;
}
static void SlideMonSpriteOff(struct PokenavSub14 *structPtr)
static void SlideMonSpriteOff(struct Pokenav_RibbonsSummaryMenu *menu)
{
StartMonSpriteSlide(&gSprites[structPtr->monSpriteId], MON_SPRITE_X_ON, MON_SPRITE_X_OFF, 6);
StartMonSpriteSlide(&gSprites[menu->monSpriteId], MON_SPRITE_X_ON, MON_SPRITE_X_OFF, 6);
}
static void SlideMonSpriteOn(struct PokenavSub14 *structPtr)
static void SlideMonSpriteOn(struct Pokenav_RibbonsSummaryMenu *menu)
{
// Switch to new mon sprite
FreeAndDestroyMonPicSprite(structPtr->monSpriteId);
structPtr->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_OFF, MON_SPRITE_Y);
FreeAndDestroyMonPicSprite(menu->monSpriteId);
menu->monSpriteId = DrawRibbonsMonFrontPic(MON_SPRITE_X_OFF, MON_SPRITE_Y);
// Slide on
StartMonSpriteSlide(&gSprites[structPtr->monSpriteId], MON_SPRITE_X_OFF, MON_SPRITE_X_ON, 6);
StartMonSpriteSlide(&gSprites[menu->monSpriteId], MON_SPRITE_X_OFF, MON_SPRITE_X_ON, 6);
}
// Is Pokémon summary sprite still sliding off/on
static bool32 IsMonSpriteAnimating(struct PokenavSub14 *structPtr)
static bool32 IsMonSpriteAnimating(struct Pokenav_RibbonsSummaryMenu *menu)
{
return (gSprites[structPtr->monSpriteId].callback != SpriteCallbackDummy);
return (gSprites[menu->monSpriteId].callback != SpriteCallbackDummy);
}
#define sCurrX data[0]
@ -1030,7 +1030,7 @@ static void SpriteCB_MonSpriteSlide(struct Sprite *sprite)
#undef sTime
#undef sDestX
static void DrawAllRibbonsSmall(struct PokenavSub14 *structPtr)
static void DrawAllRibbonsSmall(struct Pokenav_RibbonsSummaryMenu *menu)
{
u32 *ribbonIds;
@ -1211,7 +1211,7 @@ static const struct SpriteTemplate sSpriteTemplate_RibbonIconBig =
};
// Create dummy sprite to be used for the zoomed in version of the selected ribbon
static void CreateBigRibbonSprite(struct PokenavSub14 *structPtr)
static void CreateBigRibbonSprite(struct Pokenav_RibbonsSummaryMenu *menu)
{
u8 spriteId;
@ -1219,45 +1219,45 @@ static void CreateBigRibbonSprite(struct PokenavSub14 *structPtr)
Pokenav_AllocAndLoadPalettes(sSpritePalettes_RibbonIcons);
spriteId = CreateSprite(&sSpriteTemplate_RibbonIconBig, 0, 0, 0);
structPtr->bigRibbonSprite = &gSprites[spriteId];
structPtr->bigRibbonSprite->invisible = TRUE;
menu->bigRibbonSprite = &gSprites[spriteId];
menu->bigRibbonSprite->invisible = TRUE;
}
#define sInvisibleWhenDone data[0]
static void UpdateAndZoomInSelectedRibbon(struct PokenavSub14 *structPtr)
static void UpdateAndZoomInSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *menu)
{
u32 ribbonId;
s32 position = GetSelectedPosition();
s32 x = (position % RIBBONS_PER_ROW) * 16 + 96;
s32 y = (position / RIBBONS_PER_ROW) * 16 + 40;
structPtr->bigRibbonSprite->x = x;
structPtr->bigRibbonSprite->y = y;
menu->bigRibbonSprite->x = x;
menu->bigRibbonSprite->y = y;
// Set new selected ribbon's gfx data
ribbonId = GetRibbonId();
structPtr->bigRibbonSprite->oam.tileNum = (sRibbonGfxData[ribbonId].tileNumOffset * 16) + GetSpriteTileStartByTag(GFXTAG_RIBBON_ICONS_BIG);
structPtr->bigRibbonSprite->oam.paletteNum = IndexOfSpritePaletteTag(sRibbonGfxData[ribbonId].palNumOffset + PALTAG_RIBBON_ICONS_1);
menu->bigRibbonSprite->oam.tileNum = (sRibbonGfxData[ribbonId].tileNumOffset * 16) + GetSpriteTileStartByTag(GFXTAG_RIBBON_ICONS_BIG);
menu->bigRibbonSprite->oam.paletteNum = IndexOfSpritePaletteTag(sRibbonGfxData[ribbonId].palNumOffset + PALTAG_RIBBON_ICONS_1);
// Start zoom in animation
StartSpriteAffineAnim(structPtr->bigRibbonSprite, RIBBONANIM_ZOOM_IN);
structPtr->bigRibbonSprite->invisible = FALSE;
structPtr->bigRibbonSprite->sInvisibleWhenDone = FALSE;
structPtr->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
StartSpriteAffineAnim(menu->bigRibbonSprite, RIBBONANIM_ZOOM_IN);
menu->bigRibbonSprite->invisible = FALSE;
menu->bigRibbonSprite->sInvisibleWhenDone = FALSE;
menu->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
}
// Start animation to zoom out of selected ribbon
static void ZoomOutSelectedRibbon(struct PokenavSub14 *structPtr)
static void ZoomOutSelectedRibbon(struct Pokenav_RibbonsSummaryMenu *menu)
{
structPtr->bigRibbonSprite->sInvisibleWhenDone = TRUE;
StartSpriteAffineAnim(structPtr->bigRibbonSprite, RIBBONANIM_ZOOM_OUT);
structPtr->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
menu->bigRibbonSprite->sInvisibleWhenDone = TRUE;
StartSpriteAffineAnim(menu->bigRibbonSprite, RIBBONANIM_ZOOM_OUT);
menu->bigRibbonSprite->callback = SpriteCB_WaitForRibbonAnimation;
}
static bool32 IsRibbonAnimating(struct PokenavSub14 *structPtr)
static bool32 IsRibbonAnimating(struct Pokenav_RibbonsSummaryMenu *menu)
{
return (structPtr->bigRibbonSprite->callback != SpriteCallbackDummy);
return (menu->bigRibbonSprite->callback != SpriteCallbackDummy);
}
static void SpriteCB_WaitForRibbonAnimation(struct Sprite *sprite)

View File

@ -51,7 +51,7 @@
.include "src/mirage_tower.o"
.include "src/berry_fix_program.o"
.include "src/pokenav_conditions_2.o"
.include "src/pokenav_ribbons_2.o"
.include "src/pokenav_ribbons_summary.o"
.include "src/ereader_helpers.o"
.include "src/faraway_island.o"
.include "src/m4a_1.o"