Added new "mute" keyvalue and StopMovie input to logic_playmovie

This commit is contained in:
Blixibon 2021-03-12 10:15:09 -06:00
parent c4abb0b07f
commit 9432ecc40c
3 changed files with 72 additions and 13 deletions

View File

@ -36,18 +36,19 @@ void VGui_ClearVideoPanels()
struct VideoPanelParms_t struct VideoPanelParms_t
{ {
VideoPanelParms_t( bool _interrupt = true, bool _loop = false, float _fadein = 0.0f, float _fadeout = 0.0f ) VideoPanelParms_t( bool _interrupt = true, bool _loop = false, bool _mute = false )
{ {
bAllowInterrupt = _interrupt; bAllowInterrupt = _interrupt;
bLoop = _loop; bLoop = _loop;
flFadeIn = _fadein; bMute = _mute;
flFadeOut = _fadeout;
} }
bool bAllowInterrupt; bool bAllowInterrupt;
bool bLoop; bool bLoop;
float flFadeIn; bool bMute;
float flFadeOut;
//float flFadeIn;
//float flFadeOut;
}; };
VideoPanel::VideoPanel( unsigned int nXPos, unsigned int nYPos, unsigned int nHeight, unsigned int nWidth, bool allowAlternateMedia ) : VideoPanel::VideoPanel( unsigned int nXPos, unsigned int nYPos, unsigned int nHeight, unsigned int nWidth, bool allowAlternateMedia ) :
@ -182,6 +183,13 @@ bool VideoPanel::BeginPlayback( const char *pFilename )
m_VideoMaterial->SetLooping( true ); m_VideoMaterial->SetLooping( true );
} }
#ifdef MAPBASE
if ( m_bMuted )
{
m_VideoMaterial->SetMuted( true );
}
#endif
m_bStarted = true; m_bStarted = true;
// We want to be the sole audio source // We want to be the sole audio source
@ -482,8 +490,17 @@ bool VideoPanel_Create( unsigned int nXPos, unsigned int nYPos,
// Toggle if we want the panel to loop (inspired by Portal 2) // Toggle if we want the panel to loop (inspired by Portal 2)
pVideoPanel->SetLooping( parms.bLoop ); pVideoPanel->SetLooping( parms.bLoop );
// Fade parameters // Toggle if we want the panel to be muted
pVideoPanel->SetFade( parms.flFadeIn, parms.flFadeOut ); pVideoPanel->SetMuted( parms.bMute );
// TODO: Unique "Stop All Sounds" parameter
if (parms.bMute)
{
pVideoPanel->SetStopAllSounds( false );
}
// Fade parameters (unfinished)
//pVideoPanel->SetFade( parms.flFadeIn, parms.flFadeOut );
#endif #endif
// Start it going // Start it going
@ -622,13 +639,16 @@ CON_COMMAND( playvideo_complex, "Plays a video with various parameters to simpli
VideoPanelParms_t parms; VideoPanelParms_t parms;
if (args.ArgC() >= 3) if (args.ArgC() >= 3)
parms.bAllowInterrupt = atoi( args[3] ) != 1; parms.bAllowInterrupt = atoi( args[3] ) != 0;
if (args.ArgC() >= 4) if (args.ArgC() >= 4)
parms.bLoop = atoi( args[4] ) != 0; parms.bLoop = atoi( args[4] ) != 0;
if (args.ArgC() >= 5) if (args.ArgC() >= 5)
parms.flFadeIn = atof( args[5] ); parms.bMute = atoi( args[5] ) != 0;
if (args.ArgC() >= 6)
parms.flFadeOut = atof( args[6] ); //if (args.ArgC() >= 5)
// parms.flFadeIn = atof( args[5] );
//if (args.ArgC() >= 6)
// parms.flFadeOut = atof( args[6] );
// Stop a softlock // Stop a softlock
if (parms.bAllowInterrupt == false && parms.bLoop) if (parms.bAllowInterrupt == false && parms.bLoop)

View File

@ -49,8 +49,10 @@ public:
void SetBlackBackground( bool bBlack ){ m_bBlackBackground = bBlack; } void SetBlackBackground( bool bBlack ){ m_bBlackBackground = bBlack; }
void SetAllowInterrupt( bool bAllowInterrupt ) { m_bAllowInterruption = bAllowInterrupt; } void SetAllowInterrupt( bool bAllowInterrupt ) { m_bAllowInterruption = bAllowInterrupt; }
void SetStopAllSounds( bool bStopAllSounds ) { m_bStopAllSounds = bStopAllSounds; }
#ifdef MAPBASE #ifdef MAPBASE
void SetLooping( bool bLooping ) { m_bLooping = bLooping; } void SetLooping( bool bLooping ) { m_bLooping = bLooping; }
void SetMuted( bool bMuted ) { m_bMuted = bMuted; }
void SetFade( float flStartFade, float flEndFade ) { m_flFadeIn = flStartFade; m_flFadeOut = flEndFade; } void SetFade( float flStartFade, float flEndFade ) { m_flFadeIn = flStartFade; m_flFadeOut = flEndFade; }
#endif #endif
@ -75,6 +77,7 @@ protected:
#ifdef MAPBASE #ifdef MAPBASE
float m_flFadeIn; float m_flFadeIn;
float m_flFadeOut; float m_flFadeOut;
bool m_bMuted;
#endif #endif
bool m_bStopAllSounds; bool m_bStopAllSounds;
bool m_bAllowInterruption; bool m_bAllowInterruption;

View File

@ -24,12 +24,18 @@ public:
private: private:
void InputPlayMovie( inputdata_t &data ); void InputPlayMovie( inputdata_t &data );
#ifdef MAPBASE
void InputStopMovie( inputdata_t &data );
#endif
void InputMovieFinished( inputdata_t &data ); void InputMovieFinished( inputdata_t &data );
string_t m_strMovieFilename; string_t m_strMovieFilename;
bool m_bAllowUserSkip; bool m_bAllowUserSkip;
#ifdef MAPBASE #ifdef MAPBASE
bool m_bLooping; bool m_bLooping;
bool m_bMuted;
bool m_bPlayingVideo;
#endif #endif
COutputEvent m_OnPlaybackFinished; COutputEvent m_OnPlaybackFinished;
@ -43,9 +49,15 @@ BEGIN_DATADESC( CLogicPlayMovie )
DEFINE_KEYFIELD( m_bAllowUserSkip, FIELD_BOOLEAN, "allowskip" ), DEFINE_KEYFIELD( m_bAllowUserSkip, FIELD_BOOLEAN, "allowskip" ),
#ifdef MAPBASE #ifdef MAPBASE
DEFINE_KEYFIELD( m_bLooping, FIELD_BOOLEAN, "loopvideo" ), DEFINE_KEYFIELD( m_bLooping, FIELD_BOOLEAN, "loopvideo" ),
DEFINE_KEYFIELD( m_bMuted, FIELD_BOOLEAN, "mute" ),
DEFINE_FIELD( m_bPlayingVideo, FIELD_BOOLEAN ),
#endif #endif
DEFINE_INPUTFUNC( FIELD_VOID, "PlayMovie", InputPlayMovie ), DEFINE_INPUTFUNC( FIELD_VOID, "PlayMovie", InputPlayMovie ),
#ifdef MAPBASE
DEFINE_INPUTFUNC( FIELD_VOID, "StopMovie", InputStopMovie ),
#endif
DEFINE_INPUTFUNC( FIELD_VOID, "__MovieFinished", InputMovieFinished ), DEFINE_INPUTFUNC( FIELD_VOID, "__MovieFinished", InputMovieFinished ),
DEFINE_OUTPUT( m_OnPlaybackFinished, "OnPlaybackFinished" ), DEFINE_OUTPUT( m_OnPlaybackFinished, "OnPlaybackFinished" ),
@ -75,21 +87,41 @@ void CLogicPlayMovie::InputPlayMovie( inputdata_t &data )
char szClientCmd[256]; char szClientCmd[256];
Q_snprintf( szClientCmd, sizeof(szClientCmd), Q_snprintf( szClientCmd, sizeof(szClientCmd),
"playvideo_complex %s \"ent_fire %s __MovieFinished\" %d %d\n", "playvideo_complex %s \"ent_fire %s __MovieFinished\" %d %d %d\n",
STRING(m_strMovieFilename), STRING(m_strMovieFilename),
GetEntityNameAsCStr(), GetEntityNameAsCStr(),
m_bAllowUserSkip, m_bAllowUserSkip,
#ifdef MAPBASE #ifdef MAPBASE
m_bLooping m_bLooping,
m_bMuted
#else #else
0,
0 0
#endif #endif
); );
// Send it on // Send it on
engine->ServerCommand( szClientCmd ); engine->ServerCommand( szClientCmd );
#ifdef MAPBASE
m_bPlayingVideo = true;
#endif
} }
#ifdef MAPBASE
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CLogicPlayMovie::InputStopMovie( inputdata_t &data )
{
if (m_bPlayingVideo)
{
// Send it on
engine->ServerCommand( "stopvideos\n" );
}
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -97,4 +129,8 @@ void CLogicPlayMovie::InputMovieFinished( inputdata_t &data )
{ {
// Simply fire our output // Simply fire our output
m_OnPlaybackFinished.FireOutput( this, this ); m_OnPlaybackFinished.FireOutput( this, this );
#ifdef MAPBASE
m_bPlayingVideo = false;
#endif
} }