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.

111 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: VGUI panel which can play back video, in-engine
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include <vgui/IVGui.h>
  8. #include <vgui/ISurface.h>
  9. #include <KeyValues.h>
  10. #include "vgui_video.h"
  11. #include "tf_vgui_video.h"
  12. #include "engine/IEngineSound.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. DECLARE_BUILD_FACTORY( CTFVideoPanel );
  16. //-----------------------------------------------------------------------------
  17. //
  18. //-----------------------------------------------------------------------------
  19. CTFVideoPanel::CTFVideoPanel( vgui::Panel *parent, const char *panelName ) : VideoPanel( 0, 0, 50, 50 )
  20. {
  21. SetParent( parent );
  22. SetProportional( true );
  23. SetKeyBoardInputEnabled( false );
  24. SetBlackBackground( false );
  25. m_flStartAnimDelay = 0.0f;
  26. m_flEndAnimDelay = 0.0f;
  27. }
  28. //-----------------------------------------------------------------------------
  29. //
  30. //-----------------------------------------------------------------------------
  31. CTFVideoPanel::~CTFVideoPanel()
  32. {
  33. ReleaseVideo();
  34. }
  35. //-----------------------------------------------------------------------------
  36. //
  37. //-----------------------------------------------------------------------------
  38. void CTFVideoPanel::ReleaseVideo()
  39. {
  40. enginesound->NotifyEndMoviePlayback();
  41. // Destroy any previously allocated video
  42. if ( g_pVideo && m_VideoMaterial != NULL )
  43. {
  44. g_pVideo->DestroyVideoMaterial( m_VideoMaterial );
  45. m_VideoMaterial = NULL;
  46. }
  47. }
  48. //-----------------------------------------------------------------------------
  49. //
  50. //-----------------------------------------------------------------------------
  51. void CTFVideoPanel::ApplySettings( KeyValues *inResourceData )
  52. {
  53. BaseClass::ApplySettings( inResourceData );
  54. SetExitCommand( inResourceData->GetString( "command", "" ) );
  55. m_flStartAnimDelay = inResourceData->GetFloat( "start_delay", 0.0 );
  56. m_flEndAnimDelay = inResourceData->GetFloat( "end_delay", 0.0 );
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Purpose:
  60. //-----------------------------------------------------------------------------
  61. void CTFVideoPanel::GetPanelPos( int &xpos, int &ypos )
  62. {
  63. vgui::ipanel()->GetAbsPos( GetVPanel(), xpos, ypos );
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Purpose:
  67. //-----------------------------------------------------------------------------
  68. void CTFVideoPanel::OnVideoOver()
  69. {
  70. BaseClass::OnVideoOver();
  71. PostMessage( GetParent(), new KeyValues( "IntroFinished" ) );
  72. }
  73. //-----------------------------------------------------------------------------
  74. // Purpose:
  75. //-----------------------------------------------------------------------------
  76. void CTFVideoPanel::OnClose()
  77. {
  78. // Fire an exit command if we're asked to do so
  79. if ( m_szExitCommand[0] )
  80. {
  81. engine->ClientCmd( m_szExitCommand );
  82. }
  83. // intentionally skipping VideoPanel::OnClose()
  84. EditablePanel::OnClose();
  85. SetVisible( false );
  86. }
  87. //-----------------------------------------------------------------------------
  88. // Purpose:
  89. //-----------------------------------------------------------------------------
  90. void CTFVideoPanel::Shutdown()
  91. {
  92. OnClose();
  93. ReleaseVideo();
  94. }