diff --git a/src/d_main.cpp b/src/d_main.cpp index 7dcf0a7b8..51183db0c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -427,6 +427,9 @@ static bool D_Display(void) { // Fade to black first if (G_GamestateUsesLevel() == false // fades to black on its own timing, always + // Wipe between credits slides. + // But not back from attract demo, since F_CreditsDemoExitFade exists. + && (gamestate != GS_CREDITS || wipegamestate != GS_LEVEL) && wipetypepre != UINT8_MAX) { F_WipeStartScreen(); @@ -1120,8 +1123,11 @@ void D_ClearState(void) if (rendermode != render_none) V_SetPaletteLump("PLAYPAL"); - S_StopMusicCredit(); + if (!Music_Playing("credits")) + S_StopMusicCredit(); + S_StopSounds(); + S_SetSfxVolume(); // reset sound volume if (gamedata && gamedata->deferredsave) G_SaveGameData(); diff --git a/src/f_finale.c b/src/f_finale.c index eb2782538..be404b80e 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -49,6 +49,7 @@ #include "k_grandprix.h" #include "music.h" #include "k_credits.h" +#include "i_sound.h" // Stage of animation: // 0 = text, 1 = art screen @@ -1858,6 +1859,13 @@ luahook: M_DrawMenuMessage(); } +void F_PlayTitleScreenMusic(void) +{ + Music_Loop("title", looptitle); + Music_Seek("title", 38749); // kick in + Music_Play("title"); +} + // (no longer) De-Demo'd Title Screen void F_TitleScreenTicker(boolean run) { @@ -1874,8 +1882,7 @@ void F_TitleScreenTicker(boolean run) else if (!Music_Playing("title")) { // Now start the music - Music_Loop("title", looptitle); - Music_Play("title"); + F_PlayTitleScreenMusic(); } } else if (menumessage.active) @@ -2094,6 +2101,13 @@ void F_AttractDemoTicker(void) attractcredit = false; } + INT32 val = F_AttractDemoExitFade(); + if (val >= 0) + { + // Fade down sounds with screen fade + I_SetSfxVolume(cv_soundvolume.value * (31 - val) / 31); + } + if (attractcountdown > 0 && !--attractcountdown) { // Fade will be handled without a wipe (see F_AttractDemoExitFade) diff --git a/src/f_finale.h b/src/f_finale.h index 6caf0bd4b..acd195659 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -71,6 +71,8 @@ void F_StartIntro(void); void F_StartTitleScreen(void); void F_StartEnding(void); +void F_PlayTitleScreenMusic(void); + extern INT32 finalecount; extern INT32 titlescrollxspeed; extern INT32 titlescrollyspeed; diff --git a/src/k_credits.cpp b/src/k_credits.cpp index 65a916028..dc0a6eb3a 100644 --- a/src/k_credits.cpp +++ b/src/k_credits.cpp @@ -79,6 +79,7 @@ struct credits_slide_s std::vector strings; size_t strings_height; boolean play_demo_afterwards; + int fade_out_music; }; static std::vector g_credits_slides; @@ -233,6 +234,7 @@ void F_LoadCreditsDefinitions(void) } slide.play_demo_afterwards = slide_obj.value("demo", false); + slide.fade_out_music = slide_obj.value("fade_out_music", 0); g_credits_slides.push_back( slide ); } @@ -367,6 +369,10 @@ static void F_InitCreditsSlide(void) } } #endif + else if (slide->type == CRED_TYPE_KARTKREW) + { + + } // Clear the console hud just to avoid anything getting in the way. CON_ClearHUD(); @@ -449,6 +455,9 @@ void F_ContinueCredits(void) F_CreditsReset(); demo.attract = DEMO_ATTRACT_OFF; + // Do not wipe back to credits, since F_CreditsDemoExitFade exists. + wipegamestate = GS_LEVEL; + // Returning from playing a demo. // Go to the next slide. F_CreditsNextSlide(); @@ -559,6 +568,12 @@ void F_TickCreditsDemoExit(void) g_credits.demo_exit = std::max(g_credits.demo_exit, kDemoExitTicCount - 64); } + if (INT32 val = F_CreditsDemoExitFade(); val >= 0) + { + // Fade down sounds with screen fade + I_SetSfxVolume(cv_soundvolume.value * (31 - val) / 31); + } + if (g_credits.demo_exit > kDemoExitTicCount) { G_CheckDemoStatus(); @@ -811,6 +826,11 @@ static void F_HandleCreditsTick(void) } else if (finalize_slide) { + if (slide->fade_out_music) + { + I_FadeSong(0, slide->fade_out_music, nullptr); + } + if (g_credits.current_slide >= g_credits_slides.size() - 1) { g_credits.finish_counter = 5 * TICRATE; @@ -1205,3 +1225,8 @@ void F_CreditDrawer(void) star.y += FixedMul(star.vel_y, renderdeltatics); } } + +boolean F_CreditsRunning(void) +{ + return gamestate == GS_CREDITS || demo.attract == DEMO_ATTRACT_CREDITS; +} diff --git a/src/k_credits.h b/src/k_credits.h index c2836f07d..165e0e608 100644 --- a/src/k_credits.h +++ b/src/k_credits.h @@ -38,6 +38,8 @@ void F_CreditTicker(void); void F_CreditDrawer(void); +boolean F_CreditsRunning(void); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 5e472be84..0421bc664 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -116,6 +116,7 @@ #include "k_dialogue.h" #include "k_hud.h" // K_ClearPersistentMessages #include "k_endcam.h" +#include "k_credits.h" // Replay names have time #if !defined (UNDER_CE) @@ -7651,8 +7652,11 @@ static void P_InitLevelSettings(void) g_quakes = NULL; // song credit init - S_StopMusicCredit(); - cursongcredit.trans = NUMTRANSMAPS; + if (!Music_Playing("credits")) + { + S_StopMusicCredit(); + cursongcredit.trans = NUMTRANSMAPS; + } for (i = 0; i < MAXPLAYERS; i++) { diff --git a/src/s_sound.c b/src/s_sound.c index 7a10b4926..b60e1ddf1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -38,6 +38,7 @@ #include "v_video.h" // V_ThinStringWidth #include "music.h" #include "y_inter.h" // Y_PlayIntermissionMusic +#include "f_finale.h" // F_PlayTitleScreenMusic extern consvar_t cv_mastervolume; @@ -1224,8 +1225,7 @@ void S_AttemptToRestoreMusic(void) Music_Play("level"); break; case GS_TITLESCREEN: - Music_Loop("title", looptitle); - Music_Play("title"); + F_PlayTitleScreenMusic(); break; case GS_MENU: M_PlayMenuJam();