Add the ability to play SECRET_ALTMUSIC music on the Challenges screen

Supports both standard play and "E Side", if it exists (justification for Encore using the same CD)
This commit is contained in:
toaster 2024-03-10 15:03:37 +00:00
parent 6e46f97847
commit 618d40882a
3 changed files with 167 additions and 7 deletions

View file

@ -7089,6 +7089,90 @@ static void M_DrawChallengePreview(INT32 x, INT32 y)
break;
}
case SECRET_ALTMUSIC:
{
UINT16 map = M_UnlockableMapNum(ref);
if (map >= nummapheaders
|| !mapheaderinfo[map])
{
return;
}
UINT8 musicid;
for (musicid = 1; musicid < MAXMUSNAMES; musicid++)
{
if (mapheaderinfo[map]->cache_muslock[musicid - 1] == challengesmenu.currentunlock)
break;
}
if (musicid == MAXMUSNAMES)
{
return;
}
spritedef_t *sprdef = &sprites[SPR_ALTM];
spriteframe_t *sprframe;
patch_t *patch;
UINT32 addflags = 0;
x -= 10;
y += 15;
if (sprdef->numframes)
{
sprframe = &sprdef->spriteframes[0];
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 = 8;
y = BASEVIDHEIGHT-16;
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 (thismusplaying)
{
song = Music_Song("challenge_altmusic");
pushed = strcmp(song, mapheaderinfo[map]->encoremusname[musicid]) == 0;
}
K_drawButton(x&FRACUNIT, y*FRACUNIT, 0, kp_button_l, pushed);
x += SHORT(kp_button_l[0]->width);
V_DrawThinString(x, y + 1, (pushed ? V_GRAYMAP : highlightflags), "E Side");
x = 8;
y -= 10;
}
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_drawButton(x*FRACUNIT, y*FRACUNIT, 0, kp_button_a[1], pushed);
x += SHORT(kp_button_a[1][0]->width);
V_DrawThinString(x, y + 1, (pushed ? V_GRAYMAP : highlightflags), "Play CD");
}
}
default:
{
break;

View file

@ -834,6 +834,8 @@ boolean M_ChallengesInputs(INT32 ch)
{
if (M_MenuBackPressed(pid) || start)
{
Music_Stop("challenge_altmusic");
currentMenu->prevMenu = M_SpecificMenuRestore(currentMenu->prevMenu);
M_GoBack(0);
@ -1021,17 +1023,83 @@ boolean M_ChallengesInputs(INT32 ch)
return true;
}
if (M_MenuConfirmPressed(pid)
&& challengesmenu.currentunlock < MAXUNLOCKABLES
if (challengesmenu.currentunlock < MAXUNLOCKABLES
&& gamedata->unlocked[challengesmenu.currentunlock])
{
switch (unlockables[challengesmenu.currentunlock].type)
{
case SECRET_ALTTITLE: {
extern consvar_t cv_alttitle;
CV_AddValue(&cv_alttitle, 1);
S_StartSound(NULL, sfx_s3kc3s);
M_SetMenuDelay(pid);
case SECRET_ALTTITLE:
{
if (M_MenuConfirmPressed(pid))
{
extern consvar_t cv_alttitle;
CV_AddValue(&cv_alttitle, 1);
S_StartSound(NULL, sfx_s3kc3s);
M_SetMenuDelay(pid);
}
break;
}
case SECRET_ALTMUSIC:
{
UINT8 trymus = 0, musicid = MAXMUSNAMES;
if (M_MenuConfirmPressed(pid))
{
trymus = 1;
}
else if (M_MenuButtonPressed(pid, MBT_L))
{
trymus = 2;
}
if (trymus)
{
const char *trymusname = NULL;
UINT16 map = M_UnlockableMapNum(&unlockables[challengesmenu.currentunlock]);
if (map >= nummapheaders
|| !mapheaderinfo[map])
{
;
}
else for (musicid = 1; musicid < MAXMUSNAMES; musicid++)
{
if (mapheaderinfo[map]->cache_muslock[musicid - 1] == challengesmenu.currentunlock)
break;
}
if (trymus == 1)
{
if (musicid < mapheaderinfo[map]->musname_size)
{
trymusname = mapheaderinfo[map]->musname[musicid];
}
}
else
{
if (musicid < mapheaderinfo[map]->encoremusname_size)
{
trymusname = mapheaderinfo[map]->encoremusname[musicid];
}
}
if (trymusname)
{
if (!Music_Playing("challenge_altmusic")
|| strcmp(Music_Song("challenge_altmusic"), trymusname))
{
Music_Remap("challenge_altmusic", trymusname);
Music_Play("challenge_altmusic");
}
else
{
Music_Stop("challenge_altmusic");
}
M_SetMenuDelay(pid);
}
}
break;
}
default:

View file

@ -195,6 +195,14 @@ void Music_Init(void)
tune.fade_out = 5000;
tune.fade_out_inclusive = false;
}
{
Tune& tune = g_tunes.insert("challenge_altmusic");
tune.priority = 100;
tune.resist = true;
tune.credit = true;
}
}
void Music_Tick(void)