source-engine/game/client/vgui_video.h

82 lines
2.3 KiB
C
Raw Normal View History

2023-10-03 17:23:56 +03:00
//====== Copyright <20> 1996-2007, Valve Corporation, All rights reserved. =======
2020-04-22 12:56:21 -04:00
//
// Purpose: VGUI panel which can play back video, in-engine
//
//=============================================================================
#ifndef VGUI_VIDEO_H
#define VGUI_VIDEO_H
#ifdef _WIN32
#pragma once
#endif
2023-10-03 17:23:56 +03:00
#include <vgui_controls/panel.h>
#include <vgui_controls/editablepanel.h>
#include "avi/ibik.h"
2020-04-22 12:56:21 -04:00
class VideoPanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( VideoPanel, vgui::EditablePanel );
public:
2023-10-03 17:23:56 +03:00
VideoPanel( unsigned int nXPos, unsigned int nYPos, unsigned int nHeight, unsigned int nWidth );
2020-04-22 12:56:21 -04:00
2023-10-03 17:23:56 +03:00
~VideoPanel( void );
2020-04-22 12:56:21 -04:00
virtual void Activate( void );
virtual void Paint( void );
virtual void DoModal( void );
virtual void OnKeyCodeTyped( vgui::KeyCode code );
virtual void OnKeyCodePressed( vgui::KeyCode code );
virtual void OnClose( void );
virtual void GetPanelPos( int &xpos, int &ypos );
void SetExitCommand( const char *pExitCommand )
{
if ( pExitCommand && pExitCommand[0] )
{
Q_strncpy( m_szExitCommand, pExitCommand, MAX_PATH );
}
}
bool BeginPlayback( const char *pFilename );
2023-10-03 17:23:56 +03:00
void StopPlayback( void );
2020-04-22 12:56:21 -04:00
void SetBlackBackground( bool bBlack ){ m_bBlackBackground = bBlack; }
2023-10-03 17:23:56 +03:00
void SetAllowInterrupt( bool bAllowInterrupt ) { m_bAllowInterruption = bAllowInterrupt; }
2020-04-22 12:56:21 -04:00
protected:
2023-10-03 17:23:56 +03:00
virtual void OnTick( void );
2020-04-22 12:56:21 -04:00
virtual void OnCommand( const char *pcCommand ) { BaseClass::OnCommand( pcCommand ); }
2023-10-03 17:23:56 +03:00
virtual void OnVideoOver();
2020-04-22 12:56:21 -04:00
protected:
2023-10-03 17:23:56 +03:00
BIKMaterial_t m_BIKHandle;
2020-04-22 12:56:21 -04:00
IMaterial *m_pMaterial;
int m_nPlaybackHeight; // Calculated to address ratio changes
int m_nPlaybackWidth;
char m_szExitCommand[MAX_PATH]; // This call is fired at the engine when the video finishes or is interrupted
float m_flU; // U,V ranges for video on its sheet
float m_flV;
2023-10-03 17:23:56 +03:00
bool m_bLooping;
bool m_bStopAllSounds;
bool m_bAllowInterruption;
2020-04-22 12:56:21 -04:00
bool m_bBlackBackground;
2023-10-03 17:23:56 +03:00
int m_nShutdownCount;
bool m_bStarted;
2020-04-22 12:56:21 -04:00
};
// Creates a VGUI panel which plays a video and executes a client command at its finish (if specified)
extern bool VideoPanel_Create( unsigned int nXPos, unsigned int nYPos,
unsigned int nWidth, unsigned int nHeight,
const char *pVideoFilename,
const char *pExitCommand = NULL );
#endif // VGUI_VIDEO_H