MOHAWK: fix LBAnimation start/seek behaviour

svn-id: r54673
This commit is contained in:
Alyssa Milburn 2010-11-30 14:40:51 +00:00
parent 77cec92258
commit e04c0182cd
2 changed files with 12 additions and 30 deletions

View file

@ -1256,8 +1256,8 @@ LBAnimation::LBAnimation(MohawkEngine_LivingBooks *vm, LBAnimationItem *parent,
for (uint16 i = 0; i < scriptIDs.size(); i++) for (uint16 i = 0; i < scriptIDs.size(); i++)
_nodes.push_back(new LBAnimationNode(_vm, this, scriptIDs[i])); _nodes.push_back(new LBAnimationNode(_vm, this, scriptIDs[i]));
_currentFrame = 0;
_running = false; _running = false;
_done = false;
_tempo = 1; _tempo = 1;
} }
@ -1321,12 +1321,12 @@ void LBAnimation::draw() {
_nodes[i]->draw(_bounds); _nodes[i]->draw(_bounds);
} }
void LBAnimation::update() { bool LBAnimation::update() {
if (!_running) if (!_running)
return; return false;
if (_vm->_system->getMillis() / 16 <= _lastTime + (uint32)_tempo) 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 // 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)) if (_lastTime == 0 || (_vm->_system->getMillis() / 16) > _lastTime + (uint32)(_tempo * 2))
@ -1351,24 +1351,20 @@ void LBAnimation::update() {
_currentFrame++; _currentFrame++;
} else if (state == kLBNodeDone) { } else if (state == kLBNodeDone) {
_running = false; _running = false;
_done = true; return true;
} }
return false;
} }
void LBAnimation::start() { void LBAnimation::start() {
_lastTime = 0; _lastTime = 0;
_currentFrame = 0;
_running = true; _running = true;
_done = false;
for (uint32 i = 0; i < _nodes.size(); i++)
_nodes[i]->reset();
} }
void LBAnimation::seek(uint16 pos) { void LBAnimation::seek(uint16 pos) {
_lastTime = 0; _lastTime = 0;
_currentFrame = 0; _currentFrame = 0;
_done = false;
for (uint32 i = 0; i < _nodes.size(); i++) for (uint32 i = 0; i < _nodes.size(); i++)
_nodes[i]->reset(); _nodes[i]->reset();
@ -1390,15 +1386,6 @@ void LBAnimation::seek(uint16 pos) {
void LBAnimation::stop() { void LBAnimation::stop() {
_running = false; _running = false;
_done = false;
}
bool LBAnimation::wasDone() {
if (!_done)
return false;
_done = false;
return true;
} }
bool LBAnimation::transparentAt(int x, int y) { bool LBAnimation::transparentAt(int x, int y) {
@ -2304,16 +2291,12 @@ bool LBAnimationItem::contains(Common::Point point) {
void LBAnimationItem::update() { void LBAnimationItem::update() {
if (!_neverEnabled && _enabled && _running) { if (!_neverEnabled && _enabled && _running) {
_anim->update(); bool wasDone = _anim->update();
if (wasDone)
done(true);
} }
LBItem::update(); 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) { bool LBAnimationItem::togglePlaying(bool playing) {

View file

@ -166,13 +166,12 @@ public:
~LBAnimation(); ~LBAnimation();
void draw(); void draw();
void update(); bool update();
void start(); void start();
void seek(uint16 pos); void seek(uint16 pos);
void stop(); void stop();
bool wasDone();
bool transparentAt(int x, int y); bool transparentAt(int x, int y);
void setTempo(uint16 tempo); void setTempo(uint16 tempo);
@ -194,7 +193,7 @@ protected:
uint16 _tempo; uint16 _tempo;
uint32 _lastTime, _currentFrame; uint32 _lastTime, _currentFrame;
bool _running, _done; bool _running;
void loadShape(uint16 resourceId); void loadShape(uint16 resourceId);
Common::Array<uint16> _shapeResources; Common::Array<uint16> _shapeResources;