Skip to content

Commit 236cf93

Browse files
committed
Removed redundant chat setting hacks. Expanded chat scale edit box. Renamed DrawText to DrawString to avoid clash with Windows macro.
1 parent ee0858e commit 236cf93

17 files changed

+56
-99
lines changed

Client/core/CChat.cpp

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -125,50 +125,6 @@ void CChat::LoadCVars ( void )
125125
CVARS_GET ( "chat_line_fade_out", (unsigned int &)m_ulChatLineFadeOut );
126126
CVARS_GET ( "chat_font", (unsigned int &)Font ); SetChatFont ( (eChatFont)Font );
127127
CVARS_GET ( "chat_nickcompletion", m_bNickCompletion );
128-
129-
// Modify default chat box to be like 'Transparent' preset
130-
SString strFlags;
131-
CVARS_GET ( "fixup_flags", strFlags );
132-
if ( strFlags.find ( "-cb" ) == std::string::npos )
133-
{
134-
CVARS_SET ( "fixup_flags", strFlags + "-cb" );
135-
136-
if ( Font == 0 // chat_font
137-
&& m_uiNumLines == 7 // chat_lines
138-
&& m_Color == CColor (0,0,128,100) // chat_color
139-
&& m_InputColor == CColor (0,0,191,110) // chat_input_color
140-
&& m_InputTextColor == CColor (172,213,254,255) // chat_input_text_color
141-
&& m_vecScale == CVector2D ( 1.0f, 1.0f ) // chat_scale
142-
&& fWidth == 1.0f // chat_width
143-
&& m_bCssStyleText == false // chat_css_style_text
144-
&& m_bCssStyleBackground == false // chat_css_style_background
145-
&& m_ulChatLineLife == 12000 // chat_line_life
146-
&& m_ulChatLineFadeOut == 3000 // chat_line_fade_out
147-
)
148-
{
149-
CVARS_SET ( "chat_font", (unsigned int)2 );
150-
CVARS_SET ( "chat_color", CColor (0,0,0,0) );
151-
CVARS_SET ( "chat_input_color", CColor (0,0,0,0) );
152-
CVARS_SET ( "chat_lines", 10 );
153-
CVARS_SET ( "chat_width", 1.5f );
154-
LoadCVars ();
155-
}
156-
}
157-
158-
// Fix mapalpha being set incorrectly in 1.0.4-9.1752.1
159-
CVARS_GET ( "fixup_flags", strFlags );
160-
if ( strFlags.find ( "-ma" ) == std::string::npos )
161-
{
162-
CVARS_SET ( "fixup_flags", strFlags + "-ma" );
163-
164-
int iVar = -1;
165-
CVARS_GET ( "mapalpha", iVar );
166-
if ( iVar < 3 )
167-
{
168-
iVar = 155;
169-
CVARS_SET ( "mapalpha", iVar );
170-
}
171-
}
172128
}
173129

174130

