aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/game_object.cpp38
-rw-r--r--engines/titanic/core/game_object.h2
-rw-r--r--engines/titanic/support/movie.cpp6
-rw-r--r--engines/titanic/support/video_surface.cpp22
-rw-r--r--engines/titanic/support/video_surface.h12
5 files changed, 62 insertions, 18 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 02a64dcad2..d7c93b9524 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -20,14 +20,14 @@
*
*/
-#include "titanic/support/files_manager.h"
-#include "titanic/game_manager.h"
-#include "titanic/support/screen_manager.h"
-#include "titanic/titanic.h"
-#include "titanic/support/video_surface.h"
#include "titanic/core/game_object.h"
#include "titanic/core/resource_key.h"
#include "titanic/pet_control/pet_control.h"
+#include "titanic/support/files_manager.h"
+#include "titanic/support/screen_manager.h"
+#include "titanic/support/video_surface.h"
+#include "titanic/game_manager.h"
+#include "titanic/titanic.h"
namespace Titanic {
@@ -51,7 +51,7 @@ CGameObject::CGameObject(): CNamedItem() {
_visible = true;
_field60 = 0;
_cursorId = CURSOR_ARROW;
- _field78 = 0;
+ _initialFrame = 0;
_frameNumber = -1;
_field90 = 0;
_field94 = 0;
@@ -222,7 +222,7 @@ void CGameObject::draw(CScreenManager *screenManager, const Common::Point &destP
}
void CGameObject::loadResource(const CString &name) {
- switch (name.imageTypeSuffix()) {
+ switch (name.fileTypeSuffix()) {
case FILETYPE_IMAGE:
loadImage(name);
break;
@@ -233,7 +233,25 @@ void CGameObject::loadResource(const CString &name) {
}
void CGameObject::loadMovie(const CString &name, bool pendingFlag) {
- warning("TODO: CGameObject::loadMovie");
+ g_vm->_filesManager.fn5(name);
+
+ // Create the surface if it doesn't already exist
+ if (!_surface) {
+ CGameManager *gameManager = getGameManager();
+ _surface = new OSVideoSurface(CScreenManager::setCurrent(), nullptr);
+ }
+
+ // Load the new movie resource
+ CResourceKey key(name);
+ _surface->loadResource(key);
+
+ if (_surface->hasSurface() && !pendingFlag) {
+ _bounds.setWidth(_surface->getWidth());
+ _bounds.setHeight(_surface->getHeight());
+ }
+
+ if (_initialFrame)
+ loadFrame(_initialFrame);
}
void CGameObject::loadImage(const CString &name, bool pendingFlag) {
@@ -264,7 +282,7 @@ void CGameObject::loadImage(const CString &name, bool pendingFlag) {
makeDirty();
}
- _field78 = 0;
+ _initialFrame = 0;
}
void CGameObject::loadFrame(int frameNumber) {
@@ -403,7 +421,7 @@ bool CGameObject::hasActiveMovie() const {
int CGameObject::getMovie19() const {
if (_surface && _surface->_movie)
return _surface->_movie->proc19();
- return _field78;
+ return _initialFrame;
}
int CGameObject::getSurface45() const {
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 2fc047e523..3914c54226 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -70,7 +70,7 @@ protected:
int _field58;
bool _visible;
CMovieClipList _clipList1;
- int _field78;
+ int _initialFrame;
CMovieClipList _clipList2;
int _frameNumber;
int _field90;
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp
index 4fccc571ee..d614ea7d9b 100644
--- a/engines/titanic/support/movie.cpp
+++ b/engines/titanic/support/movie.cpp
@@ -145,6 +145,11 @@ void OSMovie::decodeFrame() {
OSVideoSurface *videoSurface = static_cast<OSVideoSurface *>(_videoSurface);
assert(videoSurface);
+ // If the video surface doesn't yet have an underlying surface, create it
+ if (!videoSurface->hasSurface())
+ videoSurface->resize(frame->w, frame->h);
+
+ // Lock access to the surface
videoSurface->lock();
assert(videoSurface->_rawSurface);
@@ -160,6 +165,7 @@ void OSMovie::decodeFrame() {
delete s;
}
+ // Unlock the surface
videoSurface->unlock();
}
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 1a0d48bebe..c7b437e1e7 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -241,8 +241,24 @@ void OSVideoSurface::loadJPEG(const CResourceKey &key) {
_resourceKey = key;
}
-void OSVideoSurface::loadMovie() {
- warning("TODO");
+void OSVideoSurface::loadMovie(const CResourceKey &key, bool destroyFlag) {
+ // Delete any prior movie
+ if (_movie) {
+ delete _movie;
+ _movie = nullptr;
+ }
+
+ // Create the new movie and load the first frame to the video surface
+ _movie = new OSMovie(key, this);
+ _movie->setFrame(0);
+
+ // If flagged to destroy, then immediately destroy movie instance
+ if (destroyFlag) {
+ delete _movie;
+ _movie = nullptr;
+ }
+
+ _resourceKey = key;
}
bool OSVideoSurface::lock() {
@@ -329,7 +345,7 @@ bool OSVideoSurface::load() {
return true;
case FILETYPE_MOVIE:
- loadMovie();
+ loadMovie(_resourceKey);
return true;
default:
diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h
index d39dea627b..335215d1df 100644
--- a/engines/titanic/support/video_surface.h
+++ b/engines/titanic/support/video_surface.h
@@ -93,9 +93,11 @@ public:
virtual void loadJPEG(const CResourceKey &key) = 0;
/**
- * Loads a movie file specified by the resource key
+ * Loads a movie file specified by the resource key.
+ * @param key Resource key for movie to load
+ * @param destroyFlag Immediately destroy movie after decoding first frame
*/
- virtual void loadMovie() = 0;
+ virtual void loadMovie(const CResourceKey &key, bool destroyFlag = false) = 0;
/**
* Lock the surface for direct access to the pixels
@@ -241,9 +243,11 @@ public:
virtual void loadJPEG(const CResourceKey &key);
/**
- * Loads a movie file specified by the resource key
+ * Loads a movie file specified by the resource key.
+ * @param key Resource key for movie to load
+ * @param destroyFlag Immediately destroy movie after decoding first frame
*/
- virtual void loadMovie();
+ virtual void loadMovie(const CResourceKey &key, bool destroyFlag = false);
/**
* Lock the surface for direct access to the pixels