- Stop music when ending a level, or when going back to the menu in Blood. Also play the sound on Blood's summary screen as an UI sound.

Fixes #349
This commit is contained in:
Christoph Oelckers 2020-09-05 19:20:25 +02:00
parent b4dd006a40
commit a7b198d7ee
5 changed files with 8 additions and 4 deletions

View file

@ -288,6 +288,7 @@ void GameInterface::DrawCenteredTextScreen(const DVector2& origin, const char* t
void GameInterface::QuitToTitle()
{
Mus_Stop();
gameaction = ga_mainmenu;
}

View file

@ -167,7 +167,7 @@ class DBloodSummaryScreen : public DScreenJob
void GameInterface::LevelCompleted(MapRecord *map, int skill)
{
JobDesc job = { Create<DBloodSummaryScreen>() };
sndStartSample(268, 128, -1, false);
sndStartSample(268, 128, -1, false, CHANF_UI);
RunScreenJob(&job, 1, [=](bool)
{
soundEngine->StopAllChannels();

View file

@ -158,7 +158,7 @@ void sndStartSample(const char *pzSound, int nVolume, int nChannel)
}
}
void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop)
void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop, EChanFlags chanflags)
{
if (!SoundEnabled())
return;
@ -173,7 +173,8 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop)
if (udata) nVolume = std::min(Scale(udata[2], 255, 100), 255);
else nVolume = 255;
}
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, (nChannel + 1), (bLoop? CHANF_LOOP : EChanFlags::FromInt(0)), snd, nVolume / 255.f, ATTN_NONE);
if (bLoop) chanflags |= CHANF_LOOP;
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, (nChannel + 1), chanflags, snd, nVolume / 255.f, ATTN_NONE);
}
}

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "misc.h"
#include "raze_music.h"
#include "s_soundinternal.h"
BEGIN_BLD_NS
@ -45,7 +46,7 @@ struct SFX
int sndGetRate(int format);
void sndStartSample(const char *pzSound, int nVolume, int nChannel = -1);
void sndStartSample(unsigned int nSound, int nVolume, int nChannel = -1, bool bLoop = false);
void sndStartSample(unsigned int nSound, int nVolume, int nChannel = -1, bool bLoop = false, EChanFlags soundflags = CHANF_NONE);
void sndStartWavID(unsigned int nSound, int nVolume, int nChannel = -1);
void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel = -1);
void sndKillAllSounds(void);

View file

@ -147,6 +147,7 @@ static void GameTicker()
case ga_completed:
FX_StopAllSounds();
FX_SetReverb(0);
Mus_Stop();
if (g_nextmap == currentLevel)
{
// if the same level is restarted, skip any progression stuff like summary screens or cutscenes.