diff options
Diffstat (limited to 'engines/titanic/game')
-rw-r--r-- | engines/titanic/game/phonograph.cpp | 120 | ||||
-rw-r--r-- | engines/titanic/game/phonograph.h | 8 | ||||
-rw-r--r-- | engines/titanic/game/phonograph_lid.cpp | 51 | ||||
-rw-r--r-- | engines/titanic/game/phonograph_lid.h | 9 |
4 files changed, 180 insertions, 8 deletions
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 |