mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
added a function to set the text outline colour and increased readability of nameplates on bright backgrounds. Closes #205
This commit is contained in:
parent
01ea32f816
commit
09dc08859d
|
@ -102,6 +102,11 @@ class CTextRender : public IEngineTextRender
|
||||||
float m_TextB;
|
float m_TextB;
|
||||||
float m_TextA;
|
float m_TextA;
|
||||||
|
|
||||||
|
float m_TextOutlineR;
|
||||||
|
float m_TextOutlineG;
|
||||||
|
float m_TextOutlineB;
|
||||||
|
float m_TextOutlineA;
|
||||||
|
|
||||||
int m_FontTextureFormat;
|
int m_FontTextureFormat;
|
||||||
|
|
||||||
CFont *m_pDefaultFont;
|
CFont *m_pDefaultFont;
|
||||||
|
@ -438,10 +443,14 @@ public:
|
||||||
{
|
{
|
||||||
m_pGraphics = 0;
|
m_pGraphics = 0;
|
||||||
|
|
||||||
m_TextR = 1;
|
m_TextR = 1.0f;
|
||||||
m_TextG = 1;
|
m_TextG = 1.0f;
|
||||||
m_TextB = 1;
|
m_TextB = 1.0f;
|
||||||
m_TextA = 1;
|
m_TextA = 1.0f;
|
||||||
|
m_TextOutlineR = 0.0f;
|
||||||
|
m_TextOutlineG = 0.0f;
|
||||||
|
m_TextOutlineB = 0.0f;
|
||||||
|
m_TextOutlineA = 0.3f;
|
||||||
|
|
||||||
m_pDefaultFont = 0;
|
m_pDefaultFont = 0;
|
||||||
|
|
||||||
|
@ -536,6 +545,14 @@ public:
|
||||||
m_TextA = a;
|
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)
|
virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length)
|
||||||
{
|
{
|
||||||
CFont *pFont = pCursor->m_pFont;
|
CFont *pFont = pCursor->m_pFont;
|
||||||
|
@ -614,7 +631,7 @@ public:
|
||||||
|
|
||||||
Graphics()->QuadsBegin();
|
Graphics()->QuadsBegin();
|
||||||
if (i == 0)
|
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
|
else
|
||||||
Graphics()->SetColor(m_TextR, m_TextG, m_TextB, m_TextA);
|
Graphics()->SetColor(m_TextR, m_TextG, m_TextB, m_TextA);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
|
|
||||||
// old foolish interface
|
// old foolish interface
|
||||||
virtual void TextColor(float r, float g, float b, float a) = 0;
|
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 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 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;
|
virtual int TextLineCount(void *pFontSetV, float Size, const char *pText, float LineWidth) = 0;
|
||||||
|
|
|
@ -32,6 +32,7 @@ void CNamePlates::RenderNameplate(
|
||||||
const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName;
|
const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName;
|
||||||
float tw = TextRender()->TextWidth(0, FontSize, pName, -1);
|
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);
|
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)
|
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()->TextColor(1,1,1,1);
|
||||||
|
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue