aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/core/game_object.cpp13
-rw-r--r--engines/titanic/core/game_object.h5
-rw-r--r--engines/titanic/sound/bird_song.cpp21
-rw-r--r--engines/titanic/sound/bird_song.h7
-rw-r--r--engines/titanic/sound/dome_from_top_of_well.cpp8
-rw-r--r--engines/titanic/sound/dome_from_top_of_well.h1
-rw-r--r--engines/titanic/sound/enter_view_toggles_other_music.cpp22
-rw-r--r--engines/titanic/sound/enter_view_toggles_other_music.h4
-rw-r--r--engines/titanic/sound/trigger_auto_music_player.cpp26
-rw-r--r--engines/titanic/sound/trigger_auto_music_player.h4
10 files changed, 100 insertions, 11 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index c7742cb8db..95ebe6a1e7 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -1248,6 +1248,19 @@ CRoomItem *CGameObject::getHiddenRoom() const {
return root ? root->findHiddenRoom() : nullptr;
}
+CRoomItem *CGameObject::locateRoom(const CString &name) const {
+ if (name.empty())
+ return nullptr;
+
+ CProjectItem *project = getRoot();
+ for (CRoomItem *room = project->findFirstRoom(); room; room = project->findNextRoom(room)) {
+ if (!room->getName().compareToIgnoreCase(name))
+ return room;
+ }
+
+ return nullptr;
+}
+
CGameObject *CGameObject::getHiddenObject(const CString &name) const {
CRoomItem *room = getHiddenRoom();
return room ? static_cast<CGameObject *>(findUnder(room, name)) : nullptr;
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index bcfc989288..322b62636c 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -393,6 +393,11 @@ protected:
CRoomItem *getHiddenRoom() const;
/**
+ * Locates a room with the given name
+ */
+ CRoomItem *locateRoom(const CString &name) const;
+
+ /**
* Scan the specified room for an item by name
*/
CTreeItem *findUnder(CTreeItem *parent, const CString &name) const;
diff --git a/engines/titanic/sound/bird_song.cpp b/engines/titanic/sound/bird_song.cpp
index 7f7d0ad5ce..53a25e2dbe 100644
--- a/engines/titanic/sound/bird_song.cpp
+++ b/engines/titanic/sound/bird_song.cpp
@@ -24,16 +24,33 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CBirdSong, CAutoSoundPlayer)
+ ON_MESSAGE(TurnOn)
+ ON_MESSAGE(SignalObject)
+END_MESSAGE_MAP()
+
void CBirdSong::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_value, indent);
+ file->writeNumberLine(_flag, indent);
CRoomAutoSoundPlayer::save(file, indent);
}
void CBirdSong::load(SimpleFile *file) {
file->readNumber();
- _value = file->readNumber();
+ _flag = file->readNumber();
CRoomAutoSoundPlayer::load(file);
}
+bool CBirdSong::TurnOn(CTurnOn *msg) {
+ if (!_flag)
+ CAutoSoundPlayer::TurnOn(msg);
+ return true;
+}
+
+bool CBirdSong::SignalObject(CSignalObject *msg) {
+ _flag = true;
+ CAutoSoundPlayer::SignalObject(msg);
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/bird_song.h b/engines/titanic/sound/bird_song.h
index 35758e5b77..52af94b180 100644
--- a/engines/titanic/sound/bird_song.h
+++ b/engines/titanic/sound/bird_song.h
@@ -28,11 +28,14 @@
namespace Titanic {
class CBirdSong : public CRoomAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool TurnOn(CTurnOn *msg);
+ bool SignalObject(CSignalObject *msg);
public:
- int _value;
+ bool _flag;
public:
CLASSDEF;
- CBirdSong() : CRoomAutoSoundPlayer(), _value(0) {}
+ CBirdSong() : CRoomAutoSoundPlayer(), _flag(false) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/sound/dome_from_top_of_well.cpp b/engines/titanic/sound/dome_from_top_of_well.cpp
index 3721b9f3b7..789d7fa4cb 100644
--- a/engines/titanic/sound/dome_from_top_of_well.cpp
+++ b/engines/titanic/sound/dome_from_top_of_well.cpp
@@ -26,6 +26,14 @@ namespace Titanic {
EMPTY_MESSAGE_MAP(CDomeFromTopOfWell, CViewAutoSoundPlayer);
+CDomeFromTopOfWell::CDomeFromTopOfWell() : CViewAutoSoundPlayer() {
+ _filename = "z#227.wav";
+ _volume = 25;
+ _repeated = true;
+ _stopSeconds = 1;
+ _startSeconds = 1;
+}
+
void CDomeFromTopOfWell::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CViewAutoSoundPlayer::save(file, indent);
diff --git a/engines/titanic/sound/dome_from_top_of_well.h b/engines/titanic/sound/dome_from_top_of_well.h
index e3d2877379..001f66a1a8 100644
--- a/engines/titanic/sound/dome_from_top_of_well.h
+++ b/engines/titanic/sound/dome_from_top_of_well.h
@@ -31,6 +31,7 @@ class CDomeFromTopOfWell : public CViewAutoSoundPlayer {
DECLARE_MESSAGE_MAP;
public:
CLASSDEF;
+ CDomeFromTopOfWell();
/**
* Save the data for the class to file
diff --git a/engines/titanic/sound/enter_view_toggles_other_music.cpp b/engines/titanic/sound/enter_view_toggles_other_music.cpp
index 0b149993a3..2f0091a0a3 100644
--- a/engines/titanic/sound/enter_view_toggles_other_music.cpp
+++ b/engines/titanic/sound/enter_view_toggles_other_music.cpp
@@ -24,21 +24,37 @@
namespace Titanic {
-CEnterViewTogglesOtherMusic::CEnterViewTogglesOtherMusic() : CTriggerAutoMusicPlayer(), _fieldC8(0) {
+BEGIN_MESSAGE_MAP(CEnterViewTogglesOtherMusic, CTriggerAutoMusicPlayer)
+ ON_MESSAGE(EnterViewMsg)
+END_MESSAGE_MAP()
+
+CEnterViewTogglesOtherMusic::CEnterViewTogglesOtherMusic() :
+ CTriggerAutoMusicPlayer(), _value(2) {
}
void CEnterViewTogglesOtherMusic::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_fieldC8, indent);
+ file->writeNumberLine(_value, indent);
CTriggerAutoMusicPlayer::save(file, indent);
}
void CEnterViewTogglesOtherMusic::load(SimpleFile *file) {
file->readNumber();
- _fieldC8 = file->readNumber();
+ _value = file->readNumber();
CTriggerAutoMusicPlayer::load(file);
}
+bool CEnterViewTogglesOtherMusic::EnterViewMsg(CEnterViewMsg *msg) {
+ CViewItem *view = findView();
+ if (view == msg->_newView) {
+ CTriggerAutoMusicPlayerMsg triggerMsg;
+ triggerMsg._value = _value;
+ triggerMsg.execute(this);
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/enter_view_toggles_other_music.h b/engines/titanic/sound/enter_view_toggles_other_music.h
index 6bbeea4890..a91b1e1933 100644
--- a/engines/titanic/sound/enter_view_toggles_other_music.h
+++ b/engines/titanic/sound/enter_view_toggles_other_music.h
@@ -28,8 +28,10 @@
namespace Titanic {
class CEnterViewTogglesOtherMusic : public CTriggerAutoMusicPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool EnterViewMsg(CEnterViewMsg *msg);
protected:
- int _fieldC8;
+ int _value;
public:
CLASSDEF;
CEnterViewTogglesOtherMusic();
diff --git a/engines/titanic/sound/trigger_auto_music_player.cpp b/engines/titanic/sound/trigger_auto_music_player.cpp
index 21050e0877..a332570aba 100644
--- a/engines/titanic/sound/trigger_auto_music_player.cpp
+++ b/engines/titanic/sound/trigger_auto_music_player.cpp
@@ -21,19 +21,41 @@
*/
#include "titanic/sound/trigger_auto_music_player.h"
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/core/room_item.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CTriggerAutoMusicPlayer, CGameObject)
+ ON_MESSAGE(TriggerAutoMusicPlayerMsg)
+END_MESSAGE_MAP()
+
void CTriggerAutoMusicPlayer::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeQuotedLine(_fieldBC, indent);
+ file->writeQuotedLine(_roomName, indent);
CGameObject::save(file, indent);
}
void CTriggerAutoMusicPlayer::load(SimpleFile *file) {
file->readNumber();
- _fieldBC = file->readString();
+ _roomName = file->readString();
CGameObject::load(file);
}
+bool CTriggerAutoMusicPlayer::TriggerAutoMusicPlayerMsg(CTriggerAutoMusicPlayerMsg *msg) {
+ CRoomItem *room1 = msg->_value == 1 ? locateRoom(_roomName) : findRoom();
+ CRoomItem *room2 = msg->_value == 2 ? locateRoom(_roomName) : findRoom();
+
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = 1;
+ changeMsg.execute(room1, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+
+ changeMsg._flags = 2;
+ changeMsg.execute(room2, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/trigger_auto_music_player.h b/engines/titanic/sound/trigger_auto_music_player.h
index 537e780db6..45631e08fc 100644
--- a/engines/titanic/sound/trigger_auto_music_player.h
+++ b/engines/titanic/sound/trigger_auto_music_player.h
@@ -28,8 +28,10 @@
namespace Titanic {
class CTriggerAutoMusicPlayer : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool TriggerAutoMusicPlayerMsg(CTriggerAutoMusicPlayerMsg *msg);
protected:
- CString _fieldBC;
+ CString _roomName;
public:
CLASSDEF;