aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Milburn2010-12-09 21:24:31 +0000
committerAlyssa Milburn2010-12-09 21:24:31 +0000
commit32ed3b35829dc29617c7a300d043afc2bd26999b (patch)
tree3a068106642ea670ff885c6927c9d0b661a6478e
parent8be4da02f66437fd54addbb38e2153e96a3f4ea7 (diff)
downloadscummvm-rg350-32ed3b35829dc29617c7a300d043afc2bd26999b.tar.gz
scummvm-rg350-32ed3b35829dc29617c7a300d043afc2bd26999b.tar.bz2
scummvm-rg350-32ed3b35829dc29617c7a300d043afc2bd26999b.zip
MOHAWK: Allow background videos to be played/manipulated with resource handles
svn-id: r54843
-rw-r--r--engines/mohawk/riven_external.cpp6
-rw-r--r--engines/mohawk/video.cpp28
-rw-r--r--engines/mohawk/video.h2
3 files changed, 30 insertions, 6 deletions
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 8848716967..dc3db08e92 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -223,7 +223,7 @@ void RivenExternal::runEndGame(uint16 video) {
void RivenExternal::runCredits(uint16 video) {
// TODO: Play until the last frame and then run the credits
- VideoHandle videoHandle = _vm->_video->findVideoHandle(video);
+ VideoHandle videoHandle = _vm->_video->findVideoHandleRiven(video);
while (!_vm->_video->endOfVideo(videoHandle) && !_vm->shouldQuit()) {
if (_vm->_video->updateBackgroundMovies())
@@ -247,7 +247,7 @@ void RivenExternal::runDomeButtonMovie() {
void RivenExternal::runDomeCheck() {
// Check if we clicked while the golden frame was showing
- VideoHandle video = _vm->_video->findVideoHandle(1);
+ VideoHandle video = _vm->_video->findVideoHandleRiven(1);
assert(video != NULL_VID_HANDLE);
int32 curFrame = _vm->_video->getCurFrame(video);
@@ -1531,7 +1531,7 @@ void RivenExternal::xbookclick(uint16 argc, uint16 *argv) {
_vm->_cursor->setCursor(kRivenHideCursor);
// Let's hook onto our video
- VideoHandle video = _vm->_video->findVideoHandle(argv[0]);
+ VideoHandle video = _vm->_video->findVideoHandleRiven(argv[0]);
// Convert from the standard QuickTime base time to milliseconds
// The values are in terms of 1/600 of a second.
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index ce2e2ae0f8..863a14335f 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -141,6 +141,20 @@ void VideoManager::playBackgroundMovie(const Common::String &filename, int16 x,
_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
}
+void VideoManager::playBackgroundMovie(uint16 id, int16 x, int16 y, bool loop) {
+ VideoHandle videoHandle = createVideoHandle(id, x, y, loop);
+ if (videoHandle == NULL_VID_HANDLE)
+ return;
+
+ // Center x if requested
+ if (x < 0)
+ _videoStreams[videoHandle].x = (_vm->_system->getWidth() - _videoStreams[videoHandle]->getWidth()) / 2;
+
+ // Center y if requested
+ if (y < 0)
+ _videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
+}
+
bool VideoManager::updateBackgroundMovies() {
bool updateScreen = false;
@@ -169,9 +183,9 @@ bool VideoManager::updateBackgroundMovies() {
if (frame && _videoStreams[i].enabled) {
// Convert from 8bpp to the current screen format if necessary
- if (frame->bytesPerPixel == 1) {
+ Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat();
+ if (frame->bytesPerPixel == 1 && pixelFormat.bytesPerPixel != 1) {
Graphics::Surface *newFrame = new Graphics::Surface();
- Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat();
byte *palette = _videoStreams[i]->getPalette();
assert(palette);
@@ -392,7 +406,7 @@ VideoHandle VideoManager::createVideoHandle(const Common::String &filename, uint
return _videoStreams.size() - 1;
}
-VideoHandle VideoManager::findVideoHandle(uint16 id) {
+VideoHandle VideoManager::findVideoHandleRiven(uint16 id) {
for (uint16 i = 0; i < _mlstRecords.size(); i++)
if (_mlstRecords[i].code == id)
for (uint16 j = 0; j < _videoStreams.size(); j++)
@@ -402,6 +416,14 @@ VideoHandle VideoManager::findVideoHandle(uint16 id) {
return NULL_VID_HANDLE;
}
+VideoHandle VideoManager::findVideoHandle(uint16 id) {
+ for (uint16 j = 0; j < _videoStreams.size(); j++)
+ if (_videoStreams[j].video && _videoStreams[j].id == id)
+ return j;
+
+ return NULL_VID_HANDLE;
+}
+
int32 VideoManager::getCurFrame(const VideoHandle &handle) {
assert(handle != NULL_VID_HANDLE);
return _videoStreams[handle]->getCurFrame();
diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h
index c8aff5c4f9..580bd23c98 100644
--- a/engines/mohawk/video.h
+++ b/engines/mohawk/video.h
@@ -75,6 +75,7 @@ public:
void playMovie(const Common::String &filename, uint16 x = 0, uint16 y = 0, bool clearScreen = false);
void playMovieCentered(const Common::String &filename, bool clearScreen = true);
void playBackgroundMovie(const Common::String &filename, int16 x = -1, int16 y = -1, bool loop = false);
+ void playBackgroundMovie(uint16 id, int16 x = -1, int16 y = -1, bool loop = false);
bool updateBackgroundMovies();
void pauseVideos();
void resumeVideos();
@@ -89,6 +90,7 @@ public:
void playMovie(uint16 id);
void stopMovie(uint16 id);
void playMovieBlocking(uint16 id);
+ VideoHandle findVideoHandleRiven(uint16 id);
// Handle functions
VideoHandle findVideoHandle(uint16 id);