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.

105 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #if defined( REPLAY_ENABLED )
  5. #ifndef REPLAYDEMOPLAYER_H
  6. #define REPLAYDEMOPLAYER_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. //----------------------------------------------------------------------------------------
  11. #include "replay/ireplaydemoplayer.h"
  12. #include "replay/ireplaymovie.h"
  13. #include "cl_demo.h"
  14. #include "utlstring.h"
  15. //----------------------------------------------------------------------------------------
  16. class CReplay;
  17. //----------------------------------------------------------------------------------------
  18. class CReplayDemoPlayer : public CDemoPlayer,
  19. public IReplayDemoPlayer
  20. {
  21. public:
  22. typedef CDemoPlayer BaseClass;
  23. CReplayDemoPlayer();
  24. virtual bool StartPlayback( const char *pFilename, bool bAsTimeDemo );
  25. virtual void StopPlayback();
  26. virtual void OnLastDemoInLoopPlayed();
  27. virtual bool ShouldLoopDemos();
  28. //
  29. // IReplayDemoPlayer
  30. //
  31. virtual void PlayReplay( ReplayHandle_t hReplay, int iPerformance );
  32. virtual void PlayNextReplay();
  33. virtual void ClearReplayList();
  34. virtual void AddReplayToList( ReplayHandle_t hReplay, int iPerformance );
  35. virtual CReplay *GetCurrentReplay();
  36. virtual CReplayPerformance *GetCurrentPerformance();
  37. virtual void PauseReplay();
  38. virtual bool IsReplayPaused();
  39. virtual void ResumeReplay();
  40. virtual void OnSignonStateFull();
  41. //
  42. // CDemoPlayer
  43. //
  44. virtual void OnStopCommand();
  45. virtual netpacket_t *ReadPacket();
  46. virtual float GetPlaybackTimeScale();
  47. private:
  48. void DisplayFailedToPlayMsg( int iPerformance );
  49. float CalcMovieLength() const;
  50. class CInStartPlaybackGuard
  51. {
  52. public:
  53. CInStartPlaybackGuard( bool &bState ) : m_bState( bState ) { m_bState = true; }
  54. ~CInStartPlaybackGuard() { m_bState = false; }
  55. bool &m_bState;
  56. };
  57. struct PlaybackInfo_t
  58. {
  59. PlaybackInfo_t() : m_hReplay( REPLAY_HANDLE_INVALID ), m_iPerformance( -1 ),
  60. m_nStartTick( -1 ), m_nEndTick( -1 ) {}
  61. ReplayHandle_t m_hReplay;
  62. int m_iPerformance;
  63. int m_nStartTick;
  64. int m_nEndTick;
  65. };
  66. PlaybackInfo_t *GetCurrentPlaybackInfo();
  67. const PlaybackInfo_t *GetCurrentPlaybackInfo() const;
  68. const CReplay *GetCurrentReplay() const;
  69. CUtlVector< PlaybackInfo_t * > m_vecReplaysToPlay;
  70. IReplayMovie *m_pMovie;
  71. int m_nCurReplayIndex;
  72. bool m_bInStartPlayback;
  73. bool m_bStopCommandEncountered; // We only want to handle OnStopCommand() once per playback
  74. float m_flStartRenderTime;
  75. bool m_bFullSignonStateReached;
  76. };
  77. //----------------------------------------------------------------------------------------
  78. extern IDemoPlayer *g_pReplayDemoPlayer;
  79. //----------------------------------------------------------------------------------------
  80. #endif // REPLAYDEMOPLAYER_H
  81. #endif // #if defined( REPLAY_ENABLED )