sync list menu functions with firered

This commit is contained in:
cawtds
2025-06-02 22:51:26 +02:00
parent 0c32d840fa
commit 0fc900514b
5 changed files with 97 additions and 98 deletions

View File

@@ -27,6 +27,28 @@ enum {
SCROLL_ARROW_DOWN SCROLL_ARROW_DOWN
}; };
// For ListMenuGet/SetTemplateField
enum ListMenuFields
{
LISTFIELD_MOVECURSORFUNC = 0,
LISTFIELD_MOVECURSORFUNC2,
LISTFIELD_TOTALITEMS,
LISTFIELD_MAXSHOWED,
LISTFIELD_WINDOWID,
LISTFIELD_HEADERX,
LISTFIELD_ITEMX,
LISTFIELD_CURSORX,
LISTFIELD_UPTEXTY,
LISTFIELD_CURSORPAL,
LISTFIELD_FILLVALUE,
LISTFIELD_CURSORSHADOWPAL,
LISTFIELD_LETTERSPACING,
LISTFIELD_ITEMVERTICALPADDING,
LISTFIELD_SCROLLMULTIPLE,
LISTFIELD_FONTID,
LISTFIELD_CURSORKIND,
};
struct ListMenu; struct ListMenu;
struct ListMenuItem struct ListMenuItem
@@ -120,8 +142,8 @@ void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow)
u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId); u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId);
void ListMenuOverrideSetColors(u8 cursorPal, u8 fillValue, u8 cursorShadowPal); void ListMenuOverrideSetColors(u8 cursorPal, u8 fillValue, u8 cursorShadowPal);
void ListMenuDefaultCursorMoveFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list); void ListMenuDefaultCursorMoveFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list);
s32 ListMenuGetUnkIndicatorsStructFields(u8 taskId, u8 field); s32 ListMenuGetTemplateField(u8 taskId, u8 field);
void ListMenuSetUnkIndicatorsStructField(u8 taskId, u8 field, s32 value); void ListMenuSetTemplateField(u8 taskId, u8 field, s32 value);
u8 AddScrollIndicatorArrowPair(const struct ScrollArrowsTemplate *arrowInfo, u16 *scrollOffset); u8 AddScrollIndicatorArrowPair(const struct ScrollArrowsTemplate *arrowInfo, u16 *scrollOffset);
u8 AddScrollIndicatorArrowPairParameterized(u32 arrowType, s32 commonPos, s32 firstPos, s32 secondPos, s32 fullyDownThreshold, s32 tileTag, s32 palTag, u16 *scrollOffset); u8 AddScrollIndicatorArrowPairParameterized(u32 arrowType, s32 commonPos, s32 firstPos, s32 secondPos, s32 fullyDownThreshold, s32 tileTag, s32 palTag, u16 *scrollOffset);
void RemoveScrollIndicatorArrowPair(u8 taskId); void RemoveScrollIndicatorArrowPair(u8 taskId);

View File

@@ -1312,7 +1312,7 @@ static void Task_BeginItemSwap(u8 taskId)
tListPos = gPyramidBagMenuState.scrollPosition + gPyramidBagMenuState.cursorPosition; tListPos = gPyramidBagMenuState.scrollPosition + gPyramidBagMenuState.cursorPosition;
gPyramidBagMenu->toSwapPos = tListPos; gPyramidBagMenu->toSwapPos = tListPos;
ListMenuSetUnkIndicatorsStructField(tListTaskId, 0x10, 1); ListMenuSetTemplateField(tListTaskId, 0x10, 1);
CopyItemName(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][tListPos], gStringVar1); CopyItemName(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][tListPos], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where); StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where);
FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0));

View File

