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.

189 lines
5.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef CL_REPLAYCONTEXT_H
  5. #define CL_REPLAYCONTEXT_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "shared_replaycontext.h"
  11. #include "replay/iclientreplaycontext.h"
  12. #include "igameevents.h"
  13. #include "cl_recordingsessionmanager.h"
  14. #include "cl_replaymoviemanager.h"
  15. #include "cl_recordingsessionblockmanager.h"
  16. #include "cl_performancemanager.h"
  17. #include "cl_performancecontroller.h"
  18. #include "errorsystem.h"
  19. //----------------------------------------------------------------------------------------
  20. class IReplayMovieRenderer;
  21. class CScreenshotManager;
  22. class CReplayManager;
  23. class CReplayMovieManager;
  24. class CClientRecordingSessionManager;
  25. class CReplayPerformanceManager;
  26. class CHttpDownloader;
  27. class CSessionBlockDownloader;
  28. class CClientRecordingSession;
  29. class CPerformanceController;
  30. class CRenderQueue;
  31. //----------------------------------------------------------------------------------------
  32. class CClientReplayContext : public IClientReplayContext,
  33. public IErrorReporter
  34. {
  35. public:
  36. LINK_TO_SHARED_REPLAYCONTEXT_IMP();
  37. CClientReplayContext();
  38. ~CClientReplayContext();
  39. virtual bool Init( CreateInterfaceFn fnFactory );
  40. virtual void Shutdown();
  41. virtual void Think(); // Called by engine
  42. bool ReconstructReplayIfNecessary( CReplay *pReplay );
  43. void DisableReplayOnClient( bool bDisable );
  44. bool IsClientSideReplayDisabled() const { return m_bClientSideReplayDisabled; }
  45. //
  46. // IClientReplayContext
  47. //
  48. virtual CReplay *GetReplay( ReplayHandle_t hReplay );
  49. virtual IReplayManager *GetReplayManager();
  50. virtual IReplayMovieRenderer *GetMovieRenderer();
  51. virtual IReplayMovieManager *GetMovieManager();
  52. virtual IReplayScreenshotManager *GetScreenshotManager();
  53. virtual IReplayPerformanceManager *GetPerformanceManager();
  54. virtual IReplayPerformanceController *GetPerformanceController();
  55. virtual IReplayRenderQueue *GetRenderQueue();
  56. virtual void SetMovieRenderer( IReplayMovieRenderer *pMovieRenderer );
  57. virtual void OnSignonStateFull();
  58. virtual void OnClientSideDisconnect();
  59. virtual void PlayReplay( ReplayHandle_t hReplay, int iPerformance, bool bPlaySound );
  60. virtual void OnPlayerSpawn();
  61. virtual void OnPlayerClassChanged();
  62. virtual void GetPlaybackTimes( float &flOutTime, float &flOutLength, const CReplay *pReplay, const CReplayPerformance *pPerformance );
  63. virtual uint64 GetServerSessionId( ReplayHandle_t hReplay );
  64. virtual void CleanupUnneededBlocks();
  65. //
  66. // IErrorReporter
  67. //
  68. virtual void ReportErrorsToUser( wchar_t *pErrorText );
  69. void TestDownloader( const char *pURL );
  70. CReplayManager *m_pReplayManager;
  71. CScreenshotManager *m_pScreenshotManager;
  72. IReplayMovieRenderer *m_pMovieRenderer;
  73. CReplayMovieManager *m_pMovieManager;
  74. CReplayPerformanceManager *m_pPerformanceManager;
  75. CPerformanceController *m_pPerformanceController;
  76. CSessionBlockDownloader *m_pSessionBlockDownloader;
  77. CRenderQueue *m_pRenderQueue;
  78. CHttpDownloader *m_pTestDownloader;
  79. private:
  80. void DebugThink();
  81. void ReplayThink();
  82. bool m_bClientSideReplayDisabled;
  83. };
  84. //----------------------------------------------------------------------------------------
  85. extern CClientReplayContext *g_pClientReplayContextInternal;
  86. //----------------------------------------------------------------------------------------
  87. //
  88. // Helpers
  89. //
  90. inline const char *CL_GetBasePath()
  91. {
  92. return g_pClientReplayContextInternal->m_pShared->m_strBasePath;
  93. }
  94. inline const char *CL_GetRelativeBasePath()
  95. {
  96. return g_pClientReplayContextInternal->m_pShared->m_strRelativeBasePath.Get();
  97. }
  98. inline CReplayManager *CL_GetReplayManager()
  99. {
  100. return g_pClientReplayContextInternal->m_pReplayManager;
  101. }
  102. inline CClientRecordingSessionBlockManager *CL_GetRecordingSessionBlockManager()
  103. {
  104. return static_cast< CClientRecordingSessionBlockManager * >( g_pClientReplayContextInternal->GetRecordingSessionBlockManager() );
  105. }
  106. inline CScreenshotManager *CL_GetScreenshotManager()
  107. {
  108. return g_pClientReplayContextInternal->m_pScreenshotManager;
  109. }
  110. inline IReplayMovieRenderer *CL_GetMovieRenderer()
  111. {
  112. return g_pClientReplayContextInternal->m_pMovieRenderer;
  113. }
  114. inline CReplayMovieManager *CL_GetMovieManager()
  115. {
  116. return g_pClientReplayContextInternal->m_pMovieManager;
  117. }
  118. inline const char *CL_GetReplayBaseDir()
  119. {
  120. return g_pClientReplayContextInternal->m_pShared->m_strBasePath;
  121. }
  122. inline CErrorSystem *CL_GetErrorSystem()
  123. {
  124. return g_pClientReplayContextInternal->m_pShared->m_pErrorSystem;
  125. }
  126. inline CSessionBlockDownloader *CL_GetSessionBlockDownloader()
  127. {
  128. return g_pClientReplayContextInternal->m_pSessionBlockDownloader;
  129. }
  130. inline CReplayPerformanceManager *CL_GetPerformanceManager()
  131. {
  132. return g_pClientReplayContextInternal->m_pPerformanceManager;
  133. }
  134. inline CPerformanceController *CL_GetPerformanceController()
  135. {
  136. return g_pClientReplayContextInternal->m_pPerformanceController;
  137. }
  138. inline IThreadPool *CL_GetThreadPool()
  139. {
  140. return g_pClientReplayContextInternal->m_pShared->m_pThreadPool;
  141. }
  142. inline CRenderQueue *CL_GetRenderQueue()
  143. {
  144. return g_pClientReplayContextInternal->m_pRenderQueue;
  145. }
  146. //----------------------------------------------------------------------------------------
  147. CClientRecordingSessionManager *CL_GetRecordingSessionManager();
  148. CClientRecordingSession *CL_GetRecordingSessionInProgress();
  149. //----------------------------------------------------------------------------------------
  150. #endif // CL_REPLAYCONTEXT_H