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.

290 lines
8.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_HUD_MAINMENUOVERRIDE_H
  8. #define TF_HUD_MAINMENUOVERRIDE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/EditablePanel.h>
  13. #include <vgui_controls/ScrollableEditablePanel.h>
  14. #include <game/client/iviewport.h>
  15. #include <vgui/IScheme.h>
  16. #include <vgui/ISurface.h>
  17. #include "hud.h"
  18. #include "hudelement.h"
  19. #include "tf_shareddefs.h"
  20. #include "vgui_avatarimage.h"
  21. #include "tf_imagepanel.h"
  22. #include "tf_gamestats_shared.h"
  23. #include "tf_controls.h"
  24. #include "item_model_panel.h"
  25. #include "motd.h"
  26. #include "gcsdk/gcclientsdk.h"
  27. #include "quest_log_panel.h"
  28. #include "local_steam_shared_object_listener.h"
  29. using namespace vgui;
  30. using namespace GCSDK;
  31. class CExButton;
  32. class HTML;
  33. class CSaxxyAwardsPanel;
  34. class CTFStreamListPanel;
  35. class CLobbyContainerFrame_Comp;
  36. class CLobbyContainerFrame_MvM;
  37. class CLobbyContainerFrame_Casual;
  38. enum mm_button_styles
  39. {
  40. MMBS_NORMAL = 0,
  41. MMBS_SUBBUTTON = 1,
  42. MMBS_CUSTOM,
  43. };
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. class CHudMainMenuOverride : public vgui::EditablePanel, public IViewPortPanel, public CGameEventListener, public CLocalSteamSharedObjectListener
  48. {
  49. DECLARE_CLASS_SIMPLE( CHudMainMenuOverride, vgui::EditablePanel );
  50. enum mm_highlight_anims
  51. {
  52. MMHA_TUTORIAL = 0,
  53. MMHA_PRACTICE,
  54. MMHA_NEWUSERFORUM,
  55. MMHA_OPTIONS,
  56. MMHA_LOADOUT,
  57. MMHA_STORE,
  58. MMHA_WAR,
  59. NUM_ANIMS
  60. };
  61. public:
  62. CHudMainMenuOverride( IViewPort *pViewPort );
  63. ~CHudMainMenuOverride( void );
  64. void AttachToGameUI( void );
  65. virtual const char *GetName( void ){ return PANEL_MAINMENUOVERRIDE; }
  66. virtual void SetData( KeyValues *data ){}
  67. virtual void Reset(){ Update(); SetVisible( true ); }
  68. virtual void Update() { return; }
  69. virtual bool NeedsUpdate( void ){ return false; }
  70. virtual bool HasInputElements( void ){ return true; }
  71. virtual void ShowPanel( bool bShow ) { SetVisible( true ); } // Refuses to hide
  72. // both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
  73. vgui::VPANEL GetVPanel( void ){ return BaseClass::GetVPanel(); }
  74. virtual bool IsVisible();
  75. virtual void SetParent( vgui::VPANEL parent ){ BaseClass::SetParent( parent ); }
  76. virtual void ApplySettings( KeyValues *inResourceData );
  77. virtual void ApplySchemeSettings( IScheme *scheme );
  78. virtual void PerformLayout( void );
  79. void OnCommand( const char *command );
  80. void OnKeyCodePressed( KeyCode code );
  81. void LoadMenuEntries( void );
  82. void RemoveAllMenuEntries( void );
  83. virtual void FireGameEvent( IGameEvent *event );
  84. void LoadCharacterImageFile( void );
  85. void UpdateNotifications();
  86. void SetNotificationsButtonVisible( bool bVisible );
  87. void SetNotificationsPanelVisible( bool bVisible );
  88. void AdjustNotificationsPanelHeight();
  89. void SetMOTDButtonVisible( bool bVisible );
  90. void SetMOTDVisible( bool bVisible );
  91. void SetQuestLogVisible( bool bVisible );
  92. void SetWatchStreamVisible( bool bVisible );
  93. void OpenMvMMMPanel();
  94. void OpenCompMMPanel();
  95. void OpenCasualMMPanel();
  96. void ReloadMMPanels();
  97. void UpdateMOTD( bool bNewMOTDs );
  98. bool ReloadedAllMOTDs( void ) { return m_bReloadedAllMOTDs; }
  99. CMOTDManager & GetMOTDManager() { return m_MOTDManager; }
  100. RTime32 GetLastMOTDRequestTime( void ) { return m_nLastMOTDRequestAt; }
  101. ELanguage GetLastMOTDRequestLanguage( void ) { return m_nLastMOTDRequestLanguage; }
  102. void UpdatePromotionalCodes( void );
  103. void CheckTrainingStatus( void );
  104. void StartHighlightAnimation( mm_highlight_anims iAnim );
  105. void HideHighlight( mm_highlight_anims iAnim );
  106. MESSAGE_FUNC( OnUpdateMenu, "UpdateMenu" );
  107. MESSAGE_FUNC_PARAMS( OnConfirm, "ConfirmDlgResult", data );
  108. void ScheduleTrainingCheck( bool bWasInTraining ) { m_flCheckTrainingAt = (engine->Time() + 1.5); m_bWasInTraining = bWasInTraining; }
  109. void ScheduleItemCheck( void ) { m_flCheckUnclaimedItems = (engine->Time() + 1.5); }
  110. void CheckUnclaimedItems();
  111. void OnTick();
  112. virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_NONE; } // Seems like this should be GAME_ACTION_SET_MENU, but it's not because it's apparently visible *all* *the* *damn* *time*
  113. #ifdef _DEBUG
  114. void Refresh();
  115. #endif
  116. void CheckForNewQuests( void );
  117. void UpdatePlaylistEntries( void );
  118. virtual void SOCreated( const CSteamID & steamIDOwner, const CSharedObject *pObject, ESOCacheEvent eEvent ) OVERRIDE { SOEvent( pObject ); }
  119. virtual void SOUpdated( const CSteamID & steamIDOwner, const CSharedObject *pObject, ESOCacheEvent eEvent ) OVERRIDE { SOEvent( pObject ); }
  120. CLobbyContainerFrame_Comp* GetCompLobbyPanel();
  121. CLobbyContainerFrame_MvM* GetMvMLobbyPanel();
  122. CLobbyContainerFrame_Casual* GetCasualLobbyPanel();
  123. #ifdef STAGING_ONLY
  124. void GenerateIconsThink( void );
  125. void GenerateIcons( bool bLarge, int min = -1, int max = -1 );
  126. bool m_bGeneratingIcons;
  127. bool m_bGeneratingLargeTestIcons;
  128. CEconItemView *m_pIconData;
  129. CUtlVector< item_definition_index_t > m_vecIconDefs;
  130. #endif
  131. protected:
  132. virtual void PaintTraverse( bool Repaint, bool allowForce = true ) OVERRIDE;
  133. private:
  134. void SOEvent( const CSharedObject* pObject );
  135. void PerformKeyRebindings( void );
  136. void TogglePlayListMenu( void );
  137. bool CheckAndWarnForPREC( void );
  138. void StopUpdateGlow();
  139. private:
  140. // Store
  141. CItemModelPanel *m_pFeaturedItemPanel;
  142. CItemModelPanel *m_pFeaturedItemMouseOverPanel;
  143. CItemModelPanel *m_pMouseOverItemPanel;
  144. CItemModelPanelToolTip *m_pMouseOverTooltip;
  145. // Notifications
  146. vgui::EditablePanel *m_pNotificationsShowPanel;
  147. vgui::EditablePanel *m_pNotificationsPanel;
  148. vgui::EditablePanel *m_pNotificationsControl;
  149. vgui::ScrollableEditablePanel *m_pNotificationsScroller;
  150. int m_iNumNotifications;
  151. int m_iNotiPanelWide;
  152. // MOTDs
  153. vgui::EditablePanel *m_pMOTDShowPanel;
  154. vgui::EditablePanel *m_pMOTDPanel;
  155. vgui::Label *m_pMOTDHeaderLabel;
  156. vgui::ImagePanel *m_pMOTDHeaderIcon;
  157. vgui::ScrollableEditablePanel *m_pMOTDTextScroller;
  158. vgui::EditablePanel *m_pMOTDTextPanel;
  159. vgui::Label *m_pMOTDTextLabel;
  160. vgui::Label *m_pMOTDTitleLabel;
  161. vgui::EditablePanel *m_pMOTDTitleImageContainer;
  162. vgui::ImagePanel *m_pMOTDTitleImage;
  163. int m_hTitleLabelFont;
  164. bool m_bInitMOTD;
  165. CExImageButton *m_pMOTDNextButton;
  166. CExImageButton *m_pMOTDPrevButton;
  167. CExButton *m_pMOTDURLButton;
  168. // MOTD handling
  169. CMOTDManager m_MOTDManager;
  170. bool m_bHaveNewMOTDs;
  171. RTime32 m_nLastMOTDRequestAt;
  172. ELanguage m_nLastMOTDRequestLanguage;
  173. bool m_bReloadedAllMOTDs;
  174. int m_iCurrentMOTD;
  175. bool m_bMOTDShownAtStartup;
  176. class CWarLandingPanel *m_pWarLandingPage;
  177. vgui::ImagePanel *m_pCharacterImagePanel;
  178. int m_iCharacterImageIdx;
  179. CExButton *m_pQuitButton;
  180. CExButton *m_pDisconnectButton;
  181. bool m_bIsDisconnectText;
  182. CExButton *m_pBackToReplaysButton;
  183. ImagePanel *m_pStoreHasNewItemsImage;
  184. CExButton *m_pVRModeButton;
  185. vgui::Panel *m_pVRModeBackground;
  186. KeyValues *m_pButtonKV;
  187. bool m_bReapplyButtonKVs;
  188. DHANDLE< CExplanationPopup > m_pHighlightAnims[ NUM_ANIMS ];
  189. float m_flCheckTrainingAt;
  190. bool m_bWasInTraining;
  191. float m_flCheckUnclaimedItems;
  192. vgui::ImagePanel *m_pBackground;
  193. struct mainmenu_entry_t
  194. {
  195. vgui::EditablePanel *pPanel;
  196. bool bOnlyInGame;
  197. bool bOnlyInReplay;
  198. bool bOnlyAtMenu;
  199. bool bIsVisible;
  200. bool bOnlyVREnabled;
  201. int iStyle;
  202. const char *pszImage;
  203. const char *pszTooltip;
  204. };
  205. CUtlVector<mainmenu_entry_t> m_pMMButtonEntries;
  206. CMainMenuToolTip *m_pToolTip;
  207. vgui::EditablePanel *m_pToolTipEmbeddedPanel;
  208. CSimplePanelToolTip *m_pFeaturedItemToolTip;
  209. EditablePanel *m_pQuestLogButton;
  210. EditablePanel *m_pEventPromoContainer;
  211. EditablePanel *m_pSafeModeContainer;
  212. vgui::DHANDLE<vgui::Frame> m_hReportPlayerDialog;
  213. CTFStreamListPanel *m_pWatchStreamsPanel;
  214. bool m_bPlayListExpanded;
  215. bool m_bStabilizedInitialLayout;
  216. float m_flLastWarNagTime;
  217. bool m_bBackgroundUsesCharacterImages;
  218. EditablePanel *m_pCompetitiveAccessInfo;
  219. #ifdef SAXXYMAINMENU_ENABLED
  220. CSaxxyAwardsPanel *m_pSaxxyAwardsPanel;
  221. KeyValues *m_pSaxxySettings;
  222. #endif
  223. CPanelAnimationVarAliasType( int, m_iButtonXOffset, "button_x_offset", "0", "proportional_int" );
  224. CPanelAnimationVarAliasType( int, m_iButtonY, "button_y", "0", "proportional_int" );
  225. CPanelAnimationVarAliasType( int, m_iButtonYDelta, "button_y_delta", "0", "proportional_int" );
  226. };
  227. #endif //TF_HUD_MAINMENUOVERRIDE_H