diff options
author | Paul Gilbert | 2016-08-08 20:48:06 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-08 20:48:06 -0400 |
commit | 8f8cf6eadc842f97d131437c86e17d1305c9ef56 (patch) | |
tree | 2e4d6acb842cfec494656d1bb79851c31b16249b /engines/titanic/sound/node_auto_sound_player.cpp | |
parent | dbcbb01740043f73e8b37a0289d27d95fced04c5 (diff) | |
download | scummvm-rg350-8f8cf6eadc842f97d131437c86e17d1305c9ef56.tar.gz scummvm-rg350-8f8cf6eadc842f97d131437c86e17d1305c9ef56.tar.bz2 scummvm-rg350-8f8cf6eadc842f97d131437c86e17d1305c9ef56.zip |
TITANIC: Implemented room, node, and view auto sound player classes
Diffstat (limited to 'engines/titanic/sound/node_auto_sound_player.cpp')
-rw-r--r-- | engines/titanic/sound/node_auto_sound_player.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/engines/titanic/sound/node_auto_sound_player.cpp b/engines/titanic/sound/node_auto_sound_player.cpp index f74c891644..40b3d2ea39 100644 --- a/engines/titanic/sound/node_auto_sound_player.cpp +++ b/engines/titanic/sound/node_auto_sound_player.cpp @@ -21,23 +21,63 @@ */ #include "titanic/sound/node_auto_sound_player.h" +#include "titanic/sound/auto_music_player.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CNodeAutoSoundPlayer, CAutoSoundPlayer) + ON_MESSAGE(EnterNodeMsg) + ON_MESSAGE(LeaveNodeMsg) +END_MESSAGE_MAP() + void CNodeAutoSoundPlayer::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_enabled, indent); CAutoSoundPlayer::save(file, indent); } void CNodeAutoSoundPlayer::load(SimpleFile *file) { file->readNumber(); - _fieldEC = file->readNumber(); + _enabled = file->readNumber(); CAutoSoundPlayer::load(file); } bool CNodeAutoSoundPlayer::EnterNodeMsg(CEnterNodeMsg *msg) { - warning("CNodeAutoSoundPlayer::handleEvent"); + CNodeItem *node = findNode(); + CRoomItem *room = findRoom(); + + if (node == msg->_newNode) { + CTurnOn onMsg; + onMsg.execute(this); + + if (_enabled) { + CChangeMusicMsg changeMsg; + changeMsg._flags = 1; + changeMsg.execute(room, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + } + } + + return true; +} + +bool CNodeAutoSoundPlayer::LeaveNodeMsg(CLeaveNodeMsg *msg) { + CNodeItem *node = findNode(); + CRoomItem *room = findRoom(); + + if (node == msg->_oldNode) { + CTurnOff offMsg; + offMsg.execute(this); + + if (_enabled) { + CChangeMusicMsg changeMsg; + changeMsg._flags = 2; + changeMsg.execute(room, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + } + } + return true; } |