mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #7129 from Robyt3/Team-Color-Golden-Ratio
Use golden angle to generate unique, distinct DDTeam colors
This commit is contained in:
commit
ab5834278f
|
@ -977,7 +977,7 @@ void CChat::OnPrepareLines()
|
||||||
else if(m_aLines[r].m_NameColor == TEAM_SPECTATORS)
|
else if(m_aLines[r].m_NameColor == TEAM_SPECTATORS)
|
||||||
NameColor = ColorRGBA(0.75f, 0.5f, 0.75f, 1.f);
|
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))
|
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));
|
NameColor = m_pClient->GetDDTeamColor(m_pClient->m_Teams.Team(m_aLines[r].m_ClientID), 0.75f);
|
||||||
else
|
else
|
||||||
NameColor = ColorRGBA(0.8f, 0.8f, 0.8f, 1.f);
|
NameColor = ColorRGBA(0.8f, 0.8f, 0.8f, 1.f);
|
||||||
|
|
||||||
|
|
|
@ -278,21 +278,18 @@ void CKillMessages::OnRender()
|
||||||
|
|
||||||
float x = StartX;
|
float x = StartX;
|
||||||
|
|
||||||
ColorRGBA TColor(1.f, 1.f, 1.f, 1.f);
|
|
||||||
ColorRGBA TOutlineColor(0.f, 0.f, 0.f, 0.3f);
|
|
||||||
|
|
||||||
// render victim name
|
// render victim name
|
||||||
x -= m_aKillmsgs[r].m_VictimTextWidth;
|
x -= m_aKillmsgs[r].m_VictimTextWidth;
|
||||||
|
ColorRGBA TextColor;
|
||||||
if(m_aKillmsgs[r].m_VictimID >= 0 && g_Config.m_ClChatTeamColors && m_aKillmsgs[r].m_VictimDDTeam)
|
if(m_aKillmsgs[r].m_VictimID >= 0 && g_Config.m_ClChatTeamColors && m_aKillmsgs[r].m_VictimDDTeam)
|
||||||
{
|
TextColor = m_pClient->GetDDTeamColor(m_aKillmsgs[r].m_VictimDDTeam, 0.75f);
|
||||||
TColor = color_cast<ColorRGBA>(ColorHSLA(m_aKillmsgs[r].m_VictimDDTeam / 64.0f, 1.0f, 0.75f));
|
else
|
||||||
TColor.a = 1.f;
|
TextColor = TextRender()->DefaultTextColor();
|
||||||
}
|
|
||||||
|
|
||||||
CreateKillmessageNamesIfNotCreated(m_aKillmsgs[r]);
|
CreateKillmessageNamesIfNotCreated(m_aKillmsgs[r]);
|
||||||
|
|
||||||
if(m_aKillmsgs[r].m_VictimTextContainerIndex.Valid())
|
if(m_aKillmsgs[r].m_VictimTextContainerIndex.Valid())
|
||||||
TextRender()->RenderTextContainer(m_aKillmsgs[r].m_VictimTextContainerIndex, TColor, TOutlineColor, x, y + (46.f - 36.f) / 2.f);
|
TextRender()->RenderTextContainer(m_aKillmsgs[r].m_VictimTextContainerIndex, TextColor, TextRender()->DefaultTextOutlineColor(), x, y + (46.f - 36.f) / 2.f);
|
||||||
|
|
||||||
// render victim tee
|
// render victim tee
|
||||||
x -= 24.0f;
|
x -= 24.0f;
|
||||||
|
@ -380,7 +377,7 @@ void CKillMessages::OnRender()
|
||||||
x -= m_aKillmsgs[r].m_KillerTextWidth;
|
x -= m_aKillmsgs[r].m_KillerTextWidth;
|
||||||
|
|
||||||
if(m_aKillmsgs[r].m_KillerTextContainerIndex.Valid())
|
if(m_aKillmsgs[r].m_KillerTextContainerIndex.Valid())
|
||||||
TextRender()->RenderTextContainer(m_aKillmsgs[r].m_KillerTextContainerIndex, TColor, TOutlineColor, x, y + (46.f - 36.f) / 2.f);
|
TextRender()->RenderTextContainer(m_aKillmsgs[r].m_KillerTextContainerIndex, TextColor, TextRender()->DefaultTextOutlineColor(), x, y + (46.f - 36.f) / 2.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 46.0f;
|
y += 46.0f;
|
||||||
|
|
|
@ -144,7 +144,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
|
||||||
|
|
||||||
float tw = m_aNamePlates[ClientID].m_NameTextWidth;
|
float tw = m_aNamePlates[ClientID].m_NameTextWidth;
|
||||||
if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Teams.Team(ClientID))
|
if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Teams.Team(ClientID))
|
||||||
rgb = color_cast<ColorRGBA>(ColorHSLA(m_pClient->m_Teams.Team(ClientID) / 64.0f, 1.0f, 0.75f));
|
rgb = m_pClient->GetDDTeamColor(m_pClient->m_Teams.Team(ClientID), 0.75f);
|
||||||
|
|
||||||
ColorRGBA TColor;
|
ColorRGBA TColor;
|
||||||
ColorRGBA TOutlineColor;
|
ColorRGBA TOutlineColor;
|
||||||
|
|
|
@ -355,7 +355,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
||||||
|
|
||||||
if(DDTeam != TEAM_FLOCK)
|
if(DDTeam != TEAM_FLOCK)
|
||||||
{
|
{
|
||||||
ColorRGBA Color = color_cast<ColorRGBA>(ColorHSLA(DDTeam / 64.0f, 1.0f, 0.5f, 0.5f));
|
const ColorRGBA Color = m_pClient->GetDDTeamColor(DDTeam).WithAlpha(0.5f);
|
||||||
int Corners = 0;
|
int Corners = 0;
|
||||||
if(OldDDTeam != DDTeam)
|
if(OldDDTeam != DDTeam)
|
||||||
Corners |= IGraphics::CORNER_TL | IGraphics::CORNER_TR;
|
Corners |= IGraphics::CORNER_TL | IGraphics::CORNER_TR;
|
||||||
|
|
|
@ -401,7 +401,7 @@ void CSpectator::OnRender()
|
||||||
|
|
||||||
if(DDTeam != TEAM_FLOCK)
|
if(DDTeam != TEAM_FLOCK)
|
||||||
{
|
{
|
||||||
ColorRGBA Color = color_cast<ColorRGBA>(ColorHSLA(DDTeam / 64.0f, 1.0f, 0.5f, 0.5f));
|
const ColorRGBA Color = m_pClient->GetDDTeamColor(DDTeam).WithAlpha(0.5f);
|
||||||
int Corners = 0;
|
int Corners = 0;
|
||||||
if(OldDDTeam != DDTeam)
|
if(OldDDTeam != DDTeam)
|
||||||
Corners |= IGraphics::CORNER_TL | IGraphics::CORNER_TR;
|
Corners |= IGraphics::CORNER_TL | IGraphics::CORNER_TR;
|
||||||
|
|
|
@ -765,6 +765,14 @@ bool CGameClient::Predict() const
|
||||||
return !m_Snap.m_SpecInfo.m_Active && m_Snap.m_pLocalCharacter;
|
return !m_Snap.m_SpecInfo.m_Active && m_Snap.m_pLocalCharacter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorRGBA CGameClient::GetDDTeamColor(int DDTeam, float Lightness) const
|
||||||
|
{
|
||||||
|
// Use golden angle to generate unique colors with distinct adjacent colors.
|
||||||
|
// The first DDTeam (team 1) gets angle 0°, i.e. red hue.
|
||||||
|
const float Hue = std::fmod((DDTeam - 1) * (137.50776f / 360.0f), 1.0f);
|
||||||
|
return color_cast<ColorRGBA>(ColorHSLA(Hue, 1.0f, Lightness));
|
||||||
|
}
|
||||||
|
|
||||||
void CGameClient::OnRelease()
|
void CGameClient::OnRelease()
|
||||||
{
|
{
|
||||||
// release all systems
|
// release all systems
|
||||||
|
|
|
@ -530,6 +530,7 @@ public:
|
||||||
bool Predict() const;
|
bool Predict() const;
|
||||||
bool PredictDummy() { return g_Config.m_ClPredictDummy && Client()->DummyConnected() && m_Snap.m_LocalClientID >= 0 && m_PredictedDummyID >= 0 && !m_aClients[m_PredictedDummyID].m_Paused; }
|
bool PredictDummy() { return g_Config.m_ClPredictDummy && Client()->DummyConnected() && m_Snap.m_LocalClientID >= 0 && m_PredictedDummyID >= 0 && !m_aClients[m_PredictedDummyID].m_Paused; }
|
||||||
const CTuningParams *GetTuning(int i) { return &m_aTuningList[i]; }
|
const CTuningParams *GetTuning(int i) { return &m_aTuningList[i]; }
|
||||||
|
ColorRGBA GetDDTeamColor(int DDTeam, float Lightness = 0.5f) const;
|
||||||
|
|
||||||
CGameWorld m_GameWorld;
|
CGameWorld m_GameWorld;
|
||||||
CGameWorld m_PredictedWorld;
|
CGameWorld m_PredictedWorld;
|
||||||
|
|
Loading…
Reference in a new issue