mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 21:20:54 +00:00
Play the opposite type music (Digital/MIDI) when toggling between them in menu
* S_MusicInfo method to retrieve name, flags, and looping
This commit is contained in:
parent
4aa100aa57
commit
f6ec93198f
3 changed files with 60 additions and 5 deletions
40
src/m_menu.c
40
src/m_menu.c
|
@ -9485,7 +9485,24 @@ static void M_ToggleDigital(INT32 choice)
|
||||||
{
|
{
|
||||||
digital_disabled = true;
|
digital_disabled = true;
|
||||||
if (S_MusicType() != MU_MID)
|
if (S_MusicType() != MU_MID)
|
||||||
|
{
|
||||||
|
if (midi_disabled)
|
||||||
S_StopMusic();
|
S_StopMusic();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char mmusic[7];
|
||||||
|
UINT16 mflags;
|
||||||
|
boolean looping;
|
||||||
|
|
||||||
|
if (S_MusicInfo(mmusic, &mflags, &looping) && S_MIDIExists(mmusic))
|
||||||
|
{
|
||||||
|
S_StopMusic();
|
||||||
|
S_ChangeMusic(mmusic, mflags, looping);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
S_StopMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
//M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING);
|
//M_StartMessage(M_GetText("Digital Music Disabled\n"), NULL, MM_NOTHING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9504,6 +9521,12 @@ static void M_ToggleMIDI(INT32 choice)
|
||||||
itemOn--;
|
itemOn--;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case KEY_LEFTARROW:
|
||||||
|
case KEY_RIGHTARROW:
|
||||||
|
if (S_MusicType() != MU_MID && S_MusicType() != MU_NONE)
|
||||||
|
S_StartSound(NULL, sfx_menu1);
|
||||||
|
break;
|
||||||
|
|
||||||
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
||||||
if (currentMenu->prevMenu)
|
if (currentMenu->prevMenu)
|
||||||
M_SetupNextMenu(currentMenu->prevMenu);
|
M_SetupNextMenu(currentMenu->prevMenu);
|
||||||
|
@ -9529,7 +9552,24 @@ static void M_ToggleMIDI(INT32 choice)
|
||||||
{
|
{
|
||||||
midi_disabled = true;
|
midi_disabled = true;
|
||||||
if (S_MusicType() == MU_MID)
|
if (S_MusicType() == MU_MID)
|
||||||
|
{
|
||||||
|
if (digital_disabled)
|
||||||
S_StopMusic();
|
S_StopMusic();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char mmusic[7];
|
||||||
|
UINT16 mflags;
|
||||||
|
boolean looping;
|
||||||
|
|
||||||
|
if (S_MusicInfo(mmusic, &mflags, &looping) && S_DigExists(mmusic))
|
||||||
|
{
|
||||||
|
S_StopMusic();
|
||||||
|
S_ChangeMusic(mmusic, mflags, looping);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
S_StopMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
//M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING);
|
//M_StartMessage(M_GetText("MIDI Music Disabled\n"), NULL, MM_NOTHING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1347,6 +1347,8 @@ const char *compat_special_music_slots[16] =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char music_name[7]; // up to 6-character name
|
static char music_name[7]; // up to 6-character name
|
||||||
|
static UINT16 music_flags;
|
||||||
|
static boolean music_looping;
|
||||||
|
|
||||||
/// ------------------------
|
/// ------------------------
|
||||||
/// Music Status
|
/// Music Status
|
||||||
|
@ -1382,9 +1384,17 @@ musictype_t S_MusicType(void)
|
||||||
return I_GetMusicType();
|
return I_GetMusicType();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *S_MusicName(void)
|
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
|
||||||
{
|
{
|
||||||
return music_name;
|
if (!I_MusicPlaying())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
strncpy(mname, music_name, 7);
|
||||||
|
mname[6] = 0;
|
||||||
|
*mflags = music_flags;
|
||||||
|
*looping = music_looping;
|
||||||
|
|
||||||
|
return (boolean)mname[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
|
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
|
||||||
|
@ -1453,6 +1463,8 @@ static void S_UnloadMusic(void)
|
||||||
{
|
{
|
||||||
I_UnloadSong();
|
I_UnloadSong();
|
||||||
music_name[0] = 0;
|
music_name[0] = 0;
|
||||||
|
music_flags = 0;
|
||||||
|
music_looping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean S_PlayMusic(boolean looping)
|
static boolean S_PlayMusic(boolean looping)
|
||||||
|
@ -1489,6 +1501,9 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
|
||||||
if (!S_LoadMusic(mmusic))
|
if (!S_LoadMusic(mmusic))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
music_flags = mflags;
|
||||||
|
music_looping = looping;
|
||||||
|
|
||||||
if (!S_PlayMusic(looping))
|
if (!S_PlayMusic(looping))
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, "Music cannot be played!\n");
|
CONS_Alert(CONS_ERROR, "Music cannot be played!\n");
|
||||||
|
|
|
@ -136,7 +136,7 @@ boolean S_MusicDisabled(void);
|
||||||
boolean S_MusicPlaying(void);
|
boolean S_MusicPlaying(void);
|
||||||
boolean S_MusicPaused(void);
|
boolean S_MusicPaused(void);
|
||||||
musictype_t S_MusicType(void);
|
musictype_t S_MusicType(void);
|
||||||
const char *S_MusicName(void);
|
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
|
||||||
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
|
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
|
||||||
#define S_DigExists(a) S_MusicExists(a, false, true)
|
#define S_DigExists(a) S_MusicExists(a, false, true)
|
||||||
#define S_MIDIExists(a) S_MusicExists(a, true, false)
|
#define S_MIDIExists(a) S_MusicExists(a, true, false)
|
||||||
|
|
Loading…
Reference in a new issue