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.

177 lines
4.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_TIME_PANEL_H
  8. #define TF_TIME_PANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "GameEventListener.h"
  13. #include "hudelement.h"
  14. #include <vgui_controls/ImagePanel.h>
  15. using namespace vgui;
  16. //-----------------------------------------------------------------------------
  17. // Purpose:
  18. //-----------------------------------------------------------------------------
  19. class CTFProgressBar : public vgui::ImagePanel
  20. {
  21. public:
  22. DECLARE_CLASS_SIMPLE( CTFProgressBar, vgui::ImagePanel );
  23. CTFProgressBar( vgui::Panel *parent, const char *name );
  24. virtual void Paint();
  25. void SetPercentage( float flPercentage ){ m_flPercent = flPercentage; }
  26. private:
  27. float m_flPercent;
  28. int m_iTexture;
  29. CPanelAnimationVar( Color, m_clrActive, "color_active", "TimerProgress.Active" );
  30. CPanelAnimationVar( Color, m_clrInActive, "color_inactive", "TimerProgress.InActive" );
  31. CPanelAnimationVar( Color, m_clrWarning, "color_warning", "TimerProgress.Active" );
  32. CPanelAnimationVar( float, m_flPercentWarning, "percent_warning", "0.75" );
  33. };
  34. // Floating delta text items, float off the top of the frame to
  35. // show changes to the timer value
  36. typedef struct
  37. {
  38. // amount of delta
  39. int m_nAmount;
  40. // die time
  41. float m_flDieTime;
  42. } timer_delta_t;
  43. #define NUM_TIMER_DELTA_ITEMS 10
  44. class CExLabel;
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. //-----------------------------------------------------------------------------
  48. class CTFHudTimeStatus : public vgui::EditablePanel, public CGameEventListener
  49. {
  50. DECLARE_CLASS_SIMPLE( CTFHudTimeStatus, vgui::EditablePanel );
  51. public:
  52. CTFHudTimeStatus( Panel *parent, const char *name );
  53. virtual void Paint( void );
  54. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  55. virtual void Reset();
  56. int GetTimerIndex( void ){ return m_iTimerIndex; }
  57. void SetTimerIndex( int index ){ m_iTimerIndex = ( index >= 0 ) ? index : 0; SetExtraTimePanels(); }
  58. virtual void FireGameEvent( IGameEvent *event );
  59. void SetTeam( int nTeam ){ m_nTeam = nTeam; }
  60. protected:
  61. virtual void OnThink();
  62. private:
  63. void SetExtraTimePanels();
  64. void SetTimeAdded( int iIndex, int nSeconds );
  65. void CheckClockLabelLength( CExLabel *pLabel, vgui::Panel *pBG );
  66. void SetTeamBackground( void );
  67. private:
  68. float m_flNextThink;
  69. int m_iTimerIndex;
  70. bool m_bSuddenDeath;
  71. bool m_bOvertime;
  72. CExLabel *m_pTimeValue;
  73. CTFProgressBar *m_pProgressBar;
  74. vgui::ScalableImagePanel *m_pTimerBG;
  75. CExLabel *m_pWaitingForPlayersLabel;
  76. vgui::Panel *m_pWaitingForPlayersBG;
  77. CExLabel *m_pOvertimeLabel;
  78. vgui::Panel *m_pOvertimeBG;
  79. CExLabel *m_pSetupLabel;
  80. vgui::Panel *m_pSetupBG;
  81. CExLabel *m_pServerTimeLabel;
  82. vgui::Panel *m_pServerTimeLabelBG;
  83. // we'll have a second label/bg set for the SuddenDeath panel in case we want to change the look from the Overtime label
  84. CExLabel *m_pSuddenDeathLabel;
  85. vgui::Panel *m_pSuddenDeathBG;
  86. // delta stuff
  87. int m_iTimerDeltaHead;
  88. timer_delta_t m_TimerDeltaItems[NUM_TIMER_DELTA_ITEMS];
  89. CPanelAnimationVarAliasType( float, m_flDeltaItemStartPos, "delta_item_start_y", "100", "proportional_float" );
  90. CPanelAnimationVarAliasType( float, m_flDeltaItemEndPos, "delta_item_end_y", "0", "proportional_float" );
  91. CPanelAnimationVarAliasType( float, m_flDeltaItemX, "delta_item_x", "0", "proportional_float" );
  92. CPanelAnimationVar( Color, m_DeltaPositiveColor, "PositiveColor", "0 255 0 255" );
  93. CPanelAnimationVar( Color, m_DeltaNegativeColor, "NegativeColor", "255 0 0 255" );
  94. CPanelAnimationVar( float, m_flDeltaLifetime, "delta_lifetime", "2.0" );
  95. CPanelAnimationVar( vgui::HFont, m_hDeltaItemFont, "delta_item_font", "Default" );
  96. int m_nTeam;
  97. bool m_bKothMode;
  98. bool m_bCachedOvertime;
  99. };
  100. //-----------------------------------------------------------------------------
  101. // Purpose:
  102. //-----------------------------------------------------------------------------
  103. class CTFHudKothTimeStatus : public CHudElement, public vgui::EditablePanel
  104. {
  105. DECLARE_CLASS_SIMPLE( CTFHudKothTimeStatus, vgui::EditablePanel );
  106. public:
  107. CTFHudKothTimeStatus( const char *pElementName );
  108. ~CTFHudKothTimeStatus();
  109. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  110. virtual void Reset();
  111. virtual void Think();
  112. virtual bool ShouldDraw();
  113. virtual void SetVisible( bool bVisible ) OVERRIDE;
  114. virtual int GetRenderGroupPriority( void ) { return 80; } // higher than build menus
  115. private:
  116. void UpdateActiveTeam( void );
  117. private:
  118. CTFHudTimeStatus *m_pBluePanel;
  119. CTFHudTimeStatus *m_pRedPanel;
  120. Panel *m_pActiveTimerBG;
  121. int m_nActiveTeam;
  122. CPanelAnimationVarAliasType( int, m_nBlueActiveXPos, "blue_active_xpos", "0", "proportional_int" );
  123. CPanelAnimationVarAliasType( int, m_nRedActiveXPos, "red_active_xpos", "0", "proportional_int" );
  124. };
  125. #endif // TF_TIME_PANEL_H