diff options
author | Paul Gilbert | 2016-08-15 22:31:33 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-15 22:31:33 -0400 |
commit | 33e4afedde5a31ab97a4e1965869b30dd7964e49 (patch) | |
tree | 01d2666dffea50b1f4100541c938d8d4de08084b /engines/titanic | |
parent | 7234f076f4ccf5cb427ad4abda65b4fb2d823d3b (diff) | |
download | scummvm-rg350-33e4afedde5a31ab97a4e1965869b30dd7964e49.tar.gz scummvm-rg350-33e4afedde5a31ab97a4e1965869b30dd7964e49.tar.bz2 scummvm-rg350-33e4afedde5a31ab97a4e1965869b30dd7964e49.zip |
TITANIC: Implemented CHeadPiece and ear classes
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/carry/bowl_ear.cpp | 31 | ||||
-rw-r--r-- | engines/titanic/carry/bowl_ear.h | 5 | ||||
-rw-r--r-- | engines/titanic/carry/ear.cpp | 27 | ||||
-rw-r--r-- | engines/titanic/carry/ear.h | 3 | ||||
-rw-r--r-- | engines/titanic/carry/head_piece.cpp | 50 | ||||
-rw-r--r-- | engines/titanic/carry/head_piece.h | 9 | ||||
-rw-r--r-- | engines/titanic/carry/phonograph_ear.cpp | 26 | ||||
-rw-r--r-- | engines/titanic/carry/phonograph_ear.h | 8 | ||||
-rw-r--r-- | engines/titanic/core/saveable_object.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 2 |
10 files changed, 155 insertions, 10 deletions
diff --git a/engines/titanic/carry/bowl_ear.cpp b/engines/titanic/carry/bowl_ear.cpp index bb5172e580..852a77899a 100644 --- a/engines/titanic/carry/bowl_ear.cpp +++ b/engines/titanic/carry/bowl_ear.cpp @@ -24,6 +24,13 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CBowlEar, CEar) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(ReplaceBowlAndNutsMsg) + ON_MESSAGE(NutPuzzleMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CBowlEar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CEar::save(file, indent); @@ -34,4 +41,28 @@ void CBowlEar::load(SimpleFile *file) { CEar::load(file); } +bool CBowlEar::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + CBowlStateChangeMsg changeMsg(3); + changeMsg.execute("ParrotNutBowlActor"); + + return CEar::PETGainedObjectMsg(msg); +} + +bool CBowlEar::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { + setVisible(false); + return true; +} + +bool CBowlEar::NutPuzzleMsg(CNutPuzzleMsg *msg) { + if (msg->_value == "BowlUnlocked") + _fieldE0 = 1; + + return true; +} + +bool CBowlEar::MouseDragStartMsg(CMouseDragStartMsg *msg) { + setVisible(true); + return CEar::MouseDragStartMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/bowl_ear.h b/engines/titanic/carry/bowl_ear.h index 4f2fbea478..d78092f6d7 100644 --- a/engines/titanic/carry/bowl_ear.h +++ b/engines/titanic/carry/bowl_ear.h @@ -28,6 +28,11 @@ namespace Titanic { class CBowlEar : public CEar { + DECLARE_MESSAGE_MAP; + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg); + bool NutPuzzleMsg(CNutPuzzleMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/carry/ear.cpp b/engines/titanic/carry/ear.cpp index 8d85e247f7..a2234bc6dc 100644 --- a/engines/titanic/carry/ear.cpp +++ b/engines/titanic/carry/ear.cpp @@ -21,9 +21,15 @@ */ #include "titanic/carry/ear.h" +#include "titanic/game/head_slot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CEar, CHeadPiece) + ON_MESSAGE(ActMsg) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + CEar::CEar() : CHeadPiece() { } @@ -37,4 +43,25 @@ void CEar::load(SimpleFile *file) { CHeadPiece::load(file); } +bool CEar::ActMsg(CActMsg *msg) { + if (msg->_action == "MusicSolved") + _fieldE0 = true; + return true; +} + +bool CEar::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other); + if (slot) { + setVisible(false); + petMoveToHiddenRoom(); + setPosition(Point(0, 0)); + + CAddHeadPieceMsg addMsg(getName()); + if (addMsg._value != "NULL") + addMsg.execute(addMsg._value == "Ear1" ? "Ear1Slot" : "Ear2Slot"); + } + + return CCarry::UseWithOtherMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/ear.h b/engines/titanic/carry/ear.h index edef873d35..a357f46bbf 100644 --- a/engines/titanic/carry/ear.h +++ b/engines/titanic/carry/ear.h @@ -28,6 +28,9 @@ namespace Titanic { class CEar : public CHeadPiece { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); public: CLASSDEF; CEar(); diff --git a/engines/titanic/carry/head_piece.cpp b/engines/titanic/carry/head_piece.cpp index ae709644a0..34850488a7 100644 --- a/engines/titanic/carry/head_piece.cpp +++ b/engines/titanic/carry/head_piece.cpp @@ -24,13 +24,19 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CHeadPiece, CCarry) + ON_MESSAGE(SenseWorkingMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + CHeadPiece::CHeadPiece() : CCarry(), _string6("Not Working"), - _field12C(0), _field13C(0) { + _flag(0), _field13C(false) { } void CHeadPiece::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_flag, indent); file->writeQuotedLine(_string6, indent); file->writeNumberLine(_field13C, indent); @@ -39,11 +45,49 @@ void CHeadPiece::save(SimpleFile *file, int indent) { void CHeadPiece::load(SimpleFile *file) { file->readNumber(); - _field12C = file->readNumber(); + _flag = file->readNumber(); _string6 = file->readString(); _field13C = file->readNumber(); CCarry::load(file); } +bool CHeadPiece::SenseWorkingMsg(CSenseWorkingMsg *msg) { + _string6 = msg->_value; + return true; +} + +bool CHeadPiece::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + _visibleFrame = 1; + if (!_field13C) { + stateInc38(); + _field13C = true; + } + + return true; +} + +bool CHeadPiece::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkPoint(msg->_mousePos, false, true)) { + return false; + } else if (!_fieldE0) { + return true; + } + + if (_flag) { + setVisible(true); + moveToView(); + setPosition(Point(msg->_mousePos.x - _bounds.width() / 2, + msg->_mousePos.y - _bounds.height() / 2)); + + CTakeHeadPieceMsg takeMsg(getName()); + if (takeMsg._value != "NULL") + takeMsg.execute("TitaniaControl"); + + _flag = false; + } + + return CCarry::MouseDragStartMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/head_piece.h b/engines/titanic/carry/head_piece.h index 05ac772853..a76496072b 100644 --- a/engines/titanic/carry/head_piece.h +++ b/engines/titanic/carry/head_piece.h @@ -24,14 +24,19 @@ #define TITANIC_HEAD_PIECE_H #include "titanic/carry/carry.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CHeadPiece : public CCarry { + DECLARE_MESSAGE_MAP; + bool SenseWorkingMsg(CSenseWorkingMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); private: - int _field12C; + bool _flag; CString _string6; - int _field13C; + bool _field13C; public: CLASSDEF; CHeadPiece(); diff --git a/engines/titanic/carry/phonograph_ear.cpp b/engines/titanic/carry/phonograph_ear.cpp index ceb71babd2..9cd461d7e0 100644 --- a/engines/titanic/carry/phonograph_ear.cpp +++ b/engines/titanic/carry/phonograph_ear.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPhonographEar, CEar) + ON_MESSAGE(CorrectMusicPlayedMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(TimerMsg) +END_MESSAGE_MAP() + void CPhonographEar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_field140, indent); @@ -36,4 +42,24 @@ void CPhonographEar::load(SimpleFile *file) { CEar::load(file); } +bool CPhonographEar::CorrectMusicPlayedMsg(CCorrectMusicPlayedMsg *msg) { + _fieldE0 = true; + return true; +} + +bool CPhonographEar::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + if (_field140) { + _field140 = false; + addTimer(1000); + } + + return PETGainedObjectMsg(msg); +} + +bool CPhonographEar::TimerMsg(CTimerMsg *msg) { + CVisibleMsg visibleMsg; + visibleMsg.execute("Replacement Phonograph Ear"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/phonograph_ear.h b/engines/titanic/carry/phonograph_ear.h index 582db9f7ef..b5db015f90 100644 --- a/engines/titanic/carry/phonograph_ear.h +++ b/engines/titanic/carry/phonograph_ear.h @@ -28,11 +28,15 @@ namespace Titanic { class CPhonographEar : public CEar { + DECLARE_MESSAGE_MAP; + bool CorrectMusicPlayedMsg(CCorrectMusicPlayedMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool TimerMsg(CTimerMsg *msg); private: - int _field140; + bool _field140; public: CLASSDEF; - CPhonographEar() : CEar(), _field140(1) {} + CPhonographEar() : CEar(), _field140(true) {} /** * Save the data for the class to file diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index 080c34b08b..2d44126363 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -757,7 +757,7 @@ DEFFN(CAutoSoundEvent); DEFFN(CBilgeAutoSoundEvent); DEFFN(CBilgeDispensorEvent); DEFFN(CBodyInBilgeRoomMsg); -DEFFN(CBowlStateChange); +DEFFN(CBowlStateChangeMsg); DEFFN(CCarryObjectArrivedMsg); DEFFN(CChangeMusicMsg); DEFFN(CChangeSeasonMsg); @@ -1344,7 +1344,7 @@ void CSaveableObject::initClassList() { ADDFN(CBilgeAutoSoundEvent, CAutoSoundEvent); ADDFN(CBilgeDispensorEvent, CAutoSoundEvent); ADDFN(CBodyInBilgeRoomMsg, CMessage); - ADDFN(CBowlStateChange, CMessage); + ADDFN(CBowlStateChangeMsg, CMessage); ADDFN(CCarryObjectArrivedMsg, CMessage); ADDFN(CChangeMusicMsg, CMessage); ADDFN(CChangeSeasonMsg, CMessage); diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 6076d43121..9ee9ccb70d 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -206,7 +206,7 @@ MESSAGE1(CAnimateMaitreDMsg, int, value, 0); MESSAGE1(CArboretumGateMsg, int, value, 0); MESSAGE0(CArmPickedUpFromTableMsg); MESSAGE0(CBodyInBilgeRoomMsg); -MESSAGE1(CBowlStateChange, int, value, 0); +MESSAGE1(CBowlStateChangeMsg, int, value, 0); MESSAGE2(CCarryObjectArrivedMsg, CString, strValue, "", int, numValue, 0); MESSAGE2(CChangeMusicMsg, CString, filename, "", int, flags, 0); MESSAGE1(CChangeSeasonMsg, CString, season, "Summer"); |