summaryrefslogtreecommitdiff
path: root/game/client/dod/dod_hud_spec_crosshair.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/dod/dod_hud_spec_crosshair.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/dod/dod_hud_spec_crosshair.cpp')
-rw-r--r--game/client/dod/dod_hud_spec_crosshair.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/game/client/dod/dod_hud_spec_crosshair.cpp b/game/client/dod/dod_hud_spec_crosshair.cpp
new file mode 100644
index 0000000..d3b4d6e
--- /dev/null
+++ b/game/client/dod/dod_hud_spec_crosshair.cpp
@@ -0,0 +1,87 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "cbase.h"
+#include "hud.h"
+#include "dod_hud_spec_crosshair.h"
+#include "iclientmode.h"
+#include "view.h"
+#include "vgui_controls/Controls.h"
+#include "vgui/ISurface.h"
+#include "ivrenderview.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+//ConVar crosshair( "crosshair", "1", FCVAR_ARCHIVE );
+//ConVar cl_observercrosshair( "cl_observercrosshair", "1", FCVAR_ARCHIVE );
+
+using namespace vgui;
+
+int ScreenTransform( const Vector& point, Vector& screen );
+
+DECLARE_HUDELEMENT( CHudSpecCrosshair );
+
+CHudSpecCrosshair::CHudSpecCrosshair( const char *pElementName ) :
+ CHudElement( pElementName ), BaseClass( NULL, "HudSpecCrosshair" )
+{
+ vgui::Panel *pParent = g_pClientMode->GetViewport();
+ SetParent( pParent );
+
+ m_pCrosshair = 0;
+
+ m_clrCrosshair = Color( 255, 255, 255, 255 );
+
+ SetHiddenBits( HIDEHUD_CROSSHAIR );
+}
+
+void CHudSpecCrosshair::ApplySchemeSettings( IScheme *scheme )
+{
+ BaseClass::ApplySchemeSettings( scheme );
+
+ m_pCrosshair = gHUD.GetIcon("crosshair_default");
+
+ SetPaintBackgroundEnabled( false );
+}
+
+void CHudSpecCrosshair::Paint( void )
+{
+ if ( !g_pClientMode->ShouldDrawCrosshair() )
+ return;
+
+ if ( !m_pCrosshair )
+ return;
+
+ if ( engine->IsDrawingLoadingImage() || engine->IsPaused() )
+ return;
+
+ C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
+
+ if ( !pPlayer )
+ return;
+
+ // draw a crosshair only if alive or spectating in eye
+ bool shouldDraw = false;
+
+ if ( pPlayer->GetObserverMode() == OBS_MODE_ROAMING /*&& cl_observercrosshair.GetBool()*/ )
+ shouldDraw = true;
+
+ if ( !shouldDraw )
+ return;
+
+ if ( pPlayer->entindex() != render->GetViewEntity() )
+ return;
+
+ float x, y;
+ x = ScreenWidth()/2;
+ y = ScreenHeight()/2;
+
+ m_pCrosshair->DrawSelf(
+ x - 0.5f * m_pCrosshair->Width(),
+ y - 0.5f * m_pCrosshair->Height(),
+ m_clrCrosshair );
+} \ No newline at end of file