Debug Menu: Re-render 'Flags & Vars' rather than re-create

This commit is contained in:
Martin Griffin 2024-04-20 16:31:04 +01:00
parent 143d6fb289
commit 62ce29d0e9

View file

@ -1344,36 +1344,16 @@ static void Debug_InitDebugBattleData(void)
sDebugBattleData->aiFlags[i] = FALSE;
}
static void Debug_RefreshListMenu(u8 taskId)
static void Debug_GenerateListMenuNames(u32 totalItems)
{
u16 i;
const u8 sColor_Red[] = _("{COLOR RED}");
const u8 sColor_Green[] = _("{COLOR GREEN}");
u8 totalItems = 0, flagResult = 0;
u32 i, flagResult = 0;
u8 const *name = NULL;
if (sDebugMenuListData->listId == 0)
{
gMultiuseListMenuTemplate = sDebugMenu_ListTemplate_FlagsVars;
totalItems = gMultiuseListMenuTemplate.totalItems;
}
else if (sDebugMenuListData->listId == 1 && sDebugBattleData->submenu <= 1)
{
gMultiuseListMenuTemplate = sDebugMenu_ListTemplate_Battle_1;
totalItems = gMultiuseListMenuTemplate.totalItems;
}
else if (sDebugMenuListData->listId == 1 && sDebugBattleData->submenu > 1)
{
gMultiuseListMenuTemplate = sDebugMenu_ListTemplate_Battle_2;
totalItems = 7;
}
// Failsafe to prevent memory corruption
totalItems = min(totalItems, DEBUG_MAX_MENU_ITEMS);
// Copy item names for all entries but the last (which is Cancel)
for(i = 0; i < totalItems; i++)
for (i = 0; i < totalItems; i++)
{
if (sDebugMenuListData->listId == 1 && sDebugBattleData->submenu > 1)
{
u16 species;
@ -1429,6 +1409,31 @@ static void Debug_RefreshListMenu(u8 taskId)
sDebugMenuListData->listItems[i].name = &sDebugMenuListData->itemNames[i][0];
sDebugMenuListData->listItems[i].id = i;
}
}
static void Debug_RefreshListMenu(u8 taskId)
{
u8 totalItems = 0;
if (sDebugMenuListData->listId == 0)
{
gMultiuseListMenuTemplate = sDebugMenu_ListTemplate_FlagsVars;
totalItems = gMultiuseListMenuTemplate.totalItems;
}
else if (sDebugMenuListData->listId == 1 && sDebugBattleData->submenu <= 1)
{
gMultiuseListMenuTemplate = sDebugMenu_ListTemplate_Battle_1;
totalItems = gMultiuseListMenuTemplate.totalItems;
}
else if (sDebugMenuListData->listId == 1 && sDebugBattleData->submenu > 1)
{
gMultiuseListMenuTemplate = sDebugMenu_ListTemplate_Battle_2;
totalItems = 7;
}
// Failsafe to prevent memory corruption
totalItems = min(totalItems, DEBUG_MAX_MENU_ITEMS);
Debug_GenerateListMenuNames(totalItems);
// Set list menu data
gMultiuseListMenuTemplate.items = sDebugMenuListData->listItems;
@ -1595,7 +1600,8 @@ static void DebugTask_HandleMenuInput_FlagsVars(u8 taskId)
else
{
func(taskId);
Debug_RedrawListMenu(taskId);
Debug_GenerateListMenuNames(gMultiuseListMenuTemplate.totalItems);
RedrawListMenu(gTasks[taskId].tMenuTaskId);
}
// Remove TRUE/FALSE window for functions that haven't been assigned flags