aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/animation.cpp
diff options
context:
space:
mode:
authorDenis Kasak2009-08-17 18:47:17 +0000
committerDenis Kasak2009-08-17 18:47:17 +0000
commite5774d2881fe769e31ead57870b1315c56a4ba21 (patch)
tree55cee96f15e0204a3cf13ab513ac9fcf869180a4 /engines/draci/animation.cpp
parent680bed134bd96cb4437b8265aee1a8bcfd8bb7ad (diff)
downloadscummvm-rg350-e5774d2881fe769e31ead57870b1315c56a4ba21.tar.gz
scummvm-rg350-e5774d2881fe769e31ead57870b1315c56a4ba21.tar.bz2
scummvm-rg350-e5774d2881fe769e31ead57870b1315c56a4ba21.zip
* Added pause support for animations.
* Added AnimationManager::addItem() for adding inventory items animations. svn-id: r43486
Diffstat (limited to 'engines/draci/animation.cpp')
-rw-r--r--engines/draci/animation.cpp58
1 files changed, 55 insertions, 3 deletions
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp
index 2865a1daf6..248cc09197 100644
--- a/engines/draci/animation.cpp
+++ b/engines/draci/animation.cpp
@@ -38,6 +38,7 @@ Animation::Animation(DraciEngine *vm, int index) : _vm(vm) {
_scaleY = 1.0;
_playing = false;
_looping = false;
+ _paused = false;
_tick = _vm->_system->getMillis();
_currentFrame = 0;
_callback = &Animation::doNothing;
@@ -118,6 +119,9 @@ void Animation::nextFrame(bool force) {
uint Animation::nextFrameNum() {
+ if (_paused)
+ return _currentFrame;
+
if ((_currentFrame == getFrameCount() - 1) && _looping)
return 0;
else
@@ -200,6 +204,14 @@ void Animation::setPlaying(bool playing) {
_playing = playing;
}
+bool Animation::isPaused() {
+ return _paused;
+}
+
+void Animation::setPaused(bool paused) {
+ _paused = paused;
+}
+
void Animation::setScaleFactors(double scaleX, double scaleY) {
debugC(5, kDraciAnimationDebugLevel,
@@ -304,7 +316,7 @@ Animation *AnimationManager::addAnimation(int id, uint z, bool playing) {
return anim;
}
-Animation *AnimationManager::addText(int id, bool playing) {
+Animation *AnimationManager::addItem(int id, bool playing) {
Animation *anim = new Animation(_vm, kIgnoreIndex);
@@ -317,6 +329,19 @@ Animation *AnimationManager::addText(int id, bool playing) {
return anim;
}
+Animation *AnimationManager::addText(int id, bool playing) {
+
+ Animation *anim = new Animation(_vm, kIgnoreIndex);
+
+ anim->setID(id);
+ anim->setZ(257);
+ anim->setPlaying(playing);
+
+ insertAnimation(anim);
+
+ return anim;
+}
+
void AnimationManager::play(int id) {
Animation *anim = getAnimation(id);
@@ -341,12 +366,39 @@ void AnimationManager::stop(int id) {
// Reset the animation to the beginning
anim->setCurrentFrame(0);
-
debugC(3, kDraciAnimationDebugLevel, "Stopping animation %d...", id);
}
}
+void AnimationManager::pauseAnimations() {
+
+ Common::List<Animation *>::iterator it;
+
+ for (it = _animations.begin(); it != _animations.end(); ++it) {
+ if ((*it)->getID() > 0 || (*it)->getID() == kTitleText) {
+ // Clean up the last frame that was drawn before stopping
+ (*it)->markDirtyRect(_vm->_screen->getSurface());
+
+ (*it)->setPaused(true);
+ }
+ }
+}
+
+void AnimationManager::unpauseAnimations() {
+
+ Common::List<Animation *>::iterator it;
+
+ for (it = _animations.begin(); it != _animations.end(); ++it) {
+ if ((*it)->isPaused()) {
+ // Clean up the last frame that was drawn before stopping
+ (*it)->markDirtyRect(_vm->_screen->getSurface());
+
+ (*it)->setPaused(false);
+ }
+ }
+}
+
Animation *AnimationManager::getAnimation(int id) {
Common::List<Animation *>::iterator it;
@@ -535,7 +587,7 @@ int AnimationManager::getTopAnimationID(int x, int y) {
Animation *anim = *it;
// If the animation is not playing, ignore it
- if (!anim->isPlaying()) {
+ if (!anim->isPlaying() || anim->isPaused()) {
continue;
}