mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Add Background music volume slider
as requested by hussainx3
This commit is contained in:
parent
c92af2e2df
commit
ba258d7343
|
@ -82,6 +82,7 @@ MACRO_CONFIG_INT(SndMusic, snd_enable_music, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLI
|
||||||
MACRO_CONFIG_INT(SndVolume, snd_volume, 100, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Sound volume")
|
MACRO_CONFIG_INT(SndVolume, snd_volume, 100, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Sound volume")
|
||||||
MACRO_CONFIG_INT(SndDevice, snd_device, -1, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "(deprecated) Sound device to use")
|
MACRO_CONFIG_INT(SndDevice, snd_device, -1, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "(deprecated) Sound device to use")
|
||||||
MACRO_CONFIG_INT(SndMapSoundVolume, snd_ambient_volume, 70, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Map Sound sound volume")
|
MACRO_CONFIG_INT(SndMapSoundVolume, snd_ambient_volume, 70, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Map Sound sound volume")
|
||||||
|
MACRO_CONFIG_INT(SndBackgroundMusicVolume, snd_background_music_volume, 50, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Background music sound volume")
|
||||||
|
|
||||||
MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
||||||
MACRO_CONFIG_INT(SndGame, snd_game, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable game sounds")
|
MACRO_CONFIG_INT(SndGame, snd_game, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable game sounds")
|
||||||
|
|
|
@ -1274,6 +1274,17 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
||||||
UI()->DoLabelScaled(&Label, Localize("Map sound volume"), 14.0f, -1);
|
UI()->DoLabelScaled(&Label, Localize("Map sound volume"), 14.0f, -1);
|
||||||
g_Config.m_SndMapSoundVolume = (int)(DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f);
|
g_Config.m_SndMapSoundVolume = (int)(DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// volume slider background music
|
||||||
|
{
|
||||||
|
CUIRect Button, Label;
|
||||||
|
MainView.HSplitTop(5.0f, &Button, &MainView);
|
||||||
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||||
|
Button.VSplitLeft(190.0f, &Label, &Button);
|
||||||
|
Button.HMargin(2.0f, &Button);
|
||||||
|
UI()->DoLabelScaled(&Label, Localize("Background music volume"), 14.0f, -1);
|
||||||
|
g_Config.m_SndBackgroundMusicVolume = (int)(DoScrollbarH(&g_Config.m_SndBackgroundMusicVolume, &Button, g_Config.m_SndBackgroundMusicVolume / 100.0f) * 100.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CLanguage
|
class CLanguage
|
||||||
|
|
|
@ -59,9 +59,10 @@ void CSounds::OnInit()
|
||||||
{
|
{
|
||||||
// setup sound channels
|
// setup sound channels
|
||||||
m_MapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
m_MapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
||||||
|
m_BackgroundMusicVolume = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
||||||
|
|
||||||
Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_MUSIC, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f, 1.0f);
|
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f, 1.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
||||||
|
@ -121,6 +122,13 @@ void CSounds::OnRender()
|
||||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float NewBackgroundMusicVol = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
||||||
|
if(NewBackgroundMusicVol != m_BackgroundMusicVolume)
|
||||||
|
{
|
||||||
|
m_BackgroundMusicVolume = NewBackgroundMusicVol;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// play sound from queue
|
// play sound from queue
|
||||||
if(m_QueuePos > 0)
|
if(m_QueuePos > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,7 @@ class CSounds : public CComponent
|
||||||
int GetSampleId(int SetId);
|
int GetSampleId(int SetId);
|
||||||
|
|
||||||
float m_MapSoundVolume;
|
float m_MapSoundVolume;
|
||||||
|
float m_BackgroundMusicVolume;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// sound channels
|
// sound channels
|
||||||
|
|
Loading…
Reference in a new issue