From ae4e26f03b508a62cce33fa00a3cf1c73f25bc23 Mon Sep 17 00:00:00 2001 From: Alivebyte Date: Sun, 25 Apr 2021 15:48:29 +0300 Subject: [PATCH 1/4] Added sound support for vgui_movie_display --- sp/src/game/client/c_movie_display.cpp | 1 + sp/src/game/client/c_movie_display.h | 2 ++ sp/src/game/client/vgui_movie_display.cpp | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sp/src/game/client/c_movie_display.cpp b/sp/src/game/client/c_movie_display.cpp index 2285b97e..27327403 100644 --- a/sp/src/game/client/c_movie_display.cpp +++ b/sp/src/game/client/c_movie_display.cpp @@ -13,6 +13,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_MovieDisplay, DT_MovieDisplay, CMovieDisplay ) RecvPropBool( RECVINFO( m_bEnabled ) ), RecvPropBool( RECVINFO( m_bLooping ) ), + RecvPropBool( RECVINFO( m_bMuted ) ), RecvPropString( RECVINFO( m_szMovieFilename ) ), RecvPropString( RECVINFO( m_szGroupName ) ), END_RECV_TABLE() diff --git a/sp/src/game/client/c_movie_display.h b/sp/src/game/client/c_movie_display.h index d133e82e..55d0211f 100644 --- a/sp/src/game/client/c_movie_display.h +++ b/sp/src/game/client/c_movie_display.h @@ -20,6 +20,7 @@ public: bool IsEnabled( void ) const { return m_bEnabled; } bool IsLooping( void ) const { return m_bLooping; } + bool IsMuted(void) const { return m_bMuted; } const char *GetMovieFilename( void ) const { return m_szMovieFilename; } const char *GetGroupName( void ) const { return m_szGroupName; } @@ -27,6 +28,7 @@ public: private: bool m_bEnabled; bool m_bLooping; + bool m_bMuted; char m_szMovieFilename[128]; char m_szGroupName[128]; }; diff --git a/sp/src/game/client/vgui_movie_display.cpp b/sp/src/game/client/vgui_movie_display.cpp index 0f474323..8524a338 100644 --- a/sp/src/game/client/vgui_movie_display.cpp +++ b/sp/src/game/client/vgui_movie_display.cpp @@ -81,7 +81,7 @@ private: bool m_bBlackBackground; bool m_bSlaved; bool m_bInitialized; - + bool m_bStopAllSounds; bool m_bLastActiveState; // HACK: I'd rather get a real callback... // VGUI specifics @@ -110,10 +110,10 @@ CMovieDisplayScreen::CMovieDisplayScreen( vgui::Panel *parent, const char *panel m_bBlackBackground = true; m_bSlaved = false; m_bInitialized = false; - + m_bStopAllSounds = true; // Add ourselves to the global list of movie displays g_MovieDisplays.AddToTail( this ); - + //m_VideoMaterial->SetMuted(true); m_bLastActiveState = IsActive(); } @@ -295,6 +295,11 @@ void CMovieDisplayScreen::UpdateMovie( void ) // OnVideoOver(); // StopPlayback(); } + + if (!m_hScreenEntity->IsMuted()) + { + m_VideoMaterial->SetMuted(false); + } } } @@ -376,14 +381,17 @@ bool CMovieDisplayScreen::BeginPlayback( const char *pFilename ) if ( m_VideoMaterial == NULL ) return false; - m_VideoMaterial->SetMuted( true ); // FIXME: Allow? + + + m_VideoMaterial->SetMuted(true); // FIXME: Allow? + if ( m_hScreenEntity->IsLooping() ) { m_VideoMaterial->SetLooping( true ); } - if ( m_VideoMaterial->HasAudio() ) + if ( m_VideoMaterial->HasAudio() && m_bStopAllSounds) { // We want to be the sole audio source enginesound->NotifyBeginMoviePlayback(); From f458ac122372b7ddeb3d4c0af537b55350fc3189 Mon Sep 17 00:00:00 2001 From: rzkid Date: Sun, 25 Apr 2021 17:27:26 +0300 Subject: [PATCH 2/4] removed stopallsounds --- sp/src/game/client/vgui_movie_display.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sp/src/game/client/vgui_movie_display.cpp b/sp/src/game/client/vgui_movie_display.cpp index 8524a338..8cc2c0db 100644 --- a/sp/src/game/client/vgui_movie_display.cpp +++ b/sp/src/game/client/vgui_movie_display.cpp @@ -81,7 +81,6 @@ private: bool m_bBlackBackground; bool m_bSlaved; bool m_bInitialized; - bool m_bStopAllSounds; bool m_bLastActiveState; // HACK: I'd rather get a real callback... // VGUI specifics @@ -110,7 +109,6 @@ CMovieDisplayScreen::CMovieDisplayScreen( vgui::Panel *parent, const char *panel m_bBlackBackground = true; m_bSlaved = false; m_bInitialized = false; - m_bStopAllSounds = true; // Add ourselves to the global list of movie displays g_MovieDisplays.AddToTail( this ); //m_VideoMaterial->SetMuted(true); @@ -391,7 +389,7 @@ bool CMovieDisplayScreen::BeginPlayback( const char *pFilename ) m_VideoMaterial->SetLooping( true ); } - if ( m_VideoMaterial->HasAudio() && m_bStopAllSounds) + if ( m_VideoMaterial->HasAudio()) { // We want to be the sole audio source enginesound->NotifyBeginMoviePlayback(); From 5bc2d7cb83d02eece650d0c180efdb01877be260 Mon Sep 17 00:00:00 2001 From: Alivebyte Date: Sun, 25 Apr 2021 17:35:45 +0300 Subject: [PATCH 3/4] Added missing movie_display.cpp --- sp/src/game/server/movie_display.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sp/src/game/server/movie_display.cpp b/sp/src/game/server/movie_display.cpp index 5c31fb23..01236f1c 100644 --- a/sp/src/game/server/movie_display.cpp +++ b/sp/src/game/server/movie_display.cpp @@ -53,6 +53,7 @@ private: private: CNetworkVar( bool, m_bEnabled ); CNetworkVar( bool, m_bLooping ); + CNetworkVar( bool, m_bMuted); CNetworkString( m_szDisplayText, 128 ); @@ -93,6 +94,7 @@ BEGIN_DATADESC( CMovieDisplay ) DEFINE_KEYFIELD( m_iScreenWidth, FIELD_INTEGER, "width" ), DEFINE_KEYFIELD( m_iScreenHeight, FIELD_INTEGER, "height" ), DEFINE_KEYFIELD( m_bLooping, FIELD_BOOLEAN, "looping" ), + DEFINE_KEYFIELD( m_bMuted, FIELD_BOOLEAN, "muted"), DEFINE_FIELD( m_bDoFullTransmit, FIELD_BOOLEAN ), @@ -108,6 +110,7 @@ END_DATADESC() IMPLEMENT_SERVERCLASS_ST( CMovieDisplay, DT_MovieDisplay ) SendPropBool( SENDINFO( m_bEnabled ) ), SendPropBool( SENDINFO( m_bLooping ) ), + SendPropBool( SENDINFO( m_bMuted ) ), SendPropString( SENDINFO( m_szMovieFilename ) ), SendPropString( SENDINFO( m_szGroupName ) ), END_SEND_TABLE() From 578257471170ee6fd5ada87a4d2ff4f6cfb67f87 Mon Sep 17 00:00:00 2001 From: Alivebyte Date: Sun, 25 Apr 2021 18:56:49 +0300 Subject: [PATCH 4/4] Added constructor for movie_display to mute sound by default --- sp/src/game/server/movie_display.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sp/src/game/server/movie_display.cpp b/sp/src/game/server/movie_display.cpp index 01236f1c..b5a4476c 100644 --- a/sp/src/game/server/movie_display.cpp +++ b/sp/src/game/server/movie_display.cpp @@ -21,6 +21,8 @@ public: DECLARE_DATADESC(); DECLARE_SERVERCLASS(); + CMovieDisplay() { m_bMuted = true; } + virtual ~CMovieDisplay(); virtual bool KeyValue( const char *szKeyName, const char *szValue ); @@ -123,6 +125,7 @@ CMovieDisplay::~CMovieDisplay() //----------------------------------------------------------------------------- // Read in Hammer data //----------------------------------------------------------------------------- + bool CMovieDisplay::KeyValue( const char *szKeyName, const char *szValue ) { // NOTE: Have to do these separate because they set two values instead of one