[Scummvm-cvs-logs] SF.net SVN: scummvm:[55688] scummvm/trunk/engines/mohawk
fuzzie at users.sourceforge.net
fuzzie at users.sourceforge.net
Mon Jan 31 19:03:28 CET 2011
Revision: 55688
http://scummvm.svn.sourceforge.net/scummvm/?rev=55688&view=rev
Author: fuzzie
Date: 2011-01-31 18:03:27 +0000 (Mon, 31 Jan 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/livingbooks.cpp
scummvm/trunk/engines/mohawk/livingbooks.h
Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp 2011-01-31 16:11:49 UTC (rev 55687)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp 2011-01-31 18:03:27 UTC (rev 55688)
@@ -1233,13 +1233,13 @@
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 @@
_nodes.push_back(new LBAnimationNode(_vm, this, scriptIDs[i]));
_currentFrame = 0;
+ _currentSound = 0xffff;
_running = false;
_tempo = 1;
}
@@ -1461,6 +1462,8 @@
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 @@
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 @@
if (state == kLBNodeRunning) {
_currentFrame++;
} else if (state == kLBNodeDone) {
- _running = false;
- return true;
+ if (_currentSound == 0xffff) {
+ _running = false;
+ return true;
+ }
}
return false;
@@ -1583,8 +1592,21 @@
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) {
for (uint32 i = 0; i < _nodes.size(); i++)
if (!_nodes[i]->transparentAt(x - _bounds.left, y - _bounds.top))
Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h 2011-01-31 16:11:49 UTC (rev 55687)
+++ scummvm/trunk/engines/mohawk/livingbooks.h 2011-01-31 18:03:27 UTC (rev 55688)
@@ -298,6 +298,9 @@
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 @@
Common::Array<LBAnimationNode *> _nodes;
uint16 _tempo;
+ uint16 _currentSound;
uint32 _lastTime, _currentFrame;
bool _running;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list