Merge pull request #664 from Learath2/dd_pr_friends2

Just color the heart preserving team information. Fixes #606
This commit is contained in:
heinrich5991 2017-03-12 15:18:04 +01:00 committed by GitHub
commit 94e8e26f8d
3 changed files with 20 additions and 26 deletions

View file

@ -538,20 +538,14 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
m_aLines[m_CurrentLine].m_Team = 0; m_aLines[m_CurrentLine].m_Team = 0;
Highlighted = true; Highlighted = true;
} }
else
{
if(g_Config.m_ClMessageFriend && m_pClient->m_aClients[ClientID].m_Friend)
{
str_format(m_aLines[m_CurrentLine].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName), "♥ %s", m_pClient->m_aClients[ClientID].m_aName);
m_aLines[m_CurrentLine].m_NameColor = 2;
}
else else
str_copy(m_aLines[m_CurrentLine].m_aName, m_pClient->m_aClients[ClientID].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName)); str_copy(m_aLines[m_CurrentLine].m_aName, m_pClient->m_aClients[ClientID].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName));
}
str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), ": %s", pLine); str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), ": %s", pLine);
} }
m_aLines[m_CurrentLine].m_Friend = m_pClient->m_aClients[ClientID].m_Friend;
char aBuf[1024]; char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, Team >= 2?"whisper":(m_aLines[m_CurrentLine].m_Team?"teamchat":"chat"), aBuf, Highlighted); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, Team >= 2?"whisper":(m_aLines[m_CurrentLine].m_Team?"teamchat":"chat"), aBuf, Highlighted);
@ -750,6 +744,13 @@ void CChat::OnRender()
TextRender()->SetCursor(&Cursor, Begin, y, FontSize, TEXTFLAG_RENDER); TextRender()->SetCursor(&Cursor, Begin, y, FontSize, TEXTFLAG_RENDER);
Cursor.m_LineWidth = LineWidth; Cursor.m_LineWidth = LineWidth;
if(g_Config.m_ClMessageFriend && m_aLines[r].m_Friend)
{
vec3 rgb = HslToRgb(vec3(g_Config.m_ClMessageFriendHue / 255.0f, g_Config.m_ClMessageFriendSat / 255.0f, g_Config.m_ClMessageFriendLht / 255.0f));
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, Blend);
TextRender()->TextEx(&Cursor, "", -1);
}
// render name // render name
if (m_aLines[r].m_ClientID == -1) // system if (m_aLines[r].m_ClientID == -1) // system
{ {
@ -772,11 +773,6 @@ void CChat::OnRender()
TextRender()->TextColor(0.7f, 0.7f, 1.0f, Blend); // blue TextRender()->TextColor(0.7f, 0.7f, 1.0f, Blend); // blue
else if(m_aLines[r].m_NameColor == TEAM_SPECTATORS) else if(m_aLines[r].m_NameColor == TEAM_SPECTATORS)
TextRender()->TextColor(0.75f, 0.5f, 0.75f, Blend); // spectator TextRender()->TextColor(0.75f, 0.5f, 0.75f, Blend); // spectator
else if(m_aLines[r].m_NameColor == 2)
{
vec3 rgb = HslToRgb(vec3(g_Config.m_ClMessageFriendHue / 255.0f, g_Config.m_ClMessageFriendSat / 255.0f, g_Config.m_ClMessageFriendLht / 255.0f));
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, Blend);
}
else if(m_aLines[r].m_ClientID >= 0 && g_Config.m_ClChatTeamColors && m_pClient->m_Teams.Team(m_aLines[r].m_ClientID)) else if(m_aLines[r].m_ClientID >= 0 && g_Config.m_ClChatTeamColors && m_pClient->m_Teams.Team(m_aLines[r].m_ClientID))
{ {
vec3 rgb = HslToRgb(vec3(m_pClient->m_Teams.Team(m_aLines[r].m_ClientID) / 64.0f, 1.0f, 0.75f)); vec3 rgb = HslToRgb(vec3(m_pClient->m_Teams.Team(m_aLines[r].m_ClientID) / 64.0f, 1.0f, 0.75f));

View file

@ -24,6 +24,7 @@ class CChat : public CComponent
int m_NameColor; int m_NameColor;
char m_aName[64]; char m_aName[64];
char m_aText[512]; char m_aText[512];
bool m_Friend;
bool m_Highlighted; bool m_Highlighted;
}; };

View file

@ -1318,7 +1318,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
{ {
static int pIDP1 = 0, pIDP2 = 0; static int pIDP1 = 0, pIDP2 = 0;
static int Page = 1; static int Page = 1;
CUIRect Left, Right, HUD, Messages, Button, Label, Weapon, Laser, Page1Tab, Page2Tab, Enable; CUIRect Left, Right, HUD, Messages, Button, Label, Weapon, Laser, Page1Tab, Page2Tab, Enable, Heart;
MainView.HSplitTop(150.0f, &HUD, &MainView); MainView.HSplitTop(150.0f, &HUD, &MainView);
@ -1609,21 +1609,18 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
vec3 rgbf = HslToRgb(vec3(g_Config.m_ClMessageFriendHue / 255.0f, g_Config.m_ClMessageFriendSat / 255.0f, g_Config.m_ClMessageFriendLht / 255.0f)); vec3 rgbf = HslToRgb(vec3(g_Config.m_ClMessageFriendHue / 255.0f, g_Config.m_ClMessageFriendSat / 255.0f, g_Config.m_ClMessageFriendLht / 255.0f));
TextRender()->TextColor(rgbf.r, rgbf.g, rgbf.b, 1.0f); TextRender()->TextColor(rgbf.r, rgbf.g, rgbf.b, 1.0f);
str_format(aBuf, sizeof aBuf, "♥ %s", Localize("Friend")); float hw = TextRender()->TextWidth(0, 12.0f, "", -1);
float tw = TextRender()->TextWidth(0, 12.0f, aBuf, -1); Label.VSplitLeft(hw, &Heart, &Label);
UI()->DoLabelScaled(&Heart, "", 12.0f, -1);
TextRender()->TextColor(0.8f, 0.8f, 0.8f, 1.0f);
float tw = TextRender()->TextWidth(0, 12.0f, Localize("Friend"), -1);
Label.VSplitLeft(tw, &Label, &Button); Label.VSplitLeft(tw, &Label, &Button);
UI()->DoLabelScaled(&Label, aBuf, 12.0f, -1); UI()->DoLabelScaled(&Label, Localize("Friend"), 12.0f, -1);
vec3 rgb = HslToRgb(vec3(g_Config.m_ClMessageHue / 255.0f, g_Config.m_ClMessageSat / 255.0f, g_Config.m_ClMessageLht / 255.0f)); vec3 rgb = HslToRgb(vec3(g_Config.m_ClMessageHue / 255.0f, g_Config.m_ClMessageSat / 255.0f, g_Config.m_ClMessageLht / 255.0f));
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f); TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);
char name[16]; str_format(aBuf, sizeof(aBuf), ": %s", Localize("Hi o/"));
str_copy(name, g_Config.m_PlayerName, sizeof(name));
str_format(aBuf, sizeof(aBuf), ": %s", Localize ("Look out!"));
while (TextRender()->TextWidth(0, 12.0f, aBuf, -1) > Button.w)
{
name[str_length(name) - 1] = 0;
str_format(aBuf, sizeof(aBuf), ": %s: %s", name, Localize("Look out!"));
}
UI()->DoLabelScaled(&Button, aBuf, 12.0f, -1); UI()->DoLabelScaled(&Button, aBuf, 12.0f, -1);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);