Skip to content

Commit bb56eab

Browse files
committed
Updated outline option for chat text
1 parent 6fdb55c commit bb56eab

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

Client/core/CSettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ void CSettings::CreateGUI ( void )
11321132
m_pTrayBalloon->GetPosition ( vecTemp );
11331133
m_pTrayBalloon->AutoSize ( NULL, 20.0f );
11341134

1135-
m_pChatTextBlackOutline = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( pTabInterface, _("Chat text black outline") ) );
1135+
m_pChatTextBlackOutline = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( pTabInterface, _("Chat text black/white outline") ) );
11361136
m_pChatTextBlackOutline->SetPosition ( CVector2D ( vecTemp.fX, vecTemp.fY + fLineHeight ) );
11371137
m_pChatTextBlackOutline->GetPosition ( vecTemp );
11381138
m_pChatTextBlackOutline->AutoSize ( NULL, 20.0f );

Client/core/Graphics/CGraphics.cpp

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void CGraphics::DrawString ( int uiLeft, int uiTop, int uiRight, int uiBottom, u
115115
std::wstring strText = MbUTF8ToUTF16(szText);
116116

117117
if ( bOutline )
118-
DrawStringBlurred( rect, ulColor & 0xFF000000, strText.c_str(), ulFormat, pDXFont );
118+
DrawStringOutline( rect, ulColor, strText.c_str(), ulFormat, pDXFont );
119119
pDXFont->DrawTextW ( m_pDXSprite, strText.c_str(), -1, &rect, ulFormat, ulColor );
120120
EndDrawBatch ();
121121
}
@@ -134,23 +134,43 @@ void CGraphics::DrawString ( int iX, int iY, unsigned long dwColor, float fScale
134134
}
135135

136136
// Slow
137-
void CGraphics::DrawStringBlurred(const RECT& rect, unsigned long ulColor, const wchar_t* szText, unsigned long ulFormat, LPD3DXFONT pDXFont)
138-
{
139-
// Blur definition
140-
const float E = 0;
141-
const float D = 0.33f;
142-
const float C = 0.66f;
143-
const float B = 1;
144-
const float A = 0;
145-
static const float kernelData[] = {
146-
E, D, D, D, E,
147-
D, C, B, C, D,
148-
D, B, A, B, D,
149-
D, C, B, C, D,
150-
E, D, D, D, E };
137+
void CGraphics::DrawStringOutline(const RECT& rect, unsigned long ulColor, const wchar_t* szText, unsigned long ulFormat, LPD3DXFONT pDXFont)
138+
{
151139
const uint uiKernelSizeX = 5;
152140
const uint uiKernelSizeY = 5;
153-
const float* pKernel = kernelData;
141+
const float* pKernel;
142+
143+
// Select outline style
144+
int iRed = (ulColor & 0x00FF0000) >> 16;
145+
int iGreen = (ulColor & 0x0000FF00) >> 8;
146+
int iBlue = (ulColor & 0x000000FF) >> 0;
147+
float fBrightness = (iRed * 0.299f + iGreen * 0.587f + iBlue * 0.114f);
148+
if (fBrightness > 64)
149+
{
150+
// Use black outline with thicker border
151+
ulColor = ulColor & 0xFF000000;
152+
const float F = 0, E = 0.16f, D = 0.33f, C = 0.66f, B = 1, A = 0;
153+
static const float kernelData[] = {
154+
F, E, D, E, F,
155+
E, C, B, C, E,
156+
D, B, A, B, D,
157+
E, C, B, C, E,
158+
F, E, D, E, F };
159+
pKernel = kernelData;
160+
}
161+
else
162+
{
163+
// Use white outline with thinner border
164+
ulColor = ulColor | 0x00FFFFFF;
165+
const float F = 0, E = 0, D = 0.25f, C = 0.5f, B = 1, A = 0;
166+
static const float kernelData[] = {
167+
F, E, D, E, F,
168+
E, C, B, C, E,
169+
D, B, A, B, D,
170+
E, C, B, C, E,
171+
F, E, D, E, F };
172+
pKernel = kernelData;
173+
}
154174

155175
// Apply definition
156176
int iInputAlpha = (ulColor & 0xFF000000) >> 24;

Client/core/Graphics/CGraphics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class CGraphics : public CGraphicsInterface, public CSingleton < CGraphics >
8282
void DrawString ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... );
8383
void DrawLine3D ( const CVector& vecBegin, const CVector& vecEnd, unsigned long ulColor, float fWidth = 1.0f );
8484
void DrawRectangle ( float fX, float fY, float fWidth, float fHeight, unsigned long ulColor, bool bSubPixelPositioning = false );
85-
void DrawStringBlurred ( const RECT& rect, unsigned long ulColor, const wchar_t* szText, unsigned long ulFormat, LPD3DXFONT pDXFont );
85+
void DrawStringOutline ( const RECT& rect, unsigned long ulColor, const wchar_t* szText, unsigned long ulFormat, LPD3DXFONT pDXFont );
8686

8787
void SetBlendMode ( EBlendModeType blendMode );
8888
EBlendModeType GetBlendMode ( void );

0 commit comments

Comments
 (0)