enum gdmusic_t

Replaces existing musicflag system, which only had one flag, with a priority system that overrides menu music in general.
Also adds the CHAO KEY FREE DDL WORKING 2023 goofy music for matchesplayed Chao Key generation.
This commit is contained in:
toaster 2023-06-07 23:05:19 +01:00
parent 1957f74853
commit 8efd4788e7
4 changed files with 36 additions and 12 deletions

View file

@ -372,18 +372,19 @@ boolean M_Responder(event_t *ev)
void M_PlayMenuJam(void) void M_PlayMenuJam(void)
{ {
menu_t *refMenu = (menuactive ? currentMenu : restoreMenu); menu_t *refMenu = (menuactive ? currentMenu : restoreMenu);
static boolean loserclubpermitted = false; static boolean musicstatepermitted = false;
boolean loserclub = (loserclubpermitted && (gamedata->musicflags & GDMUSIC_LOSERCLUB));
if (challengesmenu.pending) if (challengesmenu.pending)
{ {
S_StopMusic(); S_StopMusic();
S_StopMusicCredit(); S_StopMusicCredit();
loserclubpermitted = true; musicstatepermitted = true;
return; return;
} }
gdmusic_t override = musicstatepermitted ? gamedata->musicstate : 0;
if (Playing() || soundtest.playing) if (Playing() || soundtest.playing)
return; return;
@ -395,7 +396,7 @@ void M_PlayMenuJam(void)
S_StopMusicCredit(); S_StopMusicCredit();
return; return;
} }
else if (!loserclub) else if (override == 0)
{ {
if (NotCurrentlyPlaying(refMenu->music)) if (NotCurrentlyPlaying(refMenu->music))
{ {
@ -406,12 +407,21 @@ void M_PlayMenuJam(void)
} }
} }
if (loserclub) if (override != 0)
{ {
if (refMenu != NULL && NotCurrentlyPlaying("LOSERC")) // See also gdmusic_t
const char* overridetotrack[GDMUSIC_MAX-1] = {
"KEYGEN",
"LOSERC",
};
if (refMenu != NULL && NotCurrentlyPlaying(overridetotrack[override - 1]))
{ {
S_ChangeMusicInternal("LOSERC", true); S_ChangeMusicInternal(overridetotrack[override - 1], true);
S_ShowMusicCredit(); S_ShowMusicCredit();
if (override < GDMUSIC_KEEPONMENU)
gamedata->musicstate = GDMUSIC_NONE;
} }
return; return;

View file

@ -613,7 +613,7 @@ void M_ClearStats(void)
gamedata->eversavedreplay = false; gamedata->eversavedreplay = false;
gamedata->everseenspecial = false; gamedata->everseenspecial = false;
gamedata->evercrashed = false; gamedata->evercrashed = false;
gamedata->musicflags = 0; gamedata->musicstate = GDMUSIC_NONE;
gamedata->importprofilewins = false; gamedata->importprofilewins = false;
} }
@ -840,7 +840,8 @@ boolean M_CheckCondition(condition_t *cn, player_t *player)
case UC_CRASH: case UC_CRASH:
if (gamedata->evercrashed) if (gamedata->evercrashed)
{ {
gamedata->musicflags |= GDMUSIC_LOSERCLUB; if (gamedata->musicstate < GDMUSIC_LOSERCLUB)
gamedata->musicstate = GDMUSIC_LOSERCLUB;
return true; return true;
} }
return false; return false;
@ -1710,7 +1711,13 @@ boolean M_UpdateUnlockablesAndExtraEmblems(boolean loud, boolean doall)
{ {
gamedata->keyspending++; gamedata->keyspending++;
newkeys++; newkeys++;
}
if (newkeys != 0)
{
response |= true; response |= true;
if (gamedata->musicstate < GDMUSIC_KEYG)
gamedata->musicstate = GDMUSIC_KEYG;
} }
} }

View file

@ -220,7 +220,14 @@ typedef enum
#endif #endif
#define challengegridloops (gamedata->challengegridwidth >= CHALLENGEGRIDLOOPWIDTH) #define challengegridloops (gamedata->challengegridwidth >= CHALLENGEGRIDLOOPWIDTH)
#define GDMUSIC_LOSERCLUB 0x01 // See also M_PlayMenuJam
typedef enum {
GDMUSIC_NONE = 0,
GDMUSIC_KEYG,
GDMUSIC_KEEPONMENU, // Minimum to keep after leaving the Challenge Grid
GDMUSIC_LOSERCLUB = GDMUSIC_KEEPONMENU,
GDMUSIC_MAX
} gdmusic_t;
// This is the largest number of 9s that will fit in UINT32 and UINT16 respectively. // This is the largest number of 9s that will fit in UINT32 and UINT16 respectively.
#define GDMAX_RINGS 999999999 #define GDMAX_RINGS 999999999
@ -283,7 +290,7 @@ struct gamedata_t
boolean eversavedreplay; boolean eversavedreplay;
boolean everseenspecial; boolean everseenspecial;
boolean evercrashed; boolean evercrashed;
UINT8 musicflags; gdmusic_t musicstate;
// BACKWARDS COMPAT ASSIST // BACKWARDS COMPAT ASSIST
boolean importprofilewins; boolean importprofilewins;

View file

@ -7813,7 +7813,7 @@ static void P_InitGametype(void)
// Started a game? Move on to the next jam when you go back to the title screen // Started a game? Move on to the next jam when you go back to the title screen
CV_SetValue(&cv_menujam_update, 1); CV_SetValue(&cv_menujam_update, 1);
gamedata->musicflags = 0; gamedata->musicstate = GDMUSIC_NONE;
} }
struct minimapinfo minimapinfo; struct minimapinfo minimapinfo;