...
 
Commits (1)
  • musicpref console variable · 7f7ccc99
    kaysrishaq authored
    Adds musicpref to console and sound options menu, which allows users to select whether to prioritize MIDI or Digital music.
    Functions GameMIDIMusic_OnChange and GameDigiMusic_OnChange updated to not assume digital music priority, and to have more consistent behavior between the two.
    Positive side effect of using P_RestoreMusic in these functions means that powerup music (speed shoes, invincibility) will restore in the correct position when reenabling the original MusicType they loaded in with.
......@@ -1451,21 +1451,23 @@ static menuitem_t OP_OpenGLFogMenu[] =
static menuitem_t OP_SoundOptionsMenu[] =
{
{IT_HEADER, NULL, "Game Audio", NULL, 0},
{IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 12},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 22},
{IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 6},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 11},
{IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 42},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 52},
{IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 21},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 26},
{IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 72},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 82},
{IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 36},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 41},
{IT_STRING | IT_CVAR, NULL, "Music Preference", &cv_musicpref, 51},
{IT_HEADER, NULL, "Miscellaneous", NULL, 102},
{IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 114},
{IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 124},
{IT_STRING | IT_CVAR, NULL, "Default 1-Up sound", &cv_1upsound, 134},
{IT_HEADER, NULL, "Miscellaneous", NULL, 61},
{IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 67},
{IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 72},
{IT_STRING | IT_CVAR, NULL, "Default 1-Up sound", &cv_1upsound, 77},
{IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 154},
{IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 87},
};
#ifdef HAVE_OPENMPT
......@@ -2152,7 +2154,7 @@ menu_t OP_ColorOptionsDef =
0,
NULL
};
menu_t OP_SoundOptionsDef = DEFAULTMENUSTYLE(
menu_t OP_SoundOptionsDef = DEFAULTSCROLLMENUSTYLE(
MTREE2(MN_OP_MAIN, MN_OP_SOUND),
"M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 30, 30);
menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE(
......
......@@ -60,6 +60,7 @@ static void Command_RestartAudio_f(void);
static void GameMIDIMusic_OnChange(void);
static void GameSounds_OnChange(void);
static void GameDigiMusic_OnChange(void);
static void MusicPref_OnChange(void);
#ifdef HAVE_OPENMPT
static void ModFilter_OnChange(void);
......@@ -129,6 +130,14 @@ consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_O
consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL};
// Music preference
static CV_PossibleValue_t cons_musicpref_t[] = {
{0, "Digital"},
{1, "MIDI"},
{0, NULL}
};
consvar_t cv_musicpref = {"musicpref", "Digital", CV_SAVE|CV_CALL|CV_NOINIT, cons_musicpref_t, MusicPref_OnChange, 0, NULL, NULL, 0, 0, NULL};
// Window focus sound sytem toggles
consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playsoundsifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
......@@ -301,6 +310,7 @@ void S_RegisterSoundStuff(void)
CV_RegisterVar(&cv_gamesounds);
CV_RegisterVar(&cv_gamedigimusic);
CV_RegisterVar(&cv_gamemidimusic);
CV_RegisterVar(&cv_musicpref);
#ifdef HAVE_OPENMPT
CV_RegisterVar(&cv_modfilter);
#endif
......@@ -1847,19 +1857,6 @@ const char *S_MusicName(void)
return music_name;
}
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
{
if (!I_SongPlaying())
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)
{
return (
......@@ -2201,10 +2198,12 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst)
static lumpnum_t S_GetMusicLumpNum(const char *mname)
{
if (!S_DigMusicDisabled() && S_DigExists(mname))
return W_GetNumForName(va("o_%s", mname));
else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname))
return W_GetNumForName(va("d_%s", mname));
boolean midipref = cv_musicpref.value;
if (PREFAVAILABLE(midipref, mname))
return W_GetNumForName(va(midipref ? "d_%s":"o_%s", mname));
else if (ELSEAVAILABLE(midipref, mname))
return W_GetNumForName(va(midipref ? "o_%s":"d_%s", mname));
else
return LUMPERROR;
}
......@@ -2660,11 +2659,17 @@ void GameDigiMusic_OnChange(void)
else if (M_CheckParm("-nodigmusic"))
return;
boolean midipref = cv_musicpref.value;
if (digital_disabled)
{
digital_disabled = false;
I_StartupSound(); // will return early if initialised
I_InitMusic();
if (midipref && (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX))
return;
S_StopMusic();
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
......@@ -2674,27 +2679,20 @@ void GameDigiMusic_OnChange(void)
else
{
digital_disabled = true;
if (S_MusicType() != MU_MID)
if (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX)
{
if (midi_disabled)
S_StopMusic();
else
S_StopMusic();
if (!midi_disabled)
{
char mmusic[7];
UINT16 mflags;
boolean looping;
if (S_MusicInfo(mmusic, &mflags, &looping) && S_MIDIExists(mmusic))
{
S_StopMusic();
S_ChangeMusic(mmusic, mflags, looping);
}
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
else
S_StopMusic();
S_ChangeMusicInternal("_clear", false);
}
}
}
}
}
void GameMIDIMusic_OnChange(void)
{
......@@ -2703,11 +2701,18 @@ void GameMIDIMusic_OnChange(void)
else if (M_CheckParm("-nomidimusic"))
return;
boolean midipref = cv_musicpref.value;
if (midi_disabled)
{
midi_disabled = false;
I_StartupSound(); // will return early if initialised
I_InitMusic();
if (!midipref && (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX && S_MusicType() != MU_NONE))
return;
S_StopMusic();
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
else
......@@ -2718,26 +2723,42 @@ void GameMIDIMusic_OnChange(void)
midi_disabled = true;
if (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX)
{
if (digital_disabled)
S_StopMusic();
else
S_StopMusic();
if (!digital_disabled)
{
char mmusic[7];
UINT16 mflags;
boolean looping;
if (S_MusicInfo(mmusic, &mflags, &looping) && S_DigExists(mmusic))
{
S_StopMusic();
S_ChangeMusic(mmusic, mflags, looping);
}
if (Playing())
P_RestoreMusic(&players[consoleplayer]);
else
S_StopMusic();
S_ChangeMusicInternal("_clear", false);
}
}
}
}
void MusicPref_OnChange(void)
{
if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio") ||
M_CheckParm("-nomidimusic") || M_CheckParm("-nodigmusic"))
return;
boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX);
boolean midipref = cv_musicpref.value;
if (midipref == currentmidi)
return;
if (Playing() && PREFAVAILABLE(midipref, S_MusicName()))
{
S_StopMusic();
P_RestoreMusic(&players[consoleplayer]);
}
else if (PREFAVAILABLE(midipref, "_clear"))
{
S_StopMusic();
S_ChangeMusicInternal("_clear", false);
}
}
#ifdef HAVE_OPENMPT
void ModFilter_OnChange(void)
{
......
......@@ -46,6 +46,15 @@ extern consvar_t cv_1upsound;
extern consvar_t cv_gamedigimusic;
extern consvar_t cv_gamemidimusic;
extern consvar_t cv_gamesounds;
extern consvar_t cv_musicpref;
#define PREFAVAILABLE(pref, music) (pref ? \
(!S_MIDIMusicDisabled() && S_MIDIExists(music)) : \
(!S_DigMusicDisabled() && S_DigExists(music)))
#define ELSEAVAILABLE(pref, music) (pref ? \
(!S_DigMusicDisabled() && S_DigExists(music)) : \
(!S_MIDIMusicDisabled() && S_MIDIExists(music)))
extern consvar_t cv_playmusicifunfocused;
extern consvar_t cv_playsoundsifunfocused;
......@@ -178,7 +187,6 @@ boolean S_MusicPaused(void);
boolean S_MusicNotInFocus(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);
#define S_DigExists(a) S_MusicExists(a, false, true)
#define S_MIDIExists(a) S_MusicExists(a, true, false)
......