diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/messages/messages.h | 2 | ||||
-rw-r--r-- | engines/titanic/sound/auto_music_player.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/sound/auto_music_player_base.cpp | 71 | ||||
-rw-r--r-- | engines/titanic/sound/auto_music_player_base.h | 15 |
4 files changed, 75 insertions, 19 deletions
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 8884a514f3..37d41bd7d0 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -208,7 +208,7 @@ MESSAGE0(CArmPickedUpFromTableMsg); MESSAGE0(CBodyInBilgeRoomMsg); MESSAGE1(CBowlStateChange, int, value, 0); MESSAGE2(CCarryObjectArrivedMsg, CString, strValue, "", int, numValue, 0); -MESSAGE2(CChangeMusicMsg, CString, strValue, "", int, numValue, 0); +MESSAGE2(CChangeMusicMsg, CString, filename, "", int, flags, 0); MESSAGE1(CChangeSeasonMsg, CString, season, "Summer"); MESSAGE0(CCheckAllPossibleCodes); MESSAGE2(CCheckChevCode, int, value1, 0, int, value2, 0); diff --git a/engines/titanic/sound/auto_music_player.cpp b/engines/titanic/sound/auto_music_player.cpp index 964814348d..f06999e35e 100644 --- a/engines/titanic/sound/auto_music_player.cpp +++ b/engines/titanic/sound/auto_music_player.cpp @@ -42,8 +42,10 @@ void CAutoMusicPlayer::load(SimpleFile *file) { } bool CAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) { - if (!_fieldCC) { - warning("TODO"); + if (!_isRepeated) { + CRoomItem *room = findRoom(); + if (msg->_newRoom == room) + addTimer(2000); } return true; diff --git a/engines/titanic/sound/auto_music_player_base.cpp b/engines/titanic/sound/auto_music_player_base.cpp index c8b9adc275..ad8b848c03 100644 --- a/engines/titanic/sound/auto_music_player_base.cpp +++ b/engines/titanic/sound/auto_music_player_base.cpp @@ -24,29 +24,78 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CAutoMusicPlayerBase, CGameObject) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(LoadSuccessMsg) + ON_MESSAGE(ChangeMusicMsg) +END_MESSAGE_MAP() + CAutoMusicPlayerBase::CAutoMusicPlayerBase() : CGameObject(), - _fieldC8(1), _fieldCC(0), _fieldD0(-1), _fieldD4(1) { + _initialMute(true), _isRepeated(false), _volumeMode(-1), _transition(1) { } void CAutoMusicPlayerBase::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); - file->writeNumberLine(_fieldC8, indent); - file->writeNumberLine(_fieldCC, indent); - file->writeNumberLine(_fieldD0, indent); - file->writeNumberLine(_fieldD4, indent); + file->writeQuotedLine(_filename, indent); + file->writeNumberLine(_initialMute, indent); + file->writeNumberLine(_isRepeated, indent); + file->writeNumberLine(_volumeMode, indent); + file->writeNumberLine(_transition, indent); CGameObject::save(file, indent); } void CAutoMusicPlayerBase::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); - _fieldC8 = file->readNumber(); - _fieldCC = file->readNumber(); - _fieldD0 = file->readNumber(); - _fieldD4 = file->readNumber(); + _filename = file->readString(); + _initialMute = file->readNumber(); + _isRepeated = file->readNumber(); + _volumeMode = file->readNumber(); + _transition = file->readNumber(); CGameObject::load(file); } +bool CAutoMusicPlayerBase::StatusChangeMsg(CStatusChangeMsg *msg) { + return true; +} + +bool CAutoMusicPlayerBase::TimerMsg(CTimerMsg *msg) { + CChangeMusicMsg musicMsg; + musicMsg._flags = 2; + musicMsg.execute(this); + + return true; +} + +bool CAutoMusicPlayerBase::LoadSuccessMsg(CLoadSuccessMsg *msg) { + if (_isRepeated) + playGlobalSound(_filename, _volumeMode, _initialMute, true, 0); + + return true; +} + +bool CAutoMusicPlayerBase::ChangeMusicMsg(CChangeMusicMsg *msg) { + if (_isRepeated && msg->_flags == 1) { + _isRepeated = false; + stopGlobalSound(_transition, -1); + } + + if (!msg->_filename.empty()) { + _filename = msg->_filename; + + if (_isRepeated) { + stopGlobalSound(_transition, -1); + playGlobalSound(_filename, _volumeMode, _initialMute, true, 0); + } + } + + if (_isRepeated && msg->_flags == 2) { + _isRepeated = true; + playGlobalSound(_filename, _volumeMode, _initialMute, true, 0); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/sound/auto_music_player_base.h b/engines/titanic/sound/auto_music_player_base.h index 657c5272e4..0623258887 100644 --- a/engines/titanic/sound/auto_music_player_base.h +++ b/engines/titanic/sound/auto_music_player_base.h @@ -28,12 +28,17 @@ namespace Titanic { class CAutoMusicPlayerBase : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); + bool ChangeMusicMsg(CChangeMusicMsg *msg); protected: - CString _string1; - int _fieldC8; - int _fieldCC; - int _fieldD0; - int _fieldD4; + CString _filename; + bool _initialMute; + bool _isRepeated; + int _volumeMode; + int _transition; public: CLASSDEF; CAutoMusicPlayerBase(); |