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.

113 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ITEM_AD_PANEL_H
  8. #define ITEM_AD_PANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/VGUI.h>
  13. #include "vgui_controls/EditablePanel.h"
  14. using namespace vgui;
  15. class CExButton;
  16. class CBaseAdPanel : public EditablePanel
  17. {
  18. DECLARE_CLASS_SIMPLE( CBaseAdPanel, EditablePanel );
  19. public:
  20. CBaseAdPanel( Panel *parent, const char *panelName );
  21. virtual ~CBaseAdPanel() {}
  22. virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
  23. float GetPresentTime() const { return m_flPresentTime; }
  24. static bool CheckForRequiredSteamComponents( const char* pszSteamRequried, const char* pszOverlayRequired );
  25. private:
  26. float m_flPresentTime;
  27. };
  28. class CItemAdPanel : public CBaseAdPanel
  29. {
  30. DECLARE_CLASS_SIMPLE( CItemAdPanel, CBaseAdPanel );
  31. public:
  32. CItemAdPanel( Panel *parent, const char *panelName, item_definition_index_t itemDefIndex );
  33. virtual ~CItemAdPanel() {}
  34. virtual void ApplySchemeSettings( IScheme *pScheme ) OVERRIDE;
  35. virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
  36. virtual void PerformLayout() OVERRIDE;
  37. virtual void OnTick() OVERRIDE;
  38. virtual void OnCommand( const char *command ) OVERRIDE;
  39. private:
  40. const CTFItemDefinition* GetItemDef() const;
  41. bool m_bShowMarketButton;
  42. item_definition_index_t m_ItemDefIndex;
  43. };
  44. class CCyclingAdContainerPanel : public EditablePanel
  45. {
  46. DECLARE_CLASS_SIMPLE( CCyclingAdContainerPanel, EditablePanel );
  47. public:
  48. CCyclingAdContainerPanel( Panel *parent, const char *panelName );
  49. virtual ~CCyclingAdContainerPanel();
  50. virtual void ApplySchemeSettings( IScheme *pScheme ) OVERRIDE;
  51. virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
  52. virtual void PerformLayout() OVERRIDE;
  53. virtual void OnCommand( const char *command ) OVERRIDE;
  54. virtual void OnThink() OVERRIDE;
  55. void SetItemKVs( KeyValues* pKVItems );
  56. private:
  57. void CreatePanels();
  58. void PresentIndex( int nIndex );
  59. void UpdateAdPanelPositions();
  60. float GetTransitionProgress() const;
  61. bool IsTransitioningOut() const;
  62. EditablePanel* m_pAdsContainer;
  63. EditablePanel* m_pFadePanel;
  64. CExButton* m_pPrevButton;
  65. CExButton* m_pNextButton;
  66. bool m_bNeedsToCreatePanels;
  67. bool m_bSettingsApplied;
  68. struct AdData_t
  69. {
  70. ~AdData_t()
  71. {
  72. delete m_pAdPanel;
  73. }
  74. CBaseAdPanel* m_pAdPanel;
  75. KeyValues* m_pSettingsKVs;
  76. };
  77. KeyValues *m_pKVItems;
  78. CUtlVector< AdData_t > m_vecPossibleAds;
  79. int m_nTargetIndex;
  80. int m_nCurrentIndex;
  81. int m_nTransitionStartOffsetX;
  82. bool m_bTransitionRight;
  83. int m_nXPos;
  84. RealTimeCountdownTimer m_TransitionTimer;
  85. RealTimeCountdownTimer m_ShowTimer;
  86. };
  87. #endif // ITEM_AD_PANEL_H