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;
boolean requestflip;
UINT16 nowplayingtile;
UINT16 unlockcount[CMC_MAX];

View file

@ -7622,48 +7622,78 @@ static void M_DrawChallengePreview(INT32 x, INT32 y)
return;
}
spritedef_t *sprdef = &sprites[SPR_ALTM];
spriteframe_t *sprframe;
patch_t *patch;
UINT32 addflags = 0;
const char *tune = "challenge_altmusic";
x -= 10;
y += 15;
SINT8 pushed = 0;
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];
patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE);
const char *song = Music_Song(tune);
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;
y = (BASEVIDHEIGHT-14);
const boolean thismusplaying = Music_Playing("challenge_altmusic");
boolean pushed = false;
const char *song = NULL;
if (M_SecretUnlocked(SECRET_ENCORE, true)
&& musicid < mapheaderinfo[map]->encoremusname_size)
if (epossible)
{
if (thismusplaying)
{
song = Music_Song("challenge_altmusic");
pushed = strcmp(song, mapheaderinfo[map]->encoremusname[musicid]) == 0;
}
K_DrawGameControl(
x, y, 0,
(!pushed)
? "<l> <magenta>E Side"
: "<l_pressed> <gray>E Side",
(pushed < 0)
? "<l_pressed> <gray>E Stop"
: "<l> <magenta>E Side",
0, TINY_FONT, 0
);
@ -7672,22 +7702,11 @@ static void M_DrawChallengePreview(INT32 x, INT32 y)
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(
x, y, 0,
(!pushed)
? "<a> <sky>Play CD"
: "<a_pressed> <gray>Play CD",
(pushed > 0)
? "<a_pressed> <gray>Stop CD"
: "<a> <sky>Play CD",
0, TINY_FONT, 0
);
}
@ -8033,6 +8052,14 @@ static void M_DrawChallengeScrollBar(UINT8 *flashmap)
}
#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)
continue;

View file

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