diff options
author | Paul Gilbert | 2016-08-07 21:52:09 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-07 21:52:09 -0400 |
commit | a1affaa698516e93763e812281e7d9609f098193 (patch) | |
tree | 3b5deb9eb443bf1ca40b418ee35f263789b28bea /engines/titanic/sound/auto_music_player_base.cpp | |
parent | 8b6ac03f18c69a519f1fdcd9bb49920bcfe78012 (diff) | |
download | scummvm-rg350-a1affaa698516e93763e812281e7d9609f098193.tar.gz scummvm-rg350-a1affaa698516e93763e812281e7d9609f098193.tar.bz2 scummvm-rg350-a1affaa698516e93763e812281e7d9609f098193.zip |
TITANIC: Implemented CAutoMusicPlayerBase class
Diffstat (limited to 'engines/titanic/sound/auto_music_player_base.cpp')
-rw-r--r-- | engines/titanic/sound/auto_music_player_base.cpp | 71 |
1 files changed, 60 insertions, 11 deletions
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 |