diff options
-rw-r--r-- | engines/zvision/animation.cpp | 44 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 1 |
2 files changed, 45 insertions, 0 deletions
diff --git a/engines/zvision/animation.cpp b/engines/zvision/animation.cpp index 8ca892dfda..f43e854f73 100644 --- a/engines/zvision/animation.cpp +++ b/engines/zvision/animation.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "common/system.h" +#include "video/video_decoder.h" #include "zvision/zvision.h" #include "zvision/rlf_animation.h" @@ -84,4 +85,47 @@ void ZVision::playAnimation(RlfAnimation *animation, uint16 x, uint16 y, Dispose } } +void ZVision::playAnimation(Video::VideoDecoder *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse) { + _clock.stop(); + animation->start(); + + // Only continue while the video is still playing + while (!shouldQuit() && !animation->endOfVideo() && animation->isPlaying()) { + // Check for engine quit and video stop key presses + while (!animation->endOfVideo() && animation->isPlaying() && _eventMan->pollEvent(_event)) { + switch (_event.type) { + case Common::EVENT_KEYDOWN: + switch (_event.kbd.keycode) { + case Common::KEYCODE_q: + if (_event.kbd.hasFlags(Common::KBD_CTRL)) + quitGame(); + break; + case Common::KEYCODE_SPACE: + animation->stop(); + break; + default: + break; + } + default: + break; + } + } + + if (animation->needsUpdate()) { + const Graphics::Surface *frame = animation->decodeNextFrame(); + + if (frame) { + _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, x, y, frame->w, frame->h); + } + } + + // Always update the screen so the mouse continues to render + _system->updateScreen(); + + _system->delayMillis(animation->getTimeToNextFrame()); + } + + _clock.start(); +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index a02fecc43d..f961f1fda9 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -126,6 +126,7 @@ public: void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true); void playAnimation(RlfAnimation *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + void playAnimation(Video::VideoDecoder *animation, uint16 x, uint16 y, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); /** * Utility method to cycle through all the cursors in the game. After |