Skip to content

Commit

Permalink
Removed redundant chat setting hacks. Expanded chat scale edit box. R…
Browse files Browse the repository at this point in the history
…enamed DrawText to DrawString to avoid clash with Windows macro.
  • Loading branch information
ccw808 committed Jun 19, 2017
1 parent ee0858e commit 236cf93
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 99 deletions.
50 changes: 3 additions & 47 deletions Client/core/CChat.cpp
Expand Up @@ -125,50 +125,6 @@ void CChat::LoadCVars ( void )
CVARS_GET ( "chat_line_fade_out", (unsigned int &)m_ulChatLineFadeOut );
CVARS_GET ( "chat_font", (unsigned int &)Font ); SetChatFont ( (eChatFont)Font );
CVARS_GET ( "chat_nickcompletion", m_bNickCompletion );

// Modify default chat box to be like 'Transparent' preset
SString strFlags;
CVARS_GET ( "fixup_flags", strFlags );
if ( strFlags.find ( "-cb" ) == std::string::npos )
{
CVARS_SET ( "fixup_flags", strFlags + "-cb" );

if ( Font == 0 // chat_font
&& m_uiNumLines == 7 // chat_lines
&& m_Color == CColor (0,0,128,100) // chat_color
&& m_InputColor == CColor (0,0,191,110) // chat_input_color
&& m_InputTextColor == CColor (172,213,254,255) // chat_input_text_color
&& m_vecScale == CVector2D ( 1.0f, 1.0f ) // chat_scale
&& fWidth == 1.0f // chat_width
&& m_bCssStyleText == false // chat_css_style_text
&& m_bCssStyleBackground == false // chat_css_style_background
&& m_ulChatLineLife == 12000 // chat_line_life
&& m_ulChatLineFadeOut == 3000 // chat_line_fade_out
)
{
CVARS_SET ( "chat_font", (unsigned int)2 );
CVARS_SET ( "chat_color", CColor (0,0,0,0) );
CVARS_SET ( "chat_input_color", CColor (0,0,0,0) );
CVARS_SET ( "chat_lines", 10 );
CVARS_SET ( "chat_width", 1.5f );
LoadCVars ();
}
}

// Fix mapalpha being set incorrectly in 1.0.4-9.1752.1
CVARS_GET ( "fixup_flags", strFlags );
if ( strFlags.find ( "-ma" ) == std::string::npos )
{
CVARS_SET ( "fixup_flags", strFlags + "-ma" );

int iVar = -1;
CVARS_GET ( "mapalpha", iVar );
if ( iVar < 3 )
{
iVar = 155;
CVARS_SET ( "mapalpha", iVar );
}
}
}


Expand Down Expand Up @@ -968,19 +924,19 @@ void CChat::DrawTextString ( const char * szText, CRect2D DrawArea, float fZ, CR
{
// Clip text at the top
if ( DrawArea.fY1 + fLineHeight - RenderBounds.fY1 > 1 )
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 );
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 );
}
else
if ( DrawArea.fY1 + fLineHeight > RenderBounds.fY2 )
{
// Clip text at the bottom
if ( RenderBounds.fY2 - DrawArea.fY1 > 1 )
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 );
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 );
}
else
{
// Text not clipped
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 );
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 );
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions Client/core/CClientVariables.cpp
Expand Up @@ -271,15 +271,16 @@ void CClientVariables::LoadDefaults ( void )
DEFAULT ( "console_size", CVector2D ( 200, 200 ) ); // console size
DEFAULT ( "serverbrowser_size", CVector2D ( 720.0f, 495.0f ) ); // serverbrowser size
DEFAULT ( "fps_limit", 100 ); // frame limiter
DEFAULT ( "chat_font", 0 ); // chatbox font type
DEFAULT ( "chat_lines", 7 ); // chatbox lines
DEFAULT ( "chat_color", CColor (0,0,128,100) ); // chatbox color
DEFAULT ( "chat_font", 2 ); // chatbox font type
DEFAULT ( "chat_lines", 10 ); // chatbox lines
DEFAULT ( "chat_color", CColor (0,0,0,0) ); // chatbox background color
DEFAULT ( "chat_text_color", CColor (172,213,254,255) ); // chatbox text color
DEFAULT ( "chat_input_color", CColor (0,0,191,110) ); // chatbox input color
DEFAULT ( "chat_input_prefix_color", CColor (172,213,254,255) ); // chatbox prefix input color
DEFAULT ( "chat_input_text_color", CColor (172,213,254,255) ); // chatbox text input color
DEFAULT ( "chat_input_color", CColor (0,0,0,0) ); // chatbox input background color
DEFAULT ( "chat_input_prefix_color", CColor (172,213,254,255) ); // chatbox input prefix color
DEFAULT ( "chat_input_text_color", CColor (172,213,254,255) ); // chatbox input text color
DEFAULT ( "chat_scale", CVector2D ( 1.0f, 1.0f ) ); // chatbox scale
DEFAULT ( "chat_width", 1.0f ); // chatbox width
DEFAULT ( "chat_width", 1.5f ); // chatbox width

