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

fuzzie at users.sourceforge.net fuzzie at users.sourceforge.net
Thu Dec 9 22:24:31 CET 2010


Revision: 54843
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54843&view=rev
Author:   fuzzie
Date:     2010-12-09 21:24:31 +0000 (Thu, 09 Dec 2010)

Log Message:
-----------
MOHAWK: Allow background videos to be played/manipulated with resource handles

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/riven_external.cpp
    scummvm/trunk/engines/mohawk/video.cpp
    scummvm/trunk/engines/mohawk/video.h

Modified: scummvm/trunk/engines/mohawk/riven_external.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.cpp	2010-12-09 21:24:12 UTC (rev 54842)
+++ scummvm/trunk/engines/mohawk/riven_external.cpp	2010-12-09 21:24:31 UTC (rev 54843)
@@ -223,7 +223,7 @@
 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::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 @@
 	_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.

Modified: scummvm/trunk/engines/mohawk/video.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video.cpp	2010-12-09 21:24:12 UTC (rev 54842)
+++ scummvm/trunk/engines/mohawk/video.cpp	2010-12-09 21:24:31 UTC (rev 54843)
@@ -141,6 +141,20 @@
 		_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 @@
 
 			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 @@
 	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 @@
 	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();

Modified: scummvm/trunk/engines/mohawk/video.h
===================================================================
--- scummvm/trunk/engines/mohawk/video.h	2010-12-09 21:24:12 UTC (rev 54842)
+++ scummvm/trunk/engines/mohawk/video.h	2010-12-09 21:24:31 UTC (rev 54843)
@@ -75,6 +75,7 @@
 	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 @@
 	void playMovie(uint16 id);
 	void stopMovie(uint16 id);
 	void playMovieBlocking(uint16 id);
+	VideoHandle findVideoHandleRiven(uint16 id);
 
 	// Handle functions
 	VideoHandle findVideoHandle(uint16 id);


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