mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 14:51:40 +00:00
MOHAWK: Fix LBCode seek/seekToFrame.
This commit is contained in:
parent
3f30105fff
commit
1e9ea08495
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user