Merge pull request #1579 from Dune-jr/feature-filterchat

Add a new option to toggle between all chat, friend-only, no chat, with a toggle button. Fixes #1471
This commit is contained in:
oy 2018-10-28 11:43:03 +01:00 committed by GitHub
commit 05d84c90de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 9 deletions

View file

@ -367,7 +367,8 @@ void CChat::AddLine(int ClientID, int Mode, const char *pLine)
{
if(*pLine == 0 || (ClientID != -1 && (!g_Config.m_ClShowsocial || m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client
m_pClient->m_aClients[ClientID].m_ChatIgnore ||
(m_pClient->m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend))))
g_Config.m_ClFilterchat == 2 ||
(m_pClient->m_LocalClientID != ClientID && g_Config.m_ClFilterchat == 1 && !m_pClient->m_aClients[ClientID].m_Friend))))
return;
// trim right and set maximum length to 128 utf8-characters

View file

@ -261,7 +261,7 @@ void CMenus::RenderPlayers(CUIRect MainView)
ButtonBar.VSplitLeft(Width, &Button, &ButtonBar);
Button.VSplitLeft((Width-Button.h)/4.0f, 0, &Button);
Button.VSplitLeft(Button.h, &Button, 0);
if(g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[i].m_Friend)
if(g_Config.m_ClFilterchat == 2 || (g_Config.m_ClFilterchat == 1 && !m_pClient->m_aClients[i].m_Friend))
DoButton_Toggle(&s_aPlayerIDs[i][0], 1, &Button, false);
else
if(DoButton_Toggle(&s_aPlayerIDs[i][0], m_pClient->m_aClients[i].m_ChatIgnore, &Button, true))

View file

@ -734,11 +734,31 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
if(DoButton_CheckBox(&s_Showhud, Localize("Show ingame HUD"), g_Config.m_ClShowhud, &Button))
g_Config.m_ClShowhud ^= 1;
Game.HSplitTop(Spacing, 0, &Game);
Game.HSplitTop(ButtonHeight, &Button, &Game);
static int s_Friendchat = 0;
if(DoButton_CheckBox(&s_Friendchat, Localize("Show only chat messages from friends"), g_Config.m_ClShowChatFriends, &Button))
g_Config.m_ClShowChatFriends ^= 1;
// show chat messages button
{
Game.HSplitTop(Spacing, 0, &Game);
Game.HSplitTop(ButtonHeight, &Button, &Game);
RenderTools()->DrawUIRect(&Button, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
CUIRect Text;
Button.VSplitLeft(ButtonHeight+5.0f, 0, &Button);
Button.VSplitLeft(200.0f, &Text, &Button);
char aBuf[32];
str_format(aBuf, sizeof(aBuf), Localize("Show chat messages from:"));
Text.y += 2.0f;
UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
Button.VSplitLeft(100.0f, &Button, 0);
if(g_Config.m_ClFilterchat == 0)
str_format(aBuf, sizeof(aBuf), "everyone");
else if(g_Config.m_ClFilterchat == 1)
str_format(aBuf, sizeof(aBuf), "friends only");
else if(g_Config.m_ClFilterchat == 2)
str_format(aBuf, sizeof(aBuf), "no one");
static CButtonContainer s_ButtonFilterchat;
if(DoButton_Menu(&s_ButtonFilterchat, aBuf, 0, &Button))
g_Config.m_ClFilterchat = (g_Config.m_ClFilterchat + 1) % 3;
}
Game.HSplitTop(Spacing, 0, &Game);
Game.HSplitTop(ButtonHeight, &Button, &Game);
@ -835,7 +855,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
g_Config.m_ClMouseDeadzone = 300;
g_Config.m_ClAutoswitchWeapons = 1;
g_Config.m_ClShowhud = 1;
g_Config.m_ClShowChatFriends = 0;
g_Config.m_ClFilterchat = 0;
g_Config.m_ClNameplates = 1;
g_Config.m_ClNameplatesAlways = 1;
g_Config.m_ClNameplatesSize = 50;

View file

@ -14,7 +14,7 @@ MACRO_CONFIG_INT(ClNameplatesSize, cl_nameplates_size, 50, 0, 100, CFGFLAG_CLIEN
MACRO_CONFIG_INT(ClAutoswitchWeapons, cl_autoswitch_weapons, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Auto switch weapon on pickup")
MACRO_CONFIG_INT(ClShowhud, cl_showhud, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ingame HUD")
MACRO_CONFIG_INT(ClShowChatFriends, cl_show_chat_friends, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show only chat messages from friends")
MACRO_CONFIG_INT(ClFilterchat, cl_filterchat, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show chat messages from: 0=all, 1=friends only, 2=no one")
MACRO_CONFIG_INT(ClShowsocial, cl_showsocial, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show social data like names, clans, chat etc.")
MACRO_CONFIG_INT(ClShowfps, cl_showfps, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ingame FPS counter")