aboutsummaryrefslogtreecommitdiff
path: root/engines
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
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')
-rw-r--r--engines/draci/animation.cpp58
-rw-r--r--engines/draci/animation.h12
2 files changed, 66 insertions, 4 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;
}
diff --git a/engines/draci/animation.h b/engines/draci/animation.h
index cc339084e3..5d7c0bf7b6 100644
--- a/engines/draci/animation.h
+++ b/engines/draci/animation.h
@@ -38,7 +38,10 @@ enum { kOverlayImage = -1,
kWalkingMapOverlay = -2,
kTitleText = -3,
kSpeechText = -4,
- kUnused = -5 };
+ kInventorySprite = -5,
+ kDialogueLinesID = -6,
+ kUnused = -10,
+ kInventoryItemsID = -11};
/**
* Default argument to Animation::getFrame() that makes it return
@@ -81,6 +84,9 @@ public:
bool isPlaying();
void setPlaying(bool playing);
+ bool isPaused();
+ void setPaused(bool paused);
+
bool isLooping();
void setLooping(bool looping);
@@ -131,6 +137,7 @@ private:
uint _tick;
bool _playing;
bool _looping;
+ bool _paused;
Common::Array<Drawable*> _frames;
AnimationCallback _callback;
@@ -147,10 +154,13 @@ public:
Animation *addAnimation(int id, uint z, bool playing = false);
Animation *addText(int id, bool playing = false);
+ Animation *addItem(int id, bool playing = false);
void addOverlay(Drawable *overlay, uint z);
void play(int id);
void stop(int id);
+ void pauseAnimations();
+ void unpauseAnimations();
void deleteAnimation(int id);
void deleteOverlays();