diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/menu.c | 16 | ||||
-rw-r--r-- | src/script_menu.c | 133 |
2 files changed, 110 insertions, 39 deletions
diff --git a/src/menu.c b/src/menu.c index 6b35fd5dd..a06463ba3 100644 --- a/src/menu.c +++ b/src/menu.c @@ -26,8 +26,8 @@ static void MultistepInitMenuWindowInternal(const struct WindowConfig *, u16); static void InitMenuWindowInternal(const struct WindowConfig *, u16); static bool8 sub_80723D4(void); static u8 sub_8072484(u8, u8, u8, u8, u8, u8, u32); -static u8 sub_80724F4(u8, u8, u8, u8 * const [][2], u8); -static void sub_8072620(u8, u8, u8, u8 * const [][2], u8); +static u8 sub_80724F4(u8, u8, u8, const struct MenuAction[], u8); +static void sub_8072620(u8, u8, u8, const struct MenuAction[], u8); static void sub_8072D18(u8, u8); static struct Menu gMenu; @@ -407,7 +407,7 @@ static u8 sub_8072484(u8 a1, u8 a2, u8 menuItemCount, u8 a4, u8 width, u8 a6, u3 return a4; } -static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][2], u8 columnCount) +static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, const struct MenuAction menuItems[], u8 columnCount) { u8 i; u8 maxWidth; @@ -419,7 +419,7 @@ static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][ maxWidth = 0; for (i = 0; i < menuItemCount; i++) { - u8 width = (sub_8072CA4(menuItems[i][0]) + 7) / 8; + u8 width = (sub_8072CA4(menuItems[i].text) + 7) / 8; if (width > maxWidth) maxWidth = width; @@ -465,7 +465,7 @@ static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][ return maxWidth; } -static void sub_8072620(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[][2], u8 columnCount) +static void sub_8072620(u8 left, u8 top, u8 menuItemCount, const struct MenuAction menuItems[], u8 columnCount) { u8 i; u8 maxWidth; @@ -476,7 +476,7 @@ static void sub_8072620(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[ maxWidth = 0; for (i = 0; i < menuItemCount; i++) { - u8 width = (sub_8072CA4(menuItems[i][0]) + 7) / 8; + u8 width = (sub_8072CA4(menuItems[i].text) + 7) / 8; if (width > maxWidth) maxWidth = width; @@ -495,11 +495,11 @@ static void sub_8072620(u8 left, u8 top, u8 menuItemCount, u8 * const menuItems[ u8 row = 0; u8 j; for (j = 0; i + j < menuItemCount; j += columnCount, row++) - MenuPrint(menuItems[i + j][0], left + gMenu.columnXCoords[i % columnCount], top + 2 * row); + MenuPrint(menuItems[i + j].text, left + gMenu.columnXCoords[i % columnCount], top + 2 * row); } } -void sub_807274C(u8 left, u8 top, u8 menuItemCount, u8 a4, u8 * const menuItems[][2], u8 columnCount, u32 a7) +void sub_807274C(u8 left, u8 top, u8 menuItemCount, u8 a4, const struct MenuAction menuItems[], u8 columnCount, u32 a7) { u8 maxWidth = sub_80724F4(left, top, menuItemCount, menuItems, columnCount); diff --git a/src/script_menu.c b/src/script_menu.c index 1fdaba0c1..d351c3fa4 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -11,7 +11,7 @@ struct MultichoiceListStruct u8 count; }; -extern struct MultichoiceListStruct gMultichoiceLists[]; +extern const struct MultichoiceListStruct gMultichoiceLists[]; extern u16 gScriptResult; @@ -20,6 +20,7 @@ void sub_80B53B4(u8, u8, u8, struct MenuAction *list, u8); void sub_80B52B4(u8); void sub_80B5230(u8, u8, u8, u8, u8, u8); void task_yes_no_maybe(u8); +void sub_80B5684(u8); bool8 sub_80B5054(u8 left, u8 top, u8 var3, u8 var4) { @@ -65,7 +66,7 @@ void DrawMultichoiceMenu(u8 left, u8 top, u8 count, struct MenuAction *list, u8 if(width < newWidth) width = newWidth; } - + right = width; right = (right + left) + 1; @@ -102,14 +103,14 @@ void sub_80B5230(u8 left, u8 top, u8 right, u8 bottom, u8 unkVar, u8 count) void sub_80B52B4(u8 taskId) { s8 var; - + if(!gPaletteFade.active) { if(!gTasks[taskId].data[5]) var = ProcessMenuInputNoWrap(); else var = ProcessMenuInput(); - + if(var != -2) { if(var == -1) @@ -119,8 +120,10 @@ void sub_80B52B4(u8 taskId) PlaySE(5); gScriptResult = 127; } - else - return; + else + { + return; + } } else { @@ -136,14 +139,14 @@ void sub_80B52B4(u8 taskId) bool8 Multichoice(u8 var1, u8 var2, u8 var3, u8 var4) { - if(FuncIsActiveTask(sub_80B52B4) == 1) - return FALSE; - else - { - gScriptResult = 0xFF; - sub_80B53B4(var1, var2, gMultichoiceLists[var3].count, gMultichoiceLists[var3].list, var4); - return TRUE; - } + if(FuncIsActiveTask(sub_80B52B4) == 1) + return FALSE; + else + { + gScriptResult = 0xFF; + sub_80B53B4(var1, var2, gMultichoiceLists[var3].count, gMultichoiceLists[var3].list, var4); + return TRUE; + } } void sub_80B53B4(u8 left, u8 top, u8 count, struct MenuAction *list, u8 var4) @@ -172,28 +175,28 @@ void sub_80B53B4(u8 left, u8 top, u8 count, struct MenuAction *list, u8 var4) bool8 yes_no_box(u8 var1, u8 var2) { - u8 taskId; - - if(FuncIsActiveTask(task_yes_no_maybe) == 1) - return FALSE; - else - { - gScriptResult = 0xFF; - DisplayYesNoMenu(var1, var2, 1); - taskId = CreateTask(task_yes_no_maybe, 0x50); - gTasks[taskId].data[0] = var1; - gTasks[taskId].data[1] = var2; - return TRUE; - } + u8 taskId; + + if(FuncIsActiveTask(task_yes_no_maybe) == 1) + return FALSE; + else + { + gScriptResult = 0xFF; + DisplayYesNoMenu(var1, var2, 1); + taskId = CreateTask(task_yes_no_maybe, 0x50); + gTasks[taskId].data[0] = var1; + gTasks[taskId].data[1] = var2; + return TRUE; + } } // unused bool8 IsScriptActive(void) { - if(gScriptResult == 0xFF) - return FALSE; - else - return TRUE; + if(gScriptResult == 0xFF) + return FALSE; + else + return TRUE; } void task_yes_no_maybe(u8 taskId) @@ -227,3 +230,71 @@ void task_yes_no_maybe(u8 taskId) DestroyTask(taskId); EnableBothScriptContexts(); } + +bool8 sub_80B5578(u8 left, u8 top, u8 multichoiceId, u8 a4, u8 columnCount) +{ + u8 bottom = 0; + + if (FuncIsActiveTask(sub_80B5684) == TRUE) + { + return FALSE; + } + else + { + u8 taskId; + u8 width; + + gScriptResult = 255; + + sub_807274C(left, top, gMultichoiceLists[multichoiceId].count, 0, gMultichoiceLists[multichoiceId].list, columnCount, 0); + + taskId = CreateTask(sub_80B5684, 80); + + if (!((gMultichoiceLists[multichoiceId].count >> 1) < columnCount || (gMultichoiceLists[multichoiceId].count & 1)) + || columnCount == 1 || gMultichoiceLists[multichoiceId].count == columnCount) + { + bottom = (2 * (gMultichoiceLists[multichoiceId].count / columnCount)) + 1 + top; + } + else + { + bottom = (2 * (gMultichoiceLists[multichoiceId].count / columnCount)) + 3 + top; + } + + width = sub_807288C(columnCount); + gTasks[taskId].data[0] = left; + gTasks[taskId].data[1] = top; + gTasks[taskId].data[2] = width + left + 2; + gTasks[taskId].data[3] = bottom; + gTasks[taskId].data[4] = a4; + return TRUE; + } +} + +void sub_80B5684(u8 taskId) +{ + s8 var = sub_80727CC(); + + if (var != -2) + { + if (var == -1) + { + if (!gTasks[taskId].data[4]) + { + PlaySE(5); + gScriptResult = 127; + } + else + { + return; + } + } + else + { + gScriptResult = var; + } + sub_8072DEC(); + MenuZeroFillWindowRect(gTasks[taskId].data[0], gTasks[taskId].data[1], gTasks[taskId].data[2], gTasks[taskId].data[3]); + DestroyTask(taskId); + EnableBothScriptContexts(); + } +} |