MOHAWK: fix LB playback seek behaviour

svn-id: r54675
This commit is contained in:
Alyssa Milburn 2010-11-30 14:41:27 +00:00
parent 8009a86c29
commit 868e39c29a
2 changed files with 19 additions and 18 deletions

View File

@ -1622,7 +1622,7 @@ void LBItem::update() {
if (_nextTime == 0 || _nextTime > (uint32)(_vm->_system->getMillis() / 16)) if (_nextTime == 0 || _nextTime > (uint32)(_vm->_system->getMillis() / 16))
return; return;
if (togglePlaying(_playing)) { if (togglePlaying(_playing, true)) {
_nextTime = 0; _nextTime = 0;
} else if (_loops == 0 && _timingMode == 2) { } else if (_loops == 0 && _timingMode == 2) {
debug(9, "Looping in update()"); debug(9, "Looping in update()");
@ -1647,15 +1647,14 @@ void LBItem::handleMouseUp(Common::Point pos) {
runScript(kLBActionMouseUp); runScript(kLBActionMouseUp);
} }
bool LBItem::togglePlaying(bool playing) { bool LBItem::togglePlaying(bool playing, bool restart) {
if (playing) { if (playing) {
_vm->queueDelayedEvent(DelayedEvent(this, kLBDone)); _vm->queueDelayedEvent(DelayedEvent(this, kLBDone));
return true; return true;
} }
if (!_neverEnabled && _enabled && !_playing) { if (!_neverEnabled && _enabled && !_playing) {
_playing = togglePlaying(true); _playing = togglePlaying(true, restart);
if (_playing) { if (_playing) {
seek(1); // TODO: this is not good in many situations
_nextTime = 0; _nextTime = 0;
_startTime = _vm->_system->getMillis() / 16; _startTime = _vm->_system->getMillis() / 16;
@ -1689,7 +1688,7 @@ void LBItem::done(bool onlyNotify) {
// TODO: does drag box need adjusting? // TODO: does drag box need adjusting?
} }
if (_loops && _loops--) { if (_loops && --_loops) {
debug(9, "Real looping (now 0x%04x left)", _loops); debug(9, "Real looping (now 0x%04x left)", _loops);
setNextTime(_delayMin, _delayMax, _startTime); setNextTime(_delayMin, _delayMax, _startTime);
} else } else
@ -1876,9 +1875,9 @@ LBSoundItem::~LBSoundItem() {
_vm->_sound->stopSound(_resourceId); _vm->_sound->stopSound(_resourceId);
} }
bool LBSoundItem::togglePlaying(bool playing) { bool LBSoundItem::togglePlaying(bool playing, bool restart) {
if (!playing) if (!playing)
return LBItem::togglePlaying(playing); return LBItem::togglePlaying(playing, restart);
_vm->_sound->stopSound(_resourceId); _vm->_sound->stopSound(_resourceId);
@ -1944,11 +1943,11 @@ bool LBGroupItem::contains(Common::Point point) {
return false; return false;
} }
bool LBGroupItem::togglePlaying(bool playing) { bool LBGroupItem::togglePlaying(bool playing, bool restart) {
for (uint i = 0; i < _groupEntries.size(); i++) { for (uint i = 0; i < _groupEntries.size(); i++) {
LBItem *item = _vm->getItemById(_groupEntries[i].entryId); LBItem *item = _vm->getItemById(_groupEntries[i].entryId);
if (item) if (item)
item->togglePlaying(playing); item->togglePlaying(playing, restart);
} }
return false; return false;
@ -2176,9 +2175,9 @@ void LBLiveTextItem::handleMouseDown(Common::Point pos) {
return LBItem::handleMouseDown(pos); return LBItem::handleMouseDown(pos);
} }
bool LBLiveTextItem::togglePlaying(bool playing) { bool LBLiveTextItem::togglePlaying(bool playing, bool restart) {
if (!playing) if (!playing)
return LBItem::togglePlaying(playing); return LBItem::togglePlaying(playing, restart);
if (_neverEnabled || !_enabled) if (_neverEnabled || !_enabled)
return _running; return _running;
@ -2308,9 +2307,11 @@ void LBAnimationItem::update() {
LBItem::update(); LBItem::update();
} }
bool LBAnimationItem::togglePlaying(bool playing) { bool LBAnimationItem::togglePlaying(bool playing, bool restart) {
if (playing) { if (playing) {
if (!_neverEnabled && _enabled) { if (!_neverEnabled && _enabled) {
if (restart)
seek(1);
_running = true; _running = true;
_anim->start(); _anim->start();
} }
@ -2318,7 +2319,7 @@ bool LBAnimationItem::togglePlaying(bool playing) {
return _running; return _running;
} }
return LBItem::togglePlaying(playing); return LBItem::togglePlaying(playing, restart);
} }
void LBAnimationItem::done(bool onlyNotify) { void LBAnimationItem::done(bool onlyNotify) {

View File

@ -217,7 +217,7 @@ public:
virtual void handleMouseDown(Common::Point pos); // 0xB virtual void handleMouseDown(Common::Point pos); // 0xB
virtual void handleMouseMove(Common::Point pos); // 0xC virtual void handleMouseMove(Common::Point pos); // 0xC
virtual void handleMouseUp(Common::Point pos); // 0xD virtual void handleMouseUp(Common::Point pos); // 0xD
virtual bool togglePlaying(bool playing); // 0xF virtual bool togglePlaying(bool playing, bool restart = false); // 0xF
virtual void done(bool onlyNotify); // 0x10 virtual void done(bool onlyNotify); // 0x10
virtual void init() { } // 0x11 virtual void init() { } // 0x11
virtual void seek(uint16 pos) { } // 0x13 virtual void seek(uint16 pos) { } // 0x13
@ -259,7 +259,7 @@ public:
LBSoundItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect); LBSoundItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
~LBSoundItem(); ~LBSoundItem();
bool togglePlaying(bool playing); bool togglePlaying(bool playing, bool restart);
void stop(); void stop();
}; };
@ -276,7 +276,7 @@ public:
void setEnabled(bool enabled); void setEnabled(bool enabled);
bool contains(Common::Point point); bool contains(Common::Point point);
bool togglePlaying(bool playing); bool togglePlaying(bool playing, bool restart);
// 0x12 // 0x12
void seek(uint16 pos); void seek(uint16 pos);
void setVisible(bool visible); void setVisible(bool visible);
@ -322,7 +322,7 @@ public:
bool contains(Common::Point point); bool contains(Common::Point point);
void update(); void update();
void handleMouseDown(Common::Point pos); void handleMouseDown(Common::Point pos);
bool togglePlaying(bool playing); bool togglePlaying(bool playing, bool restart);
void stop(); void stop();
void notify(uint16 data, uint16 from); void notify(uint16 data, uint16 from);
@ -361,7 +361,7 @@ public:
bool contains(Common::Point point); bool contains(Common::Point point);
void update(); void update();
void draw(); void draw();
bool togglePlaying(bool playing); bool togglePlaying(bool playing, bool restart);
void done(bool onlyNotify); void done(bool onlyNotify);
void init(); void init();
void seek(uint16 pos); void seek(uint16 pos);