@@ -968,19 +924,19 @@ void CChat::DrawTextString ( const char * szText, CRect2D DrawArea, float fZ, CR
968924
{
969925
// Clip text at the top
970926
if ( DrawArea.fY1 + fLineHeight - RenderBounds.fY1 > 1 )
971-
g_pCore->GetGraphics ()->DrawText ( ( int ) DrawArea.fX1, ( int ) RenderBounds.fY1, ( int ) DrawArea.fX2, ( int ) DrawArea.fY1 + fLineHeight, ulColor, szText, fScaleX, fScaleY, DT_LEFT | DT_BOTTOM | DT_SINGLELINE , g_pChat->m_pDXFont );
927+
g_pCore->GetGraphics ()->DrawString ( ( int ) DrawArea.fX1, ( int ) RenderBounds.fY1, ( int ) DrawArea.fX2, ( int ) DrawArea.fY1 + fLineHeight, ulColor, szText, fScaleX, fScaleY, DT_LEFT | DT_BOTTOM | DT_SINGLELINE , g_pChat->m_pDXFont );
972928
}
973929
else
974930
if ( DrawArea.fY1 + fLineHeight > RenderBounds.fY2 )
975931
{
976932
// Clip text at the bottom
977933
if ( RenderBounds.fY2 - DrawArea.fY1 > 1 )
978-
g_pCore->GetGraphics ()->DrawText ( ( int ) DrawArea.fX1, ( int ) DrawArea.fY1, ( int ) DrawArea.fX2, ( int ) RenderBounds.fY2, ulColor, szText, fScaleX, fScaleY, DT_LEFT | DT_TOP | DT_SINGLELINE , g_pChat->m_pDXFont );
934+
g_pCore->GetGraphics ()->DrawString ( ( int ) DrawArea.fX1, ( int ) DrawArea.fY1, ( int ) DrawArea.fX2, ( int ) RenderBounds.fY2, ulColor, szText, fScaleX, fScaleY, DT_LEFT | DT_TOP | DT_SINGLELINE , g_pChat->m_pDXFont );
979935
}
980936
else
981937
{
982938
// Text not clipped
983-
g_pCore->GetGraphics ()->DrawText ( ( int ) DrawArea.fX1, ( int ) DrawArea.fY1, ( int ) DrawArea.fX1, ( int ) DrawArea.fY1, ulColor, szText, fScaleX, fScaleY, DT_LEFT | DT_TOP | DT_NOCLIP, g_pChat->m_pDXFont );
939+
g_pCore->GetGraphics ()->DrawString ( ( int ) DrawArea.fX1, ( int ) DrawArea.fY1, ( int ) DrawArea.fX1, ( int ) DrawArea.fY1, ulColor, szText, fScaleX, fScaleY, DT_LEFT | DT_TOP | DT_NOCLIP, g_pChat->m_pDXFont );
984940
}
985941
}
986942
}

Client/core/CClientVariables.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,16 @@ void CClientVariables::LoadDefaults ( void )
271271
DEFAULT ( "console_size", CVector2D ( 200, 200 ) ); // console size
272272
DEFAULT ( "serverbrowser_size", CVector2D ( 720.0f, 495.0f ) ); // serverbrowser size
273273
DEFAULT ( "fps_limit", 100 ); // frame limiter
274-
DEFAULT ( "chat_font", 0 ); // chatbox font type
275-
DEFAULT ( "chat_lines", 7 ); // chatbox lines
276-
DEFAULT ( "chat_color", CColor (0,0,128,100) ); // chatbox color
274+
DEFAULT ( "chat_font", 2 ); // chatbox font type
275+
DEFAULT ( "chat_lines", 10 ); // chatbox lines
276+
DEFAULT ( "chat_color", CColor (0,0,0,0) ); // chatbox background color
277277
DEFAULT ( "chat_text_color", CColor (172,213,254,255) ); // chatbox text color
278-
DEFAULT ( "chat_input_color", CColor (0,0,191,110) ); // chatbox input color
279-
DEFAULT ( "chat_input_prefix_color", CColor (172,213,254,255) ); // chatbox prefix input color
280-
DEFAULT ( "chat_input_text_color", CColor (172,213,254,255) ); // chatbox text input color
278+
DEFAULT ( "chat_input_color", CColor (0,0,0,0) ); // chatbox input background color
279+
DEFAULT ( "chat_input_prefix_color", CColor (172,213,254,255) ); // chatbox input prefix color
280+
DEFAULT ( "chat_input_text_color", CColor (172,213,254,255) ); // chatbox input text color
281281
DEFAULT ( "chat_scale", CVector2D ( 1.0f, 1.0f ) ); // chatbox scale
282-
DEFAULT ( "chat_width", 1.0f ); // chatbox width
282+
DEFAULT ( "chat_width", 1.5f ); // chatbox width
283+
283284
DEFAULT ( "chat_css_style_text", false ); // chatbox css/hl style text
284285
DEFAULT ( "chat_css_style_background", false ); // chatbox css/hl style background
285286
DEFAULT ( "chat_line_life", 12000 ); // chatbox line life time

