aboutsummaryrefslogtreecommitdiff
path: root/engines/composer/graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/composer/graphics.cpp')
-rw-r--r--engines/composer/graphics.cpp65
1 files changed, 38 insertions, 27 deletions
diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp
index 87694636d8..32b9812f32 100644
--- a/engines/composer/graphics.cpp
+++ b/engines/composer/graphics.cpp
@@ -44,9 +44,9 @@ bool Sprite::contains(const Common::Point &pos) const {
}
enum {
- kAnimOpEvent = 1,
- kAnimOpPlayWave = 2,
- kAnimOpPlayAnim = 3,
+ kAnimOpEvent = 1,
+ kAnimOpPlayWave = 2,
+ kAnimOpPlayAnim = 3,
kAnimOpDrawSprite = 4
};
@@ -57,6 +57,7 @@ Animation::Animation(Common::SeekableReadStream *stream, uint16 id, Common::Poin
// probably total size?
uint32 unknown = _stream->readUint32LE();
+ _size = unknown;
debug(8, "anim: size %d, state %08x, unknown %08x", size, _state, unknown);
@@ -82,17 +83,7 @@ void Animation::seekToCurrPos() {
_stream->seek(_offset, SEEK_SET);
}
-void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventParam) {
- // First, we check if this animation is already playing,
- // and if it is, we sabotage that running one first.
- for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
- Animation *anim = *i;
- if (anim->_id != animId)
- continue;
-
- stopAnimation(*i);
- }
-
+void ComposerEngine::loadAnimation(Animation *&anim, uint16 animId, int16 x, int16 y, int16 eventParam, int32 size) {
Common::SeekableReadStream *stream = NULL;
Pipe *newPipe = NULL;
@@ -102,7 +93,10 @@ void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventP
if (!pipe->hasResource(ID_ANIM, animId))
continue;
stream = pipe->getResource(ID_ANIM, animId, false);
- break;
+
+ // When loading from savegame, make sure we have the correct stream
+ if ((!size) || (stream->size() >= size)) break;
+ stream = NULL;
}
// If we didn't find it, try the libraries.
@@ -111,33 +105,50 @@ void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventP
warning("ignoring attempt to play invalid anim %d", animId);
return;
}
- stream = getResource(ID_ANIM, animId);
+ Common::List<Library>::iterator j;
+ for (j = _libraries.begin(); j != _libraries.end(); j++) {
+ stream = j->_archive->getResource(ID_ANIM, animId);
- uint32 type = 0;
- for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++)
- if (i->_archive->hasResource(ID_ANIM, animId)) {
- type = i->_archive->getResourceFlags(ID_ANIM, animId);
- break;
- }
+ // When loading from savegame, make sure we have the correct stream
+ if ((!size) || (stream->size() >= size)) break;
+ stream = NULL;
+ }
+
+ uint32 type = j->_archive->getResourceFlags(ID_ANIM, animId);
// If the resource is a pipe itself, then load the pipe
// and then fish the requested animation out of it.
if (type != 1) {
_pipeStreams.push_back(stream);
- newPipe = new Pipe(stream);
+ newPipe = new Pipe(stream, animId);
_pipes.push_front(newPipe);
newPipe->nextFrame();
stream = newPipe->getResource(ID_ANIM, animId, false);
}
}
- Animation *anim = new Animation(stream, animId, Common::Point(x, y), eventParam);
- _anims.push_back(anim);
- runEvent(kEventAnimStarted, animId, eventParam, 0);
+ anim = new Animation(stream, animId, Common::Point(x, y), eventParam);
if (newPipe)
newPipe->_anim = anim;
}
+void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventParam) {
+ // First, we check if this animation is already playing,
+ // and if it is, we sabotage that running one first.
+ for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
+ Animation *anim = *i;
+ if (anim->_id != animId)
+ continue;
+
+ stopAnimation(*i);
+ }
+
+ Animation *anim = NULL;
+ loadAnimation(anim, animId, x, y, eventParam);
+ _anims.push_back(anim);
+ runEvent(kEventAnimStarted, animId, eventParam, 0);
+}
+
void ComposerEngine::stopAnimation(Animation *anim, bool localOnly, bool pipesOnly) {
// disable the animation
anim->_state = 0;
@@ -376,7 +387,7 @@ void ComposerEngine::playPipe(uint16 id) {
}
Common::SeekableReadStream *stream = getResource(ID_PIPE, id);
- OldPipe *pipe = new OldPipe(stream);
+ OldPipe *pipe = new OldPipe(stream, id);
_pipes.push_front(pipe);
//pipe->nextFrame();