Skip to content

Add more sound options for chat #2277 #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: community
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ MACRO_CONFIG_INT(BrMaxRequests, br_max_requests, 25, 0, 1000, CFGFLAG_SAVE|CFGFL
MACRO_CONFIG_INT(SndBufferSize, snd_buffer_size, 512, 128, 32768, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Sound buffer size")
MACRO_CONFIG_INT(SndRate, snd_rate, 48000, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Sound mixing rate")
MACRO_CONFIG_INT(SndEnable, snd_enable, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Enable sounds")
MACRO_CONFIG_INT(SndEnableRegularChat, snd_enable_regular_chat, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Enable regular chat sounds")
MACRO_CONFIG_INT(SndEnableServerChat, snd_enable_server_chat, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Enable server chat sounds")
MACRO_CONFIG_INT(SndEnableWhisperChat, snd_enable_whisper_chat, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Enable whisper chat sounds")
MACRO_CONFIG_INT(SndEnableHighlightChat, snd_enable_highlight_chat, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Enable chat sounds when your name is highlighted")
MACRO_CONFIG_INT(SndInit, snd_init, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Initialize sound systems")
MACRO_CONFIG_INT(SndMusic, snd_enable_music, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Play background music")
MACRO_CONFIG_INT(SndVolume, snd_volume, 100, 0, 100, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Sound volume")
Expand Down
13 changes: 8 additions & 5 deletions src/game/client/components/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,21 +700,24 @@ void CChat::AddLine(const char *pLine, int ClientID, int Mode, int TargetID)
int64 Now = time_get();
if(ClientID < 0)
{
if(Now-m_aLastSoundPlayed[CHAT_SERVER] >= time_freq()*3/10)
if(Config()->m_SndEnableServerChat && Now-m_aLastSoundPlayed[CHAT_SERVER] >= time_freq()*3/10)
{
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0);
m_aLastSoundPlayed[CHAT_SERVER] = Now;
}
}
else if(Highlighted || Mode == CHAT_WHISPER)
{
if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10)
if((Highlighted && Config()->m_SndEnableHighlightChat) || (Mode == CHAT_WHISPER && Config()->m_SndEnableWhisperChat))
{
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0);
m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now;
if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10)
{
m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0);
m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now;
}
}
}
else
else if(Config()->m_SndEnableRegularChat)
{
if(Now-m_aLastSoundPlayed[CHAT_CLIENT] >= time_freq()*3/10)
{
Expand Down
30 changes: 29 additions & 1 deletion src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
CUIRect Label, Button, Sound, Detail, BottomView, Background;

// render sound menu background
int NumOptions = Config()->m_SndEnable ? 3 : 2;
int NumOptions = Config()->m_SndEnable ? 7 : 2;
float ButtonHeight = 20.0f;
float Spacing = 2.0f;
float BackgroundHeight = (float)(NumOptions+1)*ButtonHeight+(float)NumOptions*Spacing;
Expand Down Expand Up @@ -1967,6 +1967,34 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
if(DoButton_CheckBox(&s_ButtonSndNonactiveMute, Localize("Mute when not active"), Config()->m_SndNonactiveMute, &Button))
Config()->m_SndNonactiveMute ^= 1;

Sound.HSplitTop(Spacing, 0, &Sound);
Sound.HSplitTop(ButtonHeight, &Button, &Sound);
Button.VSplitLeft(ButtonHeight, 0, &Button);
static int s_ButtonSndEnableRegularChat = 0;
if(DoButton_CheckBox(&s_ButtonSndEnableRegularChat, Localize("Enable regular chat sounds"), Config()->m_SndEnableRegularChat, &Button))
Config()->m_SndEnableRegularChat ^= 1;

Sound.HSplitTop(Spacing, 0, &Sound);
Sound.HSplitTop(ButtonHeight, &Button, &Sound);
Button.VSplitLeft(ButtonHeight, 0, &Button);
static int s_ButtonSndEnableWhisperChat = 0;
if(DoButton_CheckBox(&s_ButtonSndEnableWhisperChat, Localize("Enable whisper chat sounds"), Config()->m_SndEnableWhisperChat, &Button))
Config()->m_SndEnableWhisperChat ^= 1;

Sound.HSplitTop(Spacing, 0, &Sound);
Sound.HSplitTop(ButtonHeight, &Button, &Sound);
Button.VSplitLeft(ButtonHeight, 0, &Button);
static int s_ButtonSndEnableHighlightChat = 0;
if(DoButton_CheckBox(&s_ButtonSndEnableHighlightChat, Localize("Enable chat sound when highlighted"), Config()->m_SndEnableHighlightChat, &Button))
Config()->m_SndEnableHighlightChat ^= 1;

Sound.HSplitTop(Spacing, 0, &Sound);
Sound.HSplitTop(ButtonHeight, &Button, &Sound);
Button.VSplitLeft(ButtonHeight, 0, &Button);
static int s_ButtonSndEnableServerChat = 0;
if(DoButton_CheckBox(&s_ButtonSndEnableServerChat, Localize("Enable server chat sounds"), Config()->m_SndEnableServerChat, &Button))
Config()->m_SndEnableServerChat ^= 1;

// render detail menu
Detail.HSplitTop(ButtonHeight, &Label, &Detail);
Label.y += 2.0f;
Expand Down