mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add volume slider for map sounds
This commit is contained in:
parent
0931e6ed28
commit
ef3b801999
|
@ -68,6 +68,7 @@ MACRO_CONFIG_INT(SndEnable, snd_enable, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "S
|
|||
MACRO_CONFIG_INT(SndMusic, snd_enable_music, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Play background music")
|
||||
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(SndAmbientVolume, snd_ambient_volume, 70, 0, 100, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Ambient sound volume")
|
||||
|
||||
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")
|
||||
|
|
|
@ -1054,6 +1054,18 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
|||
g_Config.m_SndVolume = (int)(DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume/100.0f)*100.0f);
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
}
|
||||
|
||||
// volume slider map sounds
|
||||
{
|
||||
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("Ambient volume"), 14.0f, -1);
|
||||
g_Config.m_SndAmbientVolume = (int)(DoScrollbarH(&g_Config.m_SndAmbientVolume, &Button, g_Config.m_SndAmbientVolume/100.0f)*100.0f);
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
}
|
||||
}
|
||||
|
||||
class CLanguage
|
||||
|
|
|
@ -64,11 +64,13 @@ int CSounds::GetSampleId(int SetId)
|
|||
void CSounds::OnInit()
|
||||
{
|
||||
// setup sound channels
|
||||
m_AmbientVolume = g_Config.m_SndAmbientVolume/100.0f;
|
||||
|
||||
Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_MUSIC, 1.0f, 0.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f, 1.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_AMBIENT, 0.7f, 1.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_AMBIENT, m_AmbientVolume, 1.0f);
|
||||
|
||||
Sound()->SetListenerPos(0.0f, 0.0f);
|
||||
|
||||
|
@ -120,6 +122,14 @@ void CSounds::OnRender()
|
|||
// set listner pos
|
||||
Sound()->SetListenerPos(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y);
|
||||
|
||||
// update volume
|
||||
float NewAmbientVol = g_Config.m_SndAmbientVolume/100.0f;
|
||||
if(NewAmbientVol != m_AmbientVolume)
|
||||
{
|
||||
m_AmbientVolume = NewAmbientVol;
|
||||
Sound()->SetChannel(CSounds::CHN_AMBIENT, m_AmbientVolume, 1.0f);
|
||||
}
|
||||
|
||||
// play sound from queue
|
||||
if(m_QueuePos > 0)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@ class CSounds : public CComponent
|
|||
|
||||
int GetSampleId(int SetId);
|
||||
|
||||
float m_AmbientVolume;
|
||||
|
||||
public:
|
||||
// sound channels
|
||||
enum
|
||||
|
|
Loading…
Reference in a new issue