Counter Strike : Global Offensive Source Code
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.

133 lines
3.8 KiB

  1. //====== Copyright � 1996-2007, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: VGUI panel which can play back video, in-engine
  4. //
  5. //=============================================================================
  6. #ifndef VGUI_VIDEO_H
  7. #define VGUI_VIDEO_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui_controls/Panel.h>
  12. #include <vgui_controls/EditablePanel.h>
  13. #include "vgui_controls/Label.h"
  14. #include "vgui_controls/ImagePanel.h"
  15. #include "vgui_controls/Frame.h"
  16. #include "avi/ibik.h"
  17. class CSubtitlePanel;
  18. class VideoPanel : public vgui::Frame
  19. {
  20. DECLARE_CLASS_SIMPLE( VideoPanel, vgui::Frame );
  21. public:
  22. VideoPanel( unsigned int nXPos, unsigned int nYPos, unsigned int nHeight, unsigned int nWidth );
  23. ~VideoPanel( void );
  24. virtual void Activate( void );
  25. virtual void Paint( void );
  26. virtual void DoModal( void );
  27. virtual void OnKeyCodeTyped( vgui::KeyCode code );
  28. virtual void OnKeyCodePressed( vgui::KeyCode code );
  29. virtual void OnMousePressed( vgui::MouseCode code );
  30. virtual void OnClose( void );
  31. virtual void GetPanelPos( int &xpos, int &ypos );
  32. void SetExitCommand( const char *pExitCommand )
  33. {
  34. if ( pExitCommand && pExitCommand[0] )
  35. {
  36. m_ExitCommand = pExitCommand;
  37. }
  38. }
  39. bool BeginPlayback( const char *pFilename );
  40. // terminate is a forceful instant shutdown, no exit commands fire
  41. void StopPlayback( bool bTerminate = false );
  42. void SetLooping( bool bLooping ) { m_bLooping = bLooping; }
  43. void SetFadeInTime( float flTime );
  44. void SetFadeOutTime( float flTime );
  45. void SetBlackBackground( bool bBlack ){ m_bBlackBackground = bBlack; }
  46. void SetAllowInterrupt( int nAllowInterrupt ) { m_nAllowInterruption = nAllowInterrupt; }
  47. void SetIsTransitionVideo( bool bIsTransitionVideo ) { m_bIsTransitionVideo = bIsTransitionVideo; }
  48. bool IsTransitionVideo( void ) { return m_bIsTransitionVideo; }
  49. void SetShouldPreload( bool bShouldPreload ) { m_bShouldPreload = bShouldPreload; }
  50. #if defined( PORTAL2 )
  51. void EnablePartnerUI( bool bEnablePartnerUI );
  52. #endif
  53. bool IsPlaying();
  54. protected:
  55. virtual void OnTick( void );
  56. virtual void OnCommand( const char *pcCommand ) { BaseClass::OnCommand( pcCommand ); }
  57. virtual void OnVideoOver();
  58. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  59. virtual void PostChildPaint();
  60. protected:
  61. float DrawMovieFrame();
  62. BIKMaterial_t m_BIKHandle;
  63. IMaterial *m_pMaterial;
  64. int m_nPlaybackHeight; // Calculated to address ratio changes
  65. int m_nPlaybackWidth;
  66. CUtlString m_ExitCommand; // This call is fired at the engine when the video finishes or is interrupted
  67. float m_flU; // U,V ranges for video on its sheet
  68. float m_flV;
  69. float m_flStartPlayTime;
  70. float m_flFadeInTime;
  71. float m_flFadeInEndTime;
  72. float m_flFadeOutTime;
  73. float m_flFadeOutEndTime;
  74. int m_nAllowInterruption;
  75. int m_nShutdownCount;
  76. bool m_bLooping;
  77. bool m_bStopAllSounds;
  78. bool m_bBlackBackground;
  79. bool m_bIsTransitionVideo;
  80. bool m_bShouldPreload;
  81. bool m_bStarted;
  82. private:
  83. void LoadLayout();
  84. #if defined( PORTAL2 )
  85. void SetupPartnerInScience( bool bEnable );
  86. void SetPartnerInScienceAlpha( int alpha );
  87. #endif
  88. void SetupCaptioning( const char *pFilename, int nPlaybackHeight );
  89. bool m_bEnablePartnerUI;
  90. vgui::Label *m_pWaitingForPlayers;
  91. vgui::ImagePanel *m_pPnlGamerPic;
  92. vgui::Label *m_pLblGamerTag;
  93. vgui::Label *m_pLblGamerTagStatus;
  94. float m_flCurrentVolume;
  95. CSubtitlePanel *m_pSubtitlePanel;
  96. };
  97. // Creates a VGUI panel which plays a video and executes a client command at its finish (if specified)
  98. extern bool VideoPanel_Create( unsigned int nXPos, unsigned int nYPos,
  99. unsigned int nWidth, unsigned int nHeight,
  100. const char *pVideoFilename,
  101. const char *pExitCommand = NULL );
  102. extern void VGui_StopAllVideoPanels();
  103. #endif // VGUI_VIDEO_H