aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-10-17 10:42:00 +0000
committerFilippos Karapetis2009-10-17 10:42:00 +0000
commitcc31846eb51cb42575f351f30c305d365fd3f812 (patch)
tree16a2a184101c19dbdcd133c6209add49e7f1b59c
parenta6445d602d4109e45ee5fcd8c53ce114d710fc74 (diff)
downloadscummvm-rg350-cc31846eb51cb42575f351f30c305d365fd3f812.tar.gz
scummvm-rg350-cc31846eb51cb42575f351f30c305d365fd3f812.tar.bz2
scummvm-rg350-cc31846eb51cb42575f351f30c305d365fd3f812.zip
Added a new console command, "play_video", which can play a SEQ or AVI file
svn-id: r45178
-rw-r--r--engines/sci/console.cpp57
-rw-r--r--engines/sci/console.h3
-rw-r--r--engines/sci/seq_decoder.h4
3 files changed, 62 insertions, 2 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 6640aba5bd..fc49e2de22 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -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 @@ Console::Console(SciEngine *vm) : GUI::Debugger() {
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 @@ void Console::postEnter() {
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 @@ bool Console::cmdUndither(int argc, const char **argv) {
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");
diff --git a/engines/sci/console.h b/engines/sci/console.h
index a632f341b8..63feb3bef6 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -94,6 +94,7 @@ private:
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:
private:
SciEngine *_vm;
bool _mouseVisible;
+ Common::String _videoFile;
+ int _videoFrameDelay;
};
} // End of namespace Sci
diff --git a/engines/sci/seq_decoder.h b/engines/sci/seq_decoder.h
index a734b52fb2..30695ca0ff 100644
--- a/engines/sci/seq_decoder.h
+++ b/engines/sci/seq_decoder.h
@@ -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 @@ public:
/**
* 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);