summaryrefslogtreecommitdiff
path: root/game/client/tf/tf_demo_support.h
blob: c122202d66687ba2b2cd03d83c5c6779a6a3170f (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $Revision: $
// $NoKeywords: $
//=============================================================================//

#ifndef TF_DEMO_SUPPORT_H
#define TF_DEMO_SUPPORT_H

#define EVENTS_FILENAME "_events.txt"

enum EDemoEventType
{
	eDemoEvent_Bookmark,
	eDemoEvent_Killstreak,

	// also need to update g_aDemoEventNames
	eDemoEvent_Last,
};

struct DemoEvent_t
{
	EDemoEventType type;
	int value;
	int tick;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CTFDemoSupport : public CAutoGameSystemPerFrame, public CGameEventListener
{
public:
	CTFDemoSupport();

	virtual bool Init() OVERRIDE;
	virtual void Update( float frametime ) OVERRIDE;
	virtual char const *Name() OVERRIDE { return "CTFDemoSupport"; }
	virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
	virtual void LevelInitPostEntity() OVERRIDE;
	virtual void LevelShutdownPostEntity() OVERRIDE;
	bool StartRecording( void );
	void StopRecording( bool bFromEngine = false );
	bool IsRecording( void ){ return m_bRecording; }
	void BookMarkCurrentTick( const char *pszValue = NULL );
	void Status( void );

private:
	bool IsValidPath( const char *pszFolder );
	void LogEvent( EDemoEventType eType, int nValue = 0, const char *pszValue = NULL );
	void Notify( char *pszMessage );

	bool m_bRecording;
	char m_szFolder[24];
	char m_szFilename[MAX_PATH];
	char m_szFolderAndFilename[MAX_PATH];
	int m_nKillCount;
	float m_flLastKill;
	float m_flScreenshotTime;
	FileHandle_t m_hGlobalEventList;
	GCSDK::CWebAPIResponse m_DemoSpecificEventList;
	GCSDK::CWebAPIValues *m_pRoot;
	GCSDK::CWebAPIValues *m_pChildArray;
	bool m_bAlreadyAutoRecordedOnce;
	float m_flNextRecordStartCheckTime;
	bool m_bFirstEvent;
	int m_nStartingTickCount;
	bool m_bHasAtLeastOneEvent;
};

#endif // TF_DEMO_SUPPORT_H