mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add chat message constants from upstream, remove redundant comments
Add `CLIENT_MSG = -2` and `SERVER_MSG = -1` constants from upstream. Remove comments for self-documenting code.
This commit is contained in:
parent
6813c807e0
commit
61bf48c1ed
|
@ -147,7 +147,7 @@ void CChat::ConchainChatOld(IConsole::IResult *pResult, void *pUserData, IConsol
|
|||
|
||||
void CChat::Echo(const char *pString)
|
||||
{
|
||||
AddLine(-2, 0, pString);
|
||||
AddLine(CLIENT_MSG, 0, pString);
|
||||
}
|
||||
|
||||
void CChat::OnConsoleInit()
|
||||
|
@ -637,7 +637,7 @@ void CChat::StoreSave(const char *pText)
|
|||
void CChat::AddLine(int ClientID, int Team, const char *pLine)
|
||||
{
|
||||
if(*pLine == 0 ||
|
||||
(ClientID == -1 && !g_Config.m_ClShowChatSystem) ||
|
||||
(ClientID == SERVER_MSG && !g_Config.m_ClShowChatSystem) ||
|
||||
(ClientID >= 0 && (m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client
|
||||
m_pClient->m_aClients[ClientID].m_ChatIgnore ||
|
||||
(m_pClient->m_Snap.m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend) ||
|
||||
|
@ -698,9 +698,9 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
|
|||
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageFriendColor));
|
||||
else if(pLine_->m_Team)
|
||||
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageTeamColor));
|
||||
else if(pLine_->m_ClientID == -1) // system
|
||||
else if(pLine_->m_ClientID == SERVER_MSG)
|
||||
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
|
||||
else if(pLine_->m_ClientID == -2) // client
|
||||
else if(pLine_->m_ClientID == CLIENT_MSG)
|
||||
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor));
|
||||
else // regular message
|
||||
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageColor));
|
||||
|
@ -848,7 +848,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
|
|||
|
||||
// play sound
|
||||
int64_t Now = time();
|
||||
if(ClientID == -1)
|
||||
if(ClientID == SERVER_MSG)
|
||||
{
|
||||
if(Now - m_aLastSoundPlayed[CHAT_SERVER] >= time_freq() * 3 / 10)
|
||||
{
|
||||
|
@ -859,7 +859,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(ClientID == -2) // Client message
|
||||
else if(ClientID == CLIENT_MSG)
|
||||
{
|
||||
// No sound yet
|
||||
}
|
||||
|
@ -1063,33 +1063,24 @@ void CChat::OnPrepareLines()
|
|||
|
||||
// render name
|
||||
ColorRGBA NameColor;
|
||||
if(m_aLines[r].m_ClientID == -1) // system
|
||||
{
|
||||
if(m_aLines[r].m_ClientID == SERVER_MSG)
|
||||
NameColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
|
||||
}
|
||||
else if(m_aLines[r].m_ClientID == -2) // client
|
||||
{
|
||||
else if(m_aLines[r].m_ClientID == CLIENT_MSG)
|
||||
NameColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor));
|
||||
}
|
||||
else if(m_aLines[r].m_Team)
|
||||
{
|
||||
NameColor = CalculateNameColor(ColorHSLA(g_Config.m_ClMessageTeamColor));
|
||||
}
|
||||
else if(m_aLines[r].m_NameColor == TEAM_RED)
|
||||
NameColor = ColorRGBA(1.0f, 0.5f, 0.5f, 1.f); // red
|
||||
NameColor = ColorRGBA(1.0f, 0.5f, 0.5f, 1.f);
|
||||
else if(m_aLines[r].m_NameColor == TEAM_BLUE)
|
||||
NameColor = ColorRGBA(0.7f, 0.7f, 1.0f, 1.f); // blue
|
||||
NameColor = ColorRGBA(0.7f, 0.7f, 1.0f, 1.f);
|
||||
else if(m_aLines[r].m_NameColor == TEAM_SPECTATORS)
|
||||
NameColor = ColorRGBA(0.75f, 0.5f, 0.75f, 1.f); // spectator
|
||||
NameColor = ColorRGBA(0.75f, 0.5f, 0.75f, 1.f);
|
||||
else if(m_aLines[r].m_ClientID >= 0 && g_Config.m_ClChatTeamColors && m_pClient->m_Teams.Team(m_aLines[r].m_ClientID))
|
||||
{
|
||||
NameColor = color_cast<ColorRGBA>(ColorHSLA(m_pClient->m_Teams.Team(m_aLines[r].m_ClientID) / 64.0f, 1.0f, 0.75f));
|
||||
}
|
||||
else
|
||||
NameColor = ColorRGBA(0.8f, 0.8f, 0.8f, 1.f);
|
||||
|
||||
TextRender()->TextColor(NameColor);
|
||||
|
||||
TextRender()->CreateOrAppendTextContainer(m_aLines[r].m_TextContainerIndex, &Cursor, aName);
|
||||
|
||||
if(m_aLines[r].m_TimesRepeated > 0)
|
||||
|
@ -1106,13 +1097,13 @@ void CChat::OnPrepareLines()
|
|||
|
||||
// render line
|
||||
ColorRGBA Color;
|
||||
if(m_aLines[r].m_ClientID == -1) // system
|
||||
if(m_aLines[r].m_ClientID == SERVER_MSG)
|
||||
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
|
||||
else if(m_aLines[r].m_ClientID == -2) // client
|
||||
else if(m_aLines[r].m_ClientID == CLIENT_MSG)
|
||||
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor));
|
||||
else if(m_aLines[r].m_Highlighted) // highlighted
|
||||
else if(m_aLines[r].m_Highlighted)
|
||||
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor));
|
||||
else if(m_aLines[r].m_Team) // team message
|
||||
else if(m_aLines[r].m_Team)
|
||||
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageTeamColor));
|
||||
else // regular message
|
||||
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageColor));
|
||||
|
|
|
@ -62,9 +62,12 @@ class CChat : public CComponent
|
|||
CLine m_aLines[MAX_LINES];
|
||||
int m_CurrentLine;
|
||||
|
||||
// chat
|
||||
enum
|
||||
{
|
||||
// client IDs for special messages
|
||||
CLIENT_MSG = -2,
|
||||
SERVER_MSG = -1,
|
||||
|
||||
MODE_NONE = 0,
|
||||
MODE_ALL,
|
||||
MODE_TEAM,
|
||||
|
|
Loading…
Reference in a new issue