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.

462 lines
15 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef REPLAYBROWSER_DETAILSPANEL_H
  8. #define REPLAYBROWSER_DETAILSPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <game/client/iviewport.h>
  13. #include "vgui_controls/EditablePanel.h"
  14. #include "vgui_controls/ScrollableEditablePanel.h"
  15. #include "replay/iqueryablereplayitem.h"
  16. #include "replay/ireplaymovie.h"
  17. #include "replay/replayhandle.h"
  18. #include "replay/gamedefs.h"
  19. #include "econ/econ_controls.h"
  20. using namespace vgui;
  21. //-----------------------------------------------------------------------------
  22. #define NUM_CLASSES_IN_LOADOUT_PANEL (TF_LAST_NORMAL_CLASS-1) // We don't allow unlockables for the civilian
  23. //-----------------------------------------------------------------------------
  24. // Purpose: Forward declarations
  25. //-----------------------------------------------------------------------------
  26. class CExLabel;
  27. class CExButton;
  28. class CTFReplay;
  29. class CReplayPerformance;
  30. class IReplayItemManager;
  31. //-----------------------------------------------------------------------------
  32. // Purpose: A panel containing 2 labels: one key, one value
  33. //-----------------------------------------------------------------------------
  34. class CKeyValueLabelPanel : public EditablePanel
  35. {
  36. DECLARE_CLASS_SIMPLE( CKeyValueLabelPanel, EditablePanel );
  37. public:
  38. CKeyValueLabelPanel( Panel *pParent, const char *pKey, const char *pValue );
  39. CKeyValueLabelPanel( Panel *pParent, const char *pKey, const wchar_t *pValue );
  40. virtual void ApplySchemeSettings( IScheme *pScheme );
  41. virtual void PerformLayout();
  42. int GetHeight() const;
  43. int GetValueHeight() const;
  44. void SetValue( const wchar_t *pValue );
  45. private:
  46. CExLabel *m_pLabels[2];
  47. };
  48. //-----------------------------------------------------------------------------
  49. // Purpose: Base details panel with left/top padding and black border
  50. //-----------------------------------------------------------------------------
  51. class CBaseDetailsPanel : public EditablePanel
  52. {
  53. DECLARE_CLASS_SIMPLE( CBaseDetailsPanel, EditablePanel );
  54. public:
  55. CBaseDetailsPanel( Panel *pParent, const char *pName, ReplayHandle_t hReplay );
  56. virtual void ApplySchemeSettings( IScheme *pScheme );
  57. virtual void PerformLayout();
  58. int GetMarginSize() const { return XRES(6); }
  59. bool ShouldShow() const { return m_bShouldShow; }
  60. protected:
  61. EditablePanel *GetInset() { return m_pInsetPanel; }
  62. ReplayHandle_t m_hReplay;
  63. bool m_bShouldShow;
  64. private:
  65. EditablePanel *m_pInsetPanel; // padding on left/top
  66. };
  67. //-----------------------------------------------------------------------------
  68. // Purpose: Score panel - contains score & any records from the round
  69. //-----------------------------------------------------------------------------
  70. class CRecordsPanel : public CBaseDetailsPanel
  71. {
  72. DECLARE_CLASS_SIMPLE( CRecordsPanel, CBaseDetailsPanel );
  73. public:
  74. CRecordsPanel( Panel *pParent, ReplayHandle_t hReplay );
  75. virtual void ApplySchemeSettings( IScheme *pScheme );
  76. virtual void PerformLayout();
  77. private:
  78. ImagePanel *m_pClassImage;
  79. };
  80. //-----------------------------------------------------------------------------
  81. // Purpose: Stats panel
  82. //-----------------------------------------------------------------------------
  83. class CStatsPanel : public CBaseDetailsPanel
  84. {
  85. DECLARE_CLASS_SIMPLE( CStatsPanel, CBaseDetailsPanel );
  86. public:
  87. CStatsPanel( Panel *pParent, ReplayHandle_t hReplay );
  88. virtual void ApplySchemeSettings( IScheme *pScheme );
  89. virtual void PerformLayout();
  90. private:
  91. CKeyValueLabelPanel *m_paStatLabels[ REPLAY_MAX_DISPLAY_GAMESTATS ];
  92. };
  93. //-----------------------------------------------------------------------------
  94. // Purpose: Dominations panel
  95. //-----------------------------------------------------------------------------
  96. class CDominationsPanel : public CBaseDetailsPanel
  97. {
  98. DECLARE_CLASS_SIMPLE( CDominationsPanel, CBaseDetailsPanel );
  99. public:
  100. CDominationsPanel( Panel *pParent, ReplayHandle_t hReplay );
  101. virtual void ApplySchemeSettings( IScheme *pScheme );
  102. virtual void PerformLayout();
  103. ImagePanel *m_pNumDominationsImage;
  104. CUtlVector< ImagePanel * > m_vecDominationImages;
  105. };
  106. //-----------------------------------------------------------------------------
  107. // Purpose: Kills panel
  108. //-----------------------------------------------------------------------------
  109. class CKillsPanel : public CBaseDetailsPanel
  110. {
  111. DECLARE_CLASS_SIMPLE( CKillsPanel, CBaseDetailsPanel );
  112. public:
  113. CKillsPanel( Panel *pParent, ReplayHandle_t hReplay );
  114. virtual void ApplySchemeSettings( IScheme *pScheme );
  115. virtual void PerformLayout();
  116. CKeyValueLabelPanel *m_pKillLabels;
  117. CUtlVector< ImagePanel * > m_vecKillImages;
  118. };
  119. //-----------------------------------------------------------------------------
  120. // Purpose:
  121. //-----------------------------------------------------------------------------
  122. class CBasicLifeInfoPanel : public CBaseDetailsPanel
  123. {
  124. DECLARE_CLASS_SIMPLE( CBasicLifeInfoPanel, CBaseDetailsPanel );
  125. public:
  126. CBasicLifeInfoPanel( Panel *pParent, ReplayHandle_t hReplay );
  127. virtual void ApplySchemeSettings( IScheme *pScheme );
  128. virtual void PerformLayout();
  129. private:
  130. CKeyValueLabelPanel *m_pKilledByLabels;
  131. CKeyValueLabelPanel *m_pMapLabels;
  132. CKeyValueLabelPanel *m_pLifeLabels;
  133. };
  134. //-----------------------------------------------------------------------------
  135. // Purpose:
  136. //-----------------------------------------------------------------------------
  137. class CMovieInfoPanel : public CBaseDetailsPanel
  138. {
  139. DECLARE_CLASS_SIMPLE( CMovieInfoPanel, CBaseDetailsPanel );
  140. public:
  141. CMovieInfoPanel( Panel *pParent, ReplayHandle_t hReplay, QueryableReplayItemHandle_t hMovie,
  142. IReplayItemManager *pItemManager );
  143. virtual void ApplySchemeSettings( IScheme *pScheme );
  144. virtual void PerformLayout();
  145. private:
  146. CKeyValueLabelPanel *m_pRenderTimeLabels;
  147. };
  148. //-----------------------------------------------------------------------------
  149. // Purpose:
  150. //-----------------------------------------------------------------------------
  151. class CYouTubeInfoPanel : public CBaseDetailsPanel
  152. {
  153. DECLARE_CLASS_SIMPLE( CYouTubeInfoPanel, CBaseDetailsPanel );
  154. public:
  155. CYouTubeInfoPanel( Panel *pParent );
  156. virtual void PerformLayout();
  157. void SetInfo( const wchar_t *pInfo );
  158. private:
  159. CKeyValueLabelPanel *m_pLabels;
  160. };
  161. //-----------------------------------------------------------------------------
  162. // Purpose:
  163. //-----------------------------------------------------------------------------
  164. class CTitleEditPanel : public EditablePanel
  165. {
  166. DECLARE_CLASS_SIMPLE( CTitleEditPanel, EditablePanel );
  167. public:
  168. CTitleEditPanel( Panel *pParent, QueryableReplayItemHandle_t hReplayItem, IReplayItemManager *pItemManager );
  169. ~CTitleEditPanel();
  170. virtual void ApplySchemeSettings( IScheme *pScheme );
  171. virtual void PerformLayout();
  172. virtual void PaintBackground();
  173. virtual void OnKeyCodeTyped(vgui::KeyCode code);
  174. virtual void OnTick();
  175. bool m_bMouseOver;
  176. TextEntry *m_pTitleEntry;
  177. ImagePanel *m_pHeaderLine;
  178. CExLabel *m_pClickToEditLabel;
  179. CExLabel *m_pCaratLabel;
  180. QueryableReplayItemHandle_t m_hReplayItem;
  181. IReplayItemManager *m_pItemManager;
  182. };
  183. //-----------------------------------------------------------------------------
  184. // Purpose:
  185. //-----------------------------------------------------------------------------
  186. class CReplayScreenshotSlideshowPanel;
  187. class CPlaybackPanel : public EditablePanel
  188. {
  189. DECLARE_CLASS_SIMPLE( CPlaybackPanel, EditablePanel );
  190. public:
  191. CPlaybackPanel( Panel *pParent );
  192. ~CPlaybackPanel();
  193. virtual void FreeMovieMaterial() {}
  194. protected:
  195. virtual void ApplySchemeSettings( IScheme *pScheme );
  196. virtual void PerformLayout();
  197. inline int GetMarginSize() { return 9; }
  198. inline int GetViewWidth() { return GetWide() - 2 * GetMarginSize(); }
  199. inline int GetViewHeight() { return GetTall() - 2 * GetMarginSize(); }
  200. };
  201. //-----------------------------------------------------------------------------
  202. // Purpose:
  203. //-----------------------------------------------------------------------------
  204. class CPlaybackPanelSlideshow : public CPlaybackPanel
  205. {
  206. DECLARE_CLASS_SIMPLE( CPlaybackPanelSlideshow, CPlaybackPanel );
  207. public:
  208. CPlaybackPanelSlideshow( Panel *pParent, ReplayHandle_t hReplay );
  209. virtual void ApplySchemeSettings( IScheme *pScheme );
  210. virtual void PerformLayout();
  211. private:
  212. ReplayHandle_t m_hReplay;
  213. CExLabel *m_pNoScreenshotLabel;
  214. CReplayScreenshotSlideshowPanel *m_pScreenshotImage;
  215. };
  216. //-----------------------------------------------------------------------------
  217. // Purpose:
  218. //-----------------------------------------------------------------------------
  219. class CMoviePlayerPanel;
  220. class CPlaybackPanelMovie : public CPlaybackPanel
  221. {
  222. DECLARE_CLASS_SIMPLE( CPlaybackPanelMovie, CPlaybackPanel );
  223. public:
  224. CPlaybackPanelMovie( Panel *pParent, ReplayHandle_t hReplay );
  225. virtual void ApplySchemeSettings( IScheme *pScheme );
  226. virtual void PerformLayout();
  227. virtual void FreeMovieMaterial();
  228. private:
  229. CExLabel *m_pLoadingLabel;
  230. CMoviePlayerPanel *m_pMoviePlayerPanel;
  231. ReplayHandle_t m_hMovie;
  232. };
  233. //-----------------------------------------------------------------------------
  234. // Purpose:
  235. //-----------------------------------------------------------------------------
  236. class CCutImagePanel : public CExImageButton
  237. {
  238. DECLARE_CLASS_SIMPLE( CCutImagePanel, CExImageButton );
  239. public:
  240. CCutImagePanel( Panel *pParent, const char *pName );
  241. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  242. virtual void SetSelected( bool bState );
  243. private:
  244. virtual IBorder *GetBorder( bool bDepressed, bool bArmed, bool bSelected, bool bKeyFocus );
  245. IBorder *m_pSelectedBorder;
  246. };
  247. //-----------------------------------------------------------------------------
  248. // Purpose:
  249. //-----------------------------------------------------------------------------
  250. class CReplayDetailsPanel;
  251. class CCutsPanel : public CBaseDetailsPanel
  252. {
  253. DECLARE_CLASS_SIMPLE( CCutsPanel, CBaseDetailsPanel );
  254. public:
  255. CCutsPanel( Panel *pParent, ReplayHandle_t hReplay, int iPerformance );
  256. ~CCutsPanel();
  257. virtual void ApplySchemeSettings( IScheme *pScheme );
  258. virtual void PerformLayout();
  259. virtual void OnCommand( const char *pCommand );
  260. virtual void ApplySettings( KeyValues *pInResourceData );
  261. void OnPerformanceDeleted( int iPerformance );
  262. CPanelAnimationVarAliasType( int, m_nCutButtonWidth, "cut_button_width", "0", "proportional_xpos" );
  263. CPanelAnimationVarAliasType( int, m_nCutButtonHeight, "cut_button_height", "0", "proportional_ypos" );
  264. CPanelAnimationVarAliasType( int, m_nCutButtonBuffer, "cut_button_buffer", "0", "proportional_xpos" );
  265. CPanelAnimationVarAliasType( int, m_nCutButtonSpace, "cut_button_space", "0", "proportional_xpos" );
  266. CPanelAnimationVarAliasType( int, m_nCutButtonSpaceWide, "cut_button_space_wide", "0", "proportional_xpos" );
  267. CPanelAnimationVarAliasType( int, m_nTopMarginHeight, "top_margin_height", "0", "proportional_ypos" );
  268. CPanelAnimationVarAliasType( int, m_nNameLabelTopMargin, "name_label_top_margin", "0", "proportional_ypos" );
  269. CPanelAnimationVarAliasType( int, m_nButtonStartY, "button_start_y", "0", "proportional_ypos" );
  270. void UpdateNameLabel( int iPerformance );
  271. private:
  272. void SelectButtonFromPerformance( int iPerformance );
  273. void SetPage( int iPage, int iButtonToSelect = 0 );
  274. int ButtonToPerformance( int iButton ) const;
  275. int PerformanceToButton( int iPerformance ) const;
  276. const CReplayPerformance *GetPerformance( int iPerformance ) const;
  277. virtual void OnTick();
  278. struct ButtonInfo_t
  279. {
  280. CExImageButton *m_pButton;
  281. CExButton *m_pAddToRenderQueueButton;
  282. int m_iPerformance;
  283. };
  284. enum Consts_t
  285. {
  286. BUTTONS_PER_PAGE = 4
  287. };
  288. ButtonInfo_t m_aButtons[ BUTTONS_PER_PAGE ];
  289. EditablePanel *m_pVerticalLine;
  290. CExLabel *m_pNoCutsLabel;
  291. CExLabel *m_pOriginalLabel;
  292. CExLabel *m_pCutsLabel;
  293. CExLabel *m_pNameLabel;
  294. CExButton *m_pPrevButton;
  295. CExButton *m_pNextButton;
  296. int m_iPage;
  297. int m_nVisibleButtons;
  298. vgui::DHANDLE< CReplayDetailsPanel > m_hDetailsPanel;
  299. };
  300. //-----------------------------------------------------------------------------
  301. // Purpose:
  302. //-----------------------------------------------------------------------------
  303. class IReplayItemManager;
  304. class CConfirmDialog;
  305. class CYouTubeGetStatsHandler;
  306. class CReplayDetailsPanel : public EditablePanel
  307. {
  308. DECLARE_CLASS_SIMPLE( CReplayDetailsPanel, EditablePanel );
  309. public:
  310. CReplayDetailsPanel( Panel *pParent, QueryableReplayItemHandle_t hReplayItem, int iPerformance, IReplayItemManager *pItemManager );
  311. ~CReplayDetailsPanel();
  312. virtual void ApplySchemeSettings( IScheme *pScheme );
  313. virtual void PerformLayout();
  314. virtual void OnMousePressed( MouseCode code );
  315. virtual void OnKeyCodeTyped( KeyCode code );
  316. virtual void OnCommand( const char *pCommand );
  317. virtual void OnMessage( const KeyValues* pParams, VPANEL hFromPanel );
  318. EditablePanel *GetInset() { return m_pInsetPanel; }
  319. void ShowRenderDialog();
  320. void FreeMovieFileLock();
  321. void ShowExportDialog();
  322. static void OnPlayerWarningDlgConfirm( bool bConfirmed, void *pContext );
  323. enum eYouTubeStatus
  324. {
  325. kYouTubeStatus_Private,
  326. kYouTubeStatus_RetrievingInfo,
  327. kYouTubeStatus_RetrievedInfo,
  328. kYouTubeStatus_CouldNotRetrieveInfo,
  329. kYouTubeStatus_NotUploaded
  330. };
  331. void SetYouTubeStatus( eYouTubeStatus status );
  332. EditablePanel *m_pInsetPanel; // Parent to most child panels listed here - narrower than screen width
  333. EditablePanel *m_pInfoPanel; // Container for info panels
  334. ScrollableEditablePanel *m_pScrollPanel;
  335. CPlaybackPanel *m_pPlaybackPanel; // Contains screenshot, playback button
  336. CRecordsPanel *m_pRecordsPanel; // Contains score, records
  337. CStatsPanel *m_pStatsPanel; // Contains stats
  338. CDominationsPanel *m_pDominationsPanel; // Dominations
  339. CBasicLifeInfoPanel *m_pBasicInfoPanel; // Killed by, map, life
  340. CKillsPanel *m_pKillsPanel; // # kills, kill class icons
  341. CYouTubeInfoPanel *m_pYouTubeInfoPanel; // YouTube Info
  342. CCutsPanel *m_pCutsPanel; // Buttons for performances
  343. CUtlVector< CBaseDetailsPanel* > m_vecInfoPanels; // List of panels on the right
  344. CTitleEditPanel *m_pTitleEditPanel;
  345. CExButton *m_pBackButton;
  346. CExButton *m_pDeleteButton;
  347. CExButton *m_pRenderButton;
  348. CExButton *m_pPlayButton;
  349. CExButton *m_pExportMovie;
  350. CExButton *m_pYouTubeUpload;
  351. CExButton *m_pYouTubeView;
  352. CExButton *m_pYouTubeShareURL;
  353. CExImageButton *m_pShowRenderInfoButton;
  354. QueryableReplayItemHandle_t m_hReplayItem;
  355. ReplayHandle_t m_hReplay;
  356. IReplayItemManager *m_pItemManager;
  357. int m_iSelectedPerformance; // Which performance to play/render/delete
  358. CYouTubeGetStatsHandler *m_pYouTubeResponseHandler;
  359. vgui::FileOpenDialog *m_hExportMovieDialog;
  360. private:
  361. void ShowRenderInfo();
  362. MESSAGE_FUNC_PARAMS( OnConfirmDisconnect, "ConfirmDlgResult", data );
  363. MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );
  364. CPanelAnimationVarAliasType( int, m_nMarginWidth, "margin_width", "0", "proportional_xpos" );
  365. void GoBack();
  366. void ShowPlayConfirmationDialog();
  367. };
  368. #endif // REPLAYBROWSER_DETAILSPANEL_H