WIP - credits audio/wipe fixes, document this later

This commit is contained in:
James R 2024-03-23 06:03:03 -07:00
parent a8851e96dc
commit a4f2712d8a
7 changed files with 60 additions and 7 deletions

View file

@ -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();

View file

@ -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)

View file

@ -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;

View file

@ -79,6 +79,7 @@ struct credits_slide_s
std::vector<std::string> strings;
size_t strings_height;
boolean play_demo_afterwards;
int fade_out_music;
};
static std::vector<struct credits_slide_s> 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;
}

View file

@ -38,6 +38,8 @@ void F_CreditTicker(void);
void F_CreditDrawer(void);
boolean F_CreditsRunning(void);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -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++)
{

View file

@ -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();