Rows and columns

This commit is contained in:
DizzyEggg 2019-04-02 15:06:44 +02:00 committed by huderlem
parent baa187665b
commit d8c9f1b30f
2 changed files with 32 additions and 32 deletions

View file

@ -69,7 +69,7 @@ u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16
void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress); void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress);
void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8); void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8);
void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8); void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8);
u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos); u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos);
u8 sub_8199134(s8, s8); u8 sub_8199134(s8, s8);
u8 GetStartMenuWindowId(void); u8 GetStartMenuWindowId(void);
void sub_819A2BC(u8, u8); void sub_819A2BC(u8, u8);
@ -91,7 +91,7 @@ void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette);
void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP); void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP);
void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram); void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram);
void sub_8197AE8(bool8 copyToVram); void sub_8197AE8(bool8 copyToVram);
void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *strs); void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *strs);
s8 Menu_ProcessInputGridLayout(void); s8 Menu_ProcessInputGridLayout(void);
u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted); u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted);
s8 Menu_ProcessInputNoWrapAround_other(void); s8 Menu_ProcessInputNoWrapAround_other(void);

View file

@ -43,8 +43,8 @@ struct Menu
u8 fontId; u8 fontId;
u8 optionWidth; u8 optionWidth;
u8 optionHeight; u8 optionHeight;
u8 horizontalCount; u8 columns;
u8 verticalCount; u8 rows;
bool8 APressMuted; bool8 APressMuted;
}; };
@ -1283,8 +1283,8 @@ u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight,
sMenu.fontId = fontId; sMenu.fontId = fontId;
sMenu.optionWidth = a4; sMenu.optionWidth = a4;
sMenu.optionHeight = cursorHeight; sMenu.optionHeight = cursorHeight;
sMenu.horizontalCount = a6; sMenu.columns = a6;
sMenu.verticalCount = a7; sMenu.rows = a7;
pos = a9; pos = a9;
@ -1308,16 +1308,16 @@ void sub_8199060(u8 oldCursorPos, u8 newCursorPos)
{ {
u8 cursorWidth = GetMenuCursorDimensionByFont(sMenu.fontId, 0); u8 cursorWidth = GetMenuCursorDimensionByFont(sMenu.fontId, 0);
u8 cursorHeight = GetMenuCursorDimensionByFont(sMenu.fontId, 1); u8 cursorHeight = GetMenuCursorDimensionByFont(sMenu.fontId, 1);
u8 xPos = (oldCursorPos % sMenu.horizontalCount) * sMenu.optionWidth + sMenu.left; u8 xPos = (oldCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left;
u8 yPos = (oldCursorPos / sMenu.horizontalCount) * sMenu.optionHeight + sMenu.top; u8 yPos = (oldCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top;
FillWindowPixelRect(sMenu.windowId, FillWindowPixelRect(sMenu.windowId,
PIXEL_FILL(1), PIXEL_FILL(1),
xPos, xPos,
yPos, yPos,
cursorWidth, cursorWidth,
cursorHeight); cursorHeight);
xPos = (newCursorPos % sMenu.horizontalCount) * sMenu.optionWidth + sMenu.left; xPos = (newCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left;
yPos = (newCursorPos / sMenu.horizontalCount) * sMenu.optionHeight + sMenu.top; yPos = (newCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top;
AddTextPrinterParameterized(sMenu.windowId, AddTextPrinterParameterized(sMenu.windowId,
sMenu.fontId, sMenu.fontId,
gText_SelectorArrow3, gText_SelectorArrow3,
@ -1333,13 +1333,13 @@ u8 sub_8199134(s8 deltaX, s8 deltaY)
if (deltaX != 0) if (deltaX != 0)
{ {
if ((sMenu.cursorPos % sMenu.horizontalCount) + deltaX < 0) if ((sMenu.cursorPos % sMenu.columns) + deltaX < 0)
{ {
sMenu.cursorPos += sMenu.horizontalCount - 1; sMenu.cursorPos += sMenu.columns - 1;
} }
else if ((sMenu.cursorPos % sMenu.horizontalCount) + deltaX >= sMenu.horizontalCount) else if ((sMenu.cursorPos % sMenu.columns) + deltaX >= sMenu.columns)
{ {
sMenu.cursorPos = (sMenu.cursorPos / sMenu.horizontalCount) * sMenu.horizontalCount; sMenu.cursorPos = (sMenu.cursorPos / sMenu.columns) * sMenu.columns;
} }
else else
{ {
@ -1349,17 +1349,17 @@ u8 sub_8199134(s8 deltaX, s8 deltaY)
if (deltaY != 0) if (deltaY != 0)
{ {
if ((sMenu.cursorPos / sMenu.horizontalCount) + deltaY < 0) if ((sMenu.cursorPos / sMenu.columns) + deltaY < 0)
{ {
sMenu.cursorPos += sMenu.horizontalCount * (sMenu.verticalCount - 1); sMenu.cursorPos += sMenu.columns * (sMenu.rows - 1);
} }
else if ((sMenu.cursorPos / sMenu.horizontalCount) + deltaY >= sMenu.verticalCount) else if ((sMenu.cursorPos / sMenu.columns) + deltaY >= sMenu.rows)
{ {
sMenu.cursorPos -= sMenu.horizontalCount * (sMenu.verticalCount - 1); sMenu.cursorPos -= sMenu.columns * (sMenu.rows - 1);
} }
else else
{ {
sMenu.cursorPos += (sMenu.horizontalCount * deltaY); sMenu.cursorPos += (sMenu.columns * deltaY);
} }
} }
@ -1381,8 +1381,8 @@ u8 sub_81991F8(s8 deltaX, s8 deltaY)
if (deltaX != 0) if (deltaX != 0)
{ {
if (((sMenu.cursorPos % sMenu.horizontalCount) + deltaX >= 0) && if (((sMenu.cursorPos % sMenu.columns) + deltaX >= 0) &&
((sMenu.cursorPos % sMenu.horizontalCount) + deltaX < sMenu.horizontalCount)) ((sMenu.cursorPos % sMenu.columns) + deltaX < sMenu.columns))
{ {
sMenu.cursorPos += deltaX; sMenu.cursorPos += deltaX;
} }
@ -1390,10 +1390,10 @@ u8 sub_81991F8(s8 deltaX, s8 deltaY)
if (deltaY != 0) if (deltaY != 0)
{ {
if (((sMenu.cursorPos / sMenu.horizontalCount) + deltaY >= 0) && if (((sMenu.cursorPos / sMenu.columns) + deltaY >= 0) &&
((sMenu.cursorPos / sMenu.horizontalCount) + deltaY < sMenu.verticalCount)) ((sMenu.cursorPos / sMenu.columns) + deltaY < sMenu.rows))
{ {
sMenu.cursorPos += (sMenu.horizontalCount * deltaY); sMenu.cursorPos += (sMenu.columns * deltaY);
} }
} }
@ -1661,14 +1661,14 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sYesNoWindowId, 2, initialCursorPos); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sYesNoWindowId, 2, initialCursorPos);
} }
void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *strs) void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *strs)
{ {
u32 i, j; u32 i, j;
for (i = 0; i < verticalCount; i++) for (i = 0; i < rows; i++)
{ {
for (j = 0; j < horizontalCount; j++) for (j = 0; j < columns; j++)
AddTextPrinterParameterized(windowId, 1, strs[(i * horizontalCount) + j].text, (optionWidth * j) + 8, (i * 16) + 1, 0xFF, NULL); AddTextPrinterParameterized(windowId, 1, strs[(i * columns) + j].text, (optionWidth * j) + 8, (i * 16) + 1, 0xFF, NULL);
} }
CopyWindowToVram(windowId, 2); CopyWindowToVram(windowId, 2);
} }
@ -1704,20 +1704,20 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M
CopyWindowToVram(windowId, 2); CopyWindowToVram(windowId, 2);
} }
u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos) u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos)
{ {
s32 pos; s32 pos;
sMenu.left = 0; sMenu.left = 0;
sMenu.top = 1; sMenu.top = 1;
sMenu.minCursorPos = 0; sMenu.minCursorPos = 0;
sMenu.maxCursorPos = (horizontalCount * verticalCount) - 1; sMenu.maxCursorPos = (columns * rows) - 1;
sMenu.windowId = windowId; sMenu.windowId = windowId;
sMenu.fontId = 1; sMenu.fontId = 1;
sMenu.optionWidth = optionWidth; sMenu.optionWidth = optionWidth;
sMenu.optionHeight = 16; sMenu.optionHeight = 16;
sMenu.horizontalCount = horizontalCount; sMenu.columns = columns;
sMenu.verticalCount = verticalCount; sMenu.rows = rows;
pos = initialCursorPos; pos = initialCursorPos;