summaryrefslogtreecommitdiff
path: root/replay/cl_replaycontext.h
blob: 3032b83359e29d269914c21cccd3b3bc62d97ce1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//

#ifndef CL_REPLAYCONTEXT_H
#define CL_REPLAYCONTEXT_H
#ifdef _WIN32
#pragma once
#endif

//----------------------------------------------------------------------------------------

#include "shared_replaycontext.h"
#include "replay/iclientreplaycontext.h"
#include "igameevents.h"
#include "cl_recordingsessionmanager.h"
#include "cl_replaymoviemanager.h"
#include "cl_recordingsessionblockmanager.h"
#include "cl_performancemanager.h"
#include "cl_performancecontroller.h"
#include "errorsystem.h"

//----------------------------------------------------------------------------------------

class IReplayMovieRenderer;
class CScreenshotManager;
class CReplayManager;
class CReplayMovieManager;
class CClientRecordingSessionManager;
class CReplayPerformanceManager;
class CHttpDownloader;
class CSessionBlockDownloader;
class CClientRecordingSession;
class CPerformanceController;
class CRenderQueue;

//----------------------------------------------------------------------------------------

class CClientReplayContext : public IClientReplayContext,
							 public IErrorReporter
{
public:
	LINK_TO_SHARED_REPLAYCONTEXT_IMP();

	CClientReplayContext();
	~CClientReplayContext();

	virtual bool				Init( CreateInterfaceFn fnFactory );
	virtual void				Shutdown();

	virtual void				Think();	// Called by engine

	bool						ReconstructReplayIfNecessary( CReplay *pReplay );
	void						DisableReplayOnClient( bool bDisable );
	bool						IsClientSideReplayDisabled() const		{ return m_bClientSideReplayDisabled; }

	//
	// IClientReplayContext
	//
	virtual CReplay				*GetReplay( ReplayHandle_t hReplay );
	virtual IReplayManager		*GetReplayManager();
	virtual IReplayMovieRenderer	*GetMovieRenderer();
	virtual IReplayMovieManager	*GetMovieManager();
	virtual IReplayScreenshotManager	*GetScreenshotManager();
	virtual IReplayPerformanceManager	*GetPerformanceManager();
	virtual IReplayPerformanceController *GetPerformanceController();
	virtual IReplayRenderQueue			*GetRenderQueue();
	virtual void				SetMovieRenderer( IReplayMovieRenderer *pMovieRenderer );
	virtual void				OnSignonStateFull();
	virtual void				OnClientSideDisconnect();
	virtual void				PlayReplay( ReplayHandle_t hReplay, int iPerformance, bool bPlaySound );
	virtual void				OnPlayerSpawn();
	virtual void				OnPlayerClassChanged();
	virtual void				GetPlaybackTimes( float &flOutTime, float &flOutLength, const CReplay *pReplay, const CReplayPerformance *pPerformance );
	virtual uint64				GetServerSessionId( ReplayHandle_t hReplay );
	virtual void				CleanupUnneededBlocks();

	//
	// IErrorReporter
	//
	virtual void				ReportErrorsToUser( wchar_t *pErrorText );

	void						TestDownloader( const char *pURL );

	CReplayManager				*m_pReplayManager;
	CScreenshotManager			*m_pScreenshotManager;
	IReplayMovieRenderer		*m_pMovieRenderer;
	CReplayMovieManager			*m_pMovieManager;
	CReplayPerformanceManager	*m_pPerformanceManager;
	CPerformanceController		*m_pPerformanceController;
	CSessionBlockDownloader		*m_pSessionBlockDownloader;
	CRenderQueue				*m_pRenderQueue;
	
	CHttpDownloader				*m_pTestDownloader;

private:
	void						DebugThink();
	void						ReplayThink();

	bool						m_bClientSideReplayDisabled;
};

//----------------------------------------------------------------------------------------

extern CClientReplayContext *g_pClientReplayContextInternal;

//----------------------------------------------------------------------------------------

//
// Helpers
//
inline const char *CL_GetBasePath()
{
	return g_pClientReplayContextInternal->m_pShared->m_strBasePath;
}

inline const char *CL_GetRelativeBasePath()
{
	return g_pClientReplayContextInternal->m_pShared->m_strRelativeBasePath.Get();
}

inline CReplayManager *CL_GetReplayManager()
{
	return g_pClientReplayContextInternal->m_pReplayManager;
}

inline CClientRecordingSessionBlockManager *CL_GetRecordingSessionBlockManager()
{
	return static_cast< CClientRecordingSessionBlockManager * >( g_pClientReplayContextInternal->GetRecordingSessionBlockManager() );
}

inline CScreenshotManager *CL_GetScreenshotManager()
{
	return g_pClientReplayContextInternal->m_pScreenshotManager;
}

inline IReplayMovieRenderer *CL_GetMovieRenderer()
{
	return g_pClientReplayContextInternal->m_pMovieRenderer;
}

inline CReplayMovieManager *CL_GetMovieManager()
{
	return g_pClientReplayContextInternal->m_pMovieManager;
}

inline const char *CL_GetReplayBaseDir()
{
	return g_pClientReplayContextInternal->m_pShared->m_strBasePath;
}

inline CErrorSystem *CL_GetErrorSystem()
{
	return g_pClientReplayContextInternal->m_pShared->m_pErrorSystem;
}

inline CSessionBlockDownloader *CL_GetSessionBlockDownloader()
{
	return g_pClientReplayContextInternal->m_pSessionBlockDownloader;
}

inline CReplayPerformanceManager *CL_GetPerformanceManager()
{
	return g_pClientReplayContextInternal->m_pPerformanceManager;
}

inline CPerformanceController *CL_GetPerformanceController()
{
	return g_pClientReplayContextInternal->m_pPerformanceController;
}

inline IThreadPool *CL_GetThreadPool()
{
	return g_pClientReplayContextInternal->m_pShared->m_pThreadPool;
}

inline CRenderQueue *CL_GetRenderQueue()
{
	return g_pClientReplayContextInternal->m_pRenderQueue;
}

//----------------------------------------------------------------------------------------

CClientRecordingSessionManager *CL_GetRecordingSessionManager();
CClientRecordingSession *CL_GetRecordingSessionInProgress();

//----------------------------------------------------------------------------------------

#endif	// CL_REPLAYCONTEXT_H