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.

132 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #include "cbase.h"
  5. #if defined( REPLAY_ENABLED )
  6. #include "replaybrowseritemmanager.h"
  7. #include "replaybrowserbasepage.h"
  8. #include "replay/ireplaymoviemanager.h"
  9. #include "replay/ireplaymanager.h"
  10. #include "replay/ireplaymovie.h"
  11. //-----------------------------------------------------------------------------
  12. using namespace vgui;
  13. //-----------------------------------------------------------------------------
  14. extern IClientReplayContext *g_pClientReplayContext;
  15. extern IReplayMovieManager *g_pReplayMovieManager;
  16. //-----------------------------------------------------------------------------
  17. class CReplayItemManager : public IReplayItemManager
  18. {
  19. public:
  20. virtual int GetItemCount()
  21. {
  22. return g_pReplayManager->GetReplayCount();
  23. }
  24. virtual void GetItems( CUtlLinkedList< IQueryableReplayItem *, int > &items )
  25. {
  26. g_pReplayManager->GetReplaysAsQueryableItems( items );
  27. }
  28. virtual IQueryableReplayItem *GetItem( ReplayItemHandle_t hItem )
  29. {
  30. return static_cast< CReplay * >( g_pReplayManager->GetReplay( (ReplayHandle_t)hItem ) );
  31. }
  32. virtual bool AreItemsMovies()
  33. {
  34. return false;
  35. }
  36. virtual void DeleteItem( Panel *pPage, ReplayItemHandle_t hItem, bool bNotifyUI )
  37. {
  38. g_pReplayManager->DeleteReplay( (ReplayHandle_t)hItem, bNotifyUI );
  39. }
  40. };
  41. //-----------------------------------------------------------------------------
  42. class CMovieItemManager : public IReplayItemManager
  43. {
  44. public:
  45. virtual int GetItemCount()
  46. {
  47. return g_pReplayMovieManager->GetMovieCount();
  48. }
  49. virtual void GetItems( CUtlLinkedList< IQueryableReplayItem *, int > &items )
  50. {
  51. g_pReplayMovieManager->GetMoviesAsQueryableItems( items );
  52. }
  53. virtual IQueryableReplayItem *GetItem( ReplayItemHandle_t hItem )
  54. {
  55. return g_pReplayMovieManager->GetMovie( (ReplayHandle_t)hItem );
  56. }
  57. virtual bool AreItemsMovies()
  58. {
  59. return true;
  60. }
  61. virtual void DeleteItem( Panel *pPage, ReplayItemHandle_t hItem, bool bNotifyUI )
  62. {
  63. CReplayBrowserBasePage *pBasePage = static_cast< CReplayBrowserBasePage * >( pPage );
  64. // Free the lock so the file is deletable
  65. pBasePage->FreeDetailsPanelMovieLock();
  66. // Delete the entry & the file
  67. g_pReplayMovieManager->DeleteMovie( hItem );
  68. }
  69. };
  70. //-----------------------------------------------------------------------------
  71. static CReplayItemManager s_ReplayItemManager;
  72. static CMovieItemManager s_MovieItemManager;
  73. //-----------------------------------------------------------------------------
  74. IReplayItemManager *GetReplayItemManager()
  75. {
  76. return &s_ReplayItemManager;
  77. }
  78. IReplayItemManager *GetReplayMovieItemManager()
  79. {
  80. return &s_MovieItemManager;
  81. }
  82. IQueryableReplayItem *FindReplayItem( ReplayItemHandle_t hItem, IReplayItemManager **ppItemManager )
  83. {
  84. static IReplayItemManager *s_pItemManagers[] = { &s_ReplayItemManager, &s_MovieItemManager };
  85. if ( ppItemManager )
  86. {
  87. *ppItemManager = NULL;
  88. }
  89. for ( int i = 0; i < 2; ++i )
  90. {
  91. IQueryableReplayItem *pItem = s_pItemManagers[ i ]->GetItem( hItem );
  92. if ( pItem )
  93. {
  94. if ( ppItemManager )
  95. {
  96. *ppItemManager = s_pItemManagers[ i ];
  97. }
  98. return pItem;
  99. }
  100. }
  101. return NULL;
  102. }
  103. #endif