Client/core/CJoystickManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ void CJoystickManager::ReadCurrentState ( void )
855855
int x = 20;
856856
int y = 20;//pGraphics->GetViewportHeight() / 2;
857857
pGraphics->DrawRectQueued( x, y, 350, 150, 0xaf000000, true );
858-
pGraphics->DrawTextQueued( x+10, y+10, 0, 0, 0xFFFFFFFF, strStatus, 1, 1, DT_NOCLIP, NULL, true );
858+
pGraphics->DrawStringQueued( x+10, y+10, 0, 0, 0xFFFFFFFF, strStatus, 1, 1, DT_NOCLIP, NULL, true );
859859
}
860860
}
861861
}
@@ -1148,7 +1148,7 @@ void CJoystickManager::ApplyAxes ( CControllerState& cs, bool bInVehicle )
11481148
cs.ShockButtonR,
11491149
cs.m_bPedWalk );
11501150

1151-
CCore::GetSingleton ().GetGraphics ()->DrawText ( 20, 150, 0xFFFFFFFF, 1, strBuffer );
1151+
CCore::GetSingleton ().GetGraphics ()->DrawString ( 20, 150, 0xFFFFFFFF, 1, strBuffer );
11521152

11531153
strBuffer = SString::Printf ( "VehicleMouseLook: %u\n"
11541154
"LeftStickX: %u\n"
@@ -1161,7 +1161,7 @@ void CJoystickManager::ApplyAxes ( CControllerState& cs, bool bInVehicle )
11611161
cs.RightStickX,
11621162
cs.RightStickY );
11631163

1164-
CCore::GetSingleton ().GetGraphics ()->DrawText ( 20, 450, 0xFFFFFFFF, 1, strBuffer );
1164+
CCore::GetSingleton ().GetGraphics ()->DrawString ( 20, 450, 0xFFFFFFFF, 1, strBuffer );
11651165

11661166

11671167
strBuffer = SString::Printf (
@@ -1181,7 +1181,7 @@ void CJoystickManager::ApplyAxes ( CControllerState& cs, bool bInVehicle )
11811181
m_JoystickState.rgfAxis[6]
11821182
);
11831183

1184-
CCore::GetSingleton ().GetGraphics ()->DrawText ( 20, 550, 0xFFFFFFFF, 1, strBuffer );
1184+
CCore::GetSingleton ().GetGraphics ()->DrawString ( 20, 550, 0xFFFFFFFF, 1, strBuffer );
11851185

11861186
#endif
11871187
#endif

Client/core/CMemStats.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ namespace
236236
for ( uint i = 0 ; i < m_ColumnList.size () ; i++ )
237237
{
238238
const SColumn& column = m_ColumnList[i];
239-
g_pGraphics->DrawTextQueued ( fX, fY, fX + column.uiWidth, fY, 0xFFFFFFFF, column.strText, 1, 1, DT_NOCLIP | column.uiAlignment, NULL, true, true );
239+
g_pGraphics->DrawStringQueued ( fX, fY, fX + column.uiWidth, fY, 0xFFFFFFFF, column.strText, 1, 1, DT_NOCLIP | column.uiAlignment, NULL, true, true );
240240
fX += column.uiWidth;
241241
}
242242
}

Client/core/CSettings.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ void CSettings::CreateGUI ( void )
10141014

10151015
m_pChatLines = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( pLayoutTab, "" ) );
10161016
m_pChatLines->SetPosition ( CVector2D ( vecTemp.fX + fIndentX, vecTemp.fY - 2.0f ) );
1017-
m_pChatLines->SetSize ( CVector2D ( 80.0f, 24.0f ) );
1017+
m_pChatLines->SetSize ( CVector2D ( 110.0f, 24.0f ) );
10181018
m_pChatLines->SetAlwaysOnTop ( true );
10191019

10201020
pLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pLayoutTab, _("Scale:") ) );
@@ -1025,17 +1025,17 @@ void CSettings::CreateGUI ( void )
10251025

