aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/video.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-01-09 17:26:22 +0000
committerMatthew Hoops2011-01-09 17:26:22 +0000
commitcd6d818ca30fc054ef60dbc6c103bc420232c7db (patch)
treed47011891cf089758602029eda8ac90b7a1a9466 /engines/mohawk/video.cpp
parent81d29aa303c0b5d0ccaa8eb01ebe6d827a7bb0a6 (diff)
downloadscummvm-rg350-cd6d818ca30fc054ef60dbc6c103bc420232c7db.tar.gz
scummvm-rg350-cd6d818ca30fc054ef60dbc6c103bc420232c7db.tar.bz2
scummvm-rg350-cd6d818ca30fc054ef60dbc6c103bc420232c7db.zip
MOHAWK: Cleanup named video handling
svn-id: r55188
Diffstat (limited to 'engines/mohawk/video.cpp')
-rw-r--r--engines/mohawk/video.cpp50
1 files changed, 38 insertions, 12 deletions
diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp
index 6e076315c1..31fd3d08d7 100644
--- a/engines/mohawk/video.cpp
+++ b/engines/mohawk/video.cpp
@@ -124,14 +124,14 @@ void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
delete _videoStreams[videoHandle].video;
_videoStreams[videoHandle].video = 0;
- _videoStreams[videoHandle].id = 0xffff;
+ _videoStreams[videoHandle].id = 0;
_videoStreams[videoHandle].filename.clear();
}
-void VideoManager::playBackgroundMovie(const Common::String &filename, int16 x, int16 y, bool loop) {
+VideoHandle VideoManager::playBackgroundMovie(const Common::String &filename, int16 x, int16 y, bool loop) {
VideoHandle videoHandle = createVideoHandle(filename, x, y, loop);
if (videoHandle == NULL_VID_HANDLE)
- return;
+ return NULL_VID_HANDLE;
// Center x if requested
if (x < 0)
@@ -140,12 +140,14 @@ void VideoManager::playBackgroundMovie(const Common::String &filename, int16 x,
// Center y if requested
if (y < 0)
_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
+
+ return videoHandle;
}
-void VideoManager::playBackgroundMovie(uint16 id, int16 x, int16 y, bool loop) {
+VideoHandle VideoManager::playBackgroundMovie(uint16 id, int16 x, int16 y, bool loop) {
VideoHandle videoHandle = createVideoHandle(id, x, y, loop);
if (videoHandle == NULL_VID_HANDLE)
- return;
+ return NULL_VID_HANDLE;
// Center x if requested
if (x < 0)
@@ -154,6 +156,8 @@ void VideoManager::playBackgroundMovie(uint16 id, int16 x, int16 y, bool loop) {
// Center y if requested
if (y < 0)
_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
+
+ return videoHandle;
}
bool VideoManager::updateBackgroundMovies() {
@@ -171,7 +175,7 @@ bool VideoManager::updateBackgroundMovies() {
} else {
delete _videoStreams[i].video;
_videoStreams[i].video = 0;
- _videoStreams[i].id = 0xffff;
+ _videoStreams[i].id = 0;
_videoStreams[i].filename.clear();
continue;
}
@@ -304,7 +308,7 @@ void VideoManager::stopMovie(uint16 id) {
if (_mlstRecords[i].movieID == _videoStreams[j].id) {
delete _videoStreams[j].video;
_videoStreams[j].video = 0;
- _videoStreams[j].id = 0xffff;
+ _videoStreams[j].id = 0;
_videoStreams[j].filename.clear();
return;
}
@@ -380,7 +384,7 @@ VideoHandle VideoManager::createVideoHandle(const Common::String &filename, uint
entry.x = x;
entry.y = y;
entry.filename = filename;
- entry.id = 0xffff;
+ entry.id = 0;
entry.loop = loop;
entry.enabled = true;
@@ -407,7 +411,7 @@ VideoHandle VideoManager::createVideoHandle(const Common::String &filename, uint
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++)
+ for (uint32 j = 0; j < _videoStreams.size(); j++)
if (_videoStreams[j].video && _mlstRecords[i].movieID == _videoStreams[j].id)
return j;
@@ -415,9 +419,23 @@ VideoHandle VideoManager::findVideoHandleRiven(uint16 id) {
}
VideoHandle VideoManager::findVideoHandle(uint16 id) {
- for (uint16 j = 0; j < _videoStreams.size(); j++)
- if (_videoStreams[j].video && _videoStreams[j].id == id)
- return j;
+ if (!id)
+ return NULL_VID_HANDLE;
+
+ for (uint32 i = 0; i < _videoStreams.size(); i++)
+ if (_videoStreams[i].video && _videoStreams[i].id == id)
+ return i;
+
+ return NULL_VID_HANDLE;
+}
+
+VideoHandle VideoManager::findVideoHandle(const Common::String &filename) {
+ if (filename.empty())
+ return NULL_VID_HANDLE;
+
+ for (uint32 i = 0; i < _videoStreams.size(); i++)
+ if (_videoStreams[i].video && _videoStreams[i].filename.equalsIgnoreCase(filename))
+ return i;
return NULL_VID_HANDLE;
}
@@ -442,4 +460,12 @@ bool VideoManager::endOfVideo(const VideoHandle &handle) {
return _videoStreams[handle]->endOfVideo();
}
+bool VideoManager::isVideoPlaying() {
+ for (uint32 i = 0; i < _videoStreams.size(); i++)
+ if (_videoStreams[i].video && !_videoStreams[i]->endOfVideo())
+ return true;
+
+ return false;
+}
+
} // End of namespace Mohawk