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.

98 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #include "cbase.h"
  5. #if defined( REPLAY_ENABLED )
  6. #include "replayperformanceplaybackhandler.h"
  7. #include "replay/replaycamera.h"
  8. #include "replay/vgui/replayperformanceeditor.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include <tier0/memdbgon.h>
  11. //-----------------------------------------------------------------------------
  12. class CReplayPerformancePlaybackHandler : public IReplayPerformancePlaybackHandler
  13. {
  14. public:
  15. CReplayPerformancePlaybackHandler() {}
  16. private:
  17. //
  18. // IReplayPerformancePlaybackController
  19. //
  20. virtual void OnEvent_Camera_Change_FirstPerson( float flTime, int nEntityIndex )
  21. {
  22. ReplayCamera()->SetMode( OBS_MODE_IN_EYE );
  23. Editor_UpdateCameraModeIcon( CAM_FIRST );
  24. }
  25. virtual void OnEvent_Camera_Change_ThirdPerson( float flTime, int nEntityIndex )
  26. {
  27. ReplayCamera()->SetMode( OBS_MODE_CHASE );
  28. Editor_UpdateCameraModeIcon( CAM_THIRD );
  29. }
  30. virtual void OnEvent_Camera_Change_Free( float flTime )
  31. {
  32. ReplayCamera()->SetMode( OBS_MODE_ROAMING );
  33. Editor_UpdateCameraModeIcon( CAM_FREE );
  34. }
  35. virtual void OnEvent_Camera_ChangePlayer( float flTime, int nEntIndex )
  36. {
  37. ReplayCamera()->SetPrimaryTarget( nEntIndex );
  38. }
  39. virtual void OnEvent_Camera_SetView( const SetViewParams_t &params )
  40. {
  41. ReplayCamera()->OverrideView( params.m_pOrigin, params.m_pAngles, params.m_flFov );
  42. Editor_UpdateFreeCamSettings( params );
  43. }
  44. virtual void OnEvent_TimeScale( float flTime, float flScale )
  45. {
  46. // Update the slider position
  47. Editor_UpdateTimeScale( flScale );
  48. }
  49. // ---
  50. void Editor_UpdateCameraModeIcon( CameraMode_t nMode )
  51. {
  52. CReplayPerformanceEditorPanel *pEditor = ReplayUI_GetPerformanceEditor();
  53. if ( !pEditor )
  54. return;
  55. pEditor->UpdateCameraSelectionPosition( nMode );
  56. }
  57. void Editor_UpdateFreeCamSettings( const SetViewParams_t &params )
  58. {
  59. CReplayPerformanceEditorPanel *pEditor = ReplayUI_GetPerformanceEditor();
  60. if ( !pEditor )
  61. return;
  62. pEditor->UpdateFreeCamSettings( params );
  63. }
  64. void Editor_UpdateTimeScale( float flScale )
  65. {
  66. CReplayPerformanceEditorPanel *pEditor = ReplayUI_GetPerformanceEditor();
  67. if ( !pEditor )
  68. return;
  69. pEditor->UpdateTimeScale( flScale );
  70. }
  71. };
  72. //-----------------------------------------------------------------------------
  73. CReplayPerformancePlaybackHandler s_ReplayPerformancePlaybackHandler;
  74. IReplayPerformancePlaybackHandler *g_pReplayPerformancePlaybackHandler = &s_ReplayPerformancePlaybackHandler;
  75. //-----------------------------------------------------------------------------
  76. #endif