diff options
-rw-r--r-- | engines/titanic/core/game_object.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 7 | ||||
-rw-r--r-- | engines/titanic/sound/auto_sound_player_adsr.cpp | 48 | ||||
-rw-r--r-- | engines/titanic/sound/auto_sound_player_adsr.h | 9 | ||||
-rw-r--r-- | engines/titanic/sound/background_sound_maker.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/sound/background_sound_maker.h | 2 |
6 files changed, 75 insertions, 9 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index ecaa415e31..c7742cb8db 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -743,6 +743,16 @@ int CGameObject::playSound(const CString &name, CProximity &prox) { return 0; } +int CGameObject::queueSound(const CString &name, uint priorHandle, uint volume, int val3, bool repeated) { + CProximity prox; + prox._fieldC = val3; + prox._repeated = repeated; + prox._channelVolume = volume; + prox._soundHandle = priorHandle; + + return playSound(name, prox); +} + void CGameObject::stopSound(int handle, uint seconds) { if (handle != 0 && handle != -1) { CGameManager *gameManager = getGameManager(); diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 799cbccbed..bcfc989288 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -196,6 +196,13 @@ protected: int playSound(const CString &name, CProximity &prox); /** + * Queues a sound to play after a specified one finishes + * @param resName Filename of sound to play + * @param volume Volume level + */ + int queueSound(const CString &name, uint priorHandle, uint volume = 100, int val3 = 0, bool repeated = false); + + /** * Stop a sound * @param handle Sound handle * @param seconds Optional number of seconds to transition sound off diff --git a/engines/titanic/sound/auto_sound_player_adsr.cpp b/engines/titanic/sound/auto_sound_player_adsr.cpp index 4bfd5578fb..f9f045759b 100644 --- a/engines/titanic/sound/auto_sound_player_adsr.cpp +++ b/engines/titanic/sound/auto_sound_player_adsr.cpp @@ -24,20 +24,56 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CAutoSoundPlayerADSR, CAutoSoundPlayer) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) +END_MESSAGE_MAP() + void CAutoSoundPlayerADSR::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string2, indent); - file->writeQuotedLine(_string3, indent); - file->writeQuotedLine(_string4, indent); + file->writeQuotedLine(_soundName1, indent); + file->writeQuotedLine(_soundName2, indent); + file->writeQuotedLine(_soundName3, indent); CAutoSoundPlayer::save(file, indent); } void CAutoSoundPlayerADSR::load(SimpleFile *file) { file->readNumber(); - _string2 = file->readString(); - _string3 = file->readString(); - _string4 = file->readString(); + _soundName1 = file->readString(); + _soundName2 = file->readString(); + _soundName3 = file->readString(); CAutoSoundPlayer::load(file); } +bool CAutoSoundPlayerADSR::TurnOn(CTurnOn *msg) { + if (_soundHandle == -1) { + if (!_soundName1.empty()) { + _soundHandle = playSound(_soundName1, _volume, _fieldD0); + + if (!_soundName2.empty()) + _soundHandle = queueSound(_soundName2, _soundHandle, _volume, _fieldD0); + + _soundHandle = queueSound(_filename, _soundHandle, _volume, _fieldD0); + _active = true; + } + } + + return true; +} + +bool CAutoSoundPlayerADSR::TurnOff(CTurnOff *msg) { + if (_soundHandle != -1) { + if (!_soundName3.empty()) + queueSound(_soundName3, _soundHandle, _volume, _fieldD0); + + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle); + + _soundHandle = -1; + _active = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/sound/auto_sound_player_adsr.h b/engines/titanic/sound/auto_sound_player_adsr.h index 6dc2853425..9f09636610 100644 --- a/engines/titanic/sound/auto_sound_player_adsr.h +++ b/engines/titanic/sound/auto_sound_player_adsr.h @@ -28,10 +28,13 @@ namespace Titanic { class CAutoSoundPlayerADSR : public CAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); private: - CString _string2; - CString _string3; - CString _string4; + CString _soundName1; + CString _soundName2; + CString _soundName3; public: CLASSDEF; diff --git a/engines/titanic/sound/background_sound_maker.cpp b/engines/titanic/sound/background_sound_maker.cpp index 0abab8906b..58dde02518 100644 --- a/engines/titanic/sound/background_sound_maker.cpp +++ b/engines/titanic/sound/background_sound_maker.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CBackgroundSoundMaker, CGameObject) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + void CBackgroundSoundMaker::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); @@ -36,4 +40,8 @@ void CBackgroundSoundMaker::load(SimpleFile *file) { CGameObject::load(file); } +bool CBackgroundSoundMaker::FrameMsg(CFrameMsg *msg) { + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/sound/background_sound_maker.h b/engines/titanic/sound/background_sound_maker.h index 022d8f4741..94f3b792dc 100644 --- a/engines/titanic/sound/background_sound_maker.h +++ b/engines/titanic/sound/background_sound_maker.h @@ -28,6 +28,8 @@ namespace Titanic { class CBackgroundSoundMaker : public CGameObject { + DECLARE_MESSAGE_MAP; + bool FrameMsg(CFrameMsg *msg); public: int _value; public: |