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.

159 lines
5.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Defines the interface that the GameUI dll exports
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GAMEUI_INTERFACE_H
  8. #define GAMEUI_INTERFACE_H
  9. #pragma once
  10. #include "GameUI/IGameUI.h"
  11. #include <vgui_controls/Panel.h>
  12. #include <vgui_controls/PHandle.h>
  13. class IGameClientExports;
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Implementation of GameUI's exposed interface
  16. //-----------------------------------------------------------------------------
  17. class CGameUI : public IGameUI
  18. {
  19. public:
  20. CGameUI();
  21. ~CGameUI();
  22. virtual void Initialize( CreateInterfaceFn appFactory );
  23. virtual void Connect( CreateInterfaceFn gameFactory );
  24. virtual void Start();
  25. virtual void Shutdown();
  26. virtual void RunFrame();
  27. virtual void PostInit();
  28. // plays the startup mp3 when GameUI starts
  29. void PlayGameStartupSound();
  30. // Engine wrappers for activating / hiding the gameUI
  31. void ActivateGameUI();
  32. void HideGameUI();
  33. // Toggle allowing the engine to hide the game UI with the escape key
  34. void PreventEngineHideGameUI();
  35. void AllowEngineHideGameUI();
  36. virtual void SetLoadingBackgroundDialog( vgui::VPANEL panel );
  37. // Bonus maps interfaces
  38. virtual void BonusMapUnlock( const char *pchFileName = NULL, const char *pchMapName = NULL );
  39. virtual void BonusMapComplete( const char *pchFileName = NULL, const char *pchMapName = NULL );
  40. virtual void BonusMapChallengeUpdate( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest );
  41. virtual void BonusMapChallengeNames( char *pchFileName, char *pchMapName, char *pchChallengeName );
  42. virtual void BonusMapChallengeObjectives( int &iBronze, int &iSilver, int &iGold );
  43. virtual void BonusMapDatabaseSave( void );
  44. virtual int BonusMapNumAdvancedCompleted( void );
  45. virtual void BonusMapNumMedals( int piNumMedals[ 3 ] );
  46. // notifications
  47. virtual void OnGameUIActivated();
  48. virtual void OnGameUIHidden();
  49. virtual void OLD_OnConnectToServer( const char *game, int IP, int port ); // OLD: use OnConnectToServer2
  50. virtual void OnConnectToServer2( const char *game, int IP, int connectionPort, int queryPort );
  51. virtual void OnDisconnectFromServer( uint8 eSteamLoginFailure );
  52. virtual void OnLevelLoadingStarted( bool bShowProgressDialog );
  53. virtual void OnLevelLoadingFinished( bool bError, const char *failureReason, const char *extendedReason );
  54. virtual void OnDisconnectFromServer_OLD( uint8 eSteamLoginFailure, const char *username ) { OnDisconnectFromServer( eSteamLoginFailure ); }
  55. // progress
  56. virtual bool UpdateProgressBar(float progress, const char *statusText);
  57. // Shows progress desc, returns previous setting... (used with custom progress bars )
  58. virtual bool SetShowProgressText( bool show );
  59. // brings up the new game dialog
  60. virtual void ShowNewGameDialog( int chapter );
  61. // Xbox 360
  62. virtual void SessionNotification( const int notification, const int param = 0 );
  63. virtual void SystemNotification( const int notification );
  64. virtual void ShowMessageDialog( const uint nType, vgui::Panel *pOwner = NULL );
  65. virtual void CloseMessageDialog( const uint nType = 0 );
  66. virtual void UpdatePlayerInfo( uint64 nPlayerId, const char *pName, int nTeam, byte cVoiceState, int nPlayersNeeded, bool bHost );
  67. virtual void SessionSearchResult( int searchIdx, void *pHostData, XSESSION_SEARCHRESULT *pResult, int ping );
  68. virtual void OnCreditsFinished( void );
  69. // X360 Storage device validation:
  70. // returns true right away if storage device has been previously selected.
  71. // otherwise returns false and will set the variable pointed by pStorageDeviceValidated to 1
  72. // once the storage device is selected by user.
  73. virtual bool ValidateStorageDevice( int *pStorageDeviceValidated );
  74. virtual void SetProgressOnStart();
  75. virtual void OnConfirmQuit( void );
  76. virtual bool IsMainMenuVisible( void );
  77. // Client DLL is providing us with a panel that it wants to replace the main menu with
  78. virtual void SetMainMenuOverride( vgui::VPANEL panel );
  79. // Client DLL is telling us that a main menu command was issued, probably from its custom main menu panel
  80. virtual void SendMainMenuCommand( const char *pszCommand );
  81. // state
  82. bool IsInLevel();
  83. bool IsInBackgroundLevel();
  84. bool IsInMultiplayer();
  85. bool IsInReplay();
  86. bool IsConsoleUI();
  87. bool HasSavedThisMenuSession();
  88. void SetSavedThisMenuSession( bool bState );
  89. void ShowLoadingBackgroundDialog();
  90. void HideLoadingBackgroundDialog();
  91. bool HasLoadingBackgroundDialog();
  92. private:
  93. void SendConnectedToGameMessage();
  94. virtual void StartProgressBar();
  95. virtual bool ContinueProgressBar(float progressFraction);
  96. virtual void StopProgressBar(bool bError, const char *failureReason, const char *extendedReason = NULL);
  97. virtual bool SetProgressBarStatusText(const char *statusText);
  98. //!! these functions currently not implemented
  99. virtual void SetSecondaryProgressBar(float progress /* range [0..1] */);
  100. virtual void SetSecondaryProgressBarText(const char *statusText);
  101. bool FindPlatformDirectory(char *platformDir, int bufferSize);
  102. void GetUpdateVersion( char *pszProd, char *pszVer);
  103. void ValidateCDKey();
  104. CreateInterfaceFn m_GameFactory;
  105. bool m_bPlayGameStartupSound : 1;
  106. bool m_bTryingToLoadFriends : 1;
  107. bool m_bActivatedUI : 1;
  108. bool m_bIsConsoleUI : 1;
  109. bool m_bHasSavedThisMenuSession : 1;
  110. bool m_bOpenProgressOnStart : 1;
  111. int m_iGameIP;
  112. int m_iGameConnectionPort;
  113. int m_iGameQueryPort;
  114. int m_iFriendsLoadPauseFrames;
  115. char m_szPreviousStatusText[128];
  116. char m_szPlatformDir[MAX_PATH];
  117. vgui::DHANDLE<class CCDKeyEntryDialog> m_hCDKeyEntryDialog;
  118. };
  119. // Purpose: singleton accessor
  120. extern CGameUI &GameUI();
  121. // expose client interface
  122. extern IGameClientExports *GameClientExports();
  123. #endif // GAMEUI_INTERFACE_H