Unlock explosions are now slightly delayed

Done so it doesn't begin during a transition, and you get to properly appreciate the first one

Comes with the following changes and refactors:
* Uses the default UN_RR00c icons for entries without icons (currently all except SECRET_SKIN)
* `challengesmenu->extradata` updated in less places
* `M_GetNextAchievedUnlock` no longer handles setting `unlocked` so we can do that during the above timer
* Test button explosion repetition no longer duplicates M_ChallengesTick code
* Instead of giving `challengesmenu->currentunlock == MAXUNLOCKABLES` special behaviour, add a `challengesmenu->requestnew`
* The crash prevention for nonexistent extradata in the input handler is now actually functional.
This commit is contained in:
toaster 2022-12-02 22:39:45 +00:00
parent 9de675165f
commit 9df1f1d34c
5 changed files with 49 additions and 47 deletions

View file

@ -1080,7 +1080,8 @@ void M_DrawReplayStartMenu(void);
void M_DrawAddons(void);
// Challenges menu:
#define UNLOCKTIME 35
#define UNLOCKTIME 5
#define MAXUNLOCKTIME 35
// Keep track of some pause menu data for visual goodness.
extern struct challengesmenu_s {
@ -1096,6 +1097,7 @@ extern struct challengesmenu_s {
UINT8 *extradata;
boolean pending;
boolean requestnew;
} challengesmenu;
menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu);

View file

@ -4508,7 +4508,7 @@ void M_DrawChallenges(void)
// ...unless we simply aren't unlocked yet.
if ((gamedata->unlocked[num] == false)
|| (num == challengesmenu.currentunlock && challengesmenu.unlockanim < 2))
|| (challengesmenu.pending && num == challengesmenu.currentunlock && challengesmenu.unlockanim <= UNLOCKTIME))
{
work = (ref->majorunlock) ? 2 : 1;
V_DrawFill(x, y, 16*work, 16*work,
@ -4530,14 +4530,18 @@ void M_DrawChallenges(void)
}
else
{
V_DrawPatch(x, y, 0, missingpat);
V_DrawMappedPatch(x, y, 0, missingpat, NULL);
}
break;
}
default:
V_DrawString(x, y, V_ALLOWLOWERCASE, va("%c", ref->name[0]));
{
patch_t *pat = W_CachePatchName(va("UN_RR00%c", ref->majorunlock ? 'B' : 'A'), PU_CACHE);
V_DrawMappedPatch(x, y, 0, pat, NULL);
//V_DrawString(x, y, V_ALLOWLOWERCASE, va("%c", ref->name[0]));
break;
}
}
drawborder:
@ -4578,6 +4582,6 @@ challengedesc:
offset = V_LSTitleLowStringWidth(str, 0) / 2;
V_DrawLSTitleLowString(BASEVIDWIDTH/2 - offset, y+6, 0, str);
if (challengesmenu.unlockanim >= UNLOCKTIME)
if (challengesmenu.unlockanim >= MAXUNLOCKTIME)
V_DrawThinString(20, 120 + 60, V_ALLOWLOWERCASE, va("Press (%c)", challengesmenu.pending ? 'A' : 'B'));
}

View file

