Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef HUD_CROSSHAIR_H
  8. #define HUD_CROSSHAIR_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "hudelement.h"
  13. #include <vgui_controls/Panel.h>
  14. namespace vgui
  15. {
  16. class IScheme;
  17. };
  18. //-----------------------------------------------------------------------------
  19. // Purpose:
  20. //-----------------------------------------------------------------------------
  21. class CHudCrosshair : public CHudElement, public vgui::Panel
  22. {
  23. DECLARE_CLASS_SIMPLE( CHudCrosshair, vgui::Panel );
  24. public:
  25. CHudCrosshair( const char *pElementName );
  26. virtual ~CHudCrosshair();
  27. virtual void SetCrosshairAngle( const QAngle& angle );
  28. virtual void SetCrosshair( CHudTexture *texture, const Color& clr );
  29. virtual void ResetCrosshair();
  30. virtual void DrawCrosshair( void ) {}
  31. virtual bool HasCrosshair( void ) { return ( m_pCrosshair != NULL ); }
  32. virtual bool ShouldDraw();
  33. // any UI element that wants to be at the aim point can use this to figure out where to draw
  34. static void GetDrawPosition ( float *pX, float *pY, bool *pbBehindCamera, QAngle angleCrosshairOffset = vec3_angle );
  35. protected:
  36. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  37. virtual void Paint();
  38. // Crosshair sprite and colors
  39. CHudTexture *m_pCrosshair;
  40. CHudTexture *m_pDefaultCrosshair;
  41. Color m_clrCrosshair;
  42. QAngle m_vecCrossHairOffsetAngle;
  43. CPanelAnimationVar( bool, m_bHideCrosshair, "never_draw", "false" );
  44. };
  45. // Enable/disable crosshair rendering.
  46. extern ConVar crosshair;
  47. #endif // HUD_CROSSHAIR_H