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.

158 lines
5.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_MATCHMAKING_DASHBOARD_H
  8. #define TF_MATCHMAKING_DASHBOARD_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tf_match_join_handlers.h"
  13. #include <vgui_controls/EditablePanel.h>
  14. #include "tf_controls.h"
  15. #include <vgui_controls/PHandle.h>
  16. #include "local_steam_shared_object_listener.h"
  17. CUtlVector< class CTFMatchmakingPopup* >& CreateMMPopupPanels( bool bRecreate = false );
  18. class CTFMatchmakingDashboard* GetMMDashboard();
  19. class CMMDashboardParentManager* GetMMDashboardParentManager();
  20. bool BInEndOfMatch();
  21. //-----------------------------------------------------------------------------
  22. // Purpose: Popup that goes underneath the dashboard and displays anything
  23. // important the user needs to know about
  24. //-----------------------------------------------------------------------------
  25. class CTFMatchmakingPopup : public CExpandablePanel
  26. , public CGameEventListener
  27. , public IMatchJoiningHandler
  28. {
  29. friend class CTFMatchmakingPopupState;
  30. friend class CTFMatchmakingDashboard;
  31. DECLARE_CLASS_SIMPLE( CTFMatchmakingPopup, CExpandablePanel );
  32. public:
  33. CTFMatchmakingPopup( const char* pszName, const char* pszResFile );
  34. virtual ~CTFMatchmakingPopup();
  35. virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) OVERRIDE;
  36. virtual void OnThink() OVERRIDE;
  37. virtual void OnCommand( const char *command ) OVERRIDE;
  38. virtual void OnTick() OVERRIDE;
  39. virtual void OnEnter();
  40. virtual void OnUpdate();
  41. virtual void OnExit();
  42. virtual void Update();
  43. virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;
  44. private:
  45. virtual void MatchFound() {} // We dont need to do anything special
  46. virtual bool ShouldBeActve() const = 0;
  47. void UpdateRematchtime();
  48. void UpdateAutoJoinTime();
  49. bool m_bActive;
  50. const char* m_pszResFile;
  51. };
  52. //-----------------------------------------------------------------------------
  53. // Purpose: Matchmaking panel that contains controls for matchmaking
  54. //-----------------------------------------------------------------------------
  55. class CTFMatchmakingDashboard : public CExpandablePanel
  56. {
  57. public:
  58. DECLARE_CLASS_SIMPLE( CTFMatchmakingDashboard, CExpandablePanel );
  59. CTFMatchmakingDashboard();
  60. virtual ~CTFMatchmakingDashboard();
  61. virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) OVERRIDE;
  62. virtual void OnCommand( const char *command ) OVERRIDE;
  63. virtual void OnTick() OVERRIDE;
  64. };
  65. //-----------------------------------------------------------------------------
  66. // CMMDashboardParentManager
  67. // Purpose: This guy keeps the MM dashboard as the top-most panel but does so
  68. // *without making it a popup*. This is important because popups look
  69. // awful whenever they overlap and transparency is involved. This class
  70. // does its dirty work by keeping track of the top-most fullscreen popup
  71. // and setting that panel as the MM dashboard's parent. When that popup
  72. // goes away, we set the parent to the next popup on the stack, or to
  73. // the GameUI if none are active. If we're in-game, then we parent to
  74. // the our special popup container. Why not always just parent to that
  75. // single popup container? Because we want the MINIMUM mouse focus area
  76. // possible because the dashboard is not a rectangle (it grows/shrinks).
  77. //
  78. //
  79. // If anything draws on top of the MM dashboard and you dont want it to
  80. // have that panel add itself to this class using PushModalFullscreenPopup
  81. // when it goes visible and PopModalFullscreenPopup when it hides itself
  82. //-----------------------------------------------------------------------------
  83. class CMMDashboardParentManager : public CGameEventListener
  84. {
  85. public:
  86. friend class CTFMatchmakingDashboard;
  87. friend class CTFMatchmakingPopup;
  88. CMMDashboardParentManager();
  89. virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
  90. void PushModalFullscreenPopup( vgui::Panel* pPanel );
  91. void PopModalFullscreenPopup( vgui::Panel* pPanel );
  92. void UpdateParenting();
  93. private:
  94. void AddPanel( CExpandablePanel* pPanel );
  95. void RemovePanel( CExpandablePanel* pPanel );
  96. void AttachToGameUI();
  97. void AttachToTopMostPopup();
  98. bool m_bAttachedToGameUI;
  99. class CUtlSortVectorPanelZPos
  100. {
  101. public:
  102. bool Less( const vgui::Panel* lhs, const vgui::Panel* rhs, void * )
  103. {
  104. return lhs->GetZPos() < rhs->GetZPos();
  105. }
  106. };
  107. CUtlSortVector< CExpandablePanel*, CUtlSortVectorPanelZPos > m_vecPanels;
  108. CUtlVector< vgui::Panel* > m_vecFullscreenPopups;
  109. vgui::PHandle m_pHUDPopup;
  110. };
  111. class IMMPopupFactory
  112. {
  113. public:
  114. virtual CTFMatchmakingPopup* Create() const = 0;
  115. static CUtlVector< IMMPopupFactory* > s_vecPopupFactories;
  116. };
  117. template< typename Type >
  118. class CMMPopupFactoryImplementation : public IMMPopupFactory
  119. {
  120. public:
  121. CMMPopupFactoryImplementation( const char* pszName, const char* pszResFile ) : m_pszName( pszName ), m_pszResFile( pszResFile )
  122. { s_vecPopupFactories.AddToTail( this ); }
  123. virtual CTFMatchmakingPopup* Create() const OVERRIDE { return new Type( m_pszName, m_pszResFile ); }
  124. private:
  125. const char* m_pszName;
  126. const char* m_pszResFile;
  127. };
  128. #define REG_MM_POPUP_FACTORY( type, name, resfile ) CMMPopupFactoryImplementation< type > g_##type##Factory( name, resfile );
  129. #endif // TF_MATCHMAKING_DASHBOARD_H