summaryrefslogtreecommitdiff
path: root/game/client/tf2/hud_vehicle_role.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf2/hud_vehicle_role.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/tf2/hud_vehicle_role.cpp')
-rw-r--r--game/client/tf2/hud_vehicle_role.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/game/client/tf2/hud_vehicle_role.cpp b/game/client/tf2/hud_vehicle_role.cpp
new file mode 100644
index 0000000..2ba956d
--- /dev/null
+++ b/game/client/tf2/hud_vehicle_role.cpp
@@ -0,0 +1,80 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#include "cbase.h"
+#include "hud_vehicle_role.h"
+#include "iclientmode.h"
+#include <vgui_controls/Controls.h>
+#include <vgui/ISurface.h>
+#include <KeyValues.h>
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+
+DECLARE_HUDELEMENT( CVehicleRoleHudElement );
+
+using namespace vgui;
+
+CVehicleRoleHudElement::CVehicleRoleHudElement( const char *pElementName ) :
+ CHudElement( pElementName ), BaseClass( NULL, "VehicleRoleHudElement" )
+{
+ vgui::Panel *pParent = g_pClientMode->GetViewport();
+ SetParent( pParent );
+
+ m_iRole = -1;
+
+ SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD );
+}
+
+void CVehicleRoleHudElement::ApplySchemeSettings( IScheme *scheme )
+{
+ BaseClass::ApplySchemeSettings( scheme );
+
+ m_hTextFont = scheme->GetFont( "Trebuchet24" );
+
+ SetPaintBackgroundEnabled( false );
+}
+
+
+void CVehicleRoleHudElement::ShowVehicleRole( int iRole )
+{
+ m_iRole = iRole;
+}
+
+
+void CVehicleRoleHudElement::Paint()
+{
+ if ( m_iRole == -1 )
+ return;
+
+ surface()->DrawSetTextFont( m_hTextFont );
+ surface()->DrawSetTextColor( GetFgColor() );
+
+ char str[512];
+ if ( m_iRole == VEHICLE_ROLE_DRIVER )
+ {
+ Q_strncpy( str, "Driver", sizeof( str ) );
+ }
+ else
+ {
+ Q_snprintf( str, sizeof( str ), "Passenger %d", m_iRole );
+ }
+
+ int pixels = UTIL_ComputeStringWidth( m_hTextFont, str );
+ int x = ( GetWide() - pixels ) / 2;
+
+ surface()->DrawSetTextPos( x, 0 );
+
+ char *p = str;
+ while ( *p )
+ {
+ surface()->DrawUnicodeChar( *p );
+ p++;
+ }
+}
+
+