[Scummvm-cvs-logs] SF.net SVN: scummvm:[45178] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Oct 17 12:42:00 CEST 2009


Revision: 45178
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45178&view=rev
Author:   thebluegr
Date:     2009-10-17 10:42:00 +0000 (Sat, 17 Oct 2009)

Log Message:
-----------
Added a new console command, "play_video", which can play a SEQ or AVI file

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    scummvm/trunk/engines/sci/seq_decoder.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-10-16 23:31:31 UTC (rev 45177)
+++ scummvm/trunk/engines/sci/console.cpp	2009-10-17 10:42:00 UTC (rev 45178)
@@ -44,6 +44,9 @@
 #include "sci/gui/gui.h"
 #include "sci/gui/gui_cursor.h"
 
+#include "graphics/video/avi_decoder.h"
+#include "sci/seq_decoder.h"
+
 #include "common/savefile.h"
 
 namespace Sci {
@@ -111,6 +114,7 @@
 	DCmd_Register("draw_cel",			WRAP_METHOD(Console, cmdDrawCel));
 	DCmd_Register("view_info",			WRAP_METHOD(Console, cmdViewInfo));
 	DCmd_Register("undither",           WRAP_METHOD(Console, cmdUndither));
+	DCmd_Register("play_video",         WRAP_METHOD(Console, cmdPlayVideo));
 	// GUI
 	DCmd_Register("current_port",		WRAP_METHOD(Console, cmdCurrentPort));
 	DCmd_Register("print_port",			WRAP_METHOD(Console, cmdPrintPort));
@@ -207,6 +211,37 @@
 	if (_vm->_gamestate)
 		_vm->_gamestate->_sound.sfx_suspend(false);
 	_vm->_mixer->pauseAll(false);
+
+	if (!_videoFile.empty()) {
+		_vm->_gamestate->_gui->hideCursor();
+
+		if (_videoFile.hasSuffix(".seq")) {
+			Graphics::SeqDecoder *seqDecoder = new Graphics::SeqDecoder();
+			Graphics::VideoPlayer *player = new Graphics::VideoPlayer(seqDecoder);
+			if (seqDecoder->loadFile(_videoFile.c_str(), _videoFrameDelay))
+				player->playVideo();
+			else
+				DebugPrintf("Failed to open movie file %s\n", _videoFile.c_str());
+			seqDecoder->closeFile();
+			delete player;
+			delete seqDecoder;
+		} else if (_videoFile.hasSuffix(".avi")) {
+			Graphics::AviDecoder *aviDecoder = new Graphics::AviDecoder(g_system->getMixer());
+			Graphics::VideoPlayer *player = new Graphics::VideoPlayer(aviDecoder);
+			if (aviDecoder->loadFile(_videoFile.c_str()))
+				player->playVideo();
+			else
+				DebugPrintf("Failed to open movie file %s\n", _videoFile.c_str());
+			aviDecoder->closeFile();
+			delete player;
+			delete aviDecoder;
+		}
+
+		_vm->_gamestate->_gui->showCursor();
+
+		_videoFile.clear();
+		_videoFrameDelay = 0;
+	}
 }
 
 
@@ -1076,6 +1111,28 @@
 	return _vm->_gamestate->_gui->debugUndither(flag);
 }
 
+bool Console::cmdPlayVideo(int argc, const char **argv) {
+	if (argc < 2) {
+		DebugPrintf("Plays a SEQ or AVI video.\n");
+		DebugPrintf("Usage: %s <video file name> <delay>\n", argv[0]);
+		DebugPrintf("The video file name should include the extension\n");
+		DebugPrintf("Delay is only used in SEQ videos and is measured in ticks (default: 10)\n");
+		return true;
+	}
+
+	Common::String filename = argv[1];
+	filename.toLowercase();
+
+	if (filename.hasSuffix(".seq") || filename.hasSuffix(".avi")) {
+		_videoFile = filename;
+		_videoFrameDelay = (argc == 2) ? 10 : atoi(argv[2]);
+		return false;
+	} else {
+		DebugPrintf("Unknown video file type\n");
+		return true;
+	}
+}
+
 bool Console::cmdUpdateZone(int argc, const char **argv) {
 	if (argc != 4) {
 		DebugPrintf("Propagates a rectangular area from the back buffer to the front buffer\n");

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-10-16 23:31:31 UTC (rev 45177)
+++ scummvm/trunk/engines/sci/console.h	2009-10-17 10:42:00 UTC (rev 45178)
@@ -94,6 +94,7 @@
 	bool cmdDrawCel(int argc, const char **argv);
 	bool cmdViewInfo(int argc, const char **argv);
 	bool cmdUndither(int argc, const char **argv);
+	bool cmdPlayVideo(int argc, const char **argv);
 	// GUI
 	bool cmdCurrentPort(int argc, const char **argv);
 	bool cmdPrintPort(int argc, const char **argv);
@@ -158,6 +159,8 @@
 private:
 	SciEngine *_vm;
 	bool _mouseVisible;
+	Common::String _videoFile;
+	int _videoFrameDelay;
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/seq_decoder.h
===================================================================
--- scummvm/trunk/engines/sci/seq_decoder.h	2009-10-16 23:31:31 UTC (rev 45177)
+++ scummvm/trunk/engines/sci/seq_decoder.h	2009-10-17 10:42:00 UTC (rev 45178)
@@ -31,7 +31,7 @@
 namespace Graphics {
 
 /**
- * Implementation of the KQ6 DOS floppy/CD SEQ decoder
+ * Implementation of the Sierra SEQ decoder, used in KQ6 DOS floppy/CD and GK1 DOS
  */
 class SeqDecoder : public VideoDecoder {
 public:
@@ -47,7 +47,7 @@
 	/**
 	 * Load a SEQ encoded video file
 	 * @param filename	the filename to load
-	 * @param frameDelay the delay between frames, in ms
+	 * @param frameDelay the delay between frames, in ticks
 	 */
 	bool loadFile(const char *fileName, int frameDelay);
 


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