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.

239 lines
7.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef REPLAYLISTITEMPANEL_H
  5. #define REPLAYLISTITEMPANEL_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. #include "replaybrowserbasepanel.h"
  10. #include "replaybrowseritemmanager.h"
  11. #include "replay/genericclassbased_replay.h"
  12. #include "game_controls/slideshowpanel.h"
  13. using namespace vgui;
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Slideshow panel that adds all screenshots associated
  16. // with a given replay.
  17. //-----------------------------------------------------------------------------
  18. class CReplayScreenshotSlideshowPanel : public CSlideshowPanel
  19. {
  20. DECLARE_CLASS_SIMPLE( CReplayScreenshotSlideshowPanel, CSlideshowPanel );
  21. public:
  22. CReplayScreenshotSlideshowPanel( Panel *pParent, const char *pName, ReplayHandle_t hReplay );
  23. virtual void PerformLayout();
  24. private:
  25. ReplayHandle_t m_hReplay;
  26. };
  27. //-----------------------------------------------------------------------------
  28. // Purpose: An individual Replay thumbnail, with download button, title, etc.
  29. //-----------------------------------------------------------------------------
  30. class CExButton;
  31. class CExLabel;
  32. class IReplayItemManager;
  33. class CMoviePlayerPanel;
  34. class CReplayBrowserThumbnail : public CReplayBasePanel
  35. {
  36. DECLARE_CLASS_SIMPLE( CReplayBrowserThumbnail, CReplayBasePanel );
  37. public:
  38. CReplayBrowserThumbnail( Panel *pParent, const char *pName, QueryableReplayItemHandle_t hReplayItem, IReplayItemManager *pReplayItemManager );
  39. ~CReplayBrowserThumbnail();
  40. virtual void ApplySchemeSettings( IScheme *pScheme );
  41. virtual void PerformLayout();
  42. virtual void OnMousePressed( MouseCode code );
  43. virtual void OnTick();
  44. virtual void OnCommand( const char *pCommand );
  45. void UpdateTitleText();
  46. void SetReplayItem( QueryableReplayItemHandle_t hReplayItem );
  47. CGenericClassBasedReplay *GetReplay();
  48. IQueryableReplayItem *GetReplayItem();
  49. MESSAGE_FUNC_PARAMS( OnDownloadClicked, "Download", pParams );
  50. MESSAGE_FUNC_PARAMS( OnDeleteReplay, "delete_replayitem", pParams );
  51. CCrossfadableImagePanel *m_pScreenshotThumb;
  52. QueryableReplayItemHandle_t m_hReplayItem;
  53. private:
  54. void SetupReplayItemUserData( void *pUserData );
  55. void UpdateProgress( bool bDownloadPhase, const CReplay *pReplay );
  56. Label *m_pTitle;
  57. Label *m_pDownloadLabel;
  58. Label *m_pRecordingInProgressLabel;
  59. ProgressBar *m_pDownloadProgress;
  60. CExButton *m_pDownloadButton;
  61. CExButton *m_pDeleteButton;
  62. Label *m_pErrorLabel;
  63. CMoviePlayerPanel *m_pMoviePlayer;
  64. Panel *m_pDownloadOverlay;
  65. EditablePanel *m_pBorderPanel;
  66. Color m_clrHighlight;
  67. Color m_clrDefaultBg;
  68. bool m_bMouseOver;
  69. IReplayItemManager *m_pReplayItemManager;
  70. float m_flLastMovieScrubTime;
  71. float m_flHoverStartTime;
  72. float m_flLastProgressChangeTime;
  73. };
  74. //-----------------------------------------------------------------------------
  75. // Purpose: A row of Replay thumbnails (CReplayBrowserThumbnail's)
  76. //-----------------------------------------------------------------------------
  77. class CReplayBrowserThumbnailRow : public EditablePanel
  78. {
  79. DECLARE_CLASS_SIMPLE( CReplayBrowserThumbnailRow, EditablePanel );
  80. public:
  81. CReplayBrowserThumbnailRow( Panel *pParent, const char *pName, IReplayItemManager *pReplayItemManager );
  82. void AddReplayThumbnail( const IQueryableReplayItem *pReplay );
  83. void AddReplayThumbnail( QueryableReplayItemHandle_t hReplayItem );
  84. void DeleteReplayItemThumbnail( const IQueryableReplayItem *pReplayItem );
  85. int GetNumReplayItems() const { return m_vecThumbnails.Count(); }
  86. int GetNumVisibleReplayItems() const;
  87. virtual void ApplySchemeSettings( IScheme *pScheme );
  88. virtual void PerformLayout();
  89. CReplayBrowserThumbnail *FindThumbnail( const IQueryableReplayItem *pReplay );
  90. CUtlVector< CReplayBrowserThumbnail * > m_vecThumbnails;
  91. IReplayItemManager *m_pReplayItemManager;
  92. };
  93. //-----------------------------------------------------------------------------
  94. // Purpose: A collection of CReplayBrowserThumbnailRows containing replays
  95. // recorded on a given day.
  96. //-----------------------------------------------------------------------------
  97. class CExLabel;
  98. class CExButton;
  99. class CReplayListPanel;
  100. class CBaseThumbnailCollection : public EditablePanel
  101. {
  102. DECLARE_CLASS_SIMPLE( CBaseThumbnailCollection, EditablePanel );
  103. public:
  104. CBaseThumbnailCollection( CReplayListPanel *pParent, const char *pName, IReplayItemManager *pReplayItemManager );
  105. void AddReplay( const IQueryableReplayItem *pItem );
  106. virtual bool IsMovieCollection() const = 0;
  107. void CleanupUIForReplayItem( ReplayItemHandle_t hReplayItem );
  108. virtual void PerformLayout();
  109. virtual void ApplySchemeSettings( IScheme *pScheme );
  110. void RemoveEmptyRows();
  111. void RemoveAll();
  112. void OnUpdated();
  113. void OnCommand( const char *pCommand );
  114. CReplayBrowserThumbnailRow *FindReplayItemThumbnailRow( const IQueryableReplayItem *pReplayItem );
  115. inline int GetNumRows() const { return m_vecRows.Count(); }
  116. typedef CUtlVector< CReplayBrowserThumbnailRow * > RowContainer_t;
  117. RowContainer_t m_vecRows;
  118. protected:
  119. // Called from PerformLayout() - layout any panels that should appear at the top (vertically)-most position
  120. virtual void LayoutUpperPanels( int nStartY, int nBgWidth ) = 0;
  121. virtual void LayoutBackgroundPanel( int nWide, int nTall ) {}
  122. virtual Panel *GetLowestPanel( int &nVerticalBuffer ) = 0;
  123. void UpdateViewingPage( void );
  124. int m_nStartX;
  125. protected:
  126. CExLabel *m_pNoReplayItemsLabel;
  127. IReplayItemManager *m_pReplayItemManager;
  128. CExButton *m_pShowNextButton;
  129. CExButton *m_pShowPrevButton;
  130. CUtlVector<ReplayItemHandle_t> m_vecReplays;
  131. int m_iViewingPage;
  132. int m_nReplayThumbnailsPerRow;
  133. int m_nMaxRows;
  134. CExLabel *m_pCaratLabel;
  135. CExLabel *m_pTitleLabel;
  136. CExButton *m_pRenderAllButton;
  137. private:
  138. int GetRowStartY();
  139. CReplayListPanel *m_pParentListPanel; // Parent gets altered so we keep this cached ptr around
  140. };
  141. //-----------------------------------------------------------------------------
  142. // Purpose:
  143. //-----------------------------------------------------------------------------
  144. class CReplayThumbnailCollection : public CBaseThumbnailCollection
  145. {
  146. DECLARE_CLASS_SIMPLE( CReplayThumbnailCollection, CBaseThumbnailCollection );
  147. public:
  148. CReplayThumbnailCollection( CReplayListPanel *pParent, const char *pName, IReplayItemManager *pReplayItemManager );
  149. virtual bool IsMovieCollection() const;
  150. virtual void PerformLayout();
  151. virtual void ApplySchemeSettings( IScheme *pScheme );
  152. virtual void LayoutUpperPanels( int nStartY, int nBgWidth );
  153. virtual void LayoutBackgroundPanel( int nWide, int nTall );
  154. virtual Panel *GetLowestPanel( int &nVerticalBuffer );
  155. Panel *m_pLinePanel;
  156. CExLabel *m_pWarningLabel;
  157. Panel *m_pUnconvertedBg;
  158. };
  159. #define OLDER_MOVIES_COLLECTION -2
  160. //-----------------------------------------------------------------------------
  161. // Purpose:
  162. //-----------------------------------------------------------------------------
  163. class CMovieThumbnailCollection : public CBaseThumbnailCollection
  164. {
  165. DECLARE_CLASS_SIMPLE( CMovieThumbnailCollection, CBaseThumbnailCollection );
  166. public:
  167. CMovieThumbnailCollection( CReplayListPanel *pParent, const char *pName, IReplayItemManager *pReplayItemManager,
  168. int nDay, int nMonth, int nYear, bool bShowSavedMoviesLabel );
  169. CMovieThumbnailCollection( CReplayListPanel *pParent, const char *pName, IReplayItemManager *pReplayItemManager,
  170. bool bShowSavedMoviesLabel );
  171. bool DoesDateMatch( int nDay, int nMonth, int nYear );
  172. virtual bool IsMovieCollection() const;
  173. private:
  174. void Init( int nDay, int nMonth, int nYear, bool bShowSavedMoviesLabel );
  175. virtual void PerformLayout();
  176. virtual void ApplySchemeSettings( IScheme *pScheme );
  177. Panel *GetLowestPanel( int &nVerticalBuffer );
  178. void LayoutUpperPanels( int nStartY, int nBgWidth );
  179. int m_nDay, m_nMonth, m_nYear;
  180. CExLabel *m_pDateLabel;
  181. bool m_bShowSavedMoviesLabel;
  182. };
  183. #endif // REPLAYLISTITEMPANEL_H