10261026
m_pChatScaleX = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( pLayoutTab, "") );
10271027
m_pChatScaleX->SetPosition ( CVector2D ( vecTemp.fX + fIndentX, vecTemp.fY - 2.0f ) );
1028-
m_pChatScaleX->SetSize ( CVector2D ( 35.0f, 24.0f ) );
1028+
m_pChatScaleX->SetSize ( CVector2D ( 50.0f, 24.0f ) );
10291029
m_pChatScaleX->SetAlwaysOnTop ( true );
10301030

10311031
pLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pLayoutTab, "x") );
1032-
pLabel->SetPosition ( CVector2D ( vecTemp.fX + fIndentX + 37.0f, vecTemp.fY + 2.0f ) );
1032+
pLabel->SetPosition ( CVector2D ( vecTemp.fX + fIndentX + 52.0f, vecTemp.fY + 2.0f ) );
10331033
pLabel->AutoSize ( );
10341034
pLabel->SetAlwaysOnTop ( true );
10351035

10361036
m_pChatScaleY = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( pLayoutTab, "") );
1037-
m_pChatScaleY->SetPosition ( CVector2D ( vecTemp.fX + fIndentX + 45.0f, vecTemp.fY - 2.0f ) );
1038-
m_pChatScaleY->SetSize ( CVector2D ( 35.0f, 24.0f ) );
1037+
m_pChatScaleY->SetPosition ( CVector2D ( vecTemp.fX + fIndentX + 60.0f, vecTemp.fY - 2.0f ) );
1038+
m_pChatScaleY->SetSize ( CVector2D ( 50.0f, 24.0f ) );
10391039
m_pChatScaleY->SetAlwaysOnTop ( true );
10401040

10411041
pLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pLayoutTab, _("Width:") ) );
@@ -1046,7 +1046,7 @@ void CSettings::CreateGUI ( void )
10461046

10471047
m_pChatWidth = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( pLayoutTab, "") );
10481048
m_pChatWidth->SetPosition ( CVector2D ( vecTemp.fX + fIndentX, vecTemp.fY - 2.0f ) );
1049-
m_pChatWidth->SetSize ( CVector2D ( 80.0f, 24.0f ) );
1049+
m_pChatWidth->SetSize ( CVector2D ( 110.0f, 24.0f ) );
10501050
m_pChatWidth->SetAlwaysOnTop ( true );
10511051

10521052
// Fading tab
@@ -2029,7 +2029,7 @@ bool CSettings::OnVideoDefaultClick ( CGUIElement* pElement )
20292029

20302030
CVARS_SET ( "streaming_memory", g_pCore->GetMaxStreamingMemory () );
20312031

2032-
CVARS_SET ( "mapalpha", 140.25f);
2032+
CVARS_SET ( "mapalpha", 155);
20332033

20342034
// Display restart required message if required
20352035
bool bIsAntiAliasingChanged = gameSettings->GetAntiAliasing () != m_pComboAntiAliasing->GetSelectedItemIndex ();
@@ -2874,9 +2874,9 @@ void CSettings::LoadData ( void )
28742874
CVARS_GET ( "chat_scale", strVar );
28752875
stringstream ss( strVar );
28762876
ss >> strVar;
2877-
m_pChatScaleX->SetText ( strVar.c_str () );
2877+
m_pChatScaleX->SetText ( SString( "%1.1f", atof( strVar.c_str() ) ) );
28782878
ss >> strVar;
2879-
m_pChatScaleY->SetText ( strVar.c_str () );
2879+
m_pChatScaleY->SetText ( SString( "%1.1f", atof( strVar.c_str() ) ) );
28802880
}
28812881
catch (...)
28822882
{

Client/core/Graphics/CGraphics.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ CGraphics::~CGraphics ( void )
7474
}
7575

7676

