Document more script_menu, lilycove harbor

This commit is contained in:
GriffinR
2019-09-19 17:26:25 -04:00
parent de0084ef7a
commit 275695c189
36 changed files with 782 additions and 737 deletions

View File

@@ -1559,8 +1559,8 @@ static void CreateMenuWithAnswers(u8 arg0)
pixelWidth = width;
}
width = convert_pixel_width_to_tile_width(pixelWidth);
left = sub_80E2D5C(left, width);
width = ConvertPixelWidthToTileWidth(pixelWidth);
left = ScriptMenu_AdjustLeftCoordFromWidth(left, width);
windowId = CreateAndShowWindow(left, top, width, count * 2);
SetStandardWindowBorderStyle(windowId, 0);

View File

@@ -785,14 +785,14 @@ struct MultichoiceListStruct
const struct MultichoiceListStruct gMultichoiceLists[] =
{
[MULTI_BRINEY_ON_DEWFORD] = MULTICHOICE(MultichoiceList_BrineyOnDewford),
[MULTI_UNUSED_1] = MULTICHOICE(MultichoiceList_Exit),
[MULTI_PC] = MULTICHOICE(MultichoiceList_Exit),
[MULTI_ENTERINFO] = MULTICHOICE(MultichoiceList_EnterInfo),
[MULTI_CONTEST_INFO] = MULTICHOICE(MultichoiceList_ContestInfo),
[MULTI_CONTEST_TYPE] = MULTICHOICE(MultichoiceList_ContestType),
[MULTI_DECOR_NOREGISTRY] = MULTICHOICE(MultichoiceList_DecorNoRegistry),
[MULTI_DECOR_REGISTRY] = MULTICHOICE(MultichoiceList_DecorRegistry),
[MULTI_REGISTER_MENU] = MULTICHOICE(MultichoiceList_RegisterMenu),
[MULTI_UNUSED_8] = MULTICHOICE(MultichoiceList_Exit),
[MULTI_SSTIDAL_LILYCOVE] = MULTICHOICE(MultichoiceList_Exit),
[MULTI_UNUSED_9] = MULTICHOICE(MultichoiceList_Exit),
[MULTI_UNUSED_10] = MULTICHOICE(MultichoiceList_Exit),
[MULTI_FRONTIER_PASS_INFO] = MULTICHOICE(MultichoiceList_FrontierPassInfo),
@@ -952,7 +952,7 @@ const u8 *const sPCNameStrings[] =
gText_LogOff,
};
const u8 *const gSSTidalDestinations[] =
const u8 *const gLilycoveSSTidalDestinations[] =
{
gText_SlateportCity,
gText_BattleFrontier,

View File

@@ -55,6 +55,7 @@
#include "constants/heal_locations.h"
#include "constants/map_types.h"
#include "constants/maps.h"
#include "constants/script_menu.h"
#include "constants/songs.h"
#include "constants/species.h"
#include "constants/moves.h"
@@ -82,6 +83,7 @@ static EWRAM_DATA u8 sPCBoxToSendMon = 0;
static EWRAM_DATA u32 sUnknown_0203AB70 = 0;
struct ListMenuTemplate gScrollableMultichoice_ListMenuTemplate;
static const u8 *const sScrollableMultichoiceOptions[][MAX_SCROLL_MULTI_LENGTH];
extern const u16 gEventObjectPalette8[];
extern const u16 gEventObjectPalette17[];
@@ -2270,144 +2272,160 @@ void BufferBattleTowerElevatorFloors(void)
gSpecialVar_0x8006 = 12;
}
// data[1]: number of options in the multichoice
// Scrollable Multichoice task data defines
#define tMaxItemsOnScreen data[0]
#define tNumItems data[1]
#define tLeft data[2]
#define tTop data[3]
#define tWidth data[4]
#define tHeight data[5]
#define tKeepOpenAfterSelect data[6]
#define tScrollOffset data[7]
#define tSelectedRow data[8]
#define tScrollMultiId data[11]
#define tScrollArrowId data[12]
#define tWindowId data[13]
#define tListTaskId data[14]
#define tTaskId data[15]
// data[9] and [10] unused
void ShowScrollableMultichoice(void)
{
u8 taskId = CreateTask(Task_ShowScrollableMultichoice, 8);
struct Task *task = &gTasks[taskId];
task->data[11] = gSpecialVar_0x8004;
task->tScrollMultiId = gSpecialVar_0x8004;
switch (gSpecialVar_0x8004)
{
case SCROLL_MULTI_NONE:
task->data[0] = 1;
task->data[1] = 1;
task->data[2] = 1;
task->data[3] = 1;
task->data[4] = 1;
task->data[5] = 1;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = 1;
task->tNumItems = 1;
task->tLeft = 1;
task->tTop = 1;
task->tWidth = 1;
task->tHeight = 1;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_GLASS_WORKSHOP_VENDOR:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN - 1;
task->data[1] = 8;
task->data[2] = 1;
task->data[3] = 1;
task->data[4] = 9;
task->data[5] = 10;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN - 1;
task->tNumItems = 8;
task->tLeft = 1;
task->tTop = 1;
task->tWidth = 9;
task->tHeight = 10;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_POKEMON_FAN_CLUB_RATER:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 12;
task->data[2] = 1;
task->data[3] = 1;
task->data[4] = 7;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 12;
task->tLeft = 1;
task->tTop = 1;
task->tWidth = 7;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 11;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 11;
task->tLeft = 14;
task->tTop = 1;
task->tWidth = 15;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 6;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 6;
task->tLeft = 14;
task->tTop = 1;
task->tWidth = 15;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 7;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 7;
task->tLeft = 14;
task->tTop = 1;
task->tWidth = 15;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 10;
task->data[2] = 14;
task->data[3] = 1;
task->data[4] = 15;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 10;
task->tLeft = 14;
task->tTop = 1;
task->tWidth = 15;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BERRY_POWDER_VENDOR:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 12;
task->data[2] = 15;
task->data[3] = 1;
task->data[4] = 14;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 12;
task->tLeft = 15;
task->tTop = 1;
task->tWidth = 14;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BF_RECEPTIONIST:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 10;
task->data[2] = 17;
task->data[3] = 1;
task->data[4] = 11;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 10;
task->tLeft = 17;
task->tTop = 1;
task->tWidth = 11;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BF_MOVE_TUTOR_1:
case SCROLL_MULTI_BF_MOVE_TUTOR_2:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 11;
task->data[2] = 15;
task->data[3] = 1;
task->data[4] = 14;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 11;
task->tLeft = 15;
task->tTop = 1;
task->tWidth = 14;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_SS_TIDAL_DESTINATION:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 7;
task->data[2] = 19;
task->data[3] = 1;
task->data[4] = 10;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 7;
task->tLeft = 19;
task->tTop = 1;
task->tWidth = 10;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
case SCROLL_MULTI_BATTLE_TENT_RULES:
task->data[0] = MAX_SCROLL_MULTI_ON_SCREEN;
task->data[1] = 7;
task->data[2] = 17;
task->data[3] = 1;
task->data[4] = 12;
task->data[5] = 12;
task->data[6] = 0;
task->data[15] = taskId;
task->tMaxItemsOnScreen = MAX_SCROLL_MULTI_ON_SCREEN;
task->tNumItems = 7;
task->tLeft = 17;
task->tTop = 1;
task->tWidth = 12;
task->tHeight = 12;
task->tKeepOpenAfterSelect = FALSE;
task->tTaskId = taskId;
break;
default:
gSpecialVar_Result = 0x7F;
gSpecialVar_Result = MULTI_B_PRESSED;
DestroyTask(taskId);
break;
}
}
static const u8 *const sScrollableMenuOptions[][MAX_SCROLL_MULTI_LENGTH] =
static const u8 *const sScrollableMultichoiceOptions[][MAX_SCROLL_MULTI_LENGTH] =
{
[SCROLL_MULTI_NONE] =
{
@@ -2565,7 +2583,7 @@ static const u8 *const sScrollableMenuOptions[][MAX_SCROLL_MULTI_LENGTH] =
static void Task_ShowScrollableMultichoice(u8 taskId)
{
u32 unk1;
u32 width;
u8 i, windowId;
struct WindowTemplate template;
struct Task *task = &gTasks[taskId];
@@ -2573,46 +2591,46 @@ static void Task_ShowScrollableMultichoice(u8 taskId)
ScriptContext2_Enable();
sScrollableMultichoice_ScrollOffset = 0;
sScrollableMultichoice_ItemSpriteId = MAX_SPRITES;
FillFrontierExchangeCornerWindowAndItemIcon(task->data[11], 0);
ShowBattleFrontierTutorWindow(task->data[11], 0);
sScrollableMultichoice_ListMenuItem = AllocZeroed(task->data[1] * 8);
FillFrontierExchangeCornerWindowAndItemIcon(task->tScrollMultiId, 0);
ShowBattleFrontierTutorWindow(task->tScrollMultiId, 0);
sScrollableMultichoice_ListMenuItem = AllocZeroed(task->tNumItems * 8);
sFrontierExchangeCorner_NeverRead = 0;
InitScrollableMultichoice();
for (unk1 = 0, i = 0; i < task->data[1]; i++)
for (width = 0, i = 0; i < task->tNumItems; i++)
{
const u8 *text = sScrollableMenuOptions[gSpecialVar_0x8004][i];
const u8 *text = sScrollableMultichoiceOptions[gSpecialVar_0x8004][i];
sScrollableMultichoice_ListMenuItem[i].name = text;
sScrollableMultichoice_ListMenuItem[i].id = i;
unk1 = display_text_and_get_width(text, unk1);
width = DisplayTextAndGetWidth(text, width);
}
task->data[4] = convert_pixel_width_to_tile_width(unk1);
task->tWidth = ConvertPixelWidthToTileWidth(width);
if (task->data[2] + task->data[4] > 0x1D)
if (task->tLeft + task->tWidth > MAX_MULTICHOICE_WIDTH + 1)
{
int unk2 = 0x1D - task->data[4];
if (unk2 < 0)
int adjustedLeft = MAX_MULTICHOICE_WIDTH + 1 - task->tWidth;
if (adjustedLeft < 0)
{
task->data[2] = 0;
task->tLeft = 0;
}
else
{
task->data[2] = unk2;
task->tLeft = adjustedLeft;
}
}
template = CreateWindowTemplate(0, task->data[2], task->data[3], task->data[4], task->data[5], 0xF, 0x64);
template = CreateWindowTemplate(0, task->tLeft, task->tTop, task->tWidth, task->tHeight, 0xF, 0x64);
windowId = AddWindow(&template);
task->data[13] = windowId;
task->tWindowId = windowId;
SetStandardWindowBorderStyle(windowId, 0);
gScrollableMultichoice_ListMenuTemplate.totalItems = task->data[1];
gScrollableMultichoice_ListMenuTemplate.maxShowed = task->data[0];
gScrollableMultichoice_ListMenuTemplate.windowId = task->data[13];
gScrollableMultichoice_ListMenuTemplate.totalItems = task->tNumItems;
gScrollableMultichoice_ListMenuTemplate.maxShowed = task->tMaxItemsOnScreen;
gScrollableMultichoice_ListMenuTemplate.windowId = task->tWindowId;
ScrollableMultichoice_UpdateScrollArrows(taskId);
task->data[14] = ListMenuInit(&gScrollableMultichoice_ListMenuTemplate, task->data[7], task->data[8]);
task->tListTaskId = ListMenuInit(&gScrollableMultichoice_ListMenuTemplate, task->tScrollOffset, task->tSelectedRow);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = ScrollableMultichoice_ProcessInput;
}
@@ -2648,12 +2666,12 @@ static void ScrollableMultichoice_MoveCursor(s32 itemIndex, bool8 onInit, struct
{
u16 selection;
struct Task *task = &gTasks[taskId];
ListMenuGetScrollAndRow(task->data[14], &selection, NULL);
ListMenuGetScrollAndRow(task->tListTaskId, &selection, NULL);
sScrollableMultichoice_ScrollOffset = selection;
ListMenuGetCurrentItemArrayId(task->data[14], &selection);
HideFrontierExchangeCornerItemIcon(task->data[11], sFrontierExchangeCorner_NeverRead);
FillFrontierExchangeCornerWindowAndItemIcon(task->data[11], selection);
ShowBattleFrontierTutorMoveDescription(task->data[11], selection);
ListMenuGetCurrentItemArrayId(task->tListTaskId, &selection);
HideFrontierExchangeCornerItemIcon(task->tScrollMultiId, sFrontierExchangeCorner_NeverRead);
FillFrontierExchangeCornerWindowAndItemIcon(task->tScrollMultiId, selection);
ShowBattleFrontierTutorMoveDescription(task->tScrollMultiId, selection);
sFrontierExchangeCorner_NeverRead = selection;
}
}
@@ -2661,25 +2679,26 @@ static void ScrollableMultichoice_MoveCursor(s32 itemIndex, bool8 onInit, struct
static void ScrollableMultichoice_ProcessInput(u8 taskId)
{
struct Task *task = &gTasks[taskId];
s32 input = ListMenu_ProcessInput(task->data[14]);
s32 input = ListMenu_ProcessInput(task->tListTaskId);
switch (input)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_CANCEL:
gSpecialVar_Result = 0x7F;
gSpecialVar_Result = MULTI_B_PRESSED;
PlaySE(SE_SELECT);
CloseScrollableMultichoice(taskId);
break;
default:
gSpecialVar_Result = input;
PlaySE(SE_SELECT);
if (!task->data[6])
if (!task->tKeepOpenAfterSelect)
{
CloseScrollableMultichoice(taskId);
}
else if (input == task->data[1] - 1)
// if selected option was the last one (Exit)
else if (input == task->tNumItems - 1)
{
CloseScrollableMultichoice(taskId);
}
@@ -2697,28 +2716,29 @@ static void CloseScrollableMultichoice(u8 taskId)
{
u16 selection;
struct Task *task = &gTasks[taskId];
ListMenuGetCurrentItemArrayId(task->data[14], &selection);
HideFrontierExchangeCornerItemIcon(task->data[11], selection);
ListMenuGetCurrentItemArrayId(task->tListTaskId, &selection);
HideFrontierExchangeCornerItemIcon(task->tScrollMultiId, selection);
ScrollableMultichoice_RemoveScrollArrows(taskId);
DestroyListMenuTask(task->data[14], NULL, NULL);
DestroyListMenuTask(task->tListTaskId, NULL, NULL);
Free(sScrollableMultichoice_ListMenuItem);
ClearStdWindowAndFrameToTransparent(task->data[13], 1);
FillWindowPixelBuffer(task->data[13], PIXEL_FILL(0));
CopyWindowToVram(task->data[13], 2);
RemoveWindow(task->data[13]);
ClearStdWindowAndFrameToTransparent(task->tWindowId, 1);
FillWindowPixelBuffer(task->tWindowId, PIXEL_FILL(0));
CopyWindowToVram(task->tWindowId, 2);
RemoveWindow(task->tWindowId);
DestroyTask(taskId);
EnableBothScriptContexts();
}
// Functionally unused; tKeepOpenAfterSelect is only != 0 in unused functions
static void sub_813A600(u8 taskId)
{
switch (gTasks[taskId].data[6])
switch (gTasks[taskId].tKeepOpenAfterSelect)
{
case 1:
default:
break;
case 2:
gTasks[taskId].data[6] = 1;
gTasks[taskId].tKeepOpenAfterSelect = 1;
gTasks[taskId].func = sub_813A664;
break;
}
@@ -2734,7 +2754,7 @@ void sub_813A630(void)
}
else
{
gTasks[taskId].data[6]++;
gTasks[taskId].tKeepOpenAfterSelect++;
}
}
@@ -2763,24 +2783,24 @@ static void ScrollableMultichoice_UpdateScrollArrows(u8 taskId)
struct Task *task = &gTasks[taskId];
struct ScrollArrowsTemplate template = sScrollableMultichoice_ScrollArrowsTemplate;
if (task->data[0] != task->data[1])
if (task->tMaxItemsOnScreen != task->data[1])
{
template.firstX = (task->data[4] / 2) * 8 + 12 + (task->data[2] - 1) * 8;
template.firstX = (task->tWidth / 2) * 8 + 12 + (task->tLeft - 1) * 8;
template.firstY = 8;
template.secondX = (task->data[4] / 2) * 8 + 12 + (task->data[2] - 1) * 8;
template.secondY = task->data[5] * 8 + 10;
template.secondX = (task->tWidth / 2) * 8 + 12 + (task->tLeft - 1) * 8;
template.secondY = task->tHeight * 8 + 10;
template.fullyUpThreshold = 0;
template.fullyDownThreshold = task->data[1] - task->data[0];
task->data[12] = AddScrollIndicatorArrowPair(&template, &sScrollableMultichoice_ScrollOffset);
template.fullyDownThreshold = task->data[1] - task->tMaxItemsOnScreen;
task->tScrollArrowId = AddScrollIndicatorArrowPair(&template, &sScrollableMultichoice_ScrollOffset);
}
}
static void ScrollableMultichoice_RemoveScrollArrows(u8 taskId)
{
struct Task *task = &gTasks[taskId];
if (task->data[0] != task->data[1])
if (task->tMaxItemsOnScreen != task->data[1])
{
RemoveScrollIndicatorArrowPair(task->data[12]);
RemoveScrollIndicatorArrowPair(task->tScrollArrowId);
}
}
@@ -3041,7 +3061,7 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
{
#include "data/battle_frontier/battle_frontier_exchange_corner.h"
if (menu > SCROLL_MULTI_POKEMON_FAN_CLUB_RATER && menu < SCROLL_MULTI_BERRY_POWDER_VENDOR)
if (menu >= SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1 && menu <= SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR)
{
FillWindowPixelRect(0, PIXEL_FILL(1), 0, 0, 216, 32);
switch (menu)
@@ -3240,17 +3260,17 @@ void sub_813ADD4(void)
if (taskId != 0xFF)
{
struct Task *task = &gTasks[taskId];
ListMenuGetScrollAndRow(task->data[14], &scrollOffset, &selectedRow);
SetStandardWindowBorderStyle(task->data[13], 0);
ListMenuGetScrollAndRow(task->tListTaskId, &scrollOffset, &selectedRow);
SetStandardWindowBorderStyle(task->tWindowId, 0);
for (i = 0; i < MAX_SCROLL_MULTI_ON_SCREEN; i++)
{
AddTextPrinterParameterized5(task->data[13], 1, sScrollableMenuOptions[gSpecialVar_0x8004][scrollOffset + i], 10, i * 16, TEXT_SPEED_FF, NULL, 0, 0);
AddTextPrinterParameterized5(task->tWindowId, 1, sScrollableMultichoiceOptions[gSpecialVar_0x8004][scrollOffset + i], 10, i * 16, TEXT_SPEED_FF, NULL, 0, 0);
}
AddTextPrinterParameterized(task->data[13], 1, gText_SelectorArrow, 0, selectedRow * 16, TEXT_SPEED_FF, NULL);
PutWindowTilemap(task->data[13]);
CopyWindowToVram(task->data[13], 3);
AddTextPrinterParameterized(task->tWindowId, 1, gText_SelectorArrow, 0, selectedRow * 16, TEXT_SPEED_FF, NULL);
PutWindowTilemap(task->tWindowId);
CopyWindowToVram(task->tWindowId, 3);
}
}
@@ -3299,17 +3319,33 @@ void sub_813AF48(void)
if (taskId != 0xFF)
{
struct Task *task = &gTasks[taskId];
DestroyListMenuTask(task->data[14], NULL, NULL);
DestroyListMenuTask(task->tListTaskId, NULL, NULL);
Free(sScrollableMultichoice_ListMenuItem);
ClearStdWindowAndFrameToTransparent(task->data[13], TRUE);
FillWindowPixelBuffer(task->data[13], PIXEL_FILL(0));
ClearWindowTilemap(task->data[13]);
CopyWindowToVram(task->data[13], 2);
RemoveWindow(task->data[13]);
ClearStdWindowAndFrameToTransparent(task->tWindowId, TRUE);
FillWindowPixelBuffer(task->tWindowId, PIXEL_FILL(0));
ClearWindowTilemap(task->tWindowId);
CopyWindowToVram(task->tWindowId, 2);
RemoveWindow(task->tWindowId);
DestroyTask(taskId);
}
}
// Undefine Scrollable Multichoice task data macros
#undef tMaxItemsOnScreen
#undef tNumItems
#undef tLeft
#undef tTop
#undef tWidth
#undef tHeight
#undef tKeepOpenAfterSelect
#undef tScrollOffset
#undef tSelectedRow
#undef tScrollMultiId
#undef tScrollArrowId
#undef tWindowId
#undef tListTaskId
#undef tTaskId
void DoDeoxysRockInteraction(void)
{
CreateTask(Task_DeoxysRockInteraction, 8);

View File

@@ -27,7 +27,7 @@ static void ReshowPCMenuAfterHallOfFamePC(void)
{
ScriptContext2_Enable();
Overworld_PlaySpecialMapMusic();
ScrSpecial_CreatePCMenu();
ScriptMenu_CreatePCMultichoice();
ScriptMenu_DisplayPCStartupPrompt();
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK);
CreateTask(Task_WaitForPaletteFade, 10);

View File

@@ -45,7 +45,7 @@ int GetMaxWidthInMenuTable(const struct MenuAction *str, int arg1)
var = stringWidth;
}
return convert_pixel_width_to_tile_width(var);
return ConvertPixelWidthToTileWidth(var);
}
int sub_81DB3D8(const struct MenuAction *str, const u8* arg1, int arg2)
@@ -59,7 +59,7 @@ int sub_81DB3D8(const struct MenuAction *str, const u8* arg1, int arg2)
var = stringWidth;
}
return convert_pixel_width_to_tile_width(var);
return ConvertPixelWidthToTileWidth(var);
}
int Intl_GetListMenuWidth(const struct ListMenuTemplate *listMenu)

