Extra polish to SECRET_ALTMUSIC on Challenges menu

If playing a given altmusic unlock...
- If selected, spin the disc
- If not selected, constantly flip the relevant tile on the board
- Either way, flash the relevant pixel in the scroll bar
This commit is contained in:
toaster 2025-08-14 17:48:26 +01:00
parent 4fcdb3c5fe
commit bc75a1702e
3 changed files with 82 additions and 49 deletions

View file

@ -1461,6 +1461,7 @@ extern struct challengesmenu_s {
UINT16 tutorialfound; UINT16 tutorialfound;
boolean requestflip; boolean requestflip;
UINT16 nowplayingtile;
UINT16 unlockcount[CMC_MAX]; UINT16 unlockcount[CMC_MAX];

View file

@ -7622,48 +7622,78 @@ static void M_DrawChallengePreview(INT32 x, INT32 y)
return; return;
} }
spritedef_t *sprdef = &sprites[SPR_ALTM]; const char *tune = "challenge_altmusic";
spriteframe_t *sprframe;
patch_t *patch;
UINT32 addflags = 0;
x -= 10; SINT8 pushed = 0;
y += 15; const boolean epossible = (M_SecretUnlocked(SECRET_ENCORE, true)
&& musicid < mapheaderinfo[map]->encoremusname_size);
if (sprdef->numframes) if (challengesmenu.nowplayingtile == ((challengesmenu.hilix * CHALLENGEGRIDHEIGHT) + challengesmenu.hiliy)
&& Music_Playing(tune))
{ {
sprframe = &sprdef->spriteframes[0]; const char *song = Music_Song(tune);
patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); if (epossible
&& strcmp(song, mapheaderinfo[map]->encoremusname[musicid]) == 0)
pushed = -1;
else if (musicid < mapheaderinfo[map]->musname_size
&& strcmp(song, mapheaderinfo[map]->musname[musicid]) == 0)
pushed = 1;
}
if (sprframe->flip & 1) // Only for first sprite // Draw CD
{
spritedef_t *sprdef = &sprites[SPR_ALTM];
spriteframe_t *sprframe;
patch_t *patch = NULL;
UINT32 addflags = 0;
x -= 10;
y += 15;
if (sprdef->numframes)
{ {
addflags ^= V_FLIP; // This sprite is left/right flipped! #ifdef ROTSPRITE
} spriteinfo_t *sprinfo = &spriteinfo[SPR_ALTM];
INT32 rollangle = 0;
if (pushed != 0)
{
rollangle = (Music_Elapsed(tune) % (ROTANGLES/2))*2;
if (pushed > 0)
rollangle = ((ROTANGLES-1) - rollangle);
}
#endif
V_DrawFixedPatch(x*FRACUNIT, (y+2)*FRACUNIT, FRACUNIT/2, addflags, patch, NULL); sprframe = &sprdef->spriteframes[0];
#ifdef ROTSPRITE
if (rollangle)
{
patch = Patch_GetRotatedSprite(sprframe, 0, 0, (sprframe->flip & 1), false, sprinfo, rollangle);
}
#endif
if (!patch)
{
patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE);
if (sprframe->flip & 1) // Only for first sprite
{
addflags ^= V_FLIP; // This sprite is left/right flipped!
}
}
V_DrawFixedPatch(x*FRACUNIT, (y+2)*FRACUNIT, FRACUNIT/2, addflags, patch, NULL);
}
} }
x = 4; x = 4;
y = (BASEVIDHEIGHT-14); y = (BASEVIDHEIGHT-14);
const boolean thismusplaying = Music_Playing("challenge_altmusic"); if (epossible)
boolean pushed = false;
const char *song = NULL;
if (M_SecretUnlocked(SECRET_ENCORE, true)
&& musicid < mapheaderinfo[map]->encoremusname_size)
{ {
if (thismusplaying)
{
song = Music_Song("challenge_altmusic");
pushed = strcmp(song, mapheaderinfo[map]->encoremusname[musicid]) == 0;
}
K_DrawGameControl( K_DrawGameControl(
x, y, 0, x, y, 0,
(!pushed) (pushed < 0)
? "<l> <magenta>E Side" ? "<l_pressed> <gray>E Stop"
: "<l_pressed> <gray>E Side", : "<l> <magenta>E Side",
0, TINY_FONT, 0 0, TINY_FONT, 0
); );
@ -7672,22 +7702,11 @@ static void M_DrawChallengePreview(INT32 x, INT32 y)
if (musicid < mapheaderinfo[map]->musname_size) if (musicid < mapheaderinfo[map]->musname_size)
{ {
if (pushed || !thismusplaying)
{
pushed = false;
}
else
{
if (!song)
song = Music_Song("challenge_altmusic");
pushed = strcmp(song, mapheaderinfo[map]->musname[musicid]) == 0;
}
K_DrawGameControl( K_DrawGameControl(
x, y, 0, x, y, 0,
(!pushed) (pushed > 0)
? "<a> <sky>Play CD" ? "<a_pressed> <gray>Stop CD"
: "<a_pressed> <gray>Play CD", : "<a> <sky>Play CD",
0, TINY_FONT, 0 0, TINY_FONT, 0
); );
} }
@ -8033,6 +8052,14 @@ static void M_DrawChallengeScrollBar(UINT8 *flashmap)
} }
#endif #endif
if (i == challengesmenu.nowplayingtile && Music_Playing("challenge_altmusic"))
{
V_DrawFill(barx + hilix, bary, hiliw, barh, (challengesmenu.ticker & 2) ? 177 : 122);
// The now-playing fill overrides everything else.
completionamount = -1;
}
if (completionamount == -1) if (completionamount == -1)
continue; continue;

