[Scummvm-cvs-logs] SF.net SVN: scummvm:[43486] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Mon Aug 17 20:47:17 CEST 2009
Revision: 43486
http://scummvm.svn.sourceforge.net/scummvm/?rev=43486&view=rev
Author: dkasak13
Date: 2009-08-17 18:47:17 +0000 (Mon, 17 Aug 2009)
Log Message:
-----------
* Added pause support for animations.
* Added AnimationManager::addItem() for adding inventory items animations.
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp
scummvm/branches/gsoc2009-draci/engines/draci/animation.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp 2009-08-17 18:25:51 UTC (rev 43485)
+++ scummvm/branches/gsoc2009-draci/engines/draci/animation.cpp 2009-08-17 18:47:17 UTC (rev 43486)
@@ -38,6 +38,7 @@
_scaleY = 1.0;
_playing = false;
_looping = false;
+ _paused = false;
_tick = _vm->_system->getMillis();
_currentFrame = 0;
_callback = &Animation::doNothing;
@@ -118,6 +119,9 @@
uint Animation::nextFrameNum() {
+ if (_paused)
+ return _currentFrame;
+
if ((_currentFrame == getFrameCount() - 1) && _looping)
return 0;
else
@@ -200,6 +204,14 @@
_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 @@
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 @@
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 @@
// 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 @@
Animation *anim = *it;
// If the animation is not playing, ignore it
- if (!anim->isPlaying()) {
+ if (!anim->isPlaying() || anim->isPaused()) {
continue;
}
Modified: scummvm/branches/gsoc2009-draci/engines/draci/animation.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/animation.h 2009-08-17 18:25:51 UTC (rev 43485)
+++ scummvm/branches/gsoc2009-draci/engines/draci/animation.h 2009-08-17 18:47:17 UTC (rev 43486)
@@ -38,7 +38,10 @@
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 @@
bool isPlaying();
void setPlaying(bool playing);
+ bool isPaused();
+ void setPaused(bool paused);
+
bool isLooping();
void setLooping(bool looping);
@@ -131,6 +137,7 @@
uint _tick;
bool _playing;
bool _looping;
+ bool _paused;
Common::Array<Drawable*> _frames;
AnimationCallback _callback;
@@ -147,10 +154,13 @@
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();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list