DEFAULT ( "chat_css_style_text", false ); // chatbox css/hl style text
DEFAULT ( "chat_css_style_background", false ); // chatbox css/hl style background
DEFAULT ( "chat_line_life", 12000 ); // chatbox line life time
Expand Down
8 changes: 4 additions & 4 deletions Client/core/CJoystickManager.cpp
Expand Up @@ -855,7 +855,7 @@ void CJoystickManager::ReadCurrentState ( void )
int x = 20;
int y = 20;//pGraphics->GetViewportHeight() / 2;
pGraphics->DrawRectQueued( x, y, 350, 150, 0xaf000000, true );
pGraphics->DrawTextQueued( x+10, y+10, 0, 0, 0xFFFFFFFF, strStatus, 1, 1, DT_NOCLIP, NULL, true );
pGraphics->DrawStringQueued( x+10, y+10, 0, 0, 0xFFFFFFFF, strStatus, 1, 1, DT_NOCLIP, NULL, true );
}
}
}
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void CJoystickManager::ApplyAxes ( CControllerState& cs, bool bInVehicle )
cs.ShockButtonR,
cs.m_bPedWalk );

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

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

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


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

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

#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion Client/core/CMemStats.cpp
Expand Up @@ -236,7 +236,7 @@ namespace
for ( uint i = 0 ; i < m_ColumnList.size () ; i++ )
{
const SColumn& column = m_ColumnList[i];
g_pGraphics->DrawTextQueued ( fX, fY, fX + column.uiWidth, fY, 0xFFFFFFFF, column.strText, 1, 1, DT_NOCLIP | column.uiAlignment, NULL, true, true );
g_pGraphics->DrawStringQueued ( fX, fY, fX + column.uiWidth, fY, 0xFFFFFFFF, column.strText, 1, 1, DT_NOCLIP | column.uiAlignment, NULL, true, true );
fX += column.uiWidth;
}
}
Expand Down
18 changes: 9 additions & 9 deletions Client/core/CSettings.cpp
Expand Up @@ -1014,7 +1014,7 @@ void CSettings::CreateGUI ( void )

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

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

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

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

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

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

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

// Fading tab
Expand Down Expand Up @@ -2029,7 +2029,7 @@ bool CSettings::OnVideoDefaultClick ( CGUIElement* pElement )

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

CVARS_SET ( "mapalpha", 140.25f);
CVARS_SET ( "mapalpha", 155);