77-
void CGraphics::DrawText ( int uiLeft, int uiTop, int uiRight, int uiBottom, unsigned long ulColor, const char* szText, float fScaleX, float fScaleY, unsigned long ulFormat, LPD3DXFONT pDXFont )
77+
void CGraphics::DrawString ( int uiLeft, int uiTop, int uiRight, int uiBottom, unsigned long ulColor, const char* szText, float fScaleX, float fScaleY, unsigned long ulFormat, LPD3DXFONT pDXFont )
7878
{
7979
if ( g_pCore->IsWindowMinimized () )
8080
return;
@@ -120,15 +120,15 @@ void CGraphics::DrawText ( int uiLeft, int uiTop, int uiRight, int uiBottom, uns
120120
}
121121

122122

123-
void CGraphics::DrawText ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... )
123+
void CGraphics::DrawString ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... )
124124
{
125125
char szBuffer [ 1024 ];
126126
va_list ap;
127127
va_start ( ap, szText );
128128
VSNPRINTF ( szBuffer, 1024, szText, ap );
129129
va_end ( ap );
130130

131-
DrawText ( iX, iY, iX, iY, dwColor, szBuffer, fScale, fScale, DT_NOCLIP );
131+
DrawString ( iX, iY, iX, iY, dwColor, szBuffer, fScale, fScale, DT_NOCLIP );
132132
}
133133

134134

@@ -839,7 +839,7 @@ void CGraphics::DrawTextureQueued ( float fX, float fY,
839839
}
840840

841841

842-
void CGraphics::DrawTextQueued ( float fLeft, float fTop,
842+
void CGraphics::DrawStringQueued ( float fLeft, float fTop,
843843
float fRight, float fBottom,
844844
unsigned long dwColor,
845845
const char* szText,
@@ -1918,7 +1918,7 @@ void CGraphics::DrawProgressMessage( bool bPreserveBackbuffer )
19181918
const uint uiMessageWidth = GetDXTextExtent( m_strProgressMessage );
19191919
const uint uiMessagePosX = uiViewportWidth / 2 - uiMessageWidth / 2;
19201920
const DWORD dwMessageColor = 0xA0FFFFFF;
1921-
DrawText( uiMessagePosX, uiViewportHeight - 57, dwMessageColor, 1, "%s", *m_strProgressMessage );
1921+
DrawString( uiMessagePosX, uiViewportHeight - 57, dwMessageColor, 1, "%s", *m_strProgressMessage );
19221922
}
19231923

19241924
if ( m_ProgressSpinnerTexture )

Client/core/Graphics/CGraphics.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class CGraphics : public CGraphicsInterface, public CSingleton < CGraphics >
7878
void CalcScreenCoors ( CVector * vecWorld, CVector * vecScreen );
7979

8080
// DirectX drawing functions
81-
void DrawText ( int iLeft, int iTop, int iRight, int iBottom, unsigned long dwColor, const char* wszText, float fScaleX, float fScaleY, unsigned long ulFormat, ID3DXFont * pDXFont = NULL );
82-
void DrawText ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... );
81+
void DrawString ( int iLeft, int iTop, int iRight, int iBottom, unsigned long dwColor, const char* wszText, float fScaleX, float fScaleY, unsigned long ulFormat, ID3DXFont * pDXFont = NULL );
82+
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 );
8585

@@ -165,7 +165,7 @@ class CGraphics : public CGraphicsInterface, public CSingleton < CGraphics >
165165
unsigned long ulColor,
166166
bool bPostGUI );
167167

168-
void DrawTextQueued ( float iLeft, float iTop,
168+
void DrawStringQueued ( float iLeft, float iTop,
169169
float iRight, float iBottom,
170170
unsigned long dwColor,
171171
const char* wszText,

Client/mods/deathmatch/logic/CClientDisplayManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void CClientDisplayManager::DrawText2D ( const char* szCaption, const CVector& v
4949
float fResHeight = static_cast < float > ( g_pCore->GetGraphics ()->GetViewportHeight () );
5050

5151
// Render
52-
g_pCore->GetGraphics ()->DrawText ( static_cast < int > ( vecPosition.fX * fResWidth ),
52+
g_pCore->GetGraphics ()->DrawString ( static_cast < int > ( vecPosition.fX * fResWidth ),
5353
static_cast < int > ( vecPosition.fY * fResHeight ),
5454
static_cast < int > ( fResWidth ),
5555
static_cast < int > ( fResHeight ),

0 commit comments

Comments
 (0)