diff options
author | Paul Gilbert | 2016-08-08 19:30:50 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-08 19:30:50 -0400 |
commit | dbcbb01740043f73e8b37a0289d27d95fced04c5 (patch) | |
tree | 93c45575f77f7dff54284f26dc9b08d9e3a1e202 /engines/titanic | |
parent | acdf655b91826039382144b30178e89e99fe7c7a (diff) | |
download | scummvm-rg350-dbcbb01740043f73e8b37a0289d27d95fced04c5.tar.gz scummvm-rg350-dbcbb01740043f73e8b37a0289d27d95fced04c5.tar.bz2 scummvm-rg350-dbcbb01740043f73e8b37a0289d27d95fced04c5.zip |
TITANIC: Implemented CAutoSoundPlayer class
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/messages/messages.h | 2 | ||||
-rw-r--r-- | engines/titanic/sound/auto_sound_player.cpp | 102 | ||||
-rw-r--r-- | engines/titanic/sound/auto_sound_player.h | 20 | ||||
-rw-r--r-- | engines/titanic/sound/water_lapping_sounds.cpp | 19 | ||||
-rw-r--r-- | engines/titanic/sound/water_lapping_sounds.h | 2 |
5 files changed, 114 insertions, 31 deletions
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 37d41bd7d0..c1d962f656 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -317,7 +317,7 @@ MESSAGE1(CSetChevRoomBits, int, value, 0); MESSAGE1(CSetFrameMsg, int, frameNumber, 0); MESSAGE0(CSetMusicControlsMsg); MESSAGE2(CSetVarMsg, CString, varName, "", int, value, 0); -MESSAGE2(CSetVolumeMsg, int, value1, 70, int, value2, 0); +MESSAGE2(CSetVolumeMsg, int, volume, 70, int, secondsTransition, 0); MESSAGE2(CShipSettingMsg, int, value, 0, CString, name, ""); MESSAGE1(CShowTextMsg, CString, value, "NO TEXT INCLUDED!!!"); MESSAGE2(CSignalObject, CString, strValue, "", int, numValue, 0); diff --git a/engines/titanic/sound/auto_sound_player.cpp b/engines/titanic/sound/auto_sound_player.cpp index 3e3d5298e4..1fb67858da 100644 --- a/engines/titanic/sound/auto_sound_player.cpp +++ b/engines/titanic/sound/auto_sound_player.cpp @@ -24,22 +24,30 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CAutoSoundPlayer, CGameObject) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(SignalObject) + ON_MESSAGE(SetVolumeMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + CAutoSoundPlayer::CAutoSoundPlayer() : CGameObject(), - _fieldBC(0), _fieldCC(70), _fieldD0(0), _fieldD4(0), _fieldD8(-1), - _fieldDC(0), _fieldE0(-1), _fieldE4(0), _fieldE8(0) { + _fieldBC(0), _volume(70), _fieldD0(0), _repeated(false), _soundHandle(-1), + _stopSeconds(0), _startSeconds(-1), _active(false), _fieldE8(0) { } void CAutoSoundPlayer::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldBC, indent); - file->writeQuotedLine(_string1, indent); - file->writeNumberLine(_fieldCC, indent); + file->writeQuotedLine(_filename, indent); + file->writeNumberLine(_volume, indent); file->writeNumberLine(_fieldD0, indent); - file->writeNumberLine(_fieldD4, indent); - file->writeNumberLine(_fieldD8, indent); - file->writeNumberLine(_fieldDC, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_repeated, indent); + file->writeNumberLine(_soundHandle, indent); + file->writeNumberLine(_stopSeconds, indent); + file->writeNumberLine(_startSeconds, indent); + file->writeNumberLine(_active, indent); file->writeNumberLine(_fieldE8, indent); CGameObject::save(file, indent); @@ -48,17 +56,79 @@ void CAutoSoundPlayer::save(SimpleFile *file, int indent) { void CAutoSoundPlayer::load(SimpleFile *file) { file->readNumber(); _fieldBC = file->readNumber(); - _string1 = file->readString(); - _fieldCC = file->readNumber(); + _filename = file->readString(); + _volume = file->readNumber(); _fieldD0 = file->readNumber(); - _fieldD4 = file->readNumber(); - _fieldD8 = file->readNumber(); - _fieldDC = file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _repeated = file->readNumber(); + _soundHandle = file->readNumber(); + _stopSeconds = file->readNumber(); + _startSeconds = file->readNumber(); + _active = file->readNumber(); _fieldE8 = file->readNumber(); CGameObject::load(file); } +bool CAutoSoundPlayer::TurnOn(CTurnOn *msg) { + if (_soundHandle == -1) { + CProximity prox; + prox._fieldC = _fieldD0; + prox._repeated = _repeated; + if (_fieldE8) + prox._field28 = 2; + prox._channelVolume = (_startSeconds == -1) ? _volume : 0; + + _soundHandle = playSound(_filename, prox); + if (_startSeconds != -1) + setSoundVolume(_soundHandle, _volume, _startSeconds); + + _active = true; + } + + return true; +} + +bool CAutoSoundPlayer::TurnOff(CTurnOff *msg) { + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, _stopSeconds); + + _soundHandle = -1; + _active = false; + } + + return true; +} + +bool CAutoSoundPlayer::SignalObject(CSignalObject *msg) { + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, msg->_numValue); + + _soundHandle = -1; + _active = false; + } + + return true; +} + +bool CAutoSoundPlayer::SetVolumeMsg(CSetVolumeMsg *msg) { + if (_soundHandle != -1 && isSoundActive(_soundHandle)) + setSoundVolume(_soundHandle, msg->_volume, msg->_secondsTransition); + + return true; +} + +bool CAutoSoundPlayer::LoadSuccessMsg(CLoadSuccessMsg *msg) { + if (_active) { + _soundHandle = -1; + _active = false; + + CTurnOn onMsg; + onMsg.execute(this); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/sound/auto_sound_player.h b/engines/titanic/sound/auto_sound_player.h index 6de2b12561..c8f1d3480e 100644 --- a/engines/titanic/sound/auto_sound_player.h +++ b/engines/titanic/sound/auto_sound_player.h @@ -28,16 +28,22 @@ namespace Titanic { class CAutoSoundPlayer : public CGameObject { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool SignalObject(CSignalObject *msg); + bool SetVolumeMsg(CSetVolumeMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); public: int _fieldBC; - CString _string1; - int _fieldCC; + CString _filename; + int _volume; int _fieldD0; - int _fieldD4; - int _fieldD8; - int _fieldDC; - int _fieldE0; - int _fieldE4; + bool _repeated; + int _soundHandle; + int _stopSeconds; + int _startSeconds; + bool _active; int _fieldE8; public: CLASSDEF; diff --git a/engines/titanic/sound/water_lapping_sounds.cpp b/engines/titanic/sound/water_lapping_sounds.cpp index c33db412e1..7616c4b43b 100644 --- a/engines/titanic/sound/water_lapping_sounds.cpp +++ b/engines/titanic/sound/water_lapping_sounds.cpp @@ -26,11 +26,18 @@ namespace Titanic { EMPTY_MESSAGE_MAP(CWaterLappingSounds, CRoomAutoSoundPlayer); +CWaterLappingSounds::CWaterLappingSounds() : CRoomAutoSoundPlayer(), + _value(0) { + _filename = "z#217.wav"; + _repeated = false; + _startSeconds = 0; +} + void CWaterLappingSounds::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); - file->writeNumberLine(_fieldD4, indent); - file->writeNumberLine(_fieldE0, indent); + file->writeQuotedLine(_filename, indent); + file->writeNumberLine(_repeated, indent); + file->writeNumberLine(_startSeconds, indent); file->writeNumberLine(_value, indent); CRoomAutoSoundPlayer::save(file, indent); @@ -38,9 +45,9 @@ void CWaterLappingSounds::save(SimpleFile *file, int indent) { void CWaterLappingSounds::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); - _fieldD4 = file->readNumber(); - _fieldE0 = file->readNumber(); + _filename = file->readString(); + _repeated = file->readNumber(); + _startSeconds = file->readNumber(); _value = file->readNumber(); CRoomAutoSoundPlayer::load(file); diff --git a/engines/titanic/sound/water_lapping_sounds.h b/engines/titanic/sound/water_lapping_sounds.h index 5db41a312e..2d0594b26b 100644 --- a/engines/titanic/sound/water_lapping_sounds.h +++ b/engines/titanic/sound/water_lapping_sounds.h @@ -33,7 +33,7 @@ public: int _value; public: CLASSDEF; - CWaterLappingSounds() : CRoomAutoSoundPlayer(), _value(0) {} + CWaterLappingSounds(); /** * Save the data for the class to file |