mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 23:31:50 +00:00
Save sound toggles to config
This commit is contained in:
parent
5069acb110
commit
981a1192fb
3 changed files with 107 additions and 105 deletions
108
src/m_menu.c
108
src/m_menu.c
|
@ -287,9 +287,6 @@ menu_t OP_VideoOptionsDef, OP_VideoModeDef;
|
||||||
menu_t OP_OpenGLOptionsDef, OP_OpenGLFogDef, OP_OpenGLColorDef;
|
menu_t OP_OpenGLOptionsDef, OP_OpenGLFogDef, OP_OpenGLColorDef;
|
||||||
#endif
|
#endif
|
||||||
menu_t OP_SoundOptionsDef;
|
menu_t OP_SoundOptionsDef;
|
||||||
static void M_ToggleSFX(void);
|
|
||||||
static void M_ToggleDigital(void);
|
|
||||||
static void M_ToggleMIDI(void);
|
|
||||||
|
|
||||||
//Misc
|
//Misc
|
||||||
menu_t OP_DataOptionsDef, OP_ScreenshotOptionsDef, OP_EraseDataDef;
|
menu_t OP_DataOptionsDef, OP_ScreenshotOptionsDef, OP_EraseDataDef;
|
||||||
|
@ -1227,9 +1224,9 @@ static menuitem_t OP_SoundOptionsMenu[] =
|
||||||
NULL, "CD Volume" , &cd_volume, 40},
|
NULL, "CD Volume" , &cd_volume, 40},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{IT_STRING | IT_CALL, NULL, "Toggle SFX" , M_ToggleSFX, 50},
|
{IT_STRING | IT_CVAR, NULL, "SFX" , &cv_gamesounds, 50},
|
||||||
{IT_STRING | IT_CALL, NULL, "Toggle Digital Music", M_ToggleDigital, 60},
|
{IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 60},
|
||||||
{IT_STRING | IT_CALL, NULL, "Toggle MIDI Music", M_ToggleMIDI, 70},
|
{IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 70},
|
||||||
};
|
};
|
||||||
|
|
||||||
static menuitem_t OP_DataOptionsMenu[] =
|
static menuitem_t OP_DataOptionsMenu[] =
|
||||||
|
@ -6943,105 +6940,6 @@ static void M_ChangeControl(INT32 choice)
|
||||||
M_StartMessage(tmp, M_ChangecontrolResponse, MM_EVENTHANDLER);
|
M_StartMessage(tmp, M_ChangecontrolResponse, MM_EVENTHANDLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====
|
|
||||||
// SOUND
|
|
||||||
// =====
|
|
||||||
|
|
||||||
// Toggles sound systems in-game.
|
|
||||||
static void M_ToggleSFX(void)
|
|
||||||
{
|
|
||||||
if (sound_disabled)
|
|
||||||
{
|
|
||||||
sound_disabled = false;
|
|
||||||
S_InitSfxChannels(cv_soundvolume.value);
|
|
||||||
S_StartSound(NULL, sfx_strpst);
|
|
||||||
M_StartMessage(M_GetText("SFX Enabled\n"), NULL, MM_NOTHING);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sound_disabled = true;
|
|
||||||
S_StopSounds();
|
|
||||||
M_StartMessage(M_GetText("SFX Disabled\n"), NULL, MM_NOTHING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void M_ToggleDigital(void)
|
|
||||||
{
|
|
||||||
if (digital_disabled)
|
|
||||||
{
|
|
||||||
digital_disabled = false;
|
|
||||||
I_InitMusic();
|
|
||||||
S_StopMusic();
|
|
||||||
if (Playing())
|
|
||||||
P_RestoreMusic(&players[consoleplayer]);
|
|
||||||
else
|
|
||||||
S_ChangeMusicInternal("lclear", false);
|
|
||||||
M_StartMessage(M_GetText("Digital Music Enabled\n"), NULL, MM_NOTHING);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
digital_disabled = true;
|
|
||||||
if (S_MusicType() != MU_MID)
|
|
||||||
{
|
|
||||||
if (midi_disabled)
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void M_ToggleMIDI(void)
|
|
||||||
{
|
|
||||||
if (midi_disabled)
|
|
||||||
{
|
|
||||||
midi_disabled = false;
|
|
||||||
I_InitMusic();
|
|
||||||
if (Playing())
|
|
||||||
P_RestoreMusic(&players[consoleplayer]);
|
|
||||||
else
|
|
||||||
S_ChangeMusicInternal("lclear", false);
|
|
||||||
M_StartMessage(M_GetText("MIDI Music Enabled\n"), NULL, MM_NOTHING);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
midi_disabled = true;
|
|
||||||
if (S_MusicType() == MU_MID)
|
|
||||||
{
|
|
||||||
if (digital_disabled)
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===============
|
// ===============
|
||||||
// VIDEO MODE MENU
|
// VIDEO MODE MENU
|
||||||
// ===============
|
// ===============
|
||||||
|
|
101
src/s_sound.c
101
src/s_sound.c
|
@ -50,6 +50,11 @@ static void SetChannelsNum(void);
|
||||||
static void Command_Tunes_f(void);
|
static void Command_Tunes_f(void);
|
||||||
static void Command_RestartAudio_f(void);
|
static void Command_RestartAudio_f(void);
|
||||||
|
|
||||||
|
// Sound system toggles
|
||||||
|
static void GameMIDIMusic_OnChange(void);
|
||||||
|
static void GameSounds_OnChange(void);
|
||||||
|
static void GameDigiMusic_OnChange(void);
|
||||||
|
|
||||||
// commands for music and sound servers
|
// commands for music and sound servers
|
||||||
#ifdef MUSSERV
|
#ifdef MUSSERV
|
||||||
consvar_t musserver_cmd = {"musserver_cmd", "musserver", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t musserver_cmd = {"musserver_cmd", "musserver", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
@ -94,6 +99,11 @@ consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned,
|
||||||
static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
// Sound system toggles, saved into the config
|
||||||
|
consvar_t cv_gamedigimusic = {"gamedigimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
consvar_t cv_gamemidimusic = {"gamemidimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
consvar_t cv_gamesounds = {"gamesounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
#define S_MAX_VOLUME 127
|
#define S_MAX_VOLUME 127
|
||||||
|
|
||||||
// when to clip out sounds
|
// when to clip out sounds
|
||||||
|
@ -248,6 +258,9 @@ void S_RegisterSoundStuff(void)
|
||||||
CV_RegisterVar(&surround);
|
CV_RegisterVar(&surround);
|
||||||
CV_RegisterVar(&cv_samplerate);
|
CV_RegisterVar(&cv_samplerate);
|
||||||
CV_RegisterVar(&cv_resetmusic);
|
CV_RegisterVar(&cv_resetmusic);
|
||||||
|
CV_RegisterVar(&cv_gamesounds);
|
||||||
|
CV_RegisterVar(&cv_gamedigimusic);
|
||||||
|
CV_RegisterVar(&cv_gamemidimusic);
|
||||||
|
|
||||||
COM_AddCommand("tunes", Command_Tunes_f);
|
COM_AddCommand("tunes", Command_Tunes_f);
|
||||||
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
||||||
|
@ -1597,3 +1610,91 @@ static void Command_RestartAudio_f(void)
|
||||||
if (Playing()) // Gotta make sure the player is in a level
|
if (Playing()) // Gotta make sure the player is in a level
|
||||||
P_RestoreMusic(&players[consoleplayer]);
|
P_RestoreMusic(&players[consoleplayer]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameSounds_OnChange(void)
|
||||||
|
{
|
||||||
|
if (sound_disabled)
|
||||||
|
{
|
||||||
|
sound_disabled = false;
|
||||||
|
S_InitSfxChannels(cv_soundvolume.value);
|
||||||
|
S_StartSound(NULL, sfx_strpst);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sound_disabled = true;
|
||||||
|
S_StopSounds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameDigiMusic_OnChange(void)
|
||||||
|
{
|
||||||
|
if (digital_disabled)
|
||||||
|
{
|
||||||
|
digital_disabled = false;
|
||||||
|
I_InitMusic();
|
||||||
|
S_StopMusic();
|
||||||
|
if (Playing())
|
||||||
|
P_RestoreMusic(&players[consoleplayer]);
|
||||||
|
else
|
||||||
|
S_ChangeMusicInternal("lclear", false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
digital_disabled = true;
|
||||||
|
if (S_MusicType() != MU_MID)
|
||||||
|
{
|
||||||
|
if (midi_disabled)
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameMIDIMusic_OnChange(void)
|
||||||
|
{
|
||||||
|
if (midi_disabled)
|
||||||
|
{
|
||||||
|
midi_disabled = false;
|
||||||
|
I_InitMusic();
|
||||||
|
if (Playing())
|
||||||
|
P_RestoreMusic(&players[consoleplayer]);
|
||||||
|
else
|
||||||
|
S_ChangeMusicInternal("lclear", false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
midi_disabled = true;
|
||||||
|
if (S_MusicType() == MU_MID)
|
||||||
|
{
|
||||||
|
if (digital_disabled)
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,9 @@ extern consvar_t stereoreverse;
|
||||||
extern consvar_t cv_soundvolume, cv_digmusicvolume, cv_midimusicvolume;
|
extern consvar_t cv_soundvolume, cv_digmusicvolume, cv_midimusicvolume;
|
||||||
extern consvar_t cv_numChannels;
|
extern consvar_t cv_numChannels;
|
||||||
extern consvar_t cv_resetmusic;
|
extern consvar_t cv_resetmusic;
|
||||||
|
extern consvar_t cv_gamedigimusic;
|
||||||
|
extern consvar_t cv_gamemidimusic;
|
||||||
|
extern consvar_t cv_gamesounds;
|
||||||
|
|
||||||
#ifdef SNDSERV
|
#ifdef SNDSERV
|
||||||
extern consvar_t sndserver_cmd, sndserver_arg;
|
extern consvar_t sndserver_cmd, sndserver_arg;
|
||||||
|
|
Loading…
Reference in a new issue