aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDenis Kasak2009-07-29 19:39:10 +0000
committerDenis Kasak2009-07-29 19:39:10 +0000
commitf42894c33cb744759a9cfd64fcc24599a8451572 (patch)
tree1c5a3c3fb4c41c274a69aa4be80e1aa00fc5d225 /engines
parent07042e31bcabd4c33f38a7c3a41ca6c603525011 (diff)
downloadscummvm-rg350-f42894c33cb744759a9cfd64fcc24599a8451572.tar.gz
scummvm-rg350-f42894c33cb744759a9cfd64fcc24599a8451572.tar.bz2
scummvm-rg350-f42894c33cb744759a9cfd64fcc24599a8451572.zip
Added support for animation callbacks and implemented a few callbacks (doNothing, exitGameLoop, stopAnimation).
svn-id: r42901
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/animation.cpp13
-rw-r--r--engines/draci/animation.h14
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;
};