aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-27 11:15:23 -0400
committerPaul Gilbert2016-08-27 11:15:23 -0400
commit40ec26b3439eb82e5bf8bff82529c16d34a5ed94 (patch)
tree909fae17fbb0068654f3920b004018a7bcc81f71
parent795cdb6365bcf01a92950e6fee8632a3a749d165 (diff)
downloadscummvm-rg350-40ec26b3439eb82e5bf8bff82529c16d34a5ed94.tar.gz
scummvm-rg350-40ec26b3439eb82e5bf8bff82529c16d34a5ed94.tar.bz2
scummvm-rg350-40ec26b3439eb82e5bf8bff82529c16d34a5ed94.zip
TITANIC: Implemented phonograph classes
-rw-r--r--engines/titanic/carry/phonograph_cylinder.cpp32
-rw-r--r--engines/titanic/game/phonograph.cpp120
-rw-r--r--engines/titanic/game/phonograph.h8
-rw-r--r--engines/titanic/game/phonograph_lid.cpp51
-rw-r--r--engines/titanic/game/phonograph_lid.h9
-rw-r--r--engines/titanic/messages/messages.h2
6 files changed, 209 insertions, 13 deletions
diff --git a/engines/titanic/carry/phonograph_cylinder.cpp b/engines/titanic/carry/phonograph_cylinder.cpp
index 0684c56611..41df050d2b 100644
--- a/engines/titanic/carry/phonograph_cylinder.cpp
+++ b/engines/titanic/carry/phonograph_cylinder.cpp
@@ -22,6 +22,7 @@
#include "titanic/carry/phonograph_cylinder.h"
#include "titanic/game/phonograph.h"
+#include "titanic/sound/music_room.h"
namespace Titanic {
@@ -162,10 +163,33 @@ bool CPhonographCylinder::RecordOntoCylinderMsg(CRecordOntoCylinderMsg *msg) {
}
bool CPhonographCylinder::SetMusicControlsMsg(CSetMusicControlsMsg *msg) {
- if (_itemName.left(7) == "STMusic") {
- //todo
- warning("TODO");
- }
+ if (!_itemName.hasPrefix("STMusic"))
+ return true;
+
+ CMusicRoom *musicRoom = getMusicRoom();
+ musicRoom->setItem5(BELLS, _bellsMuteControl);
+ musicRoom->setItem2(BELLS, _bellsPitchControl);
+ musicRoom->setItem1(BELLS, _bellsSpeedControl);
+ musicRoom->setItem4(BELLS, _bellsInversionControl);
+ musicRoom->setItem3(BELLS, _bellsDirectionControl);
+
+ musicRoom->setItem5(SNAKE, _snakeMuteControl);
+ musicRoom->setItem2(SNAKE, _snakePitchControl);
+ musicRoom->setItem1(SNAKE, _snakeSpeedControl);
+ musicRoom->setItem4(SNAKE, _snakeInversionControl);
+ musicRoom->setItem3(SNAKE, _snakeDirectionControl);
+
+ musicRoom->setItem5(PIANO, _pianoMuteControl);
+ musicRoom->setItem2(PIANO, _pianoPitchControl);
+ musicRoom->setItem1(PIANO, _pianoSpeedControl);
+ musicRoom->setItem4(PIANO, _pianoInversionControl);
+ musicRoom->setItem3(PIANO, _pianoDirectionControl);
+
+ musicRoom->setItem5(BASS, _bassMuteControl);
+ musicRoom->setItem2(BASS, _bassPitchControl);
+ musicRoom->setItem1(BASS, _bassSpeedControl);
+ musicRoom->setItem4(BASS, _bassInversionControl);
+ musicRoom->setItem3(BASS, _bassDirectionControl);
return true;
}
diff --git a/engines/titanic/game/phonograph.cpp b/engines/titanic/game/phonograph.cpp
index 9740e29273..408cfa3413 100644
--- a/engines/titanic/game/phonograph.cpp
+++ b/engines/titanic/game/phonograph.cpp
@@ -24,9 +24,18 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CPhonograph, CMusicPlayer)
+ ON_MESSAGE(PhonographPlayMsg)
+ ON_MESSAGE(PhonographStopMsg)
+ ON_MESSAGE(PhonographRecordMsg)
+ ON_MESSAGE(EnterRoomMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+ ON_MESSAGE(MusicHasStartedMsg)
+END_MESSAGE_MAP()
+
CPhonograph::CPhonograph() : CMusicPlayer(),
- _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0),
- _fieldF0(0), _fieldF4(0) {
+ _fieldE0(false), _fieldE4(0), _fieldE8(0), _fieldEC(0),
+ _fieldF0(0), _fieldF4(0) {
}
void CPhonograph::save(SimpleFile *file, int indent) {
@@ -55,8 +64,113 @@ void CPhonograph::load(SimpleFile *file) {
CMusicPlayer::load(file);
}
+bool CPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) {
+ CQueryCylinderHolderMsg holderMsg;
+ holderMsg.execute(this);
+ if (!holderMsg._value2) {
+ _fieldE0 = false;
+ return true;
+ }
+
+ CQueryCylinderMsg cylinderMsg;
+ cylinderMsg.execute(holderMsg._target);
+
+ if (cylinderMsg._name.empty()) {
+ _fieldE0 = false;
+ } else if (cylinderMsg._name.hasPrefix("STMusic")) {
+ CStartMusicMsg startMsg(this);
+ startMsg.execute(this);
+ _fieldE0 = true;
+ msg->_value = 1;
+ } else {
+ stopGlobalSound(0, -1);
+ playGlobalSound(cylinderMsg._name, -2, true, true, 0);
+ _fieldE0 = true;
+ msg->_value = 1;
+ }
+
+ return true;
+}
+
+bool CPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) {
+ CQueryCylinderHolderMsg holderMsg;
+ holderMsg.execute(this);
+ if (!holderMsg._value2)
+ return true;
+
+ _fieldE0 = false;
+ CQueryCylinderMsg cylinderMsg;
+ cylinderMsg.execute(holderMsg._target);
+
+ if (_fieldE0) {
+ if (!cylinderMsg._name.empty()) {
+ if (cylinderMsg._name.hasPrefix("STMusic")) {
+ CStopMusicMsg stopMsg;
+ stopMsg.execute(this);
+ } else {
+ stopGlobalSound(msg->_value1, -1);
+ }
+ msg->_value2 = 1;
+ }
+
+ if (!msg->_value3)
+ _fieldE0 = false;
+ } else if (_fieldE4) {
+ _fieldE4 = false;
+ msg->_value2 = 1;
+ }
+
+ return true;
+}
+
+bool CPhonograph::PhonographRecordMsg(CPhonographRecordMsg *msg) {
+ if (!_fieldE0 && !_fieldE4 && !_fieldE8) {
+ CQueryCylinderHolderMsg holderMsg;
+ holderMsg.execute(this);
+
+ if (holderMsg._value2) {
+ _fieldE4 = true;
+ CErasePhonographCylinderMsg eraseMsg;
+ eraseMsg.execute(holderMsg._target);
+ } else {
+ _fieldE4 = false;
+ }
+ }
+
+ return true;
+}
+
bool CPhonograph::EnterRoomMsg(CEnterRoomMsg *msg) {
- warning("CPhonograph::handleEvent");
+ if (_fieldE0) {
+ CPhonographPlayMsg playMsg;
+ playMsg.execute(this);
+ }
+
+ return true;
+}
+
+bool CPhonograph::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ if (_fieldE0) {
+ CPhonographStopMsg stopMsg;
+ stopMsg._value1 = 1;
+ stopMsg.execute(this);
+ }
+
+ return true;
+}
+
+bool CPhonograph::MusicHasStartedMsg(CMusicHasStartedMsg *msg) {
+ if (_fieldE4) {
+ CQueryCylinderHolderMsg holderMsg;
+ holderMsg.execute(this);
+ if (holderMsg._value2) {
+ CRecordOntoCylinderMsg recordMsg;
+ recordMsg.execute(holderMsg._target);
+ } else {
+ _fieldE4 = false;
+ }
+ }
+
return true;
}
diff --git a/engines/titanic/game/phonograph.h b/engines/titanic/game/phonograph.h
index 274d4ba367..b13a5ea910 100644
--- a/engines/titanic/game/phonograph.h
+++ b/engines/titanic/game/phonograph.h
@@ -29,10 +29,16 @@
namespace Titanic {
class CPhonograph : public CMusicPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool PhonographPlayMsg(CPhonographPlayMsg *msg);
+ bool PhonographStopMsg(CPhonographStopMsg *msg);
+ bool PhonographRecordMsg(CPhonographRecordMsg *msg);
bool EnterRoomMsg(CEnterRoomMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+ bool MusicHasStartedMsg(CMusicHasStartedMsg *msg);
protected:
CString _string2;
- int _fieldE0;
+ bool _fieldE0;
int _fieldE4;
int _fieldE8;
int _fieldEC;
diff --git a/engines/titanic/game/phonograph_lid.cpp b/engines/titanic/game/phonograph_lid.cpp
index a0518420f7..3741749fbf 100644
--- a/engines/titanic/game/phonograph_lid.cpp
+++ b/engines/titanic/game/phonograph_lid.cpp
@@ -24,16 +24,63 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CPhonographLid, CGameObject)
+ ON_MESSAGE(MouseButtonDownMsg)
+ ON_MESSAGE(MovieEndMsg)
+ ON_MESSAGE(LockPhonographMsg)
+ ON_MESSAGE(LeaveViewMsg)
+END_MESSAGE_MAP()
+
void CPhonographLid::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_value, indent);
+ file->writeNumberLine(_open, indent);
CGameObject::save(file, indent);
}
void CPhonographLid::load(SimpleFile *file) {
file->readNumber();
- _value = file->readNumber();
+ _open = file->readNumber();
CGameObject::load(file);
}
+bool CPhonographLid::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ CQueryPhonographState stateMsg;
+ stateMsg.execute(getParent(), nullptr, MSGFLAG_SCAN);
+ if (stateMsg._value) {
+ if (_open) {
+ CGameObject *lock = dynamic_cast<CGameObject *>(findByName("Music System Lock"));
+ if (lock)
+ lock->setVisible(false);
+ playMovie(0, 27, 0);
+ } else {
+ playMovie(27, 55, 0);
+ }
+
+ _open = !_open;
+ } else {
+ petDisplayMessage(0, "This is the restaurant music system. It appears to be locked.");
+ }
+
+ return true;
+}
+
+bool CPhonographLid::MovieEndMsg(CMovieEndMsg *msg) {
+ // WORKAROUND: Redundant code in original not included
+ return true;
+}
+
+bool CPhonographLid::LockPhonographMsg(CLockPhonographMsg *msg) {
+ _cursorId = msg->_value ? CURSOR_INVALID : CURSOR_ARROW;
+ return true;
+}
+
+bool CPhonographLid::LeaveViewMsg(CLeaveViewMsg *msg) {
+ if (_open) {
+ playMovie(27, 55, MOVIE_GAMESTATE);
+ _open = false;
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/phonograph_lid.h b/engines/titanic/game/phonograph_lid.h
index ab32be268b..4e71d70ec2 100644
--- a/engines/titanic/game/phonograph_lid.h
+++ b/engines/titanic/game/phonograph_lid.h
@@ -28,11 +28,16 @@
namespace Titanic {
class CPhonographLid : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+ bool MovieEndMsg(CMovieEndMsg *msg);
+ bool LockPhonographMsg(CLockPhonographMsg *msg);
+ bool LeaveViewMsg(CLeaveViewMsg *msg);
private:
- int _value;
+ bool _open;
public:
CLASSDEF;
- CPhonographLid() : CGameObject(), _value(0) {}
+ CPhonographLid() : CGameObject(), _open(false) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index dd4e38166d..7ce92d190f 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -274,7 +274,7 @@ MESSAGE2(CPumpingMsg, int, value, 0, CGameObject *, object, nullptr);
MESSAGE1(CPutBotBackInHisBoxMsg, int, value, 0);
MESSAGE1(CPutParrotBackMsg, int, value, 0);
MESSAGE0(CPuzzleSolvedMsg);
-MESSAGE3(CQueryCylinderHolderMsg, int, value1, 0, int, value2, 0, int, value3, 0);
+MESSAGE3(CQueryCylinderHolderMsg, int, value1, 0, int, value2, 0, CTreeItem *, target, (CTreeItem *)nullptr);
MESSAGE1(CQueryCylinderMsg, CString, name, "");
MESSAGE1(CQueryCylinderNameMsg, CString, name, "");
MESSAGE3(CQueryCylinderTypeMsg, int, value1, 0, int, value2, 0, int, value3, 0);