summaryrefslogtreecommitdiff
path: root/engine/cl_demouipanel.h
blob: 814669a4cde1e2406e206e822f585eca2115b7ad (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

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

#include <vgui_controls/Frame.h>


namespace vgui
{
class Button;
class CheckButton;
class Label;
class ProgressBar;
class FileOpenDialog;
class Slider;
};

class CDemoEditorPanel;
class CDemoSmootherPanel;

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CDemoUIPanel : public vgui::Frame
{
	DECLARE_CLASS_SIMPLE( CDemoUIPanel, vgui::Frame );

public:
	CDemoUIPanel( vgui::Panel *parent );
	~CDemoUIPanel();

	virtual void OnTick();

	// Command issued
	virtual void OnCommand(const char *command);
	virtual void OnMessage(const KeyValues *params,  vgui::VPANEL fromPanel);

	virtual void	OnVDMChanged( void );

	virtual bool	OverrideView( democmdinfo_t& info, int frame );
    virtual void	DrawDebuggingInfo();

	static	void	InstallDemoUI( vgui::Panel *parent );

			bool	IsInDriveMode();
			void	SetDriveViewPoint( Vector &origin, QAngle &angle );
			void	GetDriveViewPoint( Vector &origin, QAngle &angle );

protected:
	
	void			HandleInput( bool active );
	bool			IsHoldingFastForward();
	void			SetPlaybackScale( float scale );
	float			GetPlaybackScale();
	void			GetCurrentView();

	MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );

	void		OnEdit();
	void		OnSmooth();
	void		OnLoad();
	
	vgui::Label		*m_pCurrentDemo;
	vgui::Button	*m_pStop;
	vgui::Button	*m_pLoad;

	// special editor buttons
	vgui::Button	*m_pEdit;
	vgui::Button	*m_pSmooth;
	vgui::Button	*m_pDriveCamera;

	// player controls
	vgui::Button	*m_pPlayPauseResume;
	vgui::Button	*m_pGoStart;
	vgui::Button	*m_pGoEnd;
	vgui::Button	*m_pFastForward;
	vgui::Button	*m_pFastBackward;
	vgui::Button	*m_pPrevFrame;
	vgui::Button	*m_pNextFrame;

	vgui::ProgressBar *m_pProgress;
	vgui::Label	*m_pProgressLabelFrame;
	vgui::Label	*m_pProgressLabelTime;

	vgui::Slider *m_pSpeedScale;
	vgui::Label	*m_pSpeedScaleLabel;

	vgui::DHANDLE< CDemoEditorPanel > m_hDemoEditor;
	vgui::DHANDLE< CDemoSmootherPanel > m_hDemoSmoother;
	vgui::DHANDLE< vgui::FileOpenDialog > m_hFileOpenDialog;

	vgui::Button	*m_pGo;
	vgui::TextEntry *m_pGotoTick;

	bool		m_bInputActive;
	int			m_nOldCursor[2];
	Vector		m_ViewOrigin;
	QAngle		m_ViewAngles;
};

extern CDemoUIPanel *g_pDemoUI;

//-----------------------------------------------------------------------------
// Purpose: a special demo UI panel that is always visible allowing you
// to interact with the game and adding more features to the old
// demo UI panel.
//-----------------------------------------------------------------------------
class CDemoUIPanel2 : public vgui::Frame
{
	DECLARE_CLASS_SIMPLE( CDemoUIPanel2, vgui::Frame );

public:
	CDemoUIPanel2( vgui::Panel *pParentBkgnd, vgui::Panel *pParentFgnd, bool bPutToForeground );
	~CDemoUIPanel2();

	virtual void OnTick();

	// Command issued
	virtual void OnCommand(const char *command);
	virtual void OnMessage(const KeyValues *params,  vgui::VPANEL fromPanel);

	virtual void	OnVDMChanged( void );

	virtual bool	OverrideView( democmdinfo_t& info, int frame );
	virtual void	DrawDebuggingInfo();

	static	void	Install( vgui::Panel *pParentBkgnd, vgui::Panel *pParentFgnd, bool bPutToForeground );

	bool	IsInDriveMode();
	void	SetDriveViewPoint( Vector &origin, QAngle &angle );
	void	GetDriveViewPoint( Vector &origin, QAngle &angle );

	void	MakePanelForeground( bool bPutToForeground );

protected:

	void			HandleInput( bool active );
	bool			IsHoldingFastForward();
	void			SetPlaybackScale( float scale );
	float			GetPlaybackScale();

	MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );

	void		OnLoad();

	vgui::Button	*m_pStop;
	vgui::Button	*m_pLoad;

	// player controls
	vgui::Button	*m_pPlayPauseResume;
	vgui::Button	*m_pGoStart;
	vgui::Button	*m_pGoEnd;
	vgui::Button	*m_pFastForward;
	vgui::Button	*m_pFastBackward;
	vgui::Button	*m_pPrevFrame;
	vgui::Button	*m_pNextFrame;

	vgui::Slider *m_pProgress;
	vgui::Label	*m_pProgressLabelFrame;
	vgui::Label	*m_pProgressLabelTime;

	vgui::Slider *m_pSpeedScale;
	vgui::Label	*m_pSpeedScaleLabel;

	vgui::DHANDLE< vgui::FileOpenDialog > m_hFileOpenDialog;

	bool		m_bInputActive;
	int			m_nOldCursor[2];

	// Bkgnd-fgnd switch
	vgui::Panel *m_arrParents[2];
	bool		m_bIsInForeground;
};

extern CDemoUIPanel2 *g_pDemoUI2;


#endif // CL_DEMOUIPANEL_H