diff options
Diffstat (limited to 'engines/titanic/game/restaurant_phonograph.cpp')
-rw-r--r-- | engines/titanic/game/restaurant_phonograph.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/engines/titanic/game/restaurant_phonograph.cpp b/engines/titanic/game/restaurant_phonograph.cpp index 83a4ac3e71..881079e020 100644 --- a/engines/titanic/game/restaurant_phonograph.cpp +++ b/engines/titanic/game/restaurant_phonograph.cpp @@ -21,9 +21,20 @@ */ #include "titanic/game/restaurant_phonograph.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CRestaurantPhonograph, CPhonograph) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(PhonographPlayMsg) + ON_MESSAGE(PhonographStopMsg) + ON_MESSAGE(PhonographReadyToPlayMsg) + ON_MESSAGE(EjectCylinderMsg) + ON_MESSAGE(QueryPhonographState) + ON_MESSAGE(LockPhonographMsg) +END_MESSAGE_MAP() + CRestaurantPhonograph::CRestaurantPhonograph() : CPhonograph(), _fieldF8(1), _field114(0) {} @@ -48,4 +59,89 @@ void CRestaurantPhonograph::load(SimpleFile *file) { CPhonograph::load(file); } +bool CRestaurantPhonograph::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_fieldF8 && !_fieldE0) { + CQueryCylinderHolderMsg holderMsg; + holderMsg.execute(this); + + if (!holderMsg._value1) { + CPhonographPlayMsg playMsg; + playMsg.execute(this); + } else if (holderMsg._value2) { + CEjectCylinderMsg ejectMsg; + ejectMsg.execute(this); + + _fieldE8 = true; + if (_field114) { + loadFrame(_fieldEC); + playSound(_ejectSoundName); + } + } + } + + return true; +} + +bool CRestaurantPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { + if (_fieldE0) { + if (findView() == getView() && (!_fieldE8 || !_field114)) { + loadFrame(_fieldEC); + playSound(_ejectSoundName); + } + + CQueryCylinderNameMsg nameMsg; + nameMsg.execute(this); + CRestaurantMusicChanged musicMsg(nameMsg._name); + musicMsg.execute(findRoom()); + } else { + loadFrame(_fieldF0); + } + + return true; +} + +bool CRestaurantPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) { + bool flag = _fieldE0; + CPhonograph::PhonographStopMsg(msg); + + if (_fieldE0) { + loadFrame(_fieldF0); + if (flag) + playSound(_string3); + } else { + loadFrame(_fieldEC); + } + + return true; +} + +bool CRestaurantPhonograph::PhonographReadyToPlayMsg(CPhonographReadyToPlayMsg *msg) { + if (_fieldE8) { + CPhonographPlayMsg playMsg; + playMsg.execute(this); + _fieldE8 = false; + } + + return true; +} + +bool CRestaurantPhonograph::EjectCylinderMsg(CEjectCylinderMsg *msg) { + if (_fieldE0) { + CPhonographStopMsg stopMsg; + stopMsg.execute(this); + } + + return true; +} + +bool CRestaurantPhonograph::QueryPhonographState(CQueryPhonographState *msg) { + msg->_value = _fieldF8; + return true; +} + +bool CRestaurantPhonograph::LockPhonographMsg(CLockPhonographMsg *msg) { + _fieldF8 = msg->_value; + return true; +} + } // End of namespace Titanic |