@@ -1432,7 +1432,7 @@ static void StartItemSwap(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
ListMenuSetUnkIndicatorsStructField(tListTaskId, 16, 1); ListMenuSetTemplateField(tListTaskId, 16, 1);
tListPosition = gBagPosition.scrollPosition[gBagPosition.pocket] + gBagPosition.cursorPosition[gBagPosition.pocket]; tListPosition = gBagPosition.scrollPosition[gBagPosition.pocket] + gBagPosition.cursorPosition[gBagPosition.pocket];
gBagMenu->toSwapPos = tListPosition; gBagMenu->toSwapPos = tListPosition;
CopyItemName(BagGetItemIdByPocketPosition(gBagPosition.pocket + 1, tListPosition), gStringVar1); CopyItemName(BagGetItemIdByPocketPosition(gBagPosition.pocket + 1, tListPosition), gStringVar1);

View File

@@ -17,29 +17,6 @@
// This allows them to have idle animations. Cursors prior to this are simply printed text. // This allows them to have idle animations. Cursors prior to this are simply printed text.
#define CURSOR_OBJECT_START CURSOR_RED_OUTLINE #define CURSOR_OBJECT_START CURSOR_RED_OUTLINE
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;
};
struct ScrollIndicatorPair struct ScrollIndicatorPair
{ {
u8 field_0; u8 field_0;
@@ -904,104 +881,104 @@ void ListMenuDefaultCursorMoveFunc(s32 itemIndex, bool8 onInit, struct ListMenu
} }
// unused // unused
s32 ListMenuGetUnkIndicatorsStructFields(u8 taskId, u8 field) s32 ListMenuGetTemplateField(u8 taskId, u8 field)
{ {
struct UnkIndicatorsStruct *data = (void *) gTasks[taskId].data; struct ListMenu *data = (void *) gTasks[taskId].data;
switch (field) switch (field)
{ {
case 0: case LISTFIELD_MOVECURSORFUNC:
case 1: case LISTFIELD_MOVECURSORFUNC2:
return (s32)(data->field_4); return (s32)(data->template.moveCursorFunc);
case 2: case LISTFIELD_TOTALITEMS:
return data->field_C; return data->template.totalItems;
case 3: case LISTFIELD_MAXSHOWED:
return data->field_E; return data->template.maxShowed;
case 4: case LISTFIELD_WINDOWID:
return data->field_10; return data->template.windowId;
case 5: case LISTFIELD_HEADERX:
return data->field_11; return data->template.header_X;
case 6: case LISTFIELD_ITEMX:
return data->field_12; return data->template.item_X;
case 7: case LISTFIELD_CURSORX:
return data->field_13; return data->template.cursor_X;
case 8: case LISTFIELD_UPTEXTY:
return data->field_14_0; return data->template.upText_Y;
case 9: case LISTFIELD_CURSORPAL:
return data->field_14_1; return data->template.cursorPal;
case 10: case LISTFIELD_FILLVALUE:
return data->field_15_0; return data->template.fillValue;
case 11: case LISTFIELD_CURSORSHADOWPAL:
return data->field_15_1; return data->template.cursorShadowPal;
case 12: case LISTFIELD_LETTERSPACING:
return data->field_16_0; return data->template.lettersSpacing;
case 13: case LISTFIELD_ITEMVERTICALPADDING:
return data->field_16_1; return data->template.itemVerticalPadding;
case 14: case LISTFIELD_SCROLLMULTIPLE:
return data->field_16_2; return data->template.scrollMultiple;
case 15: case LISTFIELD_FONTID:
return data->field_17_0; return data->template.fontId;
case 16: case LISTFIELD_CURSORKIND:
return data->field_17_1; return data->template.cursorKind;
default: default:
return -1; return -1;
} }
} }
void ListMenuSetUnkIndicatorsStructField(u8 taskId, u8 field, s32 value) void ListMenuSetTemplateField(u8 taskId, u8 field, s32 value)
{ {
struct UnkIndicatorsStruct *data = (void *) &gTasks[taskId].data; struct ListMenu *data = (void *) &gTasks[taskId].data;
switch (field) switch (field)
{ {
case 0: case LISTFIELD_MOVECURSORFUNC:
case 1: case LISTFIELD_MOVECURSORFUNC2:
data->field_4 = (void *)(value); data->template.moveCursorFunc = (void *)value;
break; break;
case 2: case LISTFIELD_TOTALITEMS:
data->field_C = value; data->template.totalItems = value;
break; break;
case 3: case LISTFIELD_MAXSHOWED:
data->field_E = value; data->template.maxShowed = value;
break; break;
case 4: case LISTFIELD_WINDOWID:
data->field_10 = value; data->template.windowId = value;
break; break;
case 5: case LISTFIELD_HEADERX:
data->field_11 = value; data->template.header_X = value;
break; break;
case 6: case LISTFIELD_ITEMX:
data->field_12 = value; data->template.item_X = value;
break; break;
case 7: case LISTFIELD_CURSORX:
data->field_13 = value; data->template.cursor_X = value;
break; break;
case 8: case LISTFIELD_UPTEXTY:
data->field_14_0 = value; data->template.upText_Y = value;
break; break;
case 9: case LISTFIELD_CURSORPAL:
data->field_14_1 = value; data->template.cursorPal = value;
break; break;
case 10: case LISTFIELD_FILLVALUE:
data->field_15_0 = value; data->template.fillValue = value;
break; break;
case 11: case LISTFIELD_CURSORSHADOWPAL:
data->field_15_1 = value; data->template.cursorShadowPal = value;
break; break;
case 12: case LISTFIELD_LETTERSPACING:
data->field_16_0 = value; data->template.lettersSpacing = value;
break; break;
case 13: case LISTFIELD_ITEMVERTICALPADDING:
data->field_16_1 = value; data->template.itemVerticalPadding = value;
break; break;
case 14: case LISTFIELD_SCROLLMULTIPLE:
data->field_16_2 = value; data->template.scrollMultiple = value;
break; break;
case 15: case LISTFIELD_FONTID:
data->field_17_0 = value; data->template.fontId = value;
break; break;
case 16: case LISTFIELD_CURSORKIND:
data->field_17_1 = value; data->template.cursorKind = value;
break; break;
} }
} }

View File

@@ -1273,7 +1273,7 @@ static void ItemStorage_ExitItemList(u8 taskId)
static void ItemStorage_StartItemSwap(u8 taskId) static void ItemStorage_StartItemSwap(u8 taskId)
{ {
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
ListMenuSetUnkIndicatorsStructField(tListTaskId, 16, 1); ListMenuSetTemplateField(tListTaskId, 16, 1);
sItemStorageMenu->toSwapPos = gPlayerPCItemPageInfo.itemsAbove + gPlayerPCItemPageInfo.cursorPos; sItemStorageMenu->toSwapPos = gPlayerPCItemPageInfo.itemsAbove + gPlayerPCItemPageInfo.cursorPos;
ItemStorage_SetSwapArrow(tListTaskId, 0, 0); ItemStorage_SetSwapArrow(tListTaskId, 0, 0);
ItemStorage_UpdateSwapLinePos(sItemStorageMenu->toSwapPos); ItemStorage_UpdateSwapLinePos(sItemStorageMenu->toSwapPos);