From b124c8b1225627def357b284e43d9890e1fda79a Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Thu, 30 Jul 2009 01:12:07 +0000 Subject: * Added Animation::setCurrentFrame() * Moved rewinding the animation to the beginning from Animation::nextFrame() to AnimationManager::stop() (fixes the owl animation) svn-id: r42913 --- engines/draci/animation.cpp | 17 ++++++++++++++--- engines/draci/animation.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index 5ba12fb529..c5c33153ea 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -98,9 +98,6 @@ void Animation::nextFrame(bool force) { if ((_currentFrame == getFrameCount() - 1) && !_looping) { // When the animation reaches its end, call the preset callback (this->*_callback)(); - - // Reset the frame to 0 - _currentFrame = 0; } else { // Mark old frame dirty so it gets deleted markDirtyRect(surface); @@ -258,6 +255,16 @@ uint Animation::currentFrameNum() { return _currentFrame; } +void Animation::setCurrentFrame(uint frame) { + + // Check whether the value is sane + if (frame > _frames.size()) { + return; + } + + _currentFrame = frame; +} + void Animation::deleteFrames() { // If there are no frames to delete, return @@ -331,6 +338,10 @@ void AnimationManager::stop(int id) { anim->markDirtyRect(_vm->_screen->getSurface()); anim->setPlaying(false); + + // Reset the animation to the beginning + anim->setCurrentFrame(0); + debugC(3, kDraciAnimationDebugLevel, "Stopping animation %d...", id); } diff --git a/engines/draci/animation.h b/engines/draci/animation.h index 3fd4b67114..a6ab07a9a4 100644 --- a/engines/draci/animation.h +++ b/engines/draci/animation.h @@ -69,6 +69,7 @@ public: void addFrame(Drawable *frame); Drawable *getFrame(int frameNum = kCurrentFrame); + void setCurrentFrame(uint frame); uint currentFrameNum(); uint getFrameCount(); void deleteFrames(); -- cgit v1.2.3