[Scummvm-cvs-logs] SF.net SVN: scummvm:[55188] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Sun Jan 9 18:26:22 CET 2011


Revision: 55188
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55188&view=rev
Author:   mthreepwood
Date:     2011-01-09 17:26:22 +0000 (Sun, 09 Jan 2011)

Log Message:
-----------
MOHAWK: Cleanup named video handling

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/myst_areas.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/dni.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp
    scummvm/trunk/engines/mohawk/video.cpp
    scummvm/trunk/engines/mohawk/video.h

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2011-01-09 16:13:31 UTC (rev 55187)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2011-01-09 17:26:22 UTC (rev 55188)
@@ -219,9 +219,8 @@
 
 bool MystResourceType6::isPlaying() {
 	if (_videoRunning) {
-		VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
-		if (handle != NULL_VID_HANDLE)
-			return !_vm->_video->endOfVideo(handle);
+		VideoHandle handle = _vm->_video->findVideoHandle(_videoFile);
+		return handle != NULL_VID_HANDLE && !_vm->_video->endOfVideo(handle);
 	}
 
 	return false;

Modified: scummvm/trunk/engines/mohawk/myst_stacks/dni.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/dni.cpp	2011-01-09 16:13:31 UTC (rev 55187)
+++ scummvm/trunk/engines/mohawk/myst_stacks/dni.cpp	2011-01-09 17:26:22 UTC (rev 55188)
@@ -107,14 +107,13 @@
 
 void MystScriptParser_Dni::atrus_run() {
 	if (_globals.ending == 2) {
-		VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
-		if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle)) {
+		if (!_vm->_video->isVideoPlaying()) {
 			_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrus2", kDniStack), 215, 77);
 			_globals.ending = 4;
 			_globals.bluePagesInBook = 63;
 			_globals.redPagesInBook = 63;
 		}
-		// TODO: Complete / fix
+		// TODO: Complete/fix
 	} else if (_globals.ending == 1) {
 		// TODO: Complete, loop atr1page end
 	} else if (_globals.ending != 3 && _globals.ending != 4) {
@@ -122,17 +121,15 @@
 			_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atr1page", kDniStack), 215, 77);
 			_globals.ending = 1;
 
-			// TODO: Complete, movie control / looping
+			// TODO: Complete, movie control/looping
 		} else {
 			_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atr1nopg", kDniStack), 215, 77);
 			_globals.ending = 3;
 
-			// TODO: Complete, movie control / looping
+			// TODO: Complete, movie control/looping
 		}
-	} else {
-		VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
-		if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
-			_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77, true);
+	} else if (!_vm->_video->isVideoPlaying()) {
+		_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77, true);
 	}
 }
 

Modified: scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp	2011-01-09 16:13:31 UTC (rev 55187)
+++ scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp	2011-01-09 17:26:22 UTC (rev 55188)
@@ -107,16 +107,14 @@
 		} else
 			_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("broder", kIntroStack));
 	} else if (_introStep == 1) {
-		VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
-		if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
+		if (!_vm->_video->isVideoPlaying())
 			_introStep = 2;
 	} else if (_introStep == 2) {
 		_introStep = 3;
 
 		_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("cyanlogo", kIntroStack));
 	} else if (_introStep == 3) {
-		VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
-		if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
+		if (!_vm->_video->isVideoPlaying())
 			_introStep = 4;
 	}  else if (_introStep == 4) {
 		_introStep = 5;
@@ -129,15 +127,13 @@
 				_vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("intro", kIntroStack));
 		}
 	} else if (_introStep == 5) {
-		VideoHandle handle = _vm->_video->findVideoHandle(0xFFFF);
-		if (handle == NULL_VID_HANDLE || _vm->_video->endOfVideo(handle))
+		if (!_vm->_video->isVideoPlaying())
 			_introStep = 6;
 	} else {
-		if (_vm->getFeatures() & GF_DEMO) {
+		if (_vm->getFeatures() & GF_DEMO)
 			_vm->changeToCard(2001, true);
-		} else {
+		else
 			_vm->changeToCard(2, true);
-		}
 	}
 }
 
@@ -155,9 +151,8 @@
 			_vm->_gfx->copyImageToBackBuffer(4, Common::Rect(544, 333));
 			_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
 		}
-	} else {
-		if (!_linkBookMovie->isPlaying())
-			_vm->changeToCard(5, true);
+	} else if (!_linkBookMovie->isPlaying()) {
+		_vm->changeToCard(5, true);
 	}
 }
 

Modified: scummvm/trunk/engines/mohawk/video.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video.cpp	2011-01-09 16:13:31 UTC (rev 55187)
+++ scummvm/trunk/engines/mohawk/video.cpp	2011-01-09 17:26:22 UTC (rev 55188)
@@ -124,14 +124,14 @@
 
 	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 @@
 	// 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 @@
 	// 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 @@
 			} 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 @@
 				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 @@
 	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::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,13 +419,27 @@
 }
 
 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;
+}
+
 int32 VideoManager::getCurFrame(const VideoHandle &handle) {
 	assert(handle != NULL_VID_HANDLE);
 	return _videoStreams[handle]->getCurFrame();
@@ -442,4 +460,12 @@
 	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

Modified: scummvm/trunk/engines/mohawk/video.h
===================================================================
--- scummvm/trunk/engines/mohawk/video.h	2011-01-09 16:13:31 UTC (rev 55187)
+++ scummvm/trunk/engines/mohawk/video.h	2011-01-09 17:26:22 UTC (rev 55188)
@@ -75,12 +75,13 @@
 	// Generic movie functions
 	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);
+	VideoHandle playBackgroundMovie(const Common::String &filename, int16 x = -1, int16 y = -1, bool loop = false);
+	VideoHandle playBackgroundMovie(uint16 id, int16 x = -1, int16 y = -1, bool loop = false);
 	bool updateBackgroundMovies();
 	void pauseVideos();
 	void resumeVideos();
 	void stopVideos();
+	bool isVideoPlaying();
 
 	// Riven-related functions
 	void activateMLST(uint16 mlstId, uint16 card);
@@ -95,6 +96,7 @@
 
 	// Handle functions
 	VideoHandle findVideoHandle(uint16 id);
+	VideoHandle findVideoHandle(const Common::String &filename);
 	int32 getCurFrame(const VideoHandle &handle);
 	uint32 getFrameCount(const VideoHandle &handle);
 	uint32 getElapsedTime(const VideoHandle &handle);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list