mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
3048: Add GUI & Game sound volume sliders r=heinrich5991 a=def- As requested by Pipou 3063: increase buffer size for name_ban messages r=heinrich5991 a=12pm otherwise reason can be cut off Co-authored-by: def <dennis@felsin9.de> Co-authored-by: 12pm <30786226+12pm@users.noreply.github.com>
This commit is contained in:
commit
6ab806fde8
|
@ -2941,7 +2941,7 @@ void CServer::ConAuthList(IConsole::IResult *pResult, void *pUser)
|
|||
void CServer::ConNameBan(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
CServer *pThis = (CServer *)pUser;
|
||||
char aBuf[128];
|
||||
char aBuf[256];
|
||||
const char *pName = pResult->GetString(0);
|
||||
const char *pReason = pResult->NumArguments() > 3 ? pResult->GetString(3) : "";
|
||||
int Distance = pResult->NumArguments() > 1 ? pResult->GetInteger(1) : str_length(pName) / 3;
|
||||
|
@ -2976,7 +2976,7 @@ void CServer::ConNameUnban(IConsole::IResult *pResult, void *pUser)
|
|||
CNameBan *pBan = &pThis->m_aNameBans[i];
|
||||
if(str_comp(pBan->m_aName, pName) == 0)
|
||||
{
|
||||
char aBuf[64];
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "removed name='%s' distance=%d is_substring=%d reason='%s'", pBan->m_aName, pBan->m_Distance, pBan->m_IsSubstring, pBan->m_aReason);
|
||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "name_ban", aBuf);
|
||||
pThis->m_aNameBans.remove_index(i);
|
||||
|
@ -2991,7 +2991,7 @@ void CServer::ConNameBans(IConsole::IResult *pResult, void *pUser)
|
|||
for(int i = 0; i < pThis->m_aNameBans.size(); i++)
|
||||
{
|
||||
CNameBan *pBan = &pThis->m_aNameBans[i];
|
||||
char aBuf[64];
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "name='%s' distance=%d is_substring=%d reason='%s'", pBan->m_aName, pBan->m_Distance, pBan->m_IsSubstring, pBan->m_aReason);
|
||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "name_ban", aBuf);
|
||||
}
|
||||
|
|
|
@ -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(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(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(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);
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
CUIRect Button, Label;
|
||||
|
|
|
@ -58,13 +58,15 @@ int CSounds::GetSampleId(int SetId)
|
|||
void CSounds::OnInit()
|
||||
{
|
||||
// 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_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_WORLD, 0.9f, 1.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, 1.0f, 0.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f * m_GameSoundVolume, 1.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, m_GameSoundVolume, 0.0f);
|
||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.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);
|
||||
|
||||
// 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;
|
||||
if(NewMapSoundVol != m_MapSoundVolume)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,8 @@ class CSounds : public CComponent
|
|||
|
||||
int GetSampleId(int SetId);
|
||||
|
||||
float m_GuiSoundVolume;
|
||||
float m_GameSoundVolume;
|
||||
float m_MapSoundVolume;
|
||||
float m_BackgroundMusicVolume;
|
||||
|
||||
|
|
Loading…
Reference in a new issue