View File

@@ -1155,7 +1155,7 @@ static void PrintStoryList(void)
if (curWidth > width)
width = curWidth;
}
sStorytellerWindowId = CreateWindowFromRect(0, 0, convert_pixel_width_to_tile_width(width), GetFreeStorySlot() * 2 + 2);
sStorytellerWindowId = CreateWindowFromRect(0, 0, ConvertPixelWidthToTileWidth(width), GetFreeStorySlot() * 2 + 2);
SetStandardWindowBorderStyle(sStorytellerWindowId, 0);
for (i = 0; i < 4; i++)
{

View File

@@ -20,21 +20,21 @@
#include "data/script_menu.h"
EWRAM_DATA u8 gUnknown_02039F90 = 0;
EWRAM_DATA u8 gProcessInputDelay = 0;
static u8 gUnknown_03001124[ARRAY_COUNT(gSSTidalDestinations)];
static u32 filler_0300112c;
static u8 sLilycoveSSTidalSelections[ARRAY_COUNT(gLilycoveSSTidalDestinations)];
//static u32 filler_0300112c;
static void Task_HandleMultichoiceInput(u8);
static void Task_HandleYesNoInput(u8);
static void Task_HandleMultichoiceGridInput(u8);
static void DrawMultichoiceMenu(u8, u8, u8, bool8, u8);
static void sub_80E1FBC(u8, u8, u8, u8);
static void sub_80E2A94(u8);
static void CreatePCMenu(void);
static void sub_80E2578(void);
static void DrawLinkServicesMultichoiceMenu(u8);
static void CreatePCMultichoice(void);
static void CreateLilycoveSSTidalMultichoice(void);
static bool8 IsPicboxClosed(void);
static void CreateMultichoiceStartMenu(void);
static void CreateStartMenuForPokenavTutorial(void);
static void sub_80E2CC4(u8, u8, u8, u8);
bool8 ScriptMenu_Multichoice(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPress)
@@ -102,11 +102,11 @@ static void DrawMultichoiceMenu(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPre
for (i = 0; i < count; i++)
{
width = display_text_and_get_width(actions[i].text, width);
width = DisplayTextAndGetWidth(actions[i].text, width);
}
newWidth = convert_pixel_width_to_tile_width(width);
left = sub_80E2D5C(left, newWidth);
newWidth = ConvertPixelWidthToTileWidth(width);
left = ScriptMenu_AdjustLeftCoordFromWidth(left, newWidth);
windowId = CreateWindowFromRect(left, top, newWidth, count * 2);
SetStandardWindowBorderStyle(windowId, 0);
PrintMenuTable(windowId, count, actions);
@@ -128,13 +128,13 @@ static void sub_80E1FBC(u8 ignoreBPress, u8 count, u8 windowId, u8 multichoiceId
{
u8 i;
u8 taskId;
gUnknown_02039F90 = 2;
gProcessInputDelay = 2;
for (i = 0; i < ARRAY_COUNT(gLinkServicesMultichoiceIds); i++)
{
if (gLinkServicesMultichoiceIds[i] == multichoiceId)
{
gUnknown_02039F90 = 12;
gProcessInputDelay = 12;
}
}
@@ -150,7 +150,7 @@ static void sub_80E1FBC(u8 ignoreBPress, u8 count, u8 windowId, u8 multichoiceId
gTasks[taskId].tWindowId = windowId;
gTasks[taskId].tMultichoiceId = multichoiceId;
sub_80E2A94(multichoiceId);
DrawLinkServicesMultichoiceMenu(multichoiceId);
}
static void Task_HandleMultichoiceInput(u8 taskId)
@@ -160,9 +160,9 @@ static void Task_HandleMultichoiceInput(u8 taskId)
if (!gPaletteFade.active)
{
if (gUnknown_02039F90)
if (gProcessInputDelay)
{
gUnknown_02039F90--;
gProcessInputDelay--;
}
else
{
@@ -173,7 +173,7 @@ static void Task_HandleMultichoiceInput(u8 taskId)
if (gMain.newKeys & (DPAD_UP | DPAD_DOWN))
{
sub_80E2A94(tMultichoiceId);
DrawLinkServicesMultichoiceMenu(tMultichoiceId);
}
if (selection != MENU_NOTHING_CHOSEN)
@@ -266,12 +266,12 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr
for (i = 0; i < gMultichoiceLists[multichoiceId].count; i++)
{
width = display_text_and_get_width(gMultichoiceLists[multichoiceId].list[i].text, width);
width = DisplayTextAndGetWidth(gMultichoiceLists[multichoiceId].list[i].text, width);
}
newWidth = convert_pixel_width_to_tile_width(width);
newWidth = ConvertPixelWidthToTileWidth(width);
left = sub_80E2D5C(left, columnCount * newWidth);
left = ScriptMenu_AdjustLeftCoordFromWidth(left, columnCount * newWidth);
rowCount = gMultichoiceLists[multichoiceId].count / columnCount;
taskId = CreateTask(Task_HandleMultichoiceGridInput, 80);
@@ -313,7 +313,7 @@ static void Task_HandleMultichoiceGridInput(u8 taskId)
#undef tWindowId
bool16 ScrSpecial_CreatePCMenu(void)
bool16 ScriptMenu_CreatePCMultichoice(void)
{
if (FuncIsActiveTask(Task_HandleMultichoiceInput) == TRUE)
{
@@ -322,12 +322,12 @@ bool16 ScrSpecial_CreatePCMenu(void)
else
{
gSpecialVar_Result = 0xFF;
CreatePCMenu();
CreatePCMultichoice();
return TRUE;
}
}
static void CreatePCMenu(void)
static void CreatePCMultichoice(void)
{
u8 y = 8;
u32 pixelWidth = 0;
@@ -338,15 +338,15 @@ static void CreatePCMenu(void)
for (i = 0; i < ARRAY_COUNT(sPCNameStrings); i++)
{
pixelWidth = display_text_and_get_width(sPCNameStrings[i], pixelWidth);
pixelWidth = DisplayTextAndGetWidth(sPCNameStrings[i], pixelWidth);
}
if (FlagGet(FLAG_SYS_GAME_CLEAR))
{
pixelWidth = display_text_and_get_width(gText_HallOfFame, pixelWidth);
pixelWidth = DisplayTextAndGetWidth(gText_HallOfFame, pixelWidth);
}
width = convert_pixel_width_to_tile_width(pixelWidth);
width = ConvertPixelWidthToTileWidth(pixelWidth);
if (FlagGet(FLAG_SYS_GAME_CLEAR)) // player has cleared game?
{
@@ -373,7 +373,7 @@ static void CreatePCMenu(void)
PrintPlayerNameOnWindow(windowId, gStringVar4, y, 17);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, numChoices, 0);
CopyWindowToVram(windowId, 3);
sub_80E1FBC(FALSE, numChoices, windowId, 1);
sub_80E1FBC(FALSE, numChoices, windowId, MULTI_PC);
}
void ScriptMenu_DisplayPCStartupPrompt(void)
@@ -382,7 +382,7 @@ void ScriptMenu_DisplayPCStartupPrompt(void)
AddTextPrinterParameterized2(0, 1, gText_WhichPCShouldBeAccessed, 0, NULL, 2, 1, 3);
}
bool8 sub_80E2548(void)
bool8 ScriptMenu_CreateLilycoveSSTidalMultichoice(void)
{
if (FuncIsActiveTask(Task_HandleMultichoiceInput) == TRUE)
{
@@ -391,14 +391,16 @@ bool8 sub_80E2548(void)
else
{
gSpecialVar_Result = 0xFF;
sub_80E2578();
CreateLilycoveSSTidalMultichoice();
return TRUE;
}
}
static void sub_80E2578(void)
// gSpecialVar_0x8004 is 1 if the Sailor was shown multiple event tickets at the same time
// otherwise gSpecialVar_0x8004 is 0
static void CreateLilycoveSSTidalMultichoice(void)
{
u8 temp = 0;
u8 selectionCount = 0;
u8 count;
u32 pixelWidth;
u8 width;
@@ -406,21 +408,22 @@ static void sub_80E2578(void)
u8 i;
u32 j;
for (i = 0; i < ARRAY_COUNT(gUnknown_03001124); i++)
for (i = 0; i < ARRAY_COUNT(sLilycoveSSTidalSelections); i++)
{
gUnknown_03001124[i] = 0xFF;
sLilycoveSSTidalSelections[i] = 0xFF;
}
GetFontAttribute(1, FONTATTR_MAX_LETTER_WIDTH);
if (gSpecialVar_0x8004 == 0)
{
gUnknown_03001124[temp] = 0;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_SLATEPORT;
selectionCount++;
if (FlagGet(FLAG_MET_SCOTT_ON_SS_TIDAL) == TRUE)
{
gUnknown_03001124[temp] = 1;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_BATTLE_FRONTIER;
selectionCount++;
}
}
@@ -428,14 +431,14 @@ static void sub_80E2578(void)
{
if (gSpecialVar_0x8004 == 0)
{
gUnknown_03001124[temp] = 2;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_SOUTHERN_ISLAND;
selectionCount++;
}
if (gSpecialVar_0x8004 == 1 && FlagGet(FLAG_HAS_EON_TICKET) == FALSE)
{
gUnknown_03001124[temp] = 2;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_SOUTHERN_ISLAND;
selectionCount++;
FlagSet(FLAG_HAS_EON_TICKET);
}
}
@@ -444,14 +447,14 @@ static void sub_80E2578(void)
{
if (gSpecialVar_0x8004 == 0)
{
gUnknown_03001124[temp] = 3;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_NAVEL_ROCK;
selectionCount++;
}
if (gSpecialVar_0x8004 == 1 && FlagGet(FLAG_HAS_MYSTIC_TICKET) == FALSE)
{
gUnknown_03001124[temp] = 3;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_NAVEL_ROCK;
selectionCount++;
FlagSet(FLAG_HAS_MYSTIC_TICKET);
}
}
@@ -460,14 +463,14 @@ static void sub_80E2578(void)
{
if (gSpecialVar_0x8004 == 0)
{
gUnknown_03001124[temp] = 4;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_BIRTH_ISLAND;
selectionCount++;
}
if (gSpecialVar_0x8004 == 1 && FlagGet(FLAG_HAS_AURORA_TICKET) == FALSE)
{
gUnknown_03001124[temp] = 4;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_BIRTH_ISLAND;
selectionCount++;
FlagSet(FLAG_HAS_AURORA_TICKET);
}
}
@@ -476,28 +479,28 @@ static void sub_80E2578(void)
{
if (gSpecialVar_0x8004 == 0)
{
gUnknown_03001124[temp] = 5;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_FARAWAY_ISLAND;
selectionCount++;
}
if (gSpecialVar_0x8004 == 1 && FlagGet(FLAG_HAS_OLD_SEA_MAP) == FALSE)
{
gUnknown_03001124[temp] = 5;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_FARAWAY_ISLAND;
selectionCount++;
FlagSet(FLAG_HAS_OLD_SEA_MAP);
}
}
gUnknown_03001124[temp] = 6;
temp++;
sLilycoveSSTidalSelections[selectionCount] = SSTIDAL_SELECTION_EXIT;
selectionCount++;
if (gSpecialVar_0x8004 == 0 && FlagGet(FLAG_MET_SCOTT_ON_SS_TIDAL) == TRUE)
{
count = temp;
count = selectionCount;
}
count = temp;
if (count == 7)
count = selectionCount;
if (count == SSTIDAL_SELECTION_COUNT)
{
gSpecialVar_0x8004 = SCROLL_MULTI_SS_TIDAL_DESTINATION;
ShowScrollableMultichoice();
@@ -506,39 +509,39 @@ static void sub_80E2578(void)
{
pixelWidth = 0;
for (j = 0; j < ARRAY_COUNT(gSSTidalDestinations); j++)
for (j = 0; j < ARRAY_COUNT(gLilycoveSSTidalDestinations); j++)
{
u8 test = gUnknown_03001124[j];
if (test != 0xFF)
u8 selection = sLilycoveSSTidalSelections[j];
if (selection != 0xFF)
{
pixelWidth = display_text_and_get_width(gSSTidalDestinations[test], pixelWidth);
pixelWidth = DisplayTextAndGetWidth(gLilycoveSSTidalDestinations[selection], pixelWidth);
}
}
width = convert_pixel_width_to_tile_width(pixelWidth);
windowId = CreateWindowFromRect(28 - width, (6 - count) * 2, width, count * 2);
width = ConvertPixelWidthToTileWidth(pixelWidth);
windowId = CreateWindowFromRect(MAX_MULTICHOICE_WIDTH - width, (6 - count) * 2, width, count * 2);
SetStandardWindowBorderStyle(windowId, 0);
for (temp = 0, i = 0; i < ARRAY_COUNT(gSSTidalDestinations); i++)
for (selectionCount = 0, i = 0; i < ARRAY_COUNT(gLilycoveSSTidalDestinations); i++)
{
if (gUnknown_03001124[i] != 0xFF)
if (sLilycoveSSTidalSelections[i] != 0xFF)
{
AddTextPrinterParameterized(windowId, 1, gSSTidalDestinations[gUnknown_03001124[i]], 8, temp * 16 + 1, TEXT_SPEED_FF, NULL);
temp++;
AddTextPrinterParameterized(windowId, 1, gLilycoveSSTidalDestinations[sLilycoveSSTidalSelections[i]], 8, selectionCount * 16 + 1, TEXT_SPEED_FF, NULL);
selectionCount++;
}
}
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, count, count - 1);
CopyWindowToVram(windowId, 3);
sub_80E1FBC(FALSE, count, windowId, 8);
sub_80E1FBC(FALSE, count, windowId, MULTI_SSTIDAL_LILYCOVE);
}
}
void sub_80E2878(void)
void GetLilycoveSSTidalSelection(void)
{
if (gSpecialVar_Result != MULTI_B_PRESSED)
{
gSpecialVar_Result = gUnknown_03001124[gSpecialVar_Result];
gSpecialVar_Result = sLilycoveSSTidalSelections[gSpecialVar_Result];
}
}
@@ -635,7 +638,7 @@ void ClearToTransparentAndRemoveWindow(u8 windowId)
RemoveWindow(windowId);
}
static void sub_80E2A94(u8 multichoiceId)
static void DrawLinkServicesMultichoiceMenu(u8 multichoiceId)
{
switch (multichoiceId)
{
@@ -666,19 +669,21 @@ static void sub_80E2A94(u8 multichoiceId)
}
}
bool16 CreateStartMenuForPokenavTutorial(void)
bool16 ScriptMenu_CreateStartMenuForPokenavTutorial(void)
{
if (FuncIsActiveTask(Task_HandleMultichoiceInput) == TRUE)
{
return FALSE;
}
gSpecialVar_Result = 0xFF;
CreateMultichoiceStartMenu();
return TRUE;
else
{
gSpecialVar_Result = 0xFF;
CreateStartMenuForPokenavTutorial();
return TRUE;
}
}
static void CreateMultichoiceStartMenu(void)
static void CreateStartMenuForPokenavTutorial(void)
{
u8 windowId = CreateWindowFromRect(21, 0, 7, 18);
SetStandardWindowBorderStyle(windowId, 0);
@@ -700,7 +705,7 @@ static void CreateMultichoiceStartMenu(void)
static void sub_80E2CC4(bool8 ignoreBPress, u8 unused, u8 windowId, u8 multichoiceId)
{
u8 taskId;
gUnknown_02039F90 = 2;
gProcessInputDelay = 2;
taskId = CreateTask(Task_HandleMultichoiceInput, 80);
gTasks[taskId].tIgnoreBPress = ignoreBPress;
gTasks[taskId].tDoWrap = 0;
@@ -717,16 +722,16 @@ static void sub_80E2CC4(bool8 ignoreBPress, u8 unused, u8 windowId, u8 multichoi
#undef tWindowId
#undef tMultichoiceId
static int display_text_and_get_width_internal(const u8 *str)
static int DisplayTextAndGetWidthInternal(const u8 *str)
{
u8 temp[64];
StringExpandPlaceholders(temp, str);
return GetStringWidth(1, temp, 0);
}
int display_text_and_get_width(const u8 *str, int prevMaxWidth)
int DisplayTextAndGetWidth(const u8 *str, int prevMaxWidth)
{
int len = display_text_and_get_width_internal(str);
int len = DisplayTextAndGetWidthInternal(str);
if (len < prevMaxWidth)
{
len = prevMaxWidth;
@@ -734,30 +739,26 @@ int display_text_and_get_width(const u8 *str, int prevMaxWidth)
return len;
}
int convert_pixel_width_to_tile_width(int width)
int ConvertPixelWidthToTileWidth(int width)
{
return (((width + 9) / 8) + 1) > 28 ? 28 : (((width + 9) / 8) + 1);
return (((width + 9) / 8) + 1) > MAX_MULTICHOICE_WIDTH ? MAX_MULTICHOICE_WIDTH : (((width + 9) / 8) + 1);
}
int sub_80E2D5C(int a0, int a1)
int ScriptMenu_AdjustLeftCoordFromWidth(int left, int width)
{
int ret = a0;
int adjustedLeft = left;
if (a0 + a1 > 28)
if (left + width > MAX_MULTICHOICE_WIDTH)
{
if (28 - a1 < 0)
if (MAX_MULTICHOICE_WIDTH - width < 0)
{
ret = 0;
adjustedLeft = 0;
}
else
{
ret = 28 - a1;
adjustedLeft = MAX_MULTICHOICE_WIDTH - width;
}
}
else
{
ret = a0;
}
return ret;
return adjustedLeft;
}

View File

@@ -601,8 +601,8 @@ const u8 gText_Phoebe[] = _("PHOEBE");
const u8 gText_Glacia[] = _("GLACIA");
const u8 gText_Petalburg[] = _("PETALBURG");
const u8 gText_Slateport[] = _("SLATEPORT");
const u8 gText_Littleroot[] = _("LITTLEROOT"); //unused
const u8 gText_Lilycove[] = _("LILYCOVE"); //unused
const u8 gText_Littleroot[] = _("LITTLEROOT"); // Unused. Given the context, Briney may at one point have been able to sail the player here
const u8 gText_Lilycove[] = _("LILYCOVE"); // Unused. Given the context, Briney may at one point have been able to sail the player here
const u8 gText_Dewford[] = _("DEWFORD");
const u8 gText_Enter2[] = _("ENTER");
const u8 gText_Info2[] = _("INFO");

View File

@@ -71,7 +71,7 @@ void CreateAvailableDecorationsMenu(u8 taskId)
if (curWidth > windowWidth)
windowWidth = curWidth;
}
windowTemplate.width = convert_pixel_width_to_tile_width(windowWidth);
windowTemplate.width = ConvertPixelWidthToTileWidth(windowWidth);
data[3] = AddWindow(&windowTemplate);
DrawStdFrameWithCustomTileAndPalette(data[3], FALSE, 0x214, 14);
for (i = 0; i < 4; i++)