aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorAlyssa Milburn2011-01-31 18:03:27 +0000
committerAlyssa Milburn2011-01-31 18:03:27 +0000
commit309cb47572e602fbdecb3a6bfea789f50df7c4f3 (patch)
treeeddd056bc963ca1a44829e91ed37b77e0ddf4d6d /engines/mohawk
parent4a07ae68291bf0fde9b207af9b8b5277fb5049e5 (diff)
downloadscummvm-rg350-309cb47572e602fbdecb3a6bfea789f50df7c4f3.tar.gz
scummvm-rg350-309cb47572e602fbdecb3a6bfea789f50df7c4f3.tar.bz2
scummvm-rg350-309cb47572e602fbdecb3a6bfea789f50df7c4f3.zip
MOHAWK: LB anim sound improvements.
The parent animation now keeps track of sounds, and animations don't emit a done event while their sounds are still playing. svn-id: r55688
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/livingbooks.cpp30
-rw-r--r--engines/mohawk/livingbooks.h4
2 files changed, 30 insertions, 4 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 24c93cd16a..e9c7b13e14 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -1233,13 +1233,13 @@ NodeState LBAnimationNode::update(bool seeking) {
if (seeking)
break;
debug(4, "a: PlaySound(%0d)", soundResourceId);
- _vm->_sound->playSound(soundResourceId);
+ _parent->playSound(soundResourceId);
break;
case kLBAnimOpWaitForSound:
if (seeking)
break;
debug(4, "b: WaitForSound(%0d)", soundResourceId);
- if (!_vm->_sound->isPlaying(soundResourceId))
+ if (!_parent->soundPlaying(soundResourceId))
break;
_currentEntry--;
return kLBNodeWaiting;
@@ -1454,6 +1454,7 @@ LBAnimation::LBAnimation(MohawkEngine_LivingBooks *vm, LBAnimationItem *parent,
_nodes.push_back(new LBAnimationNode(_vm, this, scriptIDs[i]));
_currentFrame = 0;
+ _currentSound = 0xffff;
_running = false;
_tempo = 1;
}
@@ -1461,6 +1462,8 @@ LBAnimation::LBAnimation(MohawkEngine_LivingBooks *vm, LBAnimationItem *parent,
LBAnimation::~LBAnimation() {
for (uint32 i = 0; i < _nodes.size(); i++)
delete _nodes[i];
+ if (_currentSound != 0xffff)
+ _vm->_sound->stopSound(_currentSound);
}
void LBAnimation::loadShape(uint16 resourceId) {
@@ -1531,6 +1534,10 @@ bool LBAnimation::update() {
else
_lastTime += _tempo;
+ if (_currentSound != 0xffff && !_vm->_sound->isPlaying(_currentSound)) {
+ _currentSound = 0xffff;
+ }
+
NodeState state = kLBNodeDone;
for (uint32 i = 0; i < _nodes.size(); i++) {
NodeState s = _nodes[i]->update();
@@ -1547,8 +1554,10 @@ bool LBAnimation::update() {
if (state == kLBNodeRunning) {
_currentFrame++;
} else if (state == kLBNodeDone) {
- _running = false;
- return true;
+ if (_currentSound == 0xffff) {
+ _running = false;
+ return true;
+ }
}
return false;
@@ -1583,6 +1592,19 @@ void LBAnimation::seek(uint16 pos) {
void LBAnimation::stop() {
_running = false;
+ if (_currentSound != 0xffff) {
+ _vm->_sound->stopSound(_currentSound);
+ _currentSound = 0xffff;
+ }
+}
+
+void LBAnimation::playSound(uint16 resourceId) {
+ _currentSound = resourceId;
+ _vm->_sound->playSound(_currentSound);
+}
+
+bool LBAnimation::soundPlaying(uint16 resourceId) {
+ return _currentSound == resourceId && _vm->_sound->isPlaying(_currentSound);
}
bool LBAnimation::transparentAt(int x, int y) {
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 513db28fa8..18f37a9a3a 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -298,6 +298,9 @@ public:
void seek(uint16 pos);
void stop();
+ void playSound(uint16 resourceId);
+ bool soundPlaying(uint16 resourceId);
+
bool transparentAt(int x, int y);
void setTempo(uint16 tempo);
@@ -318,6 +321,7 @@ protected:
Common::Array<LBAnimationNode *> _nodes;
uint16 _tempo;
+ uint16 _currentSound;
uint32 _lastTime, _currentFrame;
bool _running;