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.

81 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_HUD_NOTIFICATION_PANEL_H
  7. #define TF_HUD_NOTIFICATION_PANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "hudelement.h"
  12. #include "IconPanel.h"
  13. #include <vgui_controls/ImagePanel.h>
  14. using namespace vgui;
  15. //-----------------------------------------------------------------------------
  16. // Purpose:
  17. //-----------------------------------------------------------------------------
  18. class CHudNotificationPanel : public CHudElement, public EditablePanel
  19. {
  20. DECLARE_CLASS_SIMPLE( CHudNotificationPanel, EditablePanel );
  21. public:
  22. typedef enum
  23. {
  24. kBackground_Blue,
  25. kBackground_Red,
  26. kBackground_Black,
  27. } BackgroundType_t;
  28. CHudNotificationPanel( const char *pElementName );
  29. virtual void Init( void );
  30. virtual void ApplySchemeSettings( IScheme *scheme );
  31. virtual bool ShouldDraw( void );
  32. virtual void OnTick( void );
  33. virtual void PerformLayout( void );
  34. const char *GetNotificationByType( int iType, float& flDuration );
  35. void MsgFunc_HudNotify( bf_read &msg );
  36. void MsgFunc_HudNotifyCustom( bf_read &msg );
  37. void SetupNotifyCustom( const char *pszText, const char *pszIcon, int iBackgroundTeam );
  38. void SetupNotifyCustom( const wchar_t *pszText, const char *pszIcon, int iBackgroundTeam );
  39. void SetupNotifyCustom( const wchar_t *pszText, HudNotification_t type, float overrideDuration = 0.0f );
  40. virtual void LevelInit( void ) { m_flFadeTime = 0; };
  41. bool LoadManifest( void );
  42. private:
  43. float m_flFadeTime;
  44. Label *m_pText;
  45. CIconPanel *m_pIcon;
  46. ImagePanel *m_pBackground;
  47. struct ShowCount_t
  48. {
  49. ShowCount_t() {}
  50. ShowCount_t( int nMaxShowCount, float flCooldown, ConVar* pConVar )
  51. : m_nMaxShowCount( nMaxShowCount )
  52. , m_flCooldown( flCooldown )
  53. , m_pConVar( pConVar )
  54. , m_flNextAllowedTime( 0.f )
  55. {}
  56. int m_nMaxShowCount;
  57. ConVar* m_pConVar;
  58. float m_flCooldown;
  59. float m_flNextAllowedTime;
  60. };
  61. CUtlMap< int, ShowCount_t > m_mapShowCounts;
  62. };
  63. #endif // TF_HUD_NOTIFICATION_PANEL_H