Toggle Digi/MIDI music in menu accurately; add S_MusicType

(cherry picked from commit 4aa100aa575cc7fc14a743085222c806ba2c714a)
This commit is contained in:
mazmazz 2018-08-23 12:51:45 -04:00
parent 17cf310b84
commit 7e7899ae83
3 changed files with 27 additions and 17 deletions

View File

@ -6991,7 +6991,8 @@ static void M_ToggleDigital(void)
else
{
digital_disabled = true;
S_StopMusic();
if (S_MusicType() != MU_MID)
S_StopMusic();
M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING);
}
}
@ -7012,7 +7013,8 @@ static void M_ToggleMIDI(void)
else
{
midi_disabled = true;
S_StopMusic();
if (S_MusicType() == MU_MID)
S_StopMusic();
M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING);
}
}

View File

@ -1245,6 +1245,11 @@ boolean S_MusicPaused(void)
return I_MusicPaused();
}
musictype_t S_MusicType(void)
{
return I_GetMusicType();
}
const char *S_MusicName(void)
{
return music_name;
@ -1279,20 +1284,24 @@ static boolean S_LoadMusic(const char *mname)
if (S_MusicDisabled())
return false;
if (S_DigMusicDisabled())
{
if (!S_MIDIExists(mname))
return false;
if (!S_DigMusicDisabled() && S_DigExists(mname))
mlumpnum = W_GetNumForName(va("o_%s", mname));
else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname))
mlumpnum = W_GetNumForName(va("d_%s", mname));
else if (S_DigMusicDisabled() && S_DigExists(mname))
{
CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n");
return false;
}
else if (S_MIDIMusicDisabled() && S_MIDIExists(mname))
{
CONS_Alert(CONS_NOTICE, "MIDI music is disabled!\n");
return false;
}
else
{
if (S_DigExists(mname))
mlumpnum = W_GetNumForName(va("o_%s", mname));
else if (S_MIDIExists(mname))
mlumpnum = W_GetNumForName(va("d_%s", mname));
else
return false;
CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mname);
return false;
}
// load & register it
@ -1328,8 +1337,8 @@ static void S_UnloadMusic(void)
static boolean S_PlayMusic(boolean looping)
{
if (S_DigMusicDisabled())
return false; // try midi
if (S_MusicDisabled())
return false;
if (!I_PlaySong(looping))
{
@ -1362,10 +1371,7 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
S_StopMusic(); // shutdown old music
if (!S_LoadMusic(mmusic))
{
CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mmusic);
return;
}
if (!S_PlayMusic(looping))
{

View File

@ -14,6 +14,7 @@
#ifndef __S_SOUND__
#define __S_SOUND__
#include "i_sound.h" // musictype_t
#include "sounds.h"
#include "m_fixed.h"
#include "command.h"
@ -106,6 +107,7 @@ boolean S_MIDIMusicDisabled(void);
boolean S_MusicDisabled(void);
boolean S_MusicPlaying(void);
boolean S_MusicPaused(void);
musictype_t S_MusicType(void);
const char *S_MusicName(void);
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
#define S_DigExists(a) S_MusicExists(a, false, true)