mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Add GUI & Game sound volume sliders
As requested by Pipou
This commit is contained in:
parent
284c287c99
commit
4327194d27
|
@ -81,6 +81,8 @@ MACRO_CONFIG_INT(SndEnable, snd_enable, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT,
|
||||||
MACRO_CONFIG_INT(SndMusic, snd_enable_music, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Play background music")
|
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(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(SndChatSoundVolume, snd_chat_volume, 100, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Chat sound volume")
|
||||||
|
MACRO_CONFIG_INT(SndGameSoundVolume, snd_game_volume, 100, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Game sound volume")
|
||||||
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(SndBackgroundMusicVolume, snd_background_music_volume, 50, 0, 100, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Background music sound volume")
|
||||||
|
|
||||||
|
|
|
@ -1278,6 +1278,28 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
|
||||||
g_Config.m_SndVolume = (int)(DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume / 100.0f) * 100.0f);
|
g_Config.m_SndVolume = (int)(DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume / 100.0f) * 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// volume slider game 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("Game sound volume"), 14.0f, -1);
|
||||||
|
g_Config.m_SndGameSoundVolume = (int)(DoScrollbarH(&g_Config.m_SndGameSoundVolume, &Button, g_Config.m_SndGameSoundVolume / 100.0f) * 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// volume slider gui 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("Chat sound volume"), 14.0f, -1);
|
||||||
|
g_Config.m_SndChatSoundVolume = (int)(DoScrollbarH(&g_Config.m_SndChatSoundVolume, &Button, g_Config.m_SndChatSoundVolume / 100.0f) * 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// volume slider map sounds
|
// volume slider map sounds
|
||||||
{
|
{
|
||||||
CUIRect Button, Label;
|
CUIRect Button, Label;
|
||||||
|
|
|
@ -58,13 +58,15 @@ int CSounds::GetSampleId(int SetId)
|
||||||
void CSounds::OnInit()
|
void CSounds::OnInit()
|
||||||
{
|
{
|
||||||
// setup sound channels
|
// setup sound channels
|
||||||
|
m_GuiSoundVolume = g_Config.m_SndChatSoundVolume / 100.0f;
|
||||||
|
m_GameSoundVolume = g_Config.m_SndGameSoundVolume / 100.0f;
|
||||||
m_MapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
m_MapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
||||||
m_BackgroundMusicVolume = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
m_BackgroundMusicVolume = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
||||||
|
|
||||||
Sound()->SetChannel(CSounds::CHN_GUI, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_GUI, m_GuiSoundVolume, 0.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.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 * m_GameSoundVolume, 1.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f);
|
Sound()->SetChannel(CSounds::CHN_GLOBAL, m_GameSoundVolume, 0.0f);
|
||||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
||||||
|
|
||||||
Sound()->SetListenerPos(0.0f, 0.0f);
|
Sound()->SetListenerPos(0.0f, 0.0f);
|
||||||
|
@ -115,6 +117,21 @@ void CSounds::OnRender()
|
||||||
Sound()->SetListenerPos(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y);
|
Sound()->SetListenerPos(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y);
|
||||||
|
|
||||||
// update volume
|
// update volume
|
||||||
|
float NewGuiSoundVol = g_Config.m_SndChatSoundVolume / 100.0f;
|
||||||
|
if(NewGuiSoundVol != m_GuiSoundVolume)
|
||||||
|
{
|
||||||
|
m_GuiSoundVolume = NewGuiSoundVol;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_GUI, m_GuiSoundVolume, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float NewGameSoundVol = g_Config.m_SndGameSoundVolume / 100.0f;
|
||||||
|
if(NewGameSoundVol != m_GameSoundVolume)
|
||||||
|
{
|
||||||
|
m_GameSoundVolume = NewGameSoundVol;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f * m_GameSoundVolume, 1.0f);
|
||||||
|
Sound()->SetChannel(CSounds::CHN_GLOBAL, m_GameSoundVolume, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
float NewMapSoundVol = g_Config.m_SndMapSoundVolume / 100.0f;
|
float NewMapSoundVol = g_Config.m_SndMapSoundVolume / 100.0f;
|
||||||
if(NewMapSoundVol != m_MapSoundVolume)
|
if(NewMapSoundVol != m_MapSoundVolume)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,8 @@ class CSounds : public CComponent
|
||||||
|
|
||||||
int GetSampleId(int SetId);
|
int GetSampleId(int SetId);
|
||||||
|
|
||||||
|
float m_GuiSoundVolume;
|
||||||
|
float m_GameSoundVolume;
|
||||||
float m_MapSoundVolume;
|
float m_MapSoundVolume;
|
||||||
float m_BackgroundMusicVolume;
|
float m_BackgroundMusicVolume;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue