aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-08 20:48:06 -0400
committerPaul Gilbert2016-08-08 20:48:06 -0400
commit8f8cf6eadc842f97d131437c86e17d1305c9ef56 (patch)
tree2e4d6acb842cfec494656d1bb79851c31b16249b /engines/titanic
parentdbcbb01740043f73e8b37a0289d27d95fced04c5 (diff)
downloadscummvm-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')
-rw-r--r--engines/titanic/sound/node_auto_sound_player.cpp46
-rw-r--r--engines/titanic/sound/node_auto_sound_player.h6
-rw-r--r--engines/titanic/sound/room_auto_sound_player.cpp22
-rw-r--r--engines/titanic/sound/room_auto_sound_player.h2
-rw-r--r--engines/titanic/sound/view_auto_sound_player.cpp49
-rw-r--r--engines/titanic/sound/view_auto_sound_player.h7
6 files changed, 122 insertions, 10 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;
}
diff --git a/engines/titanic/sound/node_auto_sound_player.h b/engines/titanic/sound/node_auto_sound_player.h
index e980841c36..f5bdc42c3c 100644
--- a/engines/titanic/sound/node_auto_sound_player.h
+++ b/engines/titanic/sound/node_auto_sound_player.h
@@ -29,12 +29,14 @@
namespace Titanic {
class CNodeAutoSoundPlayer : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
bool EnterNodeMsg(CEnterNodeMsg *msg);
+ bool LeaveNodeMsg(CLeaveNodeMsg *msg);
private:
- int _fieldEC;
+ bool _enabled;
public:
CLASSDEF;
- CNodeAutoSoundPlayer() : CAutoSoundPlayer(), _fieldEC(1) {}
+ CNodeAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(true) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/sound/room_auto_sound_player.cpp b/engines/titanic/sound/room_auto_sound_player.cpp
index da98d41329..cad7c10771 100644
--- a/engines/titanic/sound/room_auto_sound_player.cpp
+++ b/engines/titanic/sound/room_auto_sound_player.cpp
@@ -24,6 +24,11 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CRoomAutoSoundPlayer, CAutoSoundPlayer)
+ ON_MESSAGE(EnterRoomMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+END_MESSAGE_MAP()
+
void CRoomAutoSoundPlayer::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CAutoSoundPlayer::save(file, indent);
@@ -35,7 +40,22 @@ void CRoomAutoSoundPlayer::load(SimpleFile *file) {
}
bool CRoomAutoSoundPlayer::EnterRoomMsg(CEnterRoomMsg *msg) {
- warning("CRoomAutoSoundPlayer::handleEvent");
+ CRoomItem *room = findRoom();
+ if (room == msg->_newRoom) {
+ CTurnOn onMsg;
+ onMsg.execute(this);
+ }
+
+ return true;
+}
+
+bool CRoomAutoSoundPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ CRoomItem *room = findRoom();
+ if (room == msg->_oldRoom) {
+ CTurnOff offMsg;
+ offMsg.execute(this);
+ }
+
return true;
}
diff --git a/engines/titanic/sound/room_auto_sound_player.h b/engines/titanic/sound/room_auto_sound_player.h
index 9c3feb5d91..56525ccfa3 100644
--- a/engines/titanic/sound/room_auto_sound_player.h
+++ b/engines/titanic/sound/room_auto_sound_player.h
@@ -29,7 +29,9 @@
namespace Titanic {
class CRoomAutoSoundPlayer : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
bool EnterRoomMsg(CEnterRoomMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
public:
CLASSDEF;
diff --git a/engines/titanic/sound/view_auto_sound_player.cpp b/engines/titanic/sound/view_auto_sound_player.cpp
index 91507488fd..55501fe340 100644
--- a/engines/titanic/sound/view_auto_sound_player.cpp
+++ b/engines/titanic/sound/view_auto_sound_player.cpp
@@ -21,19 +21,64 @@
*/
#include "titanic/sound/view_auto_sound_player.h"
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/core/room_item.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CViewAutoSoundPlayer, CAutoSoundPlayer)
+ ON_MESSAGE(EnterViewMsg)
+ ON_MESSAGE(LeaveViewMsg)
+END_MESSAGE_MAP()
+
void CViewAutoSoundPlayer::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_fieldEC, indent);
+ file->writeNumberLine(_enabled, indent);
CAutoSoundPlayer::save(file, indent);
}
void CViewAutoSoundPlayer::load(SimpleFile *file) {
file->readNumber();
- _fieldEC = file->readNumber();
+ _enabled = file->readNumber();
CAutoSoundPlayer::load(file);
}
+bool CViewAutoSoundPlayer::EnterViewMsg(CEnterViewMsg *msg) {
+ CViewItem *view = findView();
+ CRoomItem *room = findRoom();
+
+ if (view == msg->_newView) {
+ 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 CViewAutoSoundPlayer::LeaveViewMsg(CLeaveViewMsg *msg) {
+ CViewItem *view = findView();
+ CRoomItem *room = findRoom();
+
+ if (view == msg->_oldView) {
+ 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;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/view_auto_sound_player.h b/engines/titanic/sound/view_auto_sound_player.h
index 29bdee71a0..b62805ea6e 100644
--- a/engines/titanic/sound/view_auto_sound_player.h
+++ b/engines/titanic/sound/view_auto_sound_player.h
@@ -28,11 +28,14 @@
namespace Titanic {
class CViewAutoSoundPlayer : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool EnterViewMsg(CEnterViewMsg *msg);
+ bool LeaveViewMsg(CLeaveViewMsg *msg);
private:
- int _fieldEC;
+ bool _enabled;
public:
CLASSDEF;
- CViewAutoSoundPlayer() : CAutoSoundPlayer(), _fieldEC(0) {}
+ CViewAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(false) {}
/**
* Save the data for the class to file