about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-03-13 12:55:00 +0100
committeroy <Tom_Adams@web.de>2011-03-13 12:55:00 +0100
commit09dc08859d7e48dbb39c61d0c39ad275719bc82d (patch)
tree3e8e5eeda158fea5a809bd068c207774fcad7fae /src
parent01ea32f816120d0c4a5bcf01f3978d8390e5ccb4 (diff)
downloadzcatch-09dc08859d7e48dbb39c61d0c39ad275719bc82d.tar.gz
zcatch-09dc08859d7e48dbb39c61d0c39ad275719bc82d.zip
added a function to set the text outline colour and increased readability of nameplates on bright backgrounds. Closes #205
Diffstat (limited to 'src')
-rw-r--r--src/engine/client/text.cpp27
-rw-r--r--src/engine/textrender.h1
-rw-r--r--src/game/client/components/nameplates.cpp2
3 files changed, 25 insertions, 5 deletions
diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp
index a0b3b311..da91980d 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 0674ce90..8d13f605 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 5664cb4e..9fa7e06a 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);
 	}
 }