diff options
Diffstat (limited to 'engines/draci')
-rw-r--r-- | engines/draci/animation.cpp | 13 | ||||
-rw-r--r-- | engines/draci/animation.h | 14 |
2 files changed, 24 insertions, 3 deletions
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index 6cde72a9d2..5ba12fb529 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -40,6 +40,7 @@ Animation::Animation(DraciEngine *vm, int index) : _vm(vm) { _looping = false; _tick = _vm->_system->getMillis(); _currentFrame = 0; + _callback = &Animation::doNothing; } Animation::~Animation() { @@ -95,8 +96,8 @@ void Animation::nextFrame(bool force) { // If we are at the last frame and not looping, stop the animation // The animation is also restarted to frame zero if ((_currentFrame == getFrameCount() - 1) && !_looping) { - // When the animation reaches its end, stop it - _vm->_anims->stop(_id); + // When the animation reaches its end, call the preset callback + (this->*_callback)(); // Reset the frame to 0 _currentFrame = 0; @@ -272,6 +273,14 @@ void Animation::deleteFrames() { } } +void Animation::stopAnimation() { + _vm->_anims->stop(_id); +} + +void Animation::exitGameLoop() { + _vm->_game->setExitLoop(true); +} + Animation *AnimationManager::addAnimation(int id, uint z, bool playing) { // Increment animation index diff --git a/engines/draci/animation.h b/engines/draci/animation.h index 6642107b25..3fd4b67114 100644 --- a/engines/draci/animation.h +++ b/engines/draci/animation.h @@ -51,7 +51,9 @@ enum { kIgnoreIndex = -2 }; class DraciEngine; class Animation { - + +typedef void (Animation::* AnimationCallback)(); + public: Animation(DraciEngine *v, int index); ~Animation(); @@ -90,6 +92,14 @@ public: void markDirtyRect(Surface *surface); + // Animation callbacks + + void registerCallback(AnimationCallback callback) { _callback = callback; } + + void doNothing() {} + void stopAnimation(); + void exitGameLoop(); + private: uint nextFrameNum(); @@ -118,6 +128,8 @@ private: bool _looping; Common::Array<Drawable*> _frames; + AnimationCallback _callback; + DraciEngine *_vm; }; |