// Display restart required message if required
bool bIsAntiAliasingChanged = gameSettings->GetAntiAliasing () != m_pComboAntiAliasing->GetSelectedItemIndex ();
Expand Down Expand Up @@ -2874,9 +2874,9 @@ void CSettings::LoadData ( void )
CVARS_GET ( "chat_scale", strVar );
stringstream ss( strVar );
ss >> strVar;
m_pChatScaleX->SetText ( strVar.c_str () );
m_pChatScaleX->SetText ( SString( "%1.1f", atof( strVar.c_str() ) ) );
ss >> strVar;
m_pChatScaleY->SetText ( strVar.c_str () );
m_pChatScaleY->SetText ( SString( "%1.1f", atof( strVar.c_str() ) ) );
}
catch (...)
{
Expand Down
10 changes: 5 additions & 5 deletions Client/core/Graphics/CGraphics.cpp
Expand Up @@ -74,7 +74,7 @@ CGraphics::~CGraphics ( void )
}


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 )
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 )
{
if ( g_pCore->IsWindowMinimized () )
return;
Expand Down Expand Up @@ -120,15 +120,15 @@ void CGraphics::DrawText ( int uiLeft, int uiTop, int uiRight, int uiBottom, uns
}


void CGraphics::DrawText ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... )
void CGraphics::DrawString ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... )
{
char szBuffer [ 1024 ];
va_list ap;
va_start ( ap, szText );
VSNPRINTF ( szBuffer, 1024, szText, ap );
va_end ( ap );

DrawText ( iX, iY, iX, iY, dwColor, szBuffer, fScale, fScale, DT_NOCLIP );
DrawString ( iX, iY, iX, iY, dwColor, szBuffer, fScale, fScale, DT_NOCLIP );
}


Expand Down Expand Up @@ -839,7 +839,7 @@ void CGraphics::DrawTextureQueued ( float fX, float fY,
}


void CGraphics::DrawTextQueued ( float fLeft, float fTop,
void CGraphics::DrawStringQueued ( float fLeft, float fTop,
float fRight, float fBottom,
unsigned long dwColor,
const char* szText,
Expand Down Expand Up @@ -1918,7 +1918,7 @@ void CGraphics::DrawProgressMessage( bool bPreserveBackbuffer )
const uint uiMessageWidth = GetDXTextExtent( m_strProgressMessage );
const uint uiMessagePosX = uiViewportWidth / 2 - uiMessageWidth / 2;
const DWORD dwMessageColor = 0xA0FFFFFF;
DrawText( uiMessagePosX, uiViewportHeight - 57, dwMessageColor, 1, "%s", *m_strProgressMessage );
DrawString( uiMessagePosX, uiViewportHeight - 57, dwMessageColor, 1, "%s", *m_strProgressMessage );
}

if ( m_ProgressSpinnerTexture )
Expand Down
6 changes: 3 additions & 3 deletions Client/core/Graphics/CGraphics.h
Expand Up @@ -78,8 +78,8 @@ class CGraphics : public CGraphicsInterface, public CSingleton < CGraphics >
void CalcScreenCoors ( CVector * vecWorld, CVector * vecScreen );

// DirectX drawing functions
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 );
void DrawText ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... );
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 );
void DrawString ( int iX, int iY, unsigned long dwColor, float fScale, const char * szText, ... );
void DrawLine3D ( const CVector& vecBegin, const CVector& vecEnd, unsigned long ulColor, float fWidth = 1.0f );
void DrawRectangle ( float fX, float fY, float fWidth, float fHeight, unsigned long ulColor, bool bSubPixelPositioning = false );

Expand Down Expand Up @@ -165,7 +165,7 @@ class CGraphics : public CGraphicsInterface, public CSingleton < CGraphics >
unsigned long ulColor,
bool bPostGUI );

void DrawTextQueued ( float iLeft, float iTop,
void DrawStringQueued ( float iLeft, float iTop,
float iRight, float iBottom,
unsigned long dwColor,
const char* wszText,
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CClientDisplayManager.cpp
Expand Up @@ -49,7 +49,7 @@ void CClientDisplayManager::DrawText2D ( const char* szCaption, const CVector& v
float fResHeight = static_cast < float > ( g_pCore->GetGraphics ()->GetViewportHeight () );

// Render
g_pCore->GetGraphics ()->DrawText ( static_cast < int > ( vecPosition.fX * fResWidth ),
g_pCore->GetGraphics ()->DrawString ( static_cast < int > ( vecPosition.fX * fResWidth ),
static_cast < int > ( vecPosition.fY * fResHeight ),
static_cast < int > ( fResWidth ),
static_cast < int > ( fResHeight ),
Expand Down

0 comments on commit 236cf93

Please sign in to comment.