View file

@ -397,6 +397,7 @@ menu_t *M_InterruptMenuWithChallenges(menu_t *desiredmenu)
if (firstopen) if (firstopen)
{ {
challengesmenu.currentunlock = MAXUNLOCKABLES; challengesmenu.currentunlock = MAXUNLOCKABLES;
challengesmenu.nowplayingtile = UINT16_MAX;
firstopen = false; firstopen = false;
} }
@ -446,6 +447,7 @@ void M_Challenges(INT32 choice)
static void M_CloseChallenges(void) static void M_CloseChallenges(void)
{ {
Music_Stop("challenge_altmusic"); Music_Stop("challenge_altmusic");
challengesmenu.nowplayingtile = UINT16_MAX;
Z_Free(challengesmenu.extradata); Z_Free(challengesmenu.extradata);
challengesmenu.extradata = NULL; challengesmenu.extradata = NULL;
@ -599,8 +601,8 @@ void M_ChallengesTick(void)
for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++) for (i = 0; i < (CHALLENGEGRIDHEIGHT * gamedata->challengegridwidth); i++)
{ {
allthewaythrough = (!seeeveryone && !challengesmenu.pending && i != id); allthewaythrough = (!seeeveryone && !challengesmenu.pending && i != id);
maxflip = ((seeeveryone || !allthewaythrough) ? (TILEFLIP_MAX/2) : TILEFLIP_MAX); maxflip = (allthewaythrough ? TILEFLIP_MAX : (TILEFLIP_MAX/2));
if ((seeeveryone || (i == id) || (challengesmenu.extradata[i].flip > 0)) if ((seeeveryone || (i == id) || (i == challengesmenu.nowplayingtile) || (challengesmenu.extradata[i].flip > 0))
&& (challengesmenu.extradata[i].flip != maxflip)) && (challengesmenu.extradata[i].flip != maxflip))
{ {
challengesmenu.extradata[i].flip++; challengesmenu.extradata[i].flip++;
@ -1324,15 +1326,18 @@ boolean M_ChallengesInputs(INT32 ch)
if (trymusname) if (trymusname)
{ {
if (!Music_Playing("challenge_altmusic") const char *tune = "challenge_altmusic";
|| strcmp(Music_Song("challenge_altmusic"), trymusname)) if (!Music_Playing(tune)
|| strcmp(Music_Song(tune), trymusname))
{ {
Music_Remap("challenge_altmusic", trymusname); Music_Remap(tune, trymusname);
Music_Play("challenge_altmusic"); Music_Play(tune);
challengesmenu.nowplayingtile = (challengesmenu.hilix * CHALLENGEGRIDHEIGHT) + challengesmenu.hiliy;
} }
else else
{ {
Music_Stop("challenge_altmusic"); Music_Stop(tune);
challengesmenu.nowplayingtile = UINT16_MAX;
} }
M_SetMenuDelay(pid); M_SetMenuDelay(pid);