@ -6832,9 +6832,8 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
{
M_UpdateUnlockablesAndExtraEmblems(false);
if (M_GetNextAchievedUnlock(false) < MAXUNLOCKABLES)
if ((challengesmenu.pending = challengesmenu.requestnew = (M_GetNextAchievedUnlock() < MAXUNLOCKABLES)))
{
challengesmenu.pending = true;
MISC_ChallengesDef.prevMenu = desiredmenu;
}
@ -6843,6 +6842,10 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
memset(setup_explosions, 0, sizeof(setup_explosions));
challengesmenu.currentunlock = MAXUNLOCKABLES;
M_PopulateChallengeGrid();
if (gamedata->challengegrid)
challengesmenu.extradata = M_ChallengeGridExtraData();
return &MISC_ChallengesDef;
}
@ -6862,8 +6865,6 @@ void M_Challenges(INT32 choice)
UINT8 selection[MAXUNLOCKABLES];
UINT8 numunlocks = 0;
challengesmenu.extradata = M_ChallengeGridExtraData();
// Get a random available unlockable.
for (i = 0; i < MAXUNLOCKABLES; i++)
{
@ -6929,18 +6930,15 @@ void M_ChallengesTick(void)
setup_explosions[i].tics--;
}
if (challengesmenu.pending && challengesmenu.currentunlock >= MAXUNLOCKABLES)
if (challengesmenu.pending && challengesmenu.requestnew)
{
if ((newunlock = M_GetNextAchievedUnlock(true)) < MAXUNLOCKABLES)
if ((newunlock = M_GetNextAchievedUnlock()) < MAXUNLOCKABLES)
{
challengesmenu.currentunlock = newunlock;
challengesmenu.unlockanim = 0;
if (gamedata->challengegrid)
{
Z_Free(challengesmenu.extradata);
challengesmenu.extradata = M_ChallengeGridExtraData();
for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++)
{
if (gamedata->challengegrid[i] != challengesmenu.currentunlock)
@ -6957,16 +6955,6 @@ void M_ChallengesTick(void)
challengesmenu.row = challengesmenu.hiliy = i%CHALLENGEGRIDHEIGHT;
break;
}
S_StartSound(NULL, sfx_s3k4e);
M_SetupReadyExplosions(false, challengesmenu.col, challengesmenu.row, SKINCOLOR_KETCHUP);
if (unlockables[challengesmenu.currentunlock].majorunlock)
{
UINT8 temp = challengesmenu.col+1;
if (temp == gamedata->challengegridwidth)
temp = 0;
M_SetupReadyExplosions(false, temp, challengesmenu.row+1, SKINCOLOR_KETCHUP);
}
}
}
else
@ -6975,14 +6963,35 @@ void M_ChallengesTick(void)
G_SaveGameData();
}
}
else if (challengesmenu.unlockanim >= UNLOCKTIME)
else if (challengesmenu.unlockanim >= MAXUNLOCKTIME)
{
;
}
else
{
challengesmenu.unlockanim++;
if (challengesmenu.pending
&& challengesmenu.currentunlock < MAXUNLOCKABLES
&& challengesmenu.unlockanim == UNLOCKTIME)
{
gamedata->unlocked[challengesmenu.currentunlock] = true;
Z_Free(challengesmenu.extradata);
challengesmenu.extradata = M_ChallengeGridExtraData();
S_StartSound(NULL, sfx_s3k4e);
M_SetupReadyExplosions(false, challengesmenu.col, challengesmenu.row, SKINCOLOR_KETCHUP);
if (unlockables[challengesmenu.currentunlock].majorunlock)
{
i = challengesmenu.col+1;
if (i == gamedata->challengegridwidth)
i = 0;
M_SetupReadyExplosions(false, i, challengesmenu.row+1, SKINCOLOR_KETCHUP);
}
}
}
challengesmenu.requestnew = false;
}
boolean M_ChallengesInputs(INT32 ch)
@ -6997,10 +7006,6 @@ boolean M_ChallengesInputs(INT32 ch)
{
;
}
if (challengesmenu.unlockanim < UNLOCKTIME)
{
;
}
#ifdef DEVELOP
else if (M_MenuExtraPressed(pid)) // debugging
{
@ -7031,24 +7036,20 @@ boolean M_ChallengesInputs(INT32 ch)
break;
}
S_StartSound(NULL, sfx_s3k4e);
M_SetupReadyExplosions(false, challengesmenu.col, challengesmenu.row, SKINCOLOR_KETCHUP);
if (unlockables[challengesmenu.currentunlock].majorunlock)
{
UINT8 temp = challengesmenu.col+1;
if (temp == gamedata->challengegridwidth)
temp = 0;
M_SetupReadyExplosions(false, temp, challengesmenu.row+1, SKINCOLOR_KETCHUP);
}
challengesmenu.pending = true;
}
return true;
}
#endif
else if (challengesmenu.pending)
{
if ((M_MenuConfirmPressed(pid) || start))
if (challengesmenu.unlockanim < MAXUNLOCKTIME)
{
challengesmenu.currentunlock = MAXUNLOCKABLES;
;
}
else if ((M_MenuConfirmPressed(pid) || start))
{
challengesmenu.requestnew = true;
}
return true;
}

View file

@ -639,7 +639,7 @@ boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud)
return false;
}
UINT8 M_GetNextAchievedUnlock(boolean set)
UINT8 M_GetNextAchievedUnlock(void)
{
UINT8 i;
@ -661,11 +661,6 @@ UINT8 M_GetNextAchievedUnlock(boolean set)
continue;
}
if (set)
{
gamedata->unlocked[i] = true;
}
return i;
}

View file

@ -193,7 +193,7 @@ void M_ClearSecrets(void);
void M_CheckUnlockConditions(void);
UINT8 M_CheckCondition(condition_t *cn);
boolean M_UpdateUnlockablesAndExtraEmblems(boolean silent);
UINT8 M_GetNextAchievedUnlock(boolean set);
UINT8 M_GetNextAchievedUnlock(void);
UINT8 M_CheckLevelEmblems(void);
UINT8 M_CompletionEmblems(void);