From 40ec26b3439eb82e5bf8bff82529c16d34a5ed94 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 27 Aug 2016 11:15:23 -0400 Subject: TITANIC: Implemented phonograph classes --- engines/titanic/game/phonograph_lid.cpp | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'engines/titanic/game/phonograph_lid.cpp') 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(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 -- cgit v1.2.3