From 647a9d0a0e19c974bfa802d474675ac0dee21270 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 17 Dec 2023 13:18:35 +0000 Subject: [PATCH] Goner setup music: Change behaviour - Hook into M_PlayMenuJam, to reduce bespoke behaviour - Use the finalised track string - Play on the Sound Options menu Also, use MAIN_Goner as reference for the password field's presence, because I lost like 30 minutes to a related bug --- src/k_menu.h | 1 + src/k_menufunc.c | 17 ++++++++++++----- src/menus/main-goner.cpp | 35 +++++++++++++++++++---------------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 9d252f326..80e3f9073 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -212,6 +212,7 @@ void M_GonerTutorial(INT32 choice); void M_GonerResetLooking(int type); void M_GonerCheckLooking(void); void M_GonerGDQ(boolean opinion); +boolean M_GonerMusicPlayable(void); extern menuitem_t PLAY_CharSelect[]; extern menu_t PLAY_CharSelectDef; diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 2f315b2bd..f2ec06d00 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -357,11 +357,6 @@ void M_PlayMenuJam(void) menu_t *refMenu = (menuactive ? currentMenu : restoreMenu); static boolean musicstatepermitted = false; - if (M_GameTrulyStarted() == false) - { - return; - } - if (challengesmenu.pending) { Music_StopAll(); @@ -375,6 +370,17 @@ void M_PlayMenuJam(void) if (Playing() || soundtest.playing) return; + if (M_GameTrulyStarted() == false) + { + if (M_GonerMusicPlayable() && NotCurrentlyPlaying("_GONER")) + { + Music_Remap("menu", "_GONER"); + Music_Play("menu"); + } + + return; + } + if (refMenu != NULL && refMenu->music != NULL) { if (refMenu->music[0] == '.' && refMenu->music[1] == '\0') @@ -582,6 +588,7 @@ void M_StartControlPanel(void) // Are you ready for the First Boot Experience? M_ResetOptions(); currentMenu = &MAIN_GonerDef; + M_PlayMenuJam(); } else if (cv_currprofile.value == -1) // Only ask once per session. { diff --git a/src/menus/main-goner.cpp b/src/menus/main-goner.cpp index 611510d07..58d90c394 100644 --- a/src/menus/main-goner.cpp +++ b/src/menus/main-goner.cpp @@ -187,7 +187,7 @@ void M_AddGonerLines(void) // This one always plays, so it checks the levelworking instead of gamedata. if (goner_levelworking == GDGONER_INTRO) { - if (!currentMenu->menuitems[0].mvar2) + if (!MAIN_Goner[0].mvar2) { LinesToDigest.emplace_front(GONERSPEAKER_EGGMAN, 0, "Metal Sonic. Are you online?"); @@ -406,28 +406,19 @@ void M_GonerRailroad(bool set) S_StartSound(NULL, sfx_s3k63); } -void M_GonerPlayMusic(void) -{ - if (gamedata->gonerlevel <= GDGONER_SOUND || Music_Playing("menu")) - return; - - Music_Remap("menu", "_OCEAN"); //"_GONER"); - Music_Play("menu"); -} - void M_GonerHidePassword(void) { - if (currentMenu->menuitems[0].mvar2) + if (MAIN_Goner[0].mvar2) return; - currentMenu->menuitems[0] = + MAIN_Goner[0] = {IT_STRING | IT_CALL, "EXIT PROGRAM", "CONCLUDE OBSERVATIONS NOW.", NULL, {.routine = M_QuitSRB2}, 0, 1}; S_StartSound(NULL, sfx_s3k5b); - M_GonerPlayMusic(); + M_PlayMenuJam(); } }; // namespace @@ -451,6 +442,20 @@ void M_GonerResetLooking(int type) goner_youactuallylooked = 0; } +boolean M_GonerMusicPlayable(void) +{ + if (!MAIN_Goner[0].mvar2) + return false; + + if (currentMenu == &OPTIONS_SoundDef) + return true; + + if (gamedata->gonerlevel <= GDGONER_SOUND) + return false; + + return true; +} + void M_GonerCheckLooking(void) { if (goner_lasttypelooking != gamedata->gonerlevel) @@ -487,7 +492,7 @@ void M_GonerTick(void) { first = goner_gdq = false; - currentMenu->menuitems[0] = + MAIN_Goner[0] = {IT_STRING | IT_CVAR | IT_CV_STRING, ". . .", "ATTEMPT ADMINISTRATOR ACCESS.", NULL, {.cvar = &cv_dummyextraspassword}, 0, 0}; @@ -508,8 +513,6 @@ void M_GonerTick(void) goner_levelworking--; } - M_GonerPlayMusic(); - lastseenlevel = gamedata->gonerlevel; }