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.

190 lines
5.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_HUD_FLAGSTATUS_H
  8. #define TF_HUD_FLAGSTATUS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "entity_capture_flag.h"
  13. #include "tf_controls.h"
  14. #include "tf_imagepanel.h"
  15. #include "GameEventListener.h"
  16. #include "hudelement.h"
  17. class CCaptureFlag;
  18. class CTFFlagCalloutPanel;
  19. //-----------------------------------------------------------------------------
  20. // Purpose: Draws the rotated arrow panels
  21. //-----------------------------------------------------------------------------
  22. class CTFArrowPanel : public vgui::Panel
  23. {
  24. public:
  25. DECLARE_CLASS_SIMPLE( CTFArrowPanel, vgui::Panel );
  26. CTFArrowPanel( vgui::Panel *parent, const char *name );
  27. virtual void Paint();
  28. virtual bool IsVisible( void );
  29. void SetEntity( EHANDLE hEntity ){ m_hEntity = hEntity; }
  30. float GetAngleRotation( void );
  31. void OnTick( void );
  32. private:
  33. EHANDLE m_hEntity;
  34. CMaterialReference m_RedMaterial;
  35. CMaterialReference m_BlueMaterial;
  36. CMaterialReference m_NeutralMaterial;
  37. CMaterialReference m_NeutralRedMaterial;
  38. CMaterialReference m_RedMaterialNoArrow;
  39. CMaterialReference m_BlueMaterialNoArrow;
  40. bool m_bUseRed;
  41. float m_flNextColorSwitch;
  42. IMaterial *m_pMaterial;
  43. };
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. class CTFFlagStatus : public vgui::EditablePanel
  48. {
  49. public:
  50. DECLARE_CLASS_SIMPLE( CTFFlagStatus, vgui::EditablePanel );
  51. CTFFlagStatus( vgui::Panel *parent, const char *name );
  52. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  53. virtual bool IsVisible( void );
  54. void UpdateStatus( void );
  55. void SetEntity( EHANDLE hEntity )
  56. {
  57. m_hEntity = hEntity;
  58. if ( m_pArrow )
  59. {
  60. m_pArrow->SetEntity( hEntity );
  61. }
  62. UpdateStatus();
  63. }
  64. CBaseEntity *GetEntity( void ){ return m_hEntity.Get(); }
  65. private:
  66. EHANDLE m_hEntity;
  67. CTFArrowPanel *m_pArrow;
  68. CTFImagePanel *m_pStatusIcon;
  69. CTFImagePanel *m_pBriefcase;
  70. };
  71. //-----------------------------------------------------------------------------
  72. // Purpose:
  73. //-----------------------------------------------------------------------------
  74. class CTFHudFlagObjectives : public vgui::EditablePanel, public CGameEventListener
  75. {
  76. DECLARE_CLASS_SIMPLE( CTFHudFlagObjectives, vgui::EditablePanel );
  77. public:
  78. CTFHudFlagObjectives( vgui::Panel *parent, const char *name );
  79. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  80. virtual bool IsVisible( void );
  81. virtual void Reset();
  82. void OnTick();
  83. public: // IGameEventListener:
  84. virtual void FireGameEvent( IGameEvent *event );
  85. private:
  86. void UpdateStatus( C_BasePlayer *pNewOwner = NULL, C_BaseEntity *pFlagEntity = NULL );
  87. void SetPlayingToLabelVisible( bool bVisible );
  88. void SetCarriedImage( const char *pchIcon );
  89. private:
  90. vgui::ImagePanel *m_pCarriedImage;
  91. CExLabel *m_pPlayingTo;
  92. vgui::Panel *m_pPlayingToBG;
  93. CTFFlagStatus *m_pRedFlag;
  94. CTFFlagStatus *m_pBlueFlag;
  95. CTFArrowPanel *m_pCapturePoint;
  96. bool m_bFlagAnimationPlayed;
  97. bool m_bCarryingFlag;
  98. vgui::ImagePanel *m_pSpecCarriedImage;
  99. vgui::ImagePanel *m_pPoisonImage;
  100. CExLabel *m_pPoisonTimeLabel;
  101. bool m_bPlayingHybrid_CTF_CP;
  102. bool m_bPlayingSpecialDeliveryMode;
  103. int m_nNumValidFlags;
  104. };
  105. //-----------------------------------------------------------------------------
  106. // Purpose:
  107. //-----------------------------------------------------------------------------
  108. class CTFFlagCalloutPanel : public CHudElement, public vgui::EditablePanel
  109. {
  110. DECLARE_CLASS_SIMPLE( CTFFlagCalloutPanel, vgui::EditablePanel );
  111. public:
  112. CTFFlagCalloutPanel( const char *pElementName );
  113. ~CTFFlagCalloutPanel( void );
  114. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  115. virtual void PerformLayout( void );
  116. virtual void OnTick( void );
  117. virtual void PaintBackground( void );
  118. virtual void Paint( void );
  119. void GetCalloutPosition( const Vector &vecDelta, float flRadius, float *xpos, float *ypos, float *flRotation );
  120. void SetFlag( CCaptureFlag *pFlag, float flDuration, Vector &vecOffset );
  121. static CTFFlagCalloutPanel *AddFlagCalloutIfNotFound( CCaptureFlag *pFlag, float flDuration, Vector &vecLocation );
  122. bool ShouldShowFlagIconToLocalPlayer( void );
  123. void ScaleAndPositionCallout( float flScale = 1.f );
  124. CHandle< CCaptureFlag > m_hFlag;
  125. private:
  126. IMaterial *m_pArrowMaterial;
  127. CTFImagePanel *m_pFlagCalloutPanel;
  128. vgui::Label *m_pFlagValueLabel;
  129. CTFImagePanel *m_pFlagStatusIcon;
  130. float m_flRemoveTime;
  131. float m_flFirstDisplayTime;
  132. Vector m_vecOffset;
  133. int m_iDrawArrow;
  134. bool m_bFlagVisible; // LOS
  135. float m_flPrevScale;
  136. int m_nPanelWideOrig;
  137. int m_nPanelTallOrig;
  138. int m_nLabelWideOrig;
  139. int m_nLabelTallOrig;
  140. int m_nIconWideOrig;
  141. int m_nIconTallOrig;
  142. static CUtlVector< CTFFlagCalloutPanel* > m_FlagCalloutPanels;
  143. };
  144. #endif // TF_HUD_FLAGSTATUS_H