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.

76 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: To display the player's health with the use of one graphic over another. A cross in this case
  4. // Currently this is only used on the freeze cam panel
  5. //
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #ifndef CS_HUD_HEALTHPANEL_H
  9. #define CS_HUD_HEALTHPANEL_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include <KeyValues.h>
  14. #include <vgui/IScheme.h>
  15. #include <vgui/ISurface.h>
  16. #include <vgui/ISystem.h>
  17. #include <vgui_controls/AnimationController.h>
  18. #include <vgui_controls/EditablePanel.h>
  19. #include "vgui/ILocalize.h"
  20. #include "hud.h"
  21. #include "hudelement.h"
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Clips the health image to the appropriate percentage
  24. //-----------------------------------------------------------------------------
  25. class CCSHealthPanel : public vgui::Panel
  26. {
  27. public:
  28. DECLARE_CLASS_SIMPLE( CCSHealthPanel, vgui::Panel );
  29. CCSHealthPanel( vgui::Panel *parent, const char *name );
  30. virtual void Paint();
  31. void SetHealth( float flHealth ){ m_flHealth = ( flHealth <= 1.0 ) ? flHealth : 1.0f; }
  32. private:
  33. float m_flHealth; // percentage from 0.0 -> 1.0
  34. int m_iMaterialIndex;
  35. int m_iDeadMaterialIndex;
  36. };
  37. //-----------------------------------------------------------------------------
  38. // Purpose: Displays player health data
  39. //-----------------------------------------------------------------------------
  40. class CCSHudPlayerHealth : public vgui::EditablePanel
  41. {
  42. DECLARE_CLASS_SIMPLE( CCSHudPlayerHealth, EditablePanel );
  43. public:
  44. CCSHudPlayerHealth( Panel *parent, const char *name );
  45. virtual const char *GetResFilename( void ) { return "resource/UI/FreezePanelKillerHealth.res"; }
  46. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  47. virtual void Reset();
  48. void SetHealth( int iNewHealth, int iMaxHealth, int iMaxBuffedHealth );
  49. void HideHealthBonusImage( void );
  50. protected:
  51. //virtual void OnThink();
  52. protected:
  53. float m_flNextThink;
  54. private:
  55. CCSHealthPanel *m_pHealthImage;
  56. vgui::ImagePanel *m_pHealthImageBG;
  57. int m_nHealth;
  58. int m_nMaxHealth;
  59. };
  60. #endif