From e04c0182cdd7672b6b471cd45495984e663d16ab Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 30 Nov 2010 14:40:51 +0000 Subject: MOHAWK: fix LBAnimation start/seek behaviour svn-id: r54673 --- engines/mohawk/livingbooks.cpp | 37 ++++++++++--------------------------- engines/mohawk/livingbooks.h | 5 ++--- 2 files changed, 12 insertions(+), 30 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 72c24afa38..5674d9f21a 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -1256,8 +1256,8 @@ LBAnimation::LBAnimation(MohawkEngine_LivingBooks *vm, LBAnimationItem *parent, for (uint16 i = 0; i < scriptIDs.size(); i++) _nodes.push_back(new LBAnimationNode(_vm, this, scriptIDs[i])); + _currentFrame = 0; _running = false; - _done = false; _tempo = 1; } @@ -1321,12 +1321,12 @@ void LBAnimation::draw() { _nodes[i]->draw(_bounds); } -void LBAnimation::update() { +bool LBAnimation::update() { if (!_running) - return; + return false; if (_vm->_system->getMillis() / 16 <= _lastTime + (uint32)_tempo) - return; + return false; // the second check is to try 'catching up' with lagged animations, might be crazy if (_lastTime == 0 || (_vm->_system->getMillis() / 16) > _lastTime + (uint32)(_tempo * 2)) @@ -1351,24 +1351,20 @@ void LBAnimation::update() { _currentFrame++; } else if (state == kLBNodeDone) { _running = false; - _done = true; + return true; } + + return false; } void LBAnimation::start() { _lastTime = 0; - _currentFrame = 0; _running = true; - _done = false; - - for (uint32 i = 0; i < _nodes.size(); i++) - _nodes[i]->reset(); } void LBAnimation::seek(uint16 pos) { _lastTime = 0; _currentFrame = 0; - _done = false; for (uint32 i = 0; i < _nodes.size(); i++) _nodes[i]->reset(); @@ -1390,15 +1386,6 @@ void LBAnimation::seek(uint16 pos) { void LBAnimation::stop() { _running = false; - _done = false; -} - -bool LBAnimation::wasDone() { - if (!_done) - return false; - - _done = false; - return true; } bool LBAnimation::transparentAt(int x, int y) { @@ -2304,16 +2291,12 @@ bool LBAnimationItem::contains(Common::Point point) { void LBAnimationItem::update() { if (!_neverEnabled && _enabled && _running) { - _anim->update(); + bool wasDone = _anim->update(); + if (wasDone) + done(true); } LBItem::update(); - - // TODO: where exactly does this go? - // TODO: what checks should we have around this? - if (!_neverEnabled && _enabled && _running && _anim->wasDone()) { - done(true); - } } bool LBAnimationItem::togglePlaying(bool playing) { diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h index 2e743e1854..060dcd960a 100644 --- a/engines/mohawk/livingbooks.h +++ b/engines/mohawk/livingbooks.h @@ -166,13 +166,12 @@ public: ~LBAnimation(); void draw(); - void update(); + bool update(); void start(); void seek(uint16 pos); void stop(); - bool wasDone(); bool transparentAt(int x, int y); void setTempo(uint16 tempo); @@ -194,7 +193,7 @@ protected: uint16 _tempo; uint32 _lastTime, _currentFrame; - bool _running, _done; + bool _running; void loadShape(uint16 resourceId); Common::Array _shapeResources; -- cgit v1.2.3