Counter Strike : Global Offensive Source Code
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.

226 lines
7.1 KiB

  1. //========= Copyright 1996-2005, 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. #include "convar.h"
  14. #if defined( INCLUDE_SCALEFORM )
  15. #include "scaleformui/scaleformui.h"
  16. #endif
  17. #include "uicomponents/uicomponent_common.h"
  18. #if defined(_PS3)
  19. #define BACKGROUND_MUSIC_FILENAME "gamestartup.ps3.wav"
  20. #else
  21. #define BACKGROUND_MUSIC_FILENAME "mainmenu.mp3"
  22. #endif
  23. #define MAX_BACKGROUND_MUSIC 3
  24. class IGameClientExports;
  25. class CCommand;
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Implementation of GameUI's exposed interface
  28. //-----------------------------------------------------------------------------
  29. class CGameUI : public IGameUI
  30. {
  31. public:
  32. CGameUI();
  33. ~CGameUI();
  34. virtual void Initialize( CreateInterfaceFn appFactory );
  35. virtual void Connect( CreateInterfaceFn gameFactory );
  36. virtual void Start();
  37. virtual void Shutdown();
  38. virtual void RunFrame();
  39. virtual void PostInit();
  40. // plays the startup mp3 when GameUI starts
  41. void PlayGameStartupSound();
  42. // Engine wrappers for activating / hiding the gameUI
  43. void ActivateGameUI();
  44. void HideGameUI();
  45. // Toggle allowing the engine to hide the game UI with the escape key
  46. void PreventEngineHideGameUI();
  47. void AllowEngineHideGameUI();
  48. virtual void SetLoadingBackgroundDialog( vgui::VPANEL panel );
  49. // notifications
  50. virtual void OnGameUIActivated();
  51. virtual void OnGameUIHidden();
  52. virtual void OLD_OnConnectToServer( const char *game, int IP, int port ); // OLD: use OnConnectToServer2
  53. virtual void OnConnectToServer2( const char *game, int IP, int connectionPort, int queryPort );
  54. virtual void OnDisconnectFromServer( uint8 eSteamLoginFailure );
  55. virtual void OnLevelLoadingStarted( const char *levelName, bool bShowProgressDialog );
  56. virtual void OnLevelLoadingFinished( bool bError, const char *failureReason, const char *extendedReason );
  57. virtual void OnDisconnectFromServer_OLD( uint8 eSteamLoginFailure, const char *username ) { OnDisconnectFromServer( eSteamLoginFailure ); }
  58. virtual void StartLoadingScreenForCommand( const char* command );
  59. virtual void StartLoadingScreenForKeyValues( KeyValues* keyValues );
  60. // progress
  61. virtual bool UpdateProgressBar(float progress, const char *statusText, bool showDialog = true );
  62. // Shows progress desc, returns previous setting... (used with custom progress bars )
  63. virtual bool SetShowProgressText( bool show );
  64. virtual bool UpdateSecondaryProgressBar(float progress, const wchar_t *desc );
  65. // Xbox 360
  66. virtual void ShowMessageDialog( const uint nType, vgui::Panel *pOwner = NULL );
  67. virtual void ShowMessageDialog( const char* messageID, const char* titleID );
  68. virtual void CreateCommandMsgBox( const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
  69. virtual void CreateCommandMsgBoxInSlot( ECommandMsgBoxSlot slot, const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
  70. // Allows the level loading progress to show map-specific info
  71. virtual void SetProgressLevelName( const char *levelName );
  72. virtual void NeedConnectionProblemWaitScreen();
  73. virtual void ShowPasswordUI( char const *pchCurrentPW );
  74. virtual bool LoadingProgressWantsIsolatedRender( bool bContextValid );
  75. virtual void RestoreTopLevelMenu();
  76. virtual void SetProgressOnStart();
  77. #if defined( _GAMECONSOLE ) && defined( _DEMO )
  78. virtual void OnDemoTimeout();
  79. #endif
  80. // state
  81. bool IsInLevel();
  82. bool IsInBackgroundLevel();
  83. bool IsInMultiplayer();
  84. bool IsConsoleUI();
  85. bool HasSavedThisMenuSession();
  86. void SetSavedThisMenuSession( bool bState );
  87. void ShowLoadingBackgroundDialog();
  88. void HideLoadingBackgroundDialog();
  89. bool HasLoadingBackgroundDialog();
  90. virtual bool IsPlayingFullScreenVideo();
  91. virtual bool IsTransitionEffectEnabled();
  92. void SetBackgroundMusicDesired( bool bPlayMusic );
  93. void SetPreviewBackgroundMusic( const char * pchPreviewMusicPrefix );
  94. void ReleaseBackgroundMusic( void );
  95. void StartBackgroundMusicFade( void );
  96. void PlayQuestAudio( const char * pchAudioFile );
  97. void StopQuestAudio( void );
  98. bool IsQuestAudioPlaying( void );
  99. #ifdef PANORAMA_ENABLE
  100. void ChangeGameUIState(CSGOGameUIState_t nNewState);
  101. CSGOGameUIState_t GetGameUIState();
  102. void RegisterGameUIStateListener(ICSGOGameUIStateListener *pListener);
  103. void UnregisterGameUIStateListener(ICSGOGameUIStateListener *pListener);
  104. #endif // PANORAMA_ENABLE
  105. CUtlVector< IUiComponentGlobalInstanceBase * > & GetUiComponents()
  106. {
  107. return m_arrUiComponents;
  108. }
  109. private:
  110. void SendConnectedToGameMessage();
  111. virtual void StartProgressBar();
  112. virtual bool ContinueProgressBar(float progressFraction, bool showDialog = true );
  113. virtual void StopProgressBar(bool bError, const char *failureReason, const char *extendedReason = NULL);
  114. virtual bool SetProgressBarStatusText(const char *statusText, bool showDialog = true );
  115. //!! these functions currently not implemented
  116. virtual void SetSecondaryProgressBar(float progress /* range [0..1] */);
  117. virtual void SetSecondaryProgressBarText( const wchar_t *desc );
  118. bool FindPlatformDirectory(char *platformDir, int bufferSize);
  119. void GetUpdateVersion( char *pszProd, char *pszVer);
  120. void ValidateCDKey();
  121. bool IsBackgroundMusicPlaying( void );
  122. void UpdateBackgroundMusic( void );
  123. CreateInterfaceFn m_GameFactory;
  124. bool m_bTryingToLoadFriends : 1;
  125. bool m_bActivatedUI : 1;
  126. bool m_bIsConsoleUI : 1;
  127. bool m_bHasSavedThisMenuSession : 1;
  128. bool m_bOpenProgressOnStart : 1;
  129. int m_iGameIP;
  130. int m_iGameConnectionPort;
  131. int m_iGameQueryPort;
  132. int m_iFriendsLoadPauseFrames;
  133. int m_iPlayGameStartupSound;
  134. char m_szPreviousStatusText[128];
  135. char m_szPlatformDir[MAX_PATH];
  136. vgui::DHANDLE<class CCDKeyEntryDialog> m_hCDKeyEntryDialog;
  137. int m_nBackgroundMusicGUID;
  138. bool m_bBackgroundMusicDesired;
  139. int m_nBackgroundMusicVersion;
  140. float m_flBackgroundMusicStopTime;
  141. const char *m_pMusicExtension;
  142. const char *m_pPreviewMusicExtension;
  143. float m_flMainMenuMusicVolume;
  144. float m_flMasterMusicVolume;
  145. float m_flQuestAudioTimeEnd;
  146. float m_flMasterMusicVolumeSavedForMissionAudio;
  147. float m_flMenuMusicVolumeSavedForMissionAudio;
  148. int m_nQuestAudioGUID;
  149. const char * m_pAudioFile;
  150. #ifdef PANORAMA_ENABLE
  151. CSGOGameUIState_t m_CSGOGameUIState;
  152. CUtlVector< ICSGOGameUIStateListener* > m_GameUIStateListeners;
  153. bool m_bFirstActivationForSession = true;
  154. bool m_bInLevelLoading = false;
  155. #endif
  156. CUtlVector< IUiComponentGlobalInstanceBase * > m_arrUiComponents;
  157. };
  158. // Purpose: singleton accessor
  159. extern CGameUI &GameUI();
  160. // expose client interface
  161. extern IGameClientExports *GameClientExports();
  162. #if defined(INCLUDE_SCALEFORM)
  163. extern IScaleformUI* ScaleformUI();
  164. #endif
  165. #endif // GAMEUI_INTERFACE_H