diff options
author | Alyssa Milburn | 2011-11-27 21:01:46 +0100 |
---|---|---|
committer | Alyssa Milburn | 2011-11-27 21:02:13 +0100 |
commit | 1e9ea0849516c545ce9f6f943f154c31597be8ef (patch) | |
tree | da9416de903cf98dce1073baae1a043b7bd76a66 /engines | |
parent | 3f30105fff58849dc24dadbf04d945bfb75916a4 (diff) | |
download | scummvm-rg350-1e9ea0849516c545ce9f6f943f154c31597be8ef.tar.gz scummvm-rg350-1e9ea0849516c545ce9f6f943f154c31597be8ef.tar.bz2 scummvm-rg350-1e9ea0849516c545ce9f6f943f154c31597be8ef.zip |
MOHAWK: Fix LBCode seek/seekToFrame.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 33 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.h | 3 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_code.cpp | 13 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_code.h | 1 |
4 files changed, 49 insertions, 1 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index d0c8bf3515..486ecb52eb 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -1859,6 +1859,35 @@ void LBAnimation::seek(uint16 pos) { } } +void LBAnimation::seekToTime(uint32 time) { + _lastTime = 0; + _currentFrame = 0; + + if (_currentSound != 0xffff) { + _vm->_sound->stopSound(_currentSound); + _currentSound = 0xffff; + } + + for (uint32 i = 0; i < _nodes.size(); i++) + _nodes[i]->reset(); + + uint32 elapsed = 0; + while (elapsed <= time) { + bool ranSomething = false; + // nodes don't wait while seeking + for (uint32 i = 0; i < _nodes.size(); i++) + ranSomething |= (_nodes[i]->update(true) != kLBNodeDone); + + elapsed += _tempo; + _currentFrame++; + + if (!ranSomething) { + _running = false; + break; + } + } +} + void LBAnimation::stop() { _running = false; if (_currentSound != 0xffff) { @@ -3612,6 +3641,10 @@ void LBAnimationItem::seek(uint16 pos) { _anim->seek(pos); } +void LBAnimationItem::seekToTime(uint32 time) { + _anim->seekToTime(time); +} + void LBAnimationItem::startPhase(uint phase) { if (phase == _phase) seek(1); diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h index 975a5f9795..39bd9cab30 100644 --- a/engines/mohawk/livingbooks.h +++ b/engines/mohawk/livingbooks.h @@ -331,6 +331,7 @@ public: void start(); void seek(uint16 pos); + void seekToTime(uint32 time); void stop(); void playSound(uint16 resourceId); @@ -393,6 +394,7 @@ public: virtual void done(bool onlyNotify); // 0x10 virtual void init(); // 0x11 virtual void seek(uint16 pos) { } // 0x13 + virtual void seekToTime(uint32 time) { } virtual void setFocused(bool focused) { } // 0x14 virtual void setVisible(bool visible); // 0x17 virtual void setGlobalVisible(bool enabled); @@ -567,6 +569,7 @@ public: void done(bool onlyNotify); void init(); void seek(uint16 pos); + void seekToTime(uint32 time); void startPhase(uint phase); void stop(); diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp index f16fd409b3..836ad8ce6d 100644 --- a/engines/mohawk/livingbooks_code.cpp +++ b/engines/mohawk/livingbooks_code.cpp @@ -1177,7 +1177,7 @@ CodeCommandInfo itemCommandInfo[NUM_ITEM_COMMANDS] = { { "mute", 0 }, { "play", 0 }, { "seek", &LBCode::itemSeek }, - { "seekToFrame", 0 }, + { "seekToFrame", &LBCode::itemSeekToFrame }, { "setParent", &LBCode::itemSetParent }, { "setZOrder", 0 }, { "setText", 0 }, @@ -1220,6 +1220,17 @@ void LBCode::itemSeek(const Common::Array<LBValue> ¶ms) { if (!item) error("attempted seek on invalid item (%s)", params[0].toString().c_str()); uint seekTo = params[1].toInt(); + item->seekToTime(seekTo); +} + +void LBCode::itemSeekToFrame(const Common::Array<LBValue> ¶ms) { + if (params.size() != 2) + error("incorrect number of parameters (%d) to seekToFrame", params.size()); + + LBItem *item = resolveItem(params[0]); + if (!item) + error("attempted seekToFrame on invalid item (%s)", params[0].toString().c_str()); + uint seekTo = params[1].toInt(); item->seek(seekTo); } diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h index 6d3812aae9..e866fca0b4 100644 --- a/engines/mohawk/livingbooks_code.h +++ b/engines/mohawk/livingbooks_code.h @@ -275,6 +275,7 @@ public: void itemIsPlaying(const Common::Array<LBValue> ¶ms); void itemMoveTo(const Common::Array<LBValue> ¶ms); void itemSeek(const Common::Array<LBValue> ¶ms); + void itemSeekToFrame(const Common::Array<LBValue> ¶ms); void itemSetParent(const Common::Array<LBValue> ¶ms); }; |