From 09dc08859d7e48dbb39c61d0c39ad275719bc82d Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 13 Mar 2011 12:55:00 +0100 Subject: [PATCH] added a function to set the text outline colour and increased readability of nameplates on bright backgrounds. Closes #205 --- src/engine/client/text.cpp | 27 ++++++++++++++++++----- src/engine/textrender.h | 1 + src/game/client/components/nameplates.cpp | 2 ++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index a0b3b3113..da91980dc 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -101,6 +101,11 @@ class CTextRender : public IEngineTextRender float m_TextG; float m_TextB; float m_TextA; + + float m_TextOutlineR; + float m_TextOutlineG; + float m_TextOutlineB; + float m_TextOutlineA; int m_FontTextureFormat; @@ -438,10 +443,14 @@ public: { m_pGraphics = 0; - m_TextR = 1; - m_TextG = 1; - m_TextB = 1; - m_TextA = 1; + m_TextR = 1.0f; + m_TextG = 1.0f; + m_TextB = 1.0f; + m_TextA = 1.0f; + m_TextOutlineR = 0.0f; + m_TextOutlineG = 0.0f; + m_TextOutlineB = 0.0f; + m_TextOutlineA = 0.3f; m_pDefaultFont = 0; @@ -535,6 +544,14 @@ public: m_TextB = b; m_TextA = a; } + + virtual void TextOutlineColor(float r, float g, float b, float a) + { + m_TextOutlineR = r; + m_TextOutlineG = g; + m_TextOutlineB = b; + m_TextOutlineA = a; + } virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length) { @@ -614,7 +631,7 @@ public: Graphics()->QuadsBegin(); if (i == 0) - Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f*m_TextA); + Graphics()->SetColor(m_TextOutlineR, m_TextOutlineG, m_TextOutlineB, m_TextOutlineA*m_TextA); else Graphics()->SetColor(m_TextR, m_TextG, m_TextB, m_TextA); } diff --git a/src/engine/textrender.h b/src/engine/textrender.h index 0674ce903..8d13f6057 100644 --- a/src/engine/textrender.h +++ b/src/engine/textrender.h @@ -46,6 +46,7 @@ public: // old foolish interface virtual void TextColor(float r, float g, float b, float a) = 0; + virtual void TextOutlineColor(float r, float g, float b, float a) = 0; virtual void Text(void *pFontSetV, float x, float y, float Size, const char *pText, int MaxWidth) = 0; virtual float TextWidth(void *pFontSetV, float Size, const char *pText, int Length) = 0; virtual int TextLineCount(void *pFontSetV, float Size, const char *pText, float LineWidth) = 0; diff --git a/src/game/client/components/nameplates.cpp b/src/game/client/components/nameplates.cpp index 5664cb4ee..9fa7e06a3 100644 --- a/src/game/client/components/nameplates.cpp +++ b/src/game/client/components/nameplates.cpp @@ -32,6 +32,7 @@ void CNamePlates::RenderNameplate( const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName; float tw = TextRender()->TextWidth(0, FontSize, pName, -1); + TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.5f*a); TextRender()->TextColor(1.0f, 1.0f, 1.0f, a); if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS) { @@ -51,6 +52,7 @@ void CNamePlates::RenderNameplate( } TextRender()->TextColor(1,1,1,1); + TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f); } }