From bc75a1702e57297bfebd97f87c3660c74c575918 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 14 Aug 2025 17:48:26 +0100 Subject: [PATCH] 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 --- src/k_menu.h | 1 + src/k_menudraw.c | 111 +++++++++++++++++++++------------- src/menus/extras-challenges.c | 19 +++--- 3 files changed, 82 insertions(+), 49 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 4847a988f..38a7edb07 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1461,6 +1461,7 @@ extern struct challengesmenu_s { UINT16 tutorialfound; boolean requestflip; + UINT16 nowplayingtile; UINT16 unlockcount[CMC_MAX]; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index ad4403166..00bc9d8f3 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -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) - ? " E Side" - : " E Side", + (pushed < 0) + ? " E Stop" + : " 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) - ? " Play CD" - : " Play CD", + (pushed > 0) + ? " Stop CD" + : " 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; diff --git a/src/menus/extras-challenges.c b/src/menus/extras-challenges.c index a1f83b756..bd8bdad4b 100644 --- a/src/menus/extras-challenges.c +++ b/src/menus/extras-challenges.c @@ -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);