aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/replay/vgui/replaybrowserdetailspanel.h
blob: 5a75ae8818a31b620a1df0f0d48a0ae44a1c00e1 (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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

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

#include <game/client/iviewport.h>
#include "vgui_controls/EditablePanel.h"
#include "vgui_controls/ScrollableEditablePanel.h"
#include "replay/iqueryablereplayitem.h"
#include "replay/ireplaymovie.h"
#include "replay/replayhandle.h"
#include "replay/gamedefs.h"
#include "econ/econ_controls.h"

using namespace vgui;

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

#define NUM_CLASSES_IN_LOADOUT_PANEL		(TF_LAST_NORMAL_CLASS-1)		// We don't allow unlockables for the civilian

//-----------------------------------------------------------------------------
// Purpose: Forward declarations
//-----------------------------------------------------------------------------
class CExLabel;
class CExButton;
class CTFReplay;
class CReplayPerformance; 
class IReplayItemManager;

//-----------------------------------------------------------------------------
// Purpose: A panel containing 2 labels: one key, one value
//-----------------------------------------------------------------------------
class CKeyValueLabelPanel : public EditablePanel
{
	DECLARE_CLASS_SIMPLE( CKeyValueLabelPanel, EditablePanel );
public:
	CKeyValueLabelPanel( Panel *pParent, const char *pKey, const char *pValue );
	CKeyValueLabelPanel( Panel *pParent, const char *pKey, const wchar_t *pValue );
	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

	int GetHeight() const;
	int GetValueHeight() const;

	void SetValue( const wchar_t *pValue );

private:
	CExLabel		*m_pLabels[2];
};

//-----------------------------------------------------------------------------
// Purpose: Base details panel with left/top padding and black border
//-----------------------------------------------------------------------------
class CBaseDetailsPanel : public EditablePanel
{
	DECLARE_CLASS_SIMPLE( CBaseDetailsPanel, EditablePanel );
public:
	CBaseDetailsPanel( Panel *pParent, const char *pName, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

	int GetMarginSize() const { return XRES(6); }

	bool ShouldShow() const { return m_bShouldShow; }

protected:
	EditablePanel *GetInset() { return m_pInsetPanel; }

	ReplayHandle_t	m_hReplay;
	bool m_bShouldShow;

private:
	EditablePanel	*m_pInsetPanel;		// padding on left/top
};

//-----------------------------------------------------------------------------
// Purpose: Score panel - contains score & any records from the round
//-----------------------------------------------------------------------------
class CRecordsPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CRecordsPanel, CBaseDetailsPanel );
public:
	CRecordsPanel( Panel *pParent, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

private:
	ImagePanel	*m_pClassImage;
};

//-----------------------------------------------------------------------------
// Purpose: Stats panel
//-----------------------------------------------------------------------------
class CStatsPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CStatsPanel, CBaseDetailsPanel );
public:
	CStatsPanel( Panel *pParent, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

private:
	CKeyValueLabelPanel	*m_paStatLabels[ REPLAY_MAX_DISPLAY_GAMESTATS ];
};


//-----------------------------------------------------------------------------
// Purpose: Dominations panel
//-----------------------------------------------------------------------------
class CDominationsPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CDominationsPanel, CBaseDetailsPanel );
public:
	CDominationsPanel( Panel *pParent, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

	ImagePanel			*m_pNumDominationsImage;
	CUtlVector< ImagePanel * > m_vecDominationImages;
};


//-----------------------------------------------------------------------------
// Purpose: Kills panel
//-----------------------------------------------------------------------------
class CKillsPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CKillsPanel, CBaseDetailsPanel );
public:
	CKillsPanel( Panel *pParent, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

	CKeyValueLabelPanel *m_pKillLabels;
	CUtlVector< ImagePanel * > m_vecKillImages;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CBasicLifeInfoPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CBasicLifeInfoPanel, CBaseDetailsPanel );
public:
	CBasicLifeInfoPanel( Panel *pParent, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

private:
	CKeyValueLabelPanel		*m_pKilledByLabels;
	CKeyValueLabelPanel		*m_pMapLabels;
	CKeyValueLabelPanel		*m_pLifeLabels;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CMovieInfoPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CMovieInfoPanel, CBaseDetailsPanel );
public:
	CMovieInfoPanel( Panel *pParent, ReplayHandle_t hReplay, QueryableReplayItemHandle_t hMovie,
		IReplayItemManager *pItemManager );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

private:
	CKeyValueLabelPanel		*m_pRenderTimeLabels;
};


//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CYouTubeInfoPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CYouTubeInfoPanel, CBaseDetailsPanel );
public:
	CYouTubeInfoPanel( Panel *pParent );

	virtual void PerformLayout();

	void SetInfo( const wchar_t *pInfo );

private:
	CKeyValueLabelPanel		*m_pLabels;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CTitleEditPanel : public EditablePanel
{
	DECLARE_CLASS_SIMPLE( CTitleEditPanel, EditablePanel );
public:
	CTitleEditPanel( Panel *pParent, QueryableReplayItemHandle_t hReplayItem, IReplayItemManager *pItemManager );
	~CTitleEditPanel();
	
	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();
	virtual void PaintBackground();

	virtual void OnKeyCodeTyped(vgui::KeyCode code);

	virtual void OnTick();

	bool			m_bMouseOver;
	TextEntry		*m_pTitleEntry;
	ImagePanel		*m_pHeaderLine;
	CExLabel		*m_pClickToEditLabel;
	CExLabel		*m_pCaratLabel;
	QueryableReplayItemHandle_t	m_hReplayItem;
	IReplayItemManager	*m_pItemManager;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CReplayScreenshotSlideshowPanel;

class CPlaybackPanel : public EditablePanel
{
	DECLARE_CLASS_SIMPLE( CPlaybackPanel, EditablePanel );
public:
	CPlaybackPanel( Panel *pParent );
	~CPlaybackPanel();

	virtual void FreeMovieMaterial() {}

protected:
	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

	inline int GetMarginSize()			{ return 9; }
	inline int GetViewWidth()			{ return GetWide() - 2 * GetMarginSize(); }
	inline int GetViewHeight()			{ return GetTall() - 2 * GetMarginSize(); }
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CPlaybackPanelSlideshow : public CPlaybackPanel
{
	DECLARE_CLASS_SIMPLE( CPlaybackPanelSlideshow, CPlaybackPanel );
public:
	CPlaybackPanelSlideshow( Panel *pParent, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

private:
	ReplayHandle_t						m_hReplay;
	CExLabel							*m_pNoScreenshotLabel;
	CReplayScreenshotSlideshowPanel		*m_pScreenshotImage;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CMoviePlayerPanel;

class CPlaybackPanelMovie : public CPlaybackPanel
{
	DECLARE_CLASS_SIMPLE( CPlaybackPanelMovie, CPlaybackPanel );
public:
	CPlaybackPanelMovie( Panel *pParent, ReplayHandle_t hReplay );

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

	virtual void FreeMovieMaterial();

private:
	CExLabel			*m_pLoadingLabel;
	CMoviePlayerPanel	*m_pMoviePlayerPanel;
	ReplayHandle_t		m_hMovie;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CCutImagePanel : public CExImageButton
{
	DECLARE_CLASS_SIMPLE( CCutImagePanel, CExImageButton );
public:
	CCutImagePanel( Panel *pParent, const char *pName );

	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );

	virtual void SetSelected( bool bState );

private:
	virtual IBorder *GetBorder( bool bDepressed, bool bArmed, bool bSelected, bool bKeyFocus );

	IBorder		*m_pSelectedBorder;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CReplayDetailsPanel;

class CCutsPanel : public CBaseDetailsPanel
{
	DECLARE_CLASS_SIMPLE( CCutsPanel, CBaseDetailsPanel );
public:
	CCutsPanel( Panel *pParent, ReplayHandle_t hReplay, int iPerformance );
	~CCutsPanel();

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();
	virtual void OnCommand( const char *pCommand );
	virtual void ApplySettings( KeyValues *pInResourceData );

	void OnPerformanceDeleted( int iPerformance );

	CPanelAnimationVarAliasType( int, m_nCutButtonWidth, "cut_button_width", "0", "proportional_xpos" );
	CPanelAnimationVarAliasType( int, m_nCutButtonHeight, "cut_button_height", "0", "proportional_ypos" );
	CPanelAnimationVarAliasType( int, m_nCutButtonBuffer, "cut_button_buffer", "0", "proportional_xpos" );
	CPanelAnimationVarAliasType( int, m_nCutButtonSpace, "cut_button_space", "0", "proportional_xpos" );
	CPanelAnimationVarAliasType( int, m_nCutButtonSpaceWide, "cut_button_space_wide", "0", "proportional_xpos" );
	CPanelAnimationVarAliasType( int, m_nTopMarginHeight, "top_margin_height", "0", "proportional_ypos" );
	CPanelAnimationVarAliasType( int, m_nNameLabelTopMargin, "name_label_top_margin", "0", "proportional_ypos" );
	CPanelAnimationVarAliasType( int, m_nButtonStartY, "button_start_y", "0", "proportional_ypos" );

	void UpdateNameLabel( int iPerformance );

private:
	void SelectButtonFromPerformance( int iPerformance );
	void SetPage( int iPage, int iButtonToSelect = 0 );
	int ButtonToPerformance( int iButton ) const;
	int PerformanceToButton( int iPerformance ) const;
	const CReplayPerformance *GetPerformance( int iPerformance ) const;

	virtual void OnTick();

	struct ButtonInfo_t
	{
		CExImageButton	*m_pButton;
		CExButton		*m_pAddToRenderQueueButton;
		int				m_iPerformance;
	};

	enum Consts_t
	{
		BUTTONS_PER_PAGE = 4
	};

	ButtonInfo_t					m_aButtons[ BUTTONS_PER_PAGE ];
	EditablePanel					*m_pVerticalLine;
	CExLabel						*m_pNoCutsLabel;
	CExLabel						*m_pOriginalLabel;
	CExLabel						*m_pCutsLabel;
	CExLabel						*m_pNameLabel;
	CExButton						*m_pPrevButton;
	CExButton						*m_pNextButton;
	int								m_iPage;
	int								m_nVisibleButtons;
	vgui::DHANDLE< CReplayDetailsPanel >	m_hDetailsPanel;
};

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class IReplayItemManager;
class CConfirmDialog;
class CYouTubeGetStatsHandler;

class CReplayDetailsPanel : public EditablePanel
{
	DECLARE_CLASS_SIMPLE( CReplayDetailsPanel, EditablePanel );
public:
	CReplayDetailsPanel( Panel *pParent, QueryableReplayItemHandle_t hReplayItem, int iPerformance, IReplayItemManager *pItemManager );
	~CReplayDetailsPanel();

	virtual void ApplySchemeSettings( IScheme *pScheme );
	virtual void PerformLayout();

	virtual void OnMousePressed( MouseCode code );
	virtual void OnKeyCodeTyped( KeyCode code );

	virtual void OnCommand( const char *pCommand );

	virtual void OnMessage( const KeyValues* pParams, VPANEL hFromPanel );

	EditablePanel *GetInset() { return m_pInsetPanel; }

	void ShowRenderDialog();
	void FreeMovieFileLock();
	void ShowExportDialog();

	static void	OnPlayerWarningDlgConfirm( bool bConfirmed, void *pContext );	

	enum eYouTubeStatus
	{
		kYouTubeStatus_Private,
		kYouTubeStatus_RetrievingInfo,
		kYouTubeStatus_RetrievedInfo,
		kYouTubeStatus_CouldNotRetrieveInfo,
		kYouTubeStatus_NotUploaded		
	};

	void SetYouTubeStatus( eYouTubeStatus status );

	EditablePanel		*m_pInsetPanel;				// Parent to most child panels listed here - narrower than screen width
	EditablePanel		*m_pInfoPanel;				// Container for info panels
	ScrollableEditablePanel *m_pScrollPanel;

	CPlaybackPanel		*m_pPlaybackPanel;			// Contains screenshot, playback button
	CRecordsPanel		*m_pRecordsPanel;				// Contains score, records
	CStatsPanel			*m_pStatsPanel;				// Contains stats
	CDominationsPanel	*m_pDominationsPanel;		// Dominations
	CBasicLifeInfoPanel *m_pBasicInfoPanel;			// Killed by, map, life
	CKillsPanel			*m_pKillsPanel;				// # kills, kill class icons
	CYouTubeInfoPanel	*m_pYouTubeInfoPanel;			// YouTube Info
	CCutsPanel			*m_pCutsPanel;				// Buttons for performances
	CUtlVector< CBaseDetailsPanel* >	m_vecInfoPanels;	// List of panels on the right
	CTitleEditPanel		*m_pTitleEditPanel;
	CExButton			*m_pBackButton;
	CExButton			*m_pDeleteButton;
	CExButton			*m_pRenderButton;
	CExButton			*m_pPlayButton;
	CExButton			*m_pExportMovie;
	CExButton			*m_pYouTubeUpload;
	CExButton			*m_pYouTubeView;
	CExButton			*m_pYouTubeShareURL;
	CExImageButton		*m_pShowRenderInfoButton;
	QueryableReplayItemHandle_t		m_hReplayItem;
	ReplayHandle_t		m_hReplay;
	IReplayItemManager	*m_pItemManager;
	int					m_iSelectedPerformance;		// Which performance to play/render/delete
	CYouTubeGetStatsHandler *m_pYouTubeResponseHandler;
	vgui::FileOpenDialog *m_hExportMovieDialog;

private:
	void ShowRenderInfo();

	MESSAGE_FUNC_PARAMS( OnConfirmDisconnect, "ConfirmDlgResult", data );
	MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );

	CPanelAnimationVarAliasType( int, m_nMarginWidth, "margin_width", "0", "proportional_xpos" );

	void GoBack();
	void ShowPlayConfirmationDialog();
};

#endif // REPLAYBROWSER_DETAILSPANEL_H