From cafdcd1c8a68fb23dd6e2841b427fb69f29dd62c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 2 Jun 2012 18:38:20 +0200 Subject: WINTERMUTE: Add in more of the missing Video-pieces, also, copy over the TheoraPlayer from SWORD25 --- engines/wintermute/Base/BGame.cpp | 54 +++++++++++++++++++++++++++++++-------- engines/wintermute/Base/BGame.h | 9 +++++-- 2 files changed, 51 insertions(+), 12 deletions(-) (limited to 'engines/wintermute/Base') diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index c9b122759d..3a4e88a612 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -67,6 +67,8 @@ #include "engines/wintermute/Base/scriptables/SXMath.h" #include "engines/wintermute/Base/scriptables/SXStore.h" #include "engines/wintermute/Base/scriptables/SXString.h" +#include "engines/wintermute/video/VidPlayer.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" #include "common/textconsole.h" #include "common/util.h" #include "common/keyboard.h" @@ -115,6 +117,9 @@ CBGame::CBGame(): CBObject(this) { _systemFont = NULL; _videoFont = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _mainObject = NULL; _activeObject = NULL; @@ -304,6 +309,8 @@ CBGame::~CBGame() { delete _scEngine; delete _fontStorage; delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; delete _soundMgr; delete _debugMgr; //SAFE_DELETE(_keyboardState); @@ -326,6 +333,8 @@ CBGame::~CBGame() { _scEngine = NULL; _fontStorage = NULL; _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; _soundMgr = NULL; _debugMgr = NULL; @@ -445,6 +454,9 @@ HRESULT CBGame::Initialize1() { _scEngine = new CScEngine(this); if (_scEngine == NULL) goto init_fail; + + _videoPlayer = new CVidPlayer(this); + if(_videoPlayer==NULL) goto init_fail; _transMgr = new CBTransitionMgr(this); if (_transMgr == NULL) goto init_fail; @@ -473,6 +485,7 @@ init_fail: if (_soundMgr) delete _soundMgr; if (_fileManager) delete _fileManager; if (_scEngine) delete _scEngine; + if (_videoPlayer) delete _videoPlayer; return E_FAIL; } @@ -1399,16 +1412,16 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - /*if(SUCCEEDED(Game->m_VideoPlayer->Initialize(Filename, SubtitleFile))) + if(SUCCEEDED(Game->_videoPlayer->initialize(Filename, SubtitleFile))) { - if(SUCCEEDED(Game->m_VideoPlayer->Play((TVideoPlayback)Type, X, Y, FreezeMusic))) + if(SUCCEEDED(Game->_videoPlayer->play((TVideoPlayback)Type, X, Y, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); } else Stack->PushBool(false); } - else */Stack->PushBool(false); + else Stack->PushBool(false); return S_OK; } @@ -1441,20 +1454,20 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS if(Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) Type = (int)VID_PLAY_STRETCH; - - /*SAFE_DELETE(m_TheoraPlayer); - m_TheoraPlayer = new CVidTheoraPlayer(this); - if(m_TheoraPlayer && SUCCEEDED(m_TheoraPlayer->Initialize(Filename, SubtitleFile))) + + delete _theoraPlayer; + _theoraPlayer = new CVidTheoraPlayer(this); + if(_theoraPlayer && SUCCEEDED(_theoraPlayer->initialize(Filename, SubtitleFile))) { - m_TheoraPlayer->m_DontDropFrames = !DropFrames; - if(SUCCEEDED(m_TheoraPlayer->Play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) + _theoraPlayer->_dontDropFrames = !DropFrames; + if(SUCCEEDED(_theoraPlayer->play((TVideoPlayback)Type, X, Y, true, FreezeMusic))) { Stack->PushBool(true); Script->Sleep(0); } else Stack->PushBool(false); } - else */Stack->PushBool(false); + else Stack->PushBool(false); return S_OK; } @@ -4195,6 +4208,27 @@ HRESULT CBGame::SetWaitCursor(const char *Filename) { } else return S_OK; } +////////////////////////////////////////////////////////////////////////// +bool CBGame::IsVideoPlaying() +{ + if(_videoPlayer->isPlaying()) return true; + if(_theoraPlayer && _theoraPlayer->isPlaying()) return true; + return false; +} + +////////////////////////////////////////////////////////////////////////// +HRESULT CBGame::StopVideo() +{ + if(_videoPlayer->isPlaying()) _videoPlayer->stop(); + if(_theoraPlayer && _theoraPlayer->isPlaying()) + { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return S_OK; +} + ////////////////////////////////////////////////////////////////////////// HRESULT CBGame::DrawCursor(CBSprite *Cursor) { diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index ac8138855f..2f9b6147ec 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -61,6 +61,8 @@ class CBSurfaceStorage; class CSXStore; class CSXMath; class CBKeyboardState; +class CVidPlayer; +class CVidTheoraPlayer; #define NUM_MUSIC_CHANNELS 5 @@ -263,8 +265,8 @@ public: HRESULT Unfreeze(); HRESULT Freeze(bool IncludingMusic = true); HRESULT FocusWindow(CUIWindow *Window); -/* CVidPlayer* _videoPlayer; - CVidTheoraPlayer* _theoraPlayer;*/ + CVidPlayer* _videoPlayer; + CVidTheoraPlayer* _theoraPlayer; bool _loadInProgress; CUIWindow *_focusedWindow; bool _editorForceScripts; @@ -323,6 +325,9 @@ public: uint32 _fps; HRESULT UpdateMusicCrossfade(); + bool IsVideoPlaying(); + HRESULT StopVideo(); + CBArray _regObjects; public: virtual HRESULT DisplayContent(bool Update = true, bool DisplayAll = false); -- cgit v1.2.3