diff options
author | johndoe123 | 2012-09-28 17:26:42 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:43:44 +0200 |
commit | 7adc1d312e5d09c0566345d5264db7f4b2322f98 (patch) | |
tree | 91bf9e3c16262ea0d0d2f8b767aea358562d8148 /engines/neverhood | |
parent | 0f04a013380c07f76ca68a14917cd6bce607184e (diff) | |
download | scummvm-rg350-7adc1d312e5d09c0566345d5264db7f4b2322f98.tar.gz scummvm-rg350-7adc1d312e5d09c0566345d5264db7f4b2322f98.tar.bz2 scummvm-rg350-7adc1d312e5d09c0566345d5264db7f4b2322f98.zip |
NEVERHOOD: Change sound stuff in Module1100
- Implement Entity::isSoundPlaying
Diffstat (limited to 'engines/neverhood')
-rw-r--r-- | engines/neverhood/entity.cpp | 4 | ||||
-rw-r--r-- | engines/neverhood/entity.h | 1 | ||||
-rw-r--r-- | engines/neverhood/module1100.cpp | 42 | ||||
-rw-r--r-- | engines/neverhood/module1100.h | 7 |
4 files changed, 24 insertions, 30 deletions
diff --git a/engines/neverhood/entity.cpp b/engines/neverhood/entity.cpp index f78d4cf23d..d7d78969d2 100644 --- a/engines/neverhood/entity.cpp +++ b/engines/neverhood/entity.cpp @@ -138,6 +138,10 @@ void Entity::playSound(uint index, uint32 fileHash) { getSoundResource(index)->play(); } +bool Entity::isSoundPlaying(uint index) { + return getSoundResource(index)->isPlaying(); +} + void Entity::deleteSoundResources() { if (_soundResources) { for (uint i = 0; i < kMaxSoundResources; ++i) diff --git a/engines/neverhood/entity.h b/engines/neverhood/entity.h index f22243705a..eafc467b55 100644 --- a/engines/neverhood/entity.h +++ b/engines/neverhood/entity.h @@ -108,6 +108,7 @@ protected: // TODO Add other sound stuff void loadSound(uint index, uint32 fileHash); void playSound(uint index, uint32 fileHash = 0); + bool isSoundPlaying(uint index); void deleteSoundResources(); }; diff --git a/engines/neverhood/module1100.cpp b/engines/neverhood/module1100.cpp index e5cca2667d..257ee27d0d 100644 --- a/engines/neverhood/module1100.cpp +++ b/engines/neverhood/module1100.cpp @@ -272,8 +272,7 @@ static const uint32 kSsScene1105SymbolDieFileHashes[] = { }; SsScene1105Button::SsScene1105Button(NeverhoodEngine *vm, Scene *parentScene, uint32 fileHash, NRect &rect) - : StaticSprite(vm, fileHash, 200), _soundResource(vm), _parentScene(parentScene), - _countdown(0) { + : StaticSprite(vm, fileHash, 200), _parentScene(parentScene), _countdown(0) { _rect = rect; SetMessageHandler(&SsScene1105Button::handleMessage); @@ -300,7 +299,7 @@ uint32 SsScene1105Button::handleMessage(int messageNum, const MessageParam ¶ case 0x480B: _countdown = 8; setVisible(true); - _soundResource.play(0x44141000); + playSound(0, 0x44141000); break; } return messageResult; @@ -356,8 +355,7 @@ void SsScene1105SymbolDie::hide() { } AsScene1105TeddyBear::AsScene1105TeddyBear(NeverhoodEngine *vm, Scene *parentScene) - : AnimatedSprite(vm, 1100), _soundResource1(vm), _soundResource2(vm), - _parentScene(parentScene) { + : AnimatedSprite(vm, 1100), _parentScene(parentScene) { // TODO createSurface3(100, dword_4AF4C0); createSurface(100, 640, 480); //TODO: Remeove once the line above is done @@ -370,8 +368,8 @@ AsScene1105TeddyBear::AsScene1105TeddyBear(NeverhoodEngine *vm, Scene *parentSce setVisible(false); _needRefresh = true; updatePosition(); - _soundResource1.load(0xCE840261); - _soundResource2.load(0xCCA41A62); + loadSound(0, 0xCE840261); + loadSound(1, 0xCCA41A62); } uint32 AsScene1105TeddyBear::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { @@ -380,10 +378,10 @@ uint32 AsScene1105TeddyBear::handleMessage(int messageNum, const MessageParam &p case 0x2002: if (getGlobalVar(0x610210B7)) { startAnimation(0x6B0C0432, 0, -1); - _soundResource1.play(); + playSound(0); } else { startAnimation(0x65084002, 0, -1); - _soundResource2.play(); + playSound(1); } break; case 0x3002: @@ -407,8 +405,7 @@ void AsScene1105TeddyBear::hide() { } SsScene1105OpenButton::SsScene1105OpenButton(NeverhoodEngine *vm, Scene *parentScene) - : StaticSprite(vm, 900), _soundResource(vm), _parentScene(parentScene), - _countdown(0), _flag1(false) { + : StaticSprite(vm, 900), _parentScene(parentScene), _countdown(0), _flag1(false) { _spriteResource.load2(0x8228A46C); createSurface(400, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height); @@ -422,7 +419,7 @@ SsScene1105OpenButton::SsScene1105OpenButton(NeverhoodEngine *vm, Scene *parentS _needRefresh = true; processDelta(); setVisible(false); - _soundResource.load(0x44045140); + loadSound(0, 0x44045140); SetUpdateHandler(&SsScene1105OpenButton::update); SetMessageHandler(&SsScene1105OpenButton::handleMessage); } @@ -441,7 +438,7 @@ uint32 SsScene1105OpenButton::handleMessage(int messageNum, const MessageParam & switch (messageNum) { case 0x1011: if (_countdown == 0 && !_flag1) { - _soundResource.play(); + playSound(0); setVisible(true); _flag1 = true; _countdown = 4; @@ -453,8 +450,7 @@ uint32 SsScene1105OpenButton::handleMessage(int messageNum, const MessageParam & } Scene1105::Scene1105(NeverhoodEngine *vm, Module *parentModule, int which) - : Scene(vm, parentModule, true), _soundResource1(vm), _soundResource2(vm), - _soundResource3(vm), _countdown(0), _flag1(false), _flag2(false), _flag3(false), + : Scene(vm, parentModule, true), _countdown(0), _flag1(false), _flag2(false), _flag3(false), _flag4(false), _flag5(false), _backgroundIndex(0) { Sprite *ssOpenButton; @@ -473,9 +469,9 @@ Scene1105::Scene1105(NeverhoodEngine *vm, Module *parentModule, int which) _vm->_collisionMan->addSprite(ssOpenButton); insertMouse435(0x10006208, 20, 620); - _soundResource1.load(0x48442057); - _soundResource2.load(0xC025014F); - _soundResource3.load(0x68E25540); + loadSound(0, 0x48442057); + loadSound(1, 0xC025014F); + loadSound(2, 0x68E25540); } @@ -514,7 +510,7 @@ uint32 Scene1105::handleMessage(int messageNum, const MessageParam ¶m, Entit getSubVar(0x7500993A, 1) == getSubVar(0x61084036, 1) && getSubVar(0x7500993A, 2) == getSubVar(0x61084036, 2)) { setGlobalVar(0x610210B7, 1); - _soundResource3.play(); + playSound(2); _flag3 = true; } else { sendMessage(_asTeddyBear, 0x2002, 0); @@ -617,7 +613,7 @@ void Scene1105::upOpenPanel() { _palette->addPalette(backgroundFileHash, 0, 256, 0); } if (_backgroundIndex == 10) { - _soundResource1.play(); + playSound(0); } if (_backgroundIndex == 0) { SetUpdateHandler(&Scene1105::update); @@ -642,7 +638,7 @@ void Scene1105::upClosePanel() { if (_backgroundIndex < 6 && _backgroundIndex % 2 == 0) { uint32 backgroundFileHash = kScene1105BackgroundFileHashes[3 - _backgroundIndex / 2]; // CHECKME if (_backgroundIndex == 4) { - _soundResource2.play(); + playSound(1); _asTeddyBear->hide(); } changeBackground(backgroundFileHash); @@ -667,10 +663,10 @@ void Scene1105::update() { if (_countdown != 0 && (--_countdown == 0)) { createObjects(); } - if (_flag4 && !_soundResource2.isPlaying()) { + if (_flag4 && !isSoundPlaying(1)) { leaveScene(_flag5); } - if (_flag3 && !_soundResource3.isPlaying()) { + if (_flag3 && !isSoundPlaying(2)) { sendMessage(_asTeddyBear, 0x2002, 0); _flag3 = false; } diff --git a/engines/neverhood/module1100.h b/engines/neverhood/module1100.h index c46c1dfbca..98d1ae6311 100644 --- a/engines/neverhood/module1100.h +++ b/engines/neverhood/module1100.h @@ -46,7 +46,6 @@ public: SsScene1105Button(NeverhoodEngine *vm, Scene *parentScene, uint32 fileHash, NRect &rect); protected: Scene *_parentScene; - SoundResource _soundResource; int _countdown; void update(); uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); @@ -75,8 +74,6 @@ public: void hide(); protected: Scene *_parentScene; - SoundResource _soundResource1; - SoundResource _soundResource2; uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); }; @@ -85,7 +82,6 @@ public: SsScene1105OpenButton(NeverhoodEngine *vm, Scene *parentScene); protected: Scene *_parentScene; - SoundResource _soundResource; int _countdown; bool _flag1; void update(); @@ -96,9 +92,6 @@ class Scene1105 : public Scene { public: Scene1105(NeverhoodEngine *vm, Module *parentModule, int which); protected: - SoundResource _soundResource1; - SoundResource _soundResource2; - SoundResource _soundResource3; int _countdown; int _backgroundIndex; bool _flag1; |