M_InterruptMenuWithChallenges: Fix a rendering error where an irrelevant unlockable could be highlighted during the fade-in before jumping into position

This commit is contained in:
toaster 2023-01-29 23:59:53 +00:00
parent 20e9b2f5e8
commit 749de36734

View file

@ -47,51 +47,6 @@ menu_t MISC_StatisticsDef = {
struct challengesmenu_s challengesmenu;
menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
{
UINT8 i;
M_UpdateUnlockablesAndExtraEmblems(false);
if ((challengesmenu.pending = challengesmenu.requestnew = (M_GetNextAchievedUnlock() < MAXUNLOCKABLES)))
{
MISC_ChallengesDef.prevMenu = desiredmenu;
}
if (challengesmenu.pending || desiredmenu == NULL)
{
challengesmenu.currentunlock = MAXUNLOCKABLES;
challengesmenu.unlockcondition = NULL;
M_PopulateChallengeGrid();
if (gamedata->challengegrid)
challengesmenu.extradata = M_ChallengeGridExtraData();
memset(setup_explosions, 0, sizeof(setup_explosions));
memset(&challengesmenu.unlockcount, 0, sizeof(challengesmenu.unlockcount));
for (i = 0; i < MAXUNLOCKABLES; i++)
{
if (!unlockables[i].conditionset)
{
continue;
}
challengesmenu.unlockcount[CC_TOTAL]++;
if (!gamedata->unlocked[i])
{
continue;
}
challengesmenu.unlockcount[CC_UNLOCKED]++;
}
return &MISC_ChallengesDef;
}
return desiredmenu;
}
static void M_ChallengesAutoFocus(UINT8 unlockid, boolean fresh)
{
UINT8 i;
@ -196,6 +151,56 @@ static void M_ChallengesAutoFocus(UINT8 unlockid, boolean fresh)
}
}
menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
{
UINT8 i;
UINT16 newunlock = M_GetNextAchievedUnlock();
M_UpdateUnlockablesAndExtraEmblems(false);
if ((challengesmenu.pending = (newunlock < MAXUNLOCKABLES)))
{
MISC_ChallengesDef.prevMenu = desiredmenu;
}
if (challengesmenu.pending || desiredmenu == NULL)
{
challengesmenu.requestnew = false;
challengesmenu.currentunlock = MAXUNLOCKABLES;
challengesmenu.unlockcondition = NULL;
M_PopulateChallengeGrid();
if (gamedata->challengegrid)
challengesmenu.extradata = M_ChallengeGridExtraData();
memset(setup_explosions, 0, sizeof(setup_explosions));
memset(&challengesmenu.unlockcount, 0, sizeof(challengesmenu.unlockcount));
for (i = 0; i < MAXUNLOCKABLES; i++)
{
if (!unlockables[i].conditionset)
{
continue;
}
challengesmenu.unlockcount[CC_TOTAL]++;
if (!gamedata->unlocked[i])
{
continue;
}
challengesmenu.unlockcount[CC_UNLOCKED]++;
}
if (challengesmenu.pending)
M_ChallengesAutoFocus(newunlock, true);
return &MISC_ChallengesDef;
}
return desiredmenu;
}
void M_Challenges(INT32 choice)
{
UINT8 i;
@ -249,7 +254,6 @@ void M_ChallengesTick(void)
{
const UINT8 pid = 0;
UINT8 i, newunlock = MAXUNLOCKABLES;
boolean fresh = (challengesmenu.currentunlock >= MAXUNLOCKABLES);
// Ticking
challengesmenu.ticker++;
@ -274,7 +278,7 @@ void M_ChallengesTick(void)
if ((newunlock = M_GetNextAchievedUnlock()) < MAXUNLOCKABLES)
{
// We got one!
M_ChallengesAutoFocus(newunlock, fresh);
M_ChallengesAutoFocus(newunlock, false);
}
else
{