From 422b732dbadde0b23aaec05b39edec9e1c81f91e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 16 Oct 2009 07:42:23 +0000 Subject: Added a new convenience method to the video player, which adds the event of skipping videos with the escape key by default, thereby simplifying the video playing code in all places where it's used svn-id: r45151 --- engines/saga/introproc_saga2.cpp | 33 ++++----------------------------- engines/sci/engine/kgraphics.cpp | 11 +---------- engines/sword1/animation.cpp | 11 +---------- engines/sword2/animation.cpp | 9 +-------- graphics/video/video_player.cpp | 11 +++++++++++ graphics/video/video_player.h | 6 ++++++ 6 files changed, 24 insertions(+), 57 deletions(-) diff --git a/engines/saga/introproc_saga2.cpp b/engines/saga/introproc_saga2.cpp index 81a60e17e5..0af31dae61 100644 --- a/engines/saga/introproc_saga2.cpp +++ b/engines/saga/introproc_saga2.cpp @@ -35,27 +35,15 @@ #include "graphics/surface.h" #include "graphics/video/smk_decoder.h" -#include "common/events.h" -#include "common/system.h" -#include "common/list.h" - namespace Saga { -Common::List stopEvents; - int Scene::DinoStartProc() { _vm->_gfx->showCursor(false); - Common::Event stopEvent; - stopEvents.clear(); - stopEvent.type = Common::EVENT_KEYDOWN; - stopEvent.kbd = Common::KEYCODE_ESCAPE; - stopEvents.push_back(stopEvent); - Graphics::SmackerDecoder *smkDecoder = new Graphics::SmackerDecoder(_vm->_mixer); Graphics::VideoPlayer *player = new Graphics::VideoPlayer(smkDecoder); if (smkDecoder->loadFile("testvid.smk")) - player->playVideo(stopEvents); // Play introduction + player->playVideo(); // Play introduction smkDecoder->closeFile(); delete player; delete smkDecoder; @@ -69,19 +57,13 @@ int Scene::DinoStartProc() { int Scene::FTA2StartProc() { _vm->_gfx->showCursor(false); - Common::Event stopEvent; - stopEvents.clear(); - stopEvent.type = Common::EVENT_KEYDOWN; - stopEvent.kbd = Common::KEYCODE_ESCAPE; - stopEvents.push_back(stopEvent); - Graphics::SmackerDecoder *smkDecoder = new Graphics::SmackerDecoder(_vm->_mixer); Graphics::VideoPlayer *player = new Graphics::VideoPlayer(smkDecoder); if (smkDecoder->loadFile("trimark.smk")) - player->playVideo(stopEvents); // Show Ignite logo + player->playVideo(); // Show Ignite logo smkDecoder->closeFile(); if (smkDecoder->loadFile("intro.smk")) - player->playVideo(stopEvents); // Play introduction + player->playVideo(); // Play introduction smkDecoder->closeFile(); delete player; delete smkDecoder; @@ -117,18 +99,11 @@ int Scene::FTA2EndProc(FTA2Endings whichEnding) { _vm->_gfx->showCursor(false); - - Common::Event stopEvent; - stopEvents.clear(); - stopEvent.type = Common::EVENT_KEYDOWN; - stopEvent.kbd = Common::KEYCODE_ESCAPE; - stopEvents.push_back(stopEvent); - // Play ending Graphics::SmackerDecoder *smkDecoder = new Graphics::SmackerDecoder(_vm->_mixer); Graphics::VideoPlayer *player = new Graphics::VideoPlayer(smkDecoder); if (smkDecoder->loadFile(videoName)) { - player->playVideo(stopEvents); + player->playVideo(); smkDecoder->closeFile(); } delete player; diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index c8782eb933..e899c22466 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -23,8 +23,6 @@ * */ -#include "common/system.h" -#include "common/events.h" #include "graphics/cursorman.h" #include "graphics/video/avi_player.h" #include "graphics/surface.h" @@ -1060,17 +1058,10 @@ static reg_t kShowMovie_DOS(EngineState *s, int argc, reg_t *argv) { Common::String filename = s->_segMan->getString(argv[0]); int delay = argv[1].toUint16(); // Time between frames in ticks - Common::Event stopEvent; - Common::List stopEvents; - stopEvents.clear(); - stopEvent.type = Common::EVENT_KEYDOWN; - stopEvent.kbd = Common::KEYCODE_ESCAPE; - stopEvents.push_back(stopEvent); - Graphics::SeqDecoder *seqDecoder = new Graphics::SeqDecoder(); Graphics::VideoPlayer *player = new Graphics::VideoPlayer(seqDecoder); if (seqDecoder->loadFile(filename.c_str(), delay)) - player->playVideo(stopEvents); + player->playVideo(); else warning("Failed to open movie file %s", filename.c_str()); seqDecoder->closeFile(); diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 014f5084eb..60e9bb13fa 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -33,9 +33,7 @@ #include "common/config-manager.h" #include "common/endian.h" #include "common/str.h" -#include "common/events.h" #include "common/system.h" -#include "common/list.h" #include "graphics/surface.h" #include "gui/message.h" @@ -153,17 +151,10 @@ void MoviePlayer::play(void) { } bool terminated = false; - Common::List stopEvents; - Common::Event stopEvent; - stopEvents.clear(); - stopEvent.type = Common::EVENT_KEYDOWN; - stopEvent.kbd = Common::KEYCODE_ESCAPE; - stopEvents.push_back(stopEvent); - _textX = 0; _textY = 0; - terminated = !playVideo(stopEvents); + terminated = !playVideo(); if (terminated) _snd->stopHandle(*_bgSoundHandle); diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index b178bd23b6..0f3d369ee9 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -107,14 +107,7 @@ void MoviePlayer::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadI bool terminated = false; - Common::List stopEvents; - Common::Event stopEvent; - stopEvents.clear(); - stopEvent.type = Common::EVENT_KEYDOWN; - stopEvent.kbd = Common::KEYCODE_ESCAPE; - stopEvents.push_back(stopEvent); - - terminated = !playVideo(stopEvents); + terminated = !playVideo(); closeTextObject(_currentMovieText, NULL); diff --git a/graphics/video/video_player.cpp b/graphics/video/video_player.cpp index 81c025d22f..a8c4ccba89 100644 --- a/graphics/video/video_player.cpp +++ b/graphics/video/video_player.cpp @@ -225,6 +225,17 @@ bool VideoPlayer::playVideo(Common::List &stopEvents) { return !_skipVideo; } +bool VideoPlayer::playVideo() { + Common::Event stopEvent; + Common::List stopEvents; + stopEvents.clear(); + stopEvent.type = Common::EVENT_KEYDOWN; + stopEvent.kbd = Common::KEYCODE_ESCAPE; + stopEvents.push_back(stopEvent); + + return playVideo(stopEvents); +} + void VideoPlayer::performPostProcessing(byte *screen) { } diff --git a/graphics/video/video_player.h b/graphics/video/video_player.h index eb02032b50..333c39f700 100644 --- a/graphics/video/video_player.h +++ b/graphics/video/video_player.h @@ -192,6 +192,12 @@ public: */ bool playVideo(Common::List &stopEvents); + /** + * Provides the same functionality as the video player, and it adds the + * event of skipping the video with the escape key by default + */ + bool playVideo(); + protected: /** * Perform postprocessing once the frame data is copied to the screen, -- cgit v1.2.3