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.

240 lines
6.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_HUD_PLAYERSTATUS_H
  8. #define TF_HUD_PLAYERSTATUS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/ImagePanel.h>
  13. #include "tf_controls.h"
  14. #include "tf_imagepanel.h"
  15. #include "GameEventListener.h"
  16. class C_TFPlayer;
  17. class CTFPlayerModelPanel;
  18. namespace vgui
  19. {
  20. class Label;
  21. }
  22. //-----------------------------------------------------------------------------
  23. // Purpose:
  24. //-----------------------------------------------------------------------------
  25. class CTFClassImage : public vgui::ImagePanel
  26. {
  27. public:
  28. DECLARE_CLASS_SIMPLE( CTFClassImage, vgui::ImagePanel );
  29. CTFClassImage( vgui::Panel *parent, const char *name ) : ImagePanel( parent, name )
  30. {
  31. }
  32. void SetClass( int iTeam, int iClass, int iCloakstate );
  33. };
  34. //-----------------------------------------------------------------------------
  35. // Purpose: Displays player class data
  36. //-----------------------------------------------------------------------------
  37. class CTFHudPlayerClass : public vgui::EditablePanel, public CGameEventListener
  38. {
  39. DECLARE_CLASS_SIMPLE( CTFHudPlayerClass, EditablePanel );
  40. public:
  41. CTFHudPlayerClass( Panel *parent, const char *name );
  42. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  43. virtual void Reset();
  44. public: // IGameEventListener Interface
  45. virtual void FireGameEvent( IGameEvent * event );
  46. protected:
  47. virtual void OnThink();
  48. private:
  49. void UpdateModelPanel();
  50. float m_flNextThink;
  51. CTFClassImage *m_pClassImage;
  52. CTFImagePanel *m_pClassImageBG;
  53. CTFImagePanel *m_pSpyImage; // used when spies are disguised
  54. CTFImagePanel *m_pSpyOutlineImage;
  55. CTFPlayerModelPanel *m_pPlayerModelPanel;
  56. CTFImagePanel *m_pPlayerModelPanelBG;
  57. EditablePanel *m_pCarryingWeaponPanel;
  58. CExLabel *m_pCarryingLabel;
  59. vgui::Label *m_pCarryingOwnerLabel;
  60. CTFImagePanel *m_pCarryingBG;
  61. int m_nTeam;
  62. int m_nClass;
  63. int m_nDisguiseTeam;
  64. int m_nDisguiseClass;
  65. EHANDLE m_hDisguiseWeapon;
  66. int m_nCloakLevel;
  67. int m_nLoadoutPosition;
  68. int m_nKillStreak;
  69. #ifdef STAGING_ONLY
  70. int m_nLOD;
  71. #endif // STAGING_ONLY
  72. bool m_bUsePlayerModel;
  73. };
  74. //-----------------------------------------------------------------------------
  75. // Purpose: Clips the health image to the appropriate percentage
  76. //-----------------------------------------------------------------------------
  77. class CTFHealthPanel : public vgui::Panel
  78. {
  79. public:
  80. DECLARE_CLASS_SIMPLE( CTFHealthPanel, vgui::Panel );
  81. CTFHealthPanel( vgui::Panel *parent, const char *name );
  82. virtual void Paint();
  83. void SetHealth( float flHealth ){ m_flHealth = ( flHealth <= 1.0 ) ? flHealth : 1.0f; }
  84. private:
  85. float m_flHealth; // percentage from 0.0 -> 1.0
  86. int m_iMaterialIndex;
  87. int m_iDeadMaterialIndex;
  88. };
  89. enum BuffClass_t
  90. {
  91. BUFF_CLASS_BULLET_RESIST,
  92. BUFF_CLASS_BLAST_RESIST,
  93. BUFF_CLASS_FIRE_RESIST,
  94. BUFF_CLASS_SOLDIER_OFFENSE,
  95. BUFF_CLASS_SOLDIER_DEFENSE,
  96. BUFF_CLASS_SOLDIER_HEALTHONHIT,
  97. DEBUFF_CLASS_STUNNED,
  98. DEBUFF_CLASS_SPY_MARKED,
  99. BUFF_CLASS_PARACHUTE,
  100. RUNE_CLASS_STRENGTH,
  101. RUNE_CLASS_HASTE,
  102. RUNE_CLASS_REGEN,
  103. RUNE_CLASS_RESIST,
  104. RUNE_CLASS_VAMPIRE,
  105. RUNE_CLASS_REFLECT,
  106. RUNE_CLASS_PRECISION,
  107. RUNE_CLASS_AGILITY,
  108. RUNE_CLASS_KNOCKOUT,
  109. RUNE_CLASS_KING,
  110. RUNE_CLASS_PLAGUE,
  111. RUNE_CLASS_SUPERNOVA,
  112. };
  113. struct CTFBuffInfo
  114. {
  115. public:
  116. CTFBuffInfo( ETFCond eCond, BuffClass_t eClass, vgui::ImagePanel* pPanel, const char* pzsBlueImage = NULL, const char* pzsRedImage = NULL )
  117. {
  118. m_eCond = eCond;
  119. m_eClass = eClass;
  120. m_pImagePanel = pPanel;
  121. m_pzsRedImage = pzsRedImage;
  122. m_pzsBlueImage = pzsBlueImage;
  123. }
  124. void Update( C_TFPlayer *pPlayer );
  125. ETFCond m_eCond;
  126. BuffClass_t m_eClass;
  127. vgui::ImagePanel *m_pImagePanel;
  128. const char* m_pzsRedImage;
  129. const char* m_pzsBlueImage;
  130. };
  131. //-----------------------------------------------------------------------------
  132. // Purpose: Displays player health data
  133. //-----------------------------------------------------------------------------
  134. class CTFHudPlayerHealth : public vgui::EditablePanel
  135. {
  136. DECLARE_CLASS_SIMPLE( CTFHudPlayerHealth, EditablePanel );
  137. public:
  138. CTFHudPlayerHealth( Panel *parent, const char *name );
  139. ~CTFHudPlayerHealth();
  140. virtual const char *GetResFilename( void ) { return "resource/UI/HudPlayerHealth.res"; }
  141. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  142. virtual void Reset();
  143. void SetHealth( int iNewHealth, int iMaxHealth, int iMaxBuffedHealth );
  144. void SetLevel( int nLevel );
  145. void HideHealthBonusImage( void );
  146. void SetBuilding( bool bBuilding ) { m_bBuilding = bBuilding; }
  147. void SetAllowAnimations( bool bValue ) { m_bAnimate = bValue; }
  148. protected:
  149. virtual void OnThink();
  150. protected:
  151. float m_flNextThink;
  152. private:
  153. CTFHealthPanel *m_pHealthImage;
  154. vgui::ImagePanel *m_pHealthBonusImage;
  155. vgui::ImagePanel *m_pHealthImageBG;
  156. vgui::ImagePanel *m_pBuildingHealthImageBG;
  157. vgui::ImagePanel *m_pBleedImage;
  158. vgui::ImagePanel *m_pHookBleedImage;
  159. vgui::ImagePanel *m_pMilkImage;
  160. vgui::ImagePanel *m_pMarkedForDeathImage;
  161. vgui::ImagePanel *m_pMarkedForDeathImageSilent;
  162. vgui::ImagePanel *m_pWheelOfDoomImage;
  163. CExLabel *m_pPlayerLevelLabel;
  164. CUtlVector<CTFBuffInfo*> m_vecBuffInfo;
  165. int m_nHealth;
  166. int m_nMaxHealth;
  167. int m_nBonusHealthOrigX;
  168. int m_nBonusHealthOrigY;
  169. int m_nBonusHealthOrigW;
  170. int m_nBonusHealthOrigH;
  171. bool m_bBuilding;
  172. int m_iAnimState;
  173. bool m_bAnimate;
  174. CPanelAnimationVar( int, m_nHealthBonusPosAdj, "HealthBonusPosAdj", "25" );
  175. CPanelAnimationVar( float, m_flHealthDeathWarning, "HealthDeathWarning", "0.49" );
  176. CPanelAnimationVar( Color, m_clrHealthDeathWarningColor, "HealthDeathWarningColor", "HUDDeathWarning" );
  177. void UpdateHalloweenStatus( void );
  178. };
  179. //-----------------------------------------------------------------------------
  180. // Purpose: Parent panel for the player class/health displays
  181. //-----------------------------------------------------------------------------
  182. class CTFHudPlayerStatus : public CHudElement, public vgui::EditablePanel
  183. {
  184. DECLARE_CLASS_SIMPLE( CTFHudPlayerStatus, vgui::EditablePanel );
  185. public:
  186. CTFHudPlayerStatus( const char *pElementName );
  187. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  188. virtual void Reset();
  189. virtual bool ShouldDraw( void ) OVERRIDE;
  190. private:
  191. CTFHudPlayerClass *m_pHudPlayerClass;
  192. CTFHudPlayerHealth *m_pHudPlayerHealth;
  193. };
  194. #endif // TF_HUD_PLAYERSTATUS_H