diff options
Diffstat (limited to 'engines/titanic')
250 files changed, 4225 insertions, 1414 deletions
diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp index 880c93d309..cbc14da477 100644 --- a/engines/titanic/carry/arm.cpp +++ b/engines/titanic/carry/arm.cpp @@ -161,9 +161,9 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { CGameObject *petItem; if (find(getName(), &petItem, FIND_PET)) { if (!_field158) - playSound("z#47.wav", 100, 0, 0); + playSound("z#47.wav"); if (_string6 == "Key" || _string6 == "AuditoryCentre") { - CGameObject *child = static_cast<CGameObject *>(getFirstChild()); + CGameObject *child = dynamic_cast<CGameObject *>(getFirstChild()); if (child) { child->setVisible(true); petAddToInventory(); @@ -184,7 +184,7 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { if (_field158) { if (_string6 == "Key" || _string6 == "AuditoryCentre") { - CCarry *child = static_cast<CCarry *>(getFirstChild()); + CCarry *child = dynamic_cast<CCarry *>(getFirstChild()); if (child) { _visibleFrame = _field170; loadFrame(_visibleFrame); diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp index 8df0de9961..64b068697b 100644 --- a/engines/titanic/carry/brain.cpp +++ b/engines/titanic/carry/brain.cpp @@ -55,7 +55,7 @@ void CBrain::load(SimpleFile *file) { } bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CBrainSlot *slot = static_cast<CBrainSlot *>(msg->_other); + CBrainSlot *slot = dynamic_cast<CBrainSlot *>(msg->_other); if (slot) { if (slot->getName() == "CentralCore") { setVisible(false); @@ -68,7 +68,7 @@ bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) { petMoveToHiddenRoom(); CAddHeadPieceMsg headpieceMsg(getName()); headpieceMsg.execute(msg->_other); - playSound("z#116.wav", 100, 0, 0); + playSound("z#116.wav"); setPosition(Point(0, 0)); setVisible(false); _field134 = 1; diff --git a/engines/titanic/carry/bridge_piece.cpp b/engines/titanic/carry/bridge_piece.cpp index fc845feff0..487ea32df6 100644 --- a/engines/titanic/carry/bridge_piece.cpp +++ b/engines/titanic/carry/bridge_piece.cpp @@ -52,17 +52,17 @@ void CBridgePiece::load(SimpleFile *file) { } bool CBridgePiece::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CShipSetting *shipSetting = static_cast<CShipSetting *>(msg->_other); + CShipSetting *shipSetting = dynamic_cast<CShipSetting *>(msg->_other); if (!shipSetting) { return CCarry::UseWithOtherMsg(msg); - } else if (shipSetting->_string4 == "NULL") { + } else if (shipSetting->_itemName != "NULL") { petAddToInventory(); return true; } else { setVisible(false); - playSound("z#54.wav", 100, 0, 0); + playSound("z#54.wav"); setPosition(shipSetting->_pos1); - shipSetting->_string4 = getName(); + shipSetting->_itemName = getName(); petMoveToHiddenRoom(); CAddHeadPieceMsg headpieceMsg(shipSetting->getName() == _string6 ? diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp index 75b3b6f35b..03798e8713 100644 --- a/engines/titanic/carry/carry.cpp +++ b/engines/titanic/carry/carry.cpp @@ -127,7 +127,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { return true; } - CCharacter *npc = static_cast<CCharacter *>(msg->_dropTarget); + CCharacter *npc = dynamic_cast<CCharacter *>(msg->_dropTarget); if (npc) { CUseWithCharMsg charMsg(npc); charMsg.execute(this, nullptr, 0); @@ -157,7 +157,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { } bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_character); if (succubus) { CSubAcceptCCarryMsg carryMsg; carryMsg._item = this; diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h index fb5519e290..06e446a1b5 100644 --- a/engines/titanic/carry/carry.h +++ b/engines/titanic/carry/carry.h @@ -44,7 +44,6 @@ class CCarry : public CGameObject { bool EnterViewMsg(CEnterViewMsg *msg); bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); protected: - CString _string1; int _fieldDC; CString _string3; CString _string4; @@ -59,6 +58,7 @@ protected: bool _enterFrameSet; int _visibleFrame; public: + CString _string1; int _fieldE0; Point _origPos; CString _fullViewName; diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp index 8a453e348c..57d82af78a 100644 --- a/engines/titanic/carry/carry_parrot.cpp +++ b/engines/titanic/carry/carry_parrot.cpp @@ -43,16 +43,15 @@ BEGIN_MESSAGE_MAP(CCarryParrot, CCarry) END_MESSAGE_MAP() CCarryParrot::CCarryParrot() : CCarry(), _string6("PerchedParrot"), - _timerId(0), _field13C(0), _field140(false), _field144(10), - _field148(25), _field14C(0), _field150(8) { + _timerId(0), _freeCounter(0), _feathersFlag(false) { } void CCarryParrot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeQuotedLine(_string6, indent); file->writeNumberLine(_timerId, indent); - file->writeNumberLine(_field13C, indent); - file->writeNumberLine(_field140, indent); + file->writeNumberLine(_freeCounter, indent); + file->writeNumberLine(_feathersFlag, indent); CCarry::save(file, indent); } @@ -61,8 +60,8 @@ void CCarryParrot::load(SimpleFile *file) { file->readNumber(); _string6 = file->readString(); _timerId = file->readNumber(); - _field13C = file->readNumber(); - _field140 = file->readNumber(); + _freeCounter = file->readNumber(); + _feathersFlag = file->readNumber(); CCarry::load(file); } @@ -77,7 +76,7 @@ bool CCarryParrot::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { bool CCarryParrot::TimerMsg(CTimerMsg *msg) { if (CParrot::_v4 == 1 || CParrot::_v4 == 4) { - if (++_field13C >= 30) { + if (++_freeCounter >= 30) { CActMsg actMsg("FreeParrot"); actMsg.execute(this); } @@ -125,7 +124,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { setVisible(false); _fieldE0 = 0; CParrot::_v4 = 2; - playSound("z#475.wav", 100, 0, 0); + playSound("z#475.wav"); sound8(true); moveUnder(findRoom()); @@ -133,14 +132,14 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { actMsg.execute("ParrotCage"); } } else { - CCharacter *character = static_cast<CCharacter *>(msg->_dropTarget); + CCharacter *character = dynamic_cast<CCharacter *>(msg->_dropTarget); if (character) { CUseWithCharMsg charMsg(character); charMsg.execute(this, nullptr, 0); } else { setVisible(false); _fieldE0 = 0; - playSound("z#475.wav", 100, 0, 0); + playSound("z#475.wav"); sound8(true); moveUnder(findRoom()); } @@ -160,19 +159,19 @@ bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { stopTimer(_timerId); _timerId = addTimer(1000, 1000); - _field13C = 0; + _freeCounter = 0; CParrot::_v4 = 1; msg->_value3 = 1; return CCarry::PassOnDragStartMsg(msg); } - CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); + CTrueTalkNPC *npc = dynamic_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); if (npc) startTalking(npc, 0x446BF); _fieldE0 = 0; - playSound("z#475.wav", 100, 0, 0); + playSound("z#475.wav"); moveUnder(findRoom()); msg->_value4 = 1; @@ -181,7 +180,7 @@ bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) { loadSurface(); - CCarryParrot *parrot = static_cast<CCarryParrot *>(getRoot()->findByName("CarryParrot")); + CCarryParrot *parrot = dynamic_cast<CCarryParrot *>(getRoot()->findByName("CarryParrot")); if (parrot) parrot->_fieldE0 = 0; @@ -189,7 +188,7 @@ bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) { } bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_character); if (succubus) CParrot::_v4 = 3; @@ -198,7 +197,7 @@ bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) { bool CCarryParrot::ActMsg(CActMsg *msg) { if (msg->_action == "FreeParrot" && (CParrot::_v4 == 4 || CParrot::_v4 == 1)) { - CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); + CTrueTalkNPC *npc = dynamic_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); if (npc) startTalking(npc, 0x446BF); @@ -209,16 +208,16 @@ bool CCarryParrot::ActMsg(CActMsg *msg) { CActMsg actMsg("Shut"); actMsg.execute("ParrotCage"); } else { - playSound("z#475.wav", 100, 0, 0); + playSound("z#475.wav"); - if (!_field140) { - CCarry *feathers = static_cast<CCarry *>(getRoot()->findByName("Feathers")); + if (!_feathersFlag) { + CCarry *feathers = dynamic_cast<CCarry *>(getRoot()->findByName("Feathers")); if (feathers) { feathers->setVisible(true); feathers->petAddToInventory(); } - _field140 = true; + _feathersFlag = true; } getPetControl()->removeFromInventory(this); diff --git a/engines/titanic/carry/carry_parrot.h b/engines/titanic/carry/carry_parrot.h index 2980f26d8a..c42475e5f0 100644 --- a/engines/titanic/carry/carry_parrot.h +++ b/engines/titanic/carry/carry_parrot.h @@ -44,12 +44,8 @@ class CCarryParrot : public CCarry { private: CString _string6; int _timerId; - int _field13C; - bool _field140; - int _field144; - int _field148; - int _field14C; - int _field150; + int _freeCounter; + bool _feathersFlag; public: CLASSDEF; CCarryParrot(); diff --git a/engines/titanic/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp index 65404dc65d..0e8f6b3653 100644 --- a/engines/titanic/carry/chicken.cpp +++ b/engines/titanic/carry/chicken.cpp @@ -80,7 +80,7 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) { petAddToInventory(); } else { - CSauceDispensor *dispensor = static_cast<CSauceDispensor *>(msg->_other); + CSauceDispensor *dispensor = dynamic_cast<CSauceDispensor *>(msg->_other); if (!dispensor || _string6 == "None") { return CCarry::UseWithOtherMsg(msg); } else { @@ -94,7 +94,7 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) { } bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_character); if (succubus) { setPosition(Point(330, 300)); CSubAcceptCCarryMsg acceptMsg; diff --git a/engines/titanic/carry/glass.h b/engines/titanic/carry/glass.h index 85443840a1..608d45cb66 100644 --- a/engines/titanic/carry/glass.h +++ b/engines/titanic/carry/glass.h @@ -35,7 +35,7 @@ class CGlass : public CCarry { bool MouseDragEndMsg(CMouseDragEndMsg *msg); bool TurnOn(CTurnOn *msg); bool TurnOff(CTurnOff *msg); -private: +public: CString _string6; public: CLASSDEF; diff --git a/engines/titanic/carry/magazine.cpp b/engines/titanic/carry/magazine.cpp index cdf92fc707..e68c63f8f9 100644 --- a/engines/titanic/carry/magazine.cpp +++ b/engines/titanic/carry/magazine.cpp @@ -52,7 +52,7 @@ void CMagazine::load(SimpleFile *file) { } bool CMagazine::UseWithCharMsg(CUseWithCharMsg *msg) { - CDeskbot *deskbot = static_cast<CDeskbot *>(msg->_character); + CDeskbot *deskbot = dynamic_cast<CDeskbot *>(msg->_character); if (deskbot) { if (deskbot->_deskbotActive) { setVisible(false); diff --git a/engines/titanic/carry/napkin.cpp b/engines/titanic/carry/napkin.cpp index d25e8b5975..d0ee9acc1a 100644 --- a/engines/titanic/carry/napkin.cpp +++ b/engines/titanic/carry/napkin.cpp @@ -43,7 +43,7 @@ void CNapkin::load(SimpleFile *file) { } bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CChicken *chicken = static_cast<CChicken *>(msg->_other); + CChicken *chicken = dynamic_cast<CChicken *>(msg->_other); if (chicken) { if (chicken->_string6 == "None" || chicken->_field12C) { CActMsg actMsg("Clean"); diff --git a/engines/titanic/carry/phonograph_cylinder.cpp b/engines/titanic/carry/phonograph_cylinder.cpp index 41df050d2b..3dedbc4ac9 100644 --- a/engines/titanic/carry/phonograph_cylinder.cpp +++ b/engines/titanic/carry/phonograph_cylinder.cpp @@ -102,7 +102,7 @@ void CPhonographCylinder::load(SimpleFile *file) { } bool CPhonographCylinder::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CPhonograph *phonograph = static_cast<CPhonograph *>(msg->_other); + CPhonograph *phonograph = dynamic_cast<CPhonograph *>(msg->_other); if (phonograph) { CSetVarMsg varMsg("m_RecordStatus", 1); return true; @@ -167,29 +167,29 @@ bool CPhonographCylinder::SetMusicControlsMsg(CSetMusicControlsMsg *msg) { 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); + musicRoom->setMuteControl(BELLS, _bellsMuteControl); + musicRoom->setPitchControl(BELLS, _bellsPitchControl); + musicRoom->setSpeedControl(BELLS, _bellsSpeedControl); + musicRoom->setInversionControl(BELLS, _bellsInversionControl); + musicRoom->setDirectionControl(BELLS, _bellsDirectionControl); + + musicRoom->setMuteControl(SNAKE, _snakeMuteControl); + musicRoom->setPitchControl(SNAKE, _snakePitchControl); + musicRoom->setSpeedControl(SNAKE, _snakeSpeedControl); + musicRoom->setInversionControl(SNAKE, _snakeInversionControl); + musicRoom->setDirectionControl(SNAKE, _snakeDirectionControl); + + musicRoom->setMuteControl(PIANO, _pianoMuteControl); + musicRoom->setPitchControl(PIANO, _pianoPitchControl); + musicRoom->setSpeedControl(PIANO, _pianoSpeedControl); + musicRoom->setInversionControl(PIANO, _pianoInversionControl); + musicRoom->setDirectionControl(PIANO, _pianoDirectionControl); + + musicRoom->setMuteControl(BASS, _bassMuteControl); + musicRoom->setPitchControl(BASS, _bassPitchControl); + musicRoom->setSpeedControl(BASS, _bassSpeedControl); + musicRoom->setInversionControl(BASS, _bassInversionControl); + musicRoom->setDirectionControl(BASS, _bassDirectionControl); return true; } diff --git a/engines/titanic/carry/plug_in.cpp b/engines/titanic/carry/plug_in.cpp index 883458c9b1..438b9a5883 100644 --- a/engines/titanic/carry/plug_in.cpp +++ b/engines/titanic/carry/plug_in.cpp @@ -28,16 +28,18 @@ BEGIN_MESSAGE_MAP(CPlugIn, CCarry) ON_MESSAGE(UseWithOtherMsg) END_MESSAGE_MAP() -CPlugIn::CPlugIn() : CCarry(), _field12C(0) { +CPlugIn::CPlugIn() : CCarry(), _unused(0) { } void CPlugIn::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); + file->writeNumberLine(_unused, indent); CCarry::save(file, indent); } void CPlugIn::load(SimpleFile *file) { file->readNumber(); + _unused = file->readNumber(); CCarry::load(file); } diff --git a/engines/titanic/carry/plug_in.h b/engines/titanic/carry/plug_in.h index 1358a99e39..5f7d5dd2b0 100644 --- a/engines/titanic/carry/plug_in.h +++ b/engines/titanic/carry/plug_in.h @@ -31,7 +31,7 @@ class CPlugIn : public CCarry { DECLARE_MESSAGE_MAP; bool UseWithOtherMsg(CUseWithOtherMsg *msg); private: - int _field12C; + int _unused; public: CLASSDEF; CPlugIn(); diff --git a/engines/titanic/carry/speech_centre.cpp b/engines/titanic/carry/speech_centre.cpp index b8076aee76..29ced484a5 100644 --- a/engines/titanic/carry/speech_centre.cpp +++ b/engines/titanic/carry/speech_centre.cpp @@ -24,10 +24,17 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSpeechCentre, CBrain) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(SpeechFallsFromTreeMsg) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + void CSpeechCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_field13C, indent); - file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_season, indent); file->writeNumberLine(_field14C, indent); CBrain::save(file, indent); @@ -36,10 +43,41 @@ void CSpeechCentre::save(SimpleFile *file, int indent) { void CSpeechCentre::load(SimpleFile *file) { file->readNumber(); _field13C = file->readNumber(); - _string1 = file->readString(); + _season = file->readString(); _field14C = file->readNumber(); CBrain::load(file); } +bool CSpeechCentre::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + if (_field13C == 1 && _season == "Autumn") + _fieldE0 = true; + return true; +} + +bool CSpeechCentre::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _season = msg->_season; + return true; +} + +bool CSpeechCentre::SpeechFallsFromTreeMsg(CSpeechFallsFromTreeMsg *msg) { + setVisible(true); + dragMove(msg->_pos); + _field14C = true; + return true; +} + +bool CSpeechCentre::FrameMsg(CFrameMsg *msg) { + if (_field14C) { + if (_bounds.top > 200) + _field14C = false; + + makeDirty(); + _bounds.top += 3; + makeDirty(); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/speech_centre.h b/engines/titanic/carry/speech_centre.h index 50f47e9c8a..806e22247b 100644 --- a/engines/titanic/carry/speech_centre.h +++ b/engines/titanic/carry/speech_centre.h @@ -28,13 +28,18 @@ namespace Titanic { class CSpeechCentre : public CBrain { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool SpeechFallsFromTreeMsg(CSpeechFallsFromTreeMsg *msg); + bool FrameMsg(CFrameMsg *msg); private: int _field13C; - CString _string1; + CString _season; int _field14C; public: CLASSDEF; - CSpeechCentre() : CBrain(), _string1("Summer"), + CSpeechCentre() : CBrain(), _season("Summer"), _field13C(1), _field14C(0) {} /** diff --git a/engines/titanic/carry/vision_centre.cpp b/engines/titanic/carry/vision_centre.cpp index 8c8bab15f8..fd30089fc5 100644 --- a/engines/titanic/carry/vision_centre.cpp +++ b/engines/titanic/carry/vision_centre.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CVisionCentre, CBrain) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CVisionCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBrain::save(file, indent); @@ -34,4 +40,27 @@ void CVisionCentre::load(SimpleFile *file) { CBrain::load(file); } +bool CVisionCentre::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _fieldE0 = true; + return true; +} + +bool CVisionCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_fieldE0) { + return CBrain::MouseButtonDownMsg(msg); + } else { + petDisplayMessage(1, "It would be nice if you could take that but you can't."); + return true; + } +} + +bool CVisionCentre::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (_fieldE0) { + return CBrain::MouseDragStartMsg(msg); + } else { + petDisplayMessage(1, "It would be nice if you could take that but you can't."); + return true; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/vision_centre.h b/engines/titanic/carry/vision_centre.h index 6cf8e2c653..14055a5f5f 100644 --- a/engines/titanic/carry/vision_centre.h +++ b/engines/titanic/carry/vision_centre.h @@ -28,6 +28,10 @@ namespace Titanic { class CVisionCentre : public CBrain { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/configure.engine b/engines/titanic/configure.engine index daf4e6b388..1697a779c0 100644 --- a/engines/titanic/configure.engine +++ b/engines/titanic/configure.engine @@ -1,3 +1,3 @@ # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] -add_engine titanic "Starship Titanic" no "" "" "16bit jpeg highres" +add_engine titanic "Starship Titanic" no "" "" "16bit jpeg highres mad" diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 0289e78823..59ae96138d 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -42,7 +42,7 @@ int CGameObject::_soundHandles[4]; void CGameObject::init() { _credits = nullptr; - _soundHandles[0] = _soundHandles[1] = 0; + _soundHandles[0] = _soundHandles[1] = -1; _soundHandles[2] = _soundHandles[3] = -1; } @@ -438,7 +438,8 @@ bool CGameObject::isSoundActive(int handle) const { return false; } -void CGameObject::playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated, int handleIndex) { +void CGameObject::playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated, + int handleIndex, Audio::Mixer::SoundType soundType) { if (handleIndex < 0 || handleIndex > 3) return; CGameManager *gameManager = getGameManager(); @@ -463,19 +464,20 @@ void CGameObject::playGlobalSound(const CString &resName, int mode, bool initial CProximity prox; prox._channelVolume = volume; prox._repeated = repeated; + prox._soundType = soundType; switch (handleIndex) { case 0: - prox._channel = 6; + prox._channelMode = 6; break; case 1: - prox._channel = 7; + prox._channelMode = 7; break; case 2: - prox._channel = 8; + prox._channelMode = 8; break; case 3: - prox._channel = 9; + prox._channelMode = 9; break; default: break; @@ -519,7 +521,6 @@ void CGameObject::stopGlobalSound(bool transition, int handleIndex) { sound.stopSound(_soundHandles[handleIndex]); _soundHandles[handleIndex] = -1; } - warning("CGameObject::soundFn4"); } void CGameObject::setGlobalSoundVolume(int mode, uint seconds, int handleIndex) { @@ -731,10 +732,10 @@ void CGameObject::loadSound(const CString &name) { } } -int CGameObject::playSound(const CString &name, uint volume, int val3, bool repeated) { +int CGameObject::playSound(const CString &name, uint volume, int balance, bool repeated) { CProximity prox; prox._channelVolume = volume; - prox._fieldC = val3; + prox._balance = balance; prox._repeated = repeated; return playSound(name, prox); } @@ -757,9 +758,9 @@ int CGameObject::playSound(const CString &name, CProximity &prox) { return 0; } -int CGameObject::queueSound(const CString &name, uint priorHandle, uint volume, int val3, bool repeated) { +int CGameObject::queueSound(const CString &name, uint priorHandle, uint volume, int balance, bool repeated) { CProximity prox; - prox._fieldC = val3; + prox._balance = balance; prox._repeated = repeated; prox._channelVolume = volume; prox._priorSoundHandle = priorHandle; @@ -870,15 +871,15 @@ CViewItem *CGameObject::parseView(const CString &viewString) { return nullptr; // Find the designated node within the room - CNodeItem *node = static_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); + CNodeItem *node = dynamic_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); while (node && node->getName() != nodeName) - node = static_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node)); + node = dynamic_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node)); if (!node) return nullptr; - CViewItem *view = static_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); + CViewItem *view = dynamic_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); while (view && view->getName() != viewName) - view = static_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view)); + view = dynamic_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view)); if (!view) return nullptr; @@ -897,7 +898,12 @@ CString CGameObject::getViewFullName() const { } void CGameObject::sleep(uint milli) { - g_vm->_events->sleep(milli); + // Use an empty event target so that standard scene drawing won't happen + Events &events = *g_vm->_events; + CEventTarget nullTarget; + events.addTarget(&nullTarget); + events.sleep(milli); + events.removeTarget(); } Point CGameObject::getMousePos() const { @@ -963,12 +969,12 @@ CGameObject *CGameObject::getNextMail(CGameObject *prior) { } CGameObject *CGameObject::findRoomObject(const CString &name) const { - return static_cast<CGameObject *>(findRoom()->findByName(name)); + return dynamic_cast<CGameObject *>(findRoom()->findByName(name)); } CGameObject *CGameObject::findInRoom(const CString &name) { CRoomItem *room = getRoom(); - return room ? static_cast<CGameObject *>(room->findByName(name)) : nullptr; + return room ? dynamic_cast<CGameObject *>(room->findByName(name)) : nullptr; } Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) { @@ -995,7 +1001,7 @@ Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) } if (findAreas & FIND_GLOBAL) { - go = static_cast<CGameObject *>(getRoot()->findByName(name)); + go = dynamic_cast<CGameObject *>(getRoot()->findByName(name)); if (go) { *item = go; return FOUND_GLOBAL; @@ -1025,12 +1031,12 @@ void CGameObject::moveToView(const CString &name) { addUnder(view); } -void CGameObject::stateInc14() { - getGameManager()->_gameState.inc14(); +void CGameObject::stateChangeSeason() { + getGameManager()->_gameState.changeSeason(); } -int CGameObject::stateGet14() const { - return getGameManager()->_gameState._field14; +Season CGameObject::stateGetSeason() const { + return getGameManager()->_gameState._seasonNum; } void CGameObject::stateSet24() { @@ -1160,8 +1166,8 @@ void CGameObject::mouseUnlockE4() { CScreenManager::_screenManagerPtr->_mouseCursor->unlockE4(); } -void CGameObject::mouseSaveState(int v1, int v2, int v3) { - CScreenManager::_screenManagerPtr->_mouseCursor->saveState(v1, v2, v3); +void CGameObject::mouseSetPosition(const Point &pt, double rate) { + CScreenManager::_screenManagerPtr->_mouseCursor->setPosition(pt, rate); } void CGameObject::lockInputHandler() { @@ -1226,7 +1232,7 @@ void CGameObject::dragMove(const Point &pt) { CGameObject *CGameObject::getDraggingObject() const { CTreeItem *item = getGameManager()->_dragItem; - return static_cast<CGameObject *>(item); + return dynamic_cast<CGameObject *>(item); } Point CGameObject::getControid() const { @@ -1254,7 +1260,7 @@ CDontSaveFileItem *CGameObject::getDontSave() const { } CPetControl *CGameObject::getPetControl() const { - return static_cast<CPetControl *>(getDontSaveChild(CPetControl::_type)); + return dynamic_cast<CPetControl *>(getDontSaveChild(CPetControl::_type)); } CMailMan *CGameObject::getMailMan() const { @@ -1293,7 +1299,7 @@ CRoomItem *CGameObject::locateRoom(const CString &name) const { CGameObject *CGameObject::getHiddenObject(const CString &name) const { CRoomItem *room = getHiddenRoom(); - return room ? static_cast<CGameObject *>(findUnder(room, name)) : nullptr; + return room ? dynamic_cast<CGameObject *>(findUnder(room, name)) : nullptr; } CTreeItem *CGameObject::findUnder(CTreeItem *parent, const CString &name) const { @@ -1505,7 +1511,7 @@ CTreeItem *CGameObject::petContainerRemove(CGameObject *obj) { if (!obj->compareRoomNameTo("CarryParcel")) return obj; - CGameObject *item = static_cast<CGameObject *>(pet->getLastChild()); + CGameObject *item = dynamic_cast<CGameObject *>(pet->getLastChild()); if (item) item->detach(); @@ -1600,11 +1606,11 @@ void CGameObject::petUnlockInput() { /*------------------------------------------------------------------------*/ CStarControl *CGameObject::getStarControl() const { - CStarControl *starControl = static_cast<CStarControl *>(getDontSaveChild(CStarControl::_type)); + CStarControl *starControl = dynamic_cast<CStarControl *>(getDontSaveChild(CStarControl::_type)); if (!starControl) { CViewItem *view = getGameManager()->getView(); if (view) - starControl = static_cast<CStarControl *>(view->findChildInstanceOf(CStarControl::_type)); + starControl = dynamic_cast<CStarControl *>(view->findChildInstanceOf(CStarControl::_type)); } return starControl; diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 53e26b5f6b..0da3fad605 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -23,6 +23,7 @@ #ifndef TITANIC_GAME_OBJECT_H #define TITANIC_GAME_OBJECT_H +#include "audio/mixer.h" #include "common/stream.h" #include "titanic/support/mouse_cursor.h" #include "titanic/support/credit_text.h" @@ -33,6 +34,7 @@ #include "titanic/core/named_item.h" #include "titanic/pet_control/pet_section.h" #include "titanic/pet_control/pet_text.h" +#include "titanic/game_state.h" namespace Titanic { @@ -165,7 +167,10 @@ protected: void mouseLockE4(); void mouseUnlockE4(); - void mouseSaveState(int v1, int v2, int v3); + /** + * Sets the mouse to a new position + */ + void mouseSetPosition(const Point &pt, double rate); /** * Lock the input handler @@ -184,24 +189,30 @@ protected: /** * Plays a sound - * @param resName Filename of sound to play + * @param name Filename of sound to play * @param volume Volume level + * @param balance Sound balance (not actually used in original) + * @param repeated If true, sound will repeat indefinitely */ - int playSound(const CString &name, uint volume = 100, int val3 = 0, bool repeated = false); + int playSound(const CString &name, uint volume = 100, int balance = 0, bool repeated = false); /** * Plays a sound - * @param resName Filename of sound to play + * @param name Filename of sound to play * @param prox Proximity object with the sound data */ int playSound(const CString &name, CProximity &prox); /** * Queues a sound to play after a specified one finishes - * @param resName Filename of sound to play - * @param volume Volume level + * @param name Filename of sound to play + * @param priorHandle Sound to wait until finished before playing + * @param volume Volume level + * @param balance Sound balance (not actually used by original) + * @param repeated If true, sound will repeat indefinitely */ - int queueSound(const CString &name, uint priorHandle, uint volume = 100, int val3 = 0, bool repeated = false); + int queueSound(const CString &name, uint priorHandle, uint volume = 100, + int balance = 0, bool repeated = false); /** * Stop a sound @@ -230,8 +241,10 @@ protected: * @param initialMute If set, sound transitions in from mute over 2 seconds * @param repeated Flag for repeating sounds * @param handleIndex Slot 0 to 3 in the shared sound handle list to store the sound's handle + * @param soundType Specifies whether the sound is a sound effect or music */ - void playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated, int handleIndex); + void playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated, + int handleIndex, Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType); /** * Stops a sound saved in the global sound handle list @@ -941,8 +954,17 @@ public: /*--- CGameState Methods ---*/ void setState1C(bool flag); - void stateInc14(); - int stateGet14() const; + + /** + * Change to the next season + */ + void stateChangeSeason(); + + /** + * Returns the currently active season + */ + Season stateGetSeason() const; + void stateSet24(); int stateGet24() const; void stateInc38(); diff --git a/engines/titanic/core/game_object_desc_item.cpp b/engines/titanic/core/game_object_desc_item.cpp index 409334c9d7..a6ee7e3cf5 100644 --- a/engines/titanic/core/game_object_desc_item.cpp +++ b/engines/titanic/core/game_object_desc_item.cpp @@ -30,7 +30,7 @@ CGameObjectDescItem::CGameObjectDescItem(): CTreeItem() { void CGameObjectDescItem::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); _clipList.save(file, indent); - file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_name, indent); file->writeQuotedLine(_string2, indent); _list1.save(file, indent); _list2.save(file, indent); @@ -45,7 +45,7 @@ void CGameObjectDescItem::load(SimpleFile *file) { if (val) _clipList.load(file); - _string1 = file->readString(); + _name = file->readString(); _string2 = file->readString(); _list1.load(file); _list1.load(file); diff --git a/engines/titanic/core/game_object_desc_item.h b/engines/titanic/core/game_object_desc_item.h index 7bfecaf5a2..4f485e0d55 100644 --- a/engines/titanic/core/game_object_desc_item.h +++ b/engines/titanic/core/game_object_desc_item.h @@ -31,7 +31,7 @@ namespace Titanic { class CGameObjectDescItem : public CTreeItem { protected: - CString _string1; + CString _name; CString _string2; List<ListItem> _list1; List<ListItem> _list2; @@ -49,6 +49,11 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file); + + /** + * Gets the name of the item, if any + */ + virtual const CString getName() const { return _name; } }; } // End of namespace Titanic diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp index afe13bebad..11e17fc4e5 100644 --- a/engines/titanic/core/mail_man.cpp +++ b/engines/titanic/core/mail_man.cpp @@ -37,14 +37,14 @@ void CMailMan::load(SimpleFile *file) { } CGameObject *CMailMan::getFirstObject() const { - return static_cast<CGameObject *>(getFirstChild()); + return dynamic_cast<CGameObject *>(getFirstChild()); } CGameObject *CMailMan::getNextObject(CGameObject *prior) const { if (!prior || prior->getParent() != this) return nullptr; - return static_cast<CGameObject *>(prior->getNextSibling()); + return dynamic_cast<CGameObject *>(prior->getNextSibling()); } void CMailMan::addMail(CGameObject *obj, int id) { diff --git a/engines/titanic/core/room_item.cpp b/engines/titanic/core/room_item.cpp index 541a8e1a9e..49b3232ba1 100644 --- a/engines/titanic/core/room_item.cpp +++ b/engines/titanic/core/room_item.cpp @@ -36,8 +36,8 @@ void CRoomItem::save(SimpleFile *file, int indent) { _exitMovieKey.save(file, indent); file->writeQuotedLine("Room dimensions x 1000", indent); - file->writeNumberLine(_roomDimensionX * 1000.0, indent + 1); - file->writeNumberLine(_roomDimensionY * 1000.0, indent + 1); + file->writeNumberLine((int)(_roomDimensionX * 1000.0), indent + 1); + file->writeNumberLine((int)(_roomDimensionY * 1000.0), indent + 1); file->writeQuotedLine("Transition Movie", indent); _transitionMovieKey.save(file, indent); diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index eee71cfc43..db3249c107 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -286,7 +286,6 @@ #include "titanic/gfx/chev_right_off.h" #include "titanic/gfx/chev_right_on.h" #include "titanic/gfx/chev_send_rec_switch.h" -#include "titanic/gfx/chev_switch.h" #include "titanic/gfx/edit_control.h" #include "titanic/gfx/elevator_button.h" #include "titanic/gfx/get_from_succ.h" @@ -705,7 +704,6 @@ DEFFN(CChevLeftOn); DEFFN(CChevRightOff); DEFFN(CChevRightOn); DEFFN(CChevSendRecSwitch); -DEFFN(CChevSwitch); DEFFN(CEditControl); DEFFN(CElevatorButton); DEFFN(CGetFromSucc); @@ -1289,7 +1287,6 @@ void CSaveableObject::initClassList() { ADDFN(CChevRightOff, CToggleSwitch); ADDFN(CChevRightOn, CToggleSwitch); ADDFN(CChevSendRecSwitch, CToggleSwitch); - ADDFN(CChevSwitch, CToggleSwitch); ADDFN(CEditControl, CGameObject); ADDFN(CElevatorButton, CSTButton); ADDFN(CGetFromSucc, CToggleSwitch); diff --git a/engines/titanic/core/turn_on_play_sound.cpp b/engines/titanic/core/turn_on_play_sound.cpp index 2f9dba24a6..ab50b33134 100644 --- a/engines/titanic/core/turn_on_play_sound.cpp +++ b/engines/titanic/core/turn_on_play_sound.cpp @@ -24,26 +24,37 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CTurnOnPlaySound, CTurnOnObject) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + CTurnOnPlaySound::CTurnOnPlaySound() : CTurnOnObject(), - _string3("NULL"), _fieldF8(80), _fieldFC(0) { + _soundName("NULL"), _soundVolume(80), _soundVal3(0) { } void CTurnOnPlaySound::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string3, indent); - file->writeNumberLine(_fieldF8, indent); - file->writeNumberLine(_fieldFC, indent); + file->writeQuotedLine(_soundName, indent); + file->writeNumberLine(_soundVolume, indent); + file->writeNumberLine(_soundVal3, indent); CTurnOnObject::save(file, indent); } void CTurnOnPlaySound::load(SimpleFile *file) { file->readNumber(); - _string3 = file->readString(); - _fieldF8 = file->readNumber(); - _fieldFC = file->readNumber(); + _soundName = file->readString(); + _soundVolume = file->readNumber(); + _soundVal3 = file->readNumber(); CTurnOnObject::load(file); } +bool CTurnOnPlaySound::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (_soundName != "NULL") + playSound(_soundName, _soundVolume, _soundVal3); + + return CTurnOnObject::MouseButtonUpMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/core/turn_on_play_sound.h b/engines/titanic/core/turn_on_play_sound.h index 1164135071..29a25a5665 100644 --- a/engines/titanic/core/turn_on_play_sound.h +++ b/engines/titanic/core/turn_on_play_sound.h @@ -28,10 +28,12 @@ namespace Titanic { class CTurnOnPlaySound : public CTurnOnObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); private: - CString _string3; - int _fieldF8; - int _fieldFC; + CString _soundName; + int _soundVolume; + int _soundVal3; public: CLASSDEF; CTurnOnPlaySound(); diff --git a/engines/titanic/core/turn_on_turn_off.cpp b/engines/titanic/core/turn_on_turn_off.cpp index d43ddf7038..6498c226a0 100644 --- a/engines/titanic/core/turn_on_turn_off.cpp +++ b/engines/titanic/core/turn_on_turn_off.cpp @@ -24,16 +24,21 @@ namespace Titanic { -CTurnOnTurnOff::CTurnOnTurnOff() : CBackground(), _fieldE0(0), - _fieldE4(0), _fieldE8(0), _fieldEC(0), _fieldF0(0) { +BEGIN_MESSAGE_MAP(CTurnOnTurnOff, CBackground) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) +END_MESSAGE_MAP() + +CTurnOnTurnOff::CTurnOnTurnOff() : CBackground(), _startFrameOn(0), + _endFrameOn(0), _startFrameOff(0), _endFrameOff(0), _fieldF0(false) { } void CTurnOnTurnOff::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); - file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_startFrameOn, indent); + file->writeNumberLine(_endFrameOn, indent); + file->writeNumberLine(_startFrameOff, indent); + file->writeNumberLine(_endFrameOff, indent); file->writeNumberLine(_fieldF0, indent); CBackground::save(file, indent); @@ -41,13 +46,37 @@ void CTurnOnTurnOff::save(SimpleFile *file, int indent) { void CTurnOnTurnOff::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); - _fieldEC = file->readNumber(); + _startFrameOn = file->readNumber(); + _endFrameOn = file->readNumber(); + _startFrameOff = file->readNumber(); + _endFrameOff = file->readNumber(); _fieldF0 = file->readNumber(); CBackground::load(file); } +bool CTurnOnTurnOff::TurnOn(CTurnOn *msg) { + if (!_fieldF0) { + if (_fieldDC) + playMovie(_startFrameOn, _endFrameOn, MOVIE_GAMESTATE); + else + playMovie(_startFrameOn, _endFrameOn, MOVIE_NOTIFY_OBJECT); + _fieldF0 = true; + } + + return true; +} + +bool CTurnOnTurnOff::TurnOff(CTurnOff *msg) { + if (!_fieldF0) { + if (_fieldDC) + playMovie(_startFrameOff, _endFrameOff, MOVIE_GAMESTATE); + else + playMovie(_startFrameOff, _endFrameOff, MOVIE_NOTIFY_OBJECT); + _fieldF0 = true; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/turn_on_turn_off.h b/engines/titanic/core/turn_on_turn_off.h index adca6876ff..c09f0e0d7d 100644 --- a/engines/titanic/core/turn_on_turn_off.h +++ b/engines/titanic/core/turn_on_turn_off.h @@ -28,12 +28,15 @@ namespace Titanic { class CTurnOnTurnOff : public CBackground { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); private: - int _fieldE0; - int _fieldE4; - int _fieldE8; - int _fieldEC; - int _fieldF0; + int _startFrameOn; + int _endFrameOn; + int _startFrameOff; + int _endFrameOff; + bool _fieldF0; public: CLASSDEF; CTurnOnTurnOff(); diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 03e2753839..176765b12f 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -115,19 +115,19 @@ void CViewItem::preEnterView(CViewItem *newView) { // Only do the processing if we've been passed a view, and it's not the same if (newView && newView != this) { CPreEnterViewMsg viewMsg(this, newView); - viewMsg.execute(this, nullptr, MSGFLAG_SCAN); + viewMsg.execute(newView, nullptr, MSGFLAG_SCAN); CNodeItem *oldNode = findNode(); CNodeItem *newNode = newView->findNode(); if (newNode != oldNode) { CPreEnterNodeMsg nodeMsg(oldNode, newNode); - nodeMsg.execute(oldNode, nullptr, MSGFLAG_SCAN); + nodeMsg.execute(newNode, nullptr, MSGFLAG_SCAN); CRoomItem *oldRoom = oldNode->findRoom(); CRoomItem *newRoom = newNode->findRoom(); if (newRoom != oldRoom) { CPreEnterRoomMsg roomMsg(oldRoom, newRoom); - roomMsg.execute(oldRoom, nullptr, MSGFLAG_SCAN); + roomMsg.execute(newRoom, nullptr, MSGFLAG_SCAN); } } } @@ -137,13 +137,13 @@ void CViewItem::enterView(CViewItem *newView) { // Only do the processing if we've been passed a view, and it's not the same if (newView && newView != this) { CEnterViewMsg viewMsg(this, newView); - viewMsg.execute(this, nullptr, MSGFLAG_SCAN); + viewMsg.execute(newView, nullptr, MSGFLAG_SCAN); CNodeItem *oldNode = findNode(); CNodeItem *newNode = newView->findNode(); if (newNode != oldNode) { CEnterNodeMsg nodeMsg(oldNode, newNode); - nodeMsg.execute(oldNode, nullptr, MSGFLAG_SCAN); + nodeMsg.execute(newNode, nullptr, MSGFLAG_SCAN); CRoomItem *oldRoom = oldNode->findRoom(); CRoomItem *newRoom = newNode->findRoom(); @@ -157,7 +157,7 @@ void CViewItem::enterView(CViewItem *newView) { if (newRoom != oldRoom) { CEnterRoomMsg roomMsg(oldRoom, newRoom); - roomMsg.execute(oldRoom, nullptr, MSGFLAG_SCAN); + roomMsg.execute(newRoom, nullptr, MSGFLAG_SCAN); if (petControl) petControl->enterRoom(newRoom); @@ -168,8 +168,8 @@ void CViewItem::enterView(CViewItem *newView) { CLinkItem *CViewItem::findLink(CViewItem *newView) { for (CTreeItem *treeItem = getFirstChild(); treeItem; - treeItem = scan(treeItem)) { - CLinkItem *link = static_cast<CLinkItem *>(treeItem); + treeItem = treeItem->scan(this)) { + CLinkItem *link = dynamic_cast<CLinkItem *>(treeItem); if (link && link->connectsTo(newView)) return link; } diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp index 37fc546851..a9da83f724 100644 --- a/engines/titanic/debugger.cpp +++ b/engines/titanic/debugger.cpp @@ -231,7 +231,7 @@ bool Debugger::cmdItem(int argc, const char **argv) { } // Get the item - CCarry *item = static_cast<CCarry *>( + CCarry *item = dynamic_cast<CCarry *>( g_vm->_window->_project->findByName(argv[1])); assert(item); diff --git a/engines/titanic/detection.cpp b/engines/titanic/detection.cpp index 86d26f2f27..096cd4b618 100644 --- a/engines/titanic/detection.cpp +++ b/engines/titanic/detection.cpp @@ -90,7 +90,8 @@ bool TitanicMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSupportsLoadingDuringStartup) || (f == kSupportsDeleteSave) || (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail); + (f == kSavesSupportThumbnail) || + (f == kSimpleSavesNames); } bool Titanic::TitanicEngine::hasFeature(EngineFeature f) const { diff --git a/engines/titanic/events.cpp b/engines/titanic/events.cpp index 318ddf5726..fa057de432 100644 --- a/engines/titanic/events.cpp +++ b/engines/titanic/events.cpp @@ -125,12 +125,17 @@ void Events::sleep(uint time) { } bool Events::waitForPress(uint expiry) { + CGameManager *gameManager = g_vm->_window->_gameManager; uint32 delayEnd = g_system->getMillis() + expiry; while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) { g_system->delayMillis(10); checkForNextFrameCounter(); + // Regularly update the sound mixer + if (gameManager) + gameManager->_sound.updateMixer(); + Common::Event event; if (g_system->getEventManager()->pollEvent(event)) { switch (event.type) { diff --git a/engines/titanic/game/arboretum_gate.cpp b/engines/titanic/game/arboretum_gate.cpp index 4c3ca03b7a..1435e3e204 100644 --- a/engines/titanic/game/arboretum_gate.cpp +++ b/engines/titanic/game/arboretum_gate.cpp @@ -21,7 +21,6 @@ */ #include "titanic/game/arboretum_gate.h" -#include "titanic/game/seasonal_adjustment.h" namespace Titanic { @@ -45,30 +44,30 @@ CArboretumGate::CArboretumGate() : CBackground() { _viewName2 = "NULL"; _seasonNum = 0; _fieldF0 = 0; - _winterOffStartFrame = 244; - _winterOffEndFrame = 304; - _springOffStartFrame = 122; - _springOffEndFrame = 182; - _summerOffStartFrame1 = 183; - _summerOffEndFrame1 = 243; - _summerOffStartFrame2 = 665; - _summerOffEndFrame2 = 724; - _autumnOffStartFrame1 = 61; - _autumnOffEndFrame1 = 121; - _autumnOffStartFrame2 = 0; - _autumnOffEndFrame2 = 60; - _winterOnStartFrame = 485; - _winterOnEndFrame = 544; - _springOnStartFrame = 425; - _springOnEndFrame = 484; - _summerOnStartFrame1 = 545; - _summerOnEndFrame1 = 604; - _summerOnStartFrame2 = 605; - _summerOnEndFrame2 = 664; - _autumnOnStartFrame1 = 305; - _autumnOnEndFrame1 = 364; - _autumnOnStartFrame2 = 365; - _autumnOnEndFrame2 = 424; + _startFrameSpringOff = 244; + _endFrameSpringOff = 304; + _startFrameSummerOff = 122; + _endFrameSummerOff = 182; + _startFrameAutumnOff1 = 183; + _endFrameAutumnOff1 = 243; + _startFrameAutumnOff2 = 665; + _endFrameAutumnOff2 = 724; + _startFrameWinterOff1 = 61; + _endFrameWinterOff1 = 121; + _startFrameWinterOff2 = 0; + _endFrameWinterOff2 = 60; + _startFrameSpringOn = 485; + _endFrameSpringOn = 544; + _startFrameSummerOn = 425; + _endFrameSummerOn = 484; + _startFrameAutumnOn1 = 545; + _endFrameAutumnOn1 = 604; + _startFrameAutumnOn2 = 605; + _endFrameAutumnOn2 = 664; + _startFrameWinterOn1 = 305; + _endFrameWinterOn1 = 364; + _startFrameWinterOn2 = 365; + _endFrameWinterOn2 = 424; } void CArboretumGate::save(SimpleFile *file, int indent) { @@ -79,30 +78,30 @@ void CArboretumGate::save(SimpleFile *file, int indent) { file->writeNumberLine(_v3, indent); file->writeQuotedLine(_viewName1, indent); file->writeNumberLine(_fieldF0, indent); - file->writeNumberLine(_winterOffStartFrame, indent); - file->writeNumberLine(_winterOffEndFrame, indent); - file->writeNumberLine(_springOffStartFrame, indent); - file->writeNumberLine(_springOffEndFrame, indent); - file->writeNumberLine(_summerOffStartFrame1, indent); - file->writeNumberLine(_summerOffEndFrame1, indent); - file->writeNumberLine(_summerOffStartFrame2, indent); - file->writeNumberLine(_summerOffEndFrame2, indent); - file->writeNumberLine(_autumnOffStartFrame1, indent); - file->writeNumberLine(_autumnOffEndFrame1, indent); - file->writeNumberLine(_autumnOffStartFrame2, indent); - file->writeNumberLine(_autumnOffEndFrame2, indent); - file->writeNumberLine(_winterOnStartFrame, indent); - file->writeNumberLine(_winterOnEndFrame, indent); - file->writeNumberLine(_springOnStartFrame, indent); - file->writeNumberLine(_springOnEndFrame, indent); - file->writeNumberLine(_summerOnStartFrame1, indent); - file->writeNumberLine(_summerOnEndFrame1, indent); - file->writeNumberLine(_summerOnStartFrame2, indent); - file->writeNumberLine(_summerOnEndFrame2, indent); - file->writeNumberLine(_autumnOnStartFrame1, indent); - file->writeNumberLine(_autumnOnEndFrame1, indent); - file->writeNumberLine(_autumnOnStartFrame2, indent); - file->writeNumberLine(_autumnOnEndFrame2, indent); + file->writeNumberLine(_startFrameSpringOff, indent); + file->writeNumberLine(_endFrameSpringOff, indent); + file->writeNumberLine(_startFrameSummerOff, indent); + file->writeNumberLine(_endFrameSummerOff, indent); + file->writeNumberLine(_startFrameAutumnOff1, indent); + file->writeNumberLine(_endFrameAutumnOff1, indent); + file->writeNumberLine(_startFrameAutumnOff2, indent); + file->writeNumberLine(_endFrameAutumnOff2, indent); + file->writeNumberLine(_startFrameWinterOff1, indent); + file->writeNumberLine(_endFrameWinterOff1, indent); + file->writeNumberLine(_startFrameWinterOff2, indent); + file->writeNumberLine(_endFrameWinterOff2, indent); + file->writeNumberLine(_startFrameSpringOn, indent); + file->writeNumberLine(_endFrameSpringOn, indent); + file->writeNumberLine(_startFrameSummerOn, indent); + file->writeNumberLine(_endFrameSummerOn, indent); + file->writeNumberLine(_startFrameAutumnOn1, indent); + file->writeNumberLine(_endFrameAutumnOn1, indent); + file->writeNumberLine(_startFrameAutumnOn2, indent); + file->writeNumberLine(_endFrameAutumnOn2, indent); + file->writeNumberLine(_startFrameWinterOn1, indent); + file->writeNumberLine(_endFrameWinterOn1, indent); + file->writeNumberLine(_startFrameWinterOn2, indent); + file->writeNumberLine(_endFrameWinterOn2, indent); file->writeQuotedLine(_viewName2, indent); CBackground::save(file, indent); @@ -116,30 +115,30 @@ void CArboretumGate::load(SimpleFile *file) { _v3 = file->readNumber(); _viewName1 = file->readString(); _fieldF0 = file->readNumber(); - _winterOffStartFrame = file->readNumber(); - _winterOffEndFrame = file->readNumber(); - _springOffStartFrame = file->readNumber(); - _springOffEndFrame = file->readNumber(); - _summerOffStartFrame1 = file->readNumber(); - _summerOffEndFrame1 = file->readNumber(); - _summerOffStartFrame2 = file->readNumber(); - _summerOffEndFrame2 = file->readNumber(); - _autumnOffStartFrame1 = file->readNumber(); - _autumnOffEndFrame1 = file->readNumber(); - _autumnOffStartFrame2 = file->readNumber(); - _autumnOffEndFrame2 = file->readNumber(); - _winterOnStartFrame = file->readNumber(); - _winterOnEndFrame = file->readNumber(); - _springOnStartFrame = file->readNumber(); - _springOnEndFrame = file->readNumber(); - _summerOnStartFrame1 = file->readNumber(); - _summerOnEndFrame1 = file->readNumber(); - _summerOnStartFrame2 = file->readNumber(); - _summerOnEndFrame2 = file->readNumber(); - _autumnOnStartFrame1 = file->readNumber(); - _autumnOnEndFrame1 = file->readNumber(); - _autumnOnStartFrame2 = file->readNumber(); - _autumnOnEndFrame2 = file->readNumber(); + _startFrameSpringOff = file->readNumber(); + _endFrameSpringOff = file->readNumber(); + _startFrameSummerOff = file->readNumber(); + _endFrameSummerOff = file->readNumber(); + _startFrameAutumnOff1 = file->readNumber(); + _endFrameAutumnOff1 = file->readNumber(); + _startFrameAutumnOff2 = file->readNumber(); + _endFrameAutumnOff2 = file->readNumber(); + _startFrameWinterOff1 = file->readNumber(); + _endFrameWinterOff1 = file->readNumber(); + _startFrameWinterOff2 = file->readNumber(); + _endFrameWinterOff2 = file->readNumber(); + _startFrameSpringOn = file->readNumber(); + _endFrameSpringOn = file->readNumber(); + _startFrameSummerOn = file->readNumber(); + _endFrameSummerOn = file->readNumber(); + _startFrameAutumnOn1 = file->readNumber(); + _endFrameAutumnOn1 = file->readNumber(); + _startFrameAutumnOn2 = file->readNumber(); + _endFrameAutumnOn2 = file->readNumber(); + _startFrameWinterOn1 = file->readNumber(); + _endFrameWinterOn1 = file->readNumber(); + _startFrameWinterOn2 = file->readNumber(); + _endFrameWinterOn2 = file->readNumber(); _viewName2 = file->readString(); CBackground::load(file); @@ -213,28 +212,28 @@ bool CArboretumGate::LeaveViewMsg(CLeaveViewMsg *msg) { bool CArboretumGate::TurnOff(CTurnOff *msg) { if (!_v3) { switch (_seasonNum) { - case SPRING: - playMovie(_springOffStartFrame, _springOffEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SUMMER: + playMovie(_startFrameSummerOff, _endFrameSummerOff, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; - case SUMMER: + case SEASON_AUTUMN: if (_v1) { - playMovie(_summerOffStartFrame2, _summerOffEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOff2, _endFrameAutumnOff2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_summerOffStartFrame1, _summerOffEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOff1, _endFrameAutumnOff1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case AUTUMN: + case SEASON_WINTER: if (_v1) { - playMovie(_autumnOffStartFrame2, _autumnOffEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOff2, _endFrameWinterOff2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_autumnOffStartFrame1, _autumnOffEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOff1, _endFrameWinterOff1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case WINTER: - playMovie(_winterOffStartFrame, _winterOffEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SPRING: + playMovie(_startFrameSpringOff, _endFrameSpringOff, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; default: @@ -256,28 +255,28 @@ bool CArboretumGate::TurnOn(CTurnOn *msg) { setVisible(true); switch (_seasonNum) { - case SPRING: - playMovie(_springOnStartFrame, _springOnEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SUMMER: + playMovie(_startFrameSummerOn, _endFrameSummerOn, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; - case SUMMER: + case SEASON_AUTUMN: if (_v1) { - playMovie(_summerOnStartFrame2, _summerOnEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOn2, _endFrameAutumnOn2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_summerOnStartFrame1, _summerOnEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOn1, _endFrameAutumnOn1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case AUTUMN: + case SEASON_WINTER: if (_v1) { - playMovie(_autumnOnStartFrame2, _autumnOnEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOn2, _endFrameWinterOn2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_autumnOnStartFrame1, _autumnOnEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOn1, _endFrameWinterOn1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case WINTER: - playMovie(_winterOnStartFrame, _winterOnEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SPRING: + playMovie(_startFrameSpringOn, _endFrameSpringOn, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; default: @@ -302,20 +301,20 @@ bool CArboretumGate::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { bool CArboretumGate::EnterViewMsg(CEnterViewMsg *msg) { if (!_v3) { switch (_seasonNum) { - case SPRING: - _initialFrame = _springOffStartFrame; + case SEASON_SUMMER: + _initialFrame = _startFrameSummerOff; break; - case SUMMER: - _initialFrame = _v1 ? _summerOffStartFrame2 : _summerOffStartFrame1; + case SEASON_AUTUMN: + _initialFrame = _v1 ? _startFrameAutumnOff2 : _startFrameAutumnOff1; break; - case AUTUMN: - _initialFrame = _v1 ? _autumnOffStartFrame1 : _autumnOffStartFrame2; + case SEASON_WINTER: + _initialFrame = _v1 ? _startFrameWinterOff1 : _startFrameWinterOff2; break; - case WINTER: - _initialFrame = _winterOffStartFrame; + case SEASON_SPRING: + _initialFrame = _startFrameSpringOff; break; default: diff --git a/engines/titanic/game/arboretum_gate.h b/engines/titanic/game/arboretum_gate.h index 62c9200a64..b1c06cf773 100644 --- a/engines/titanic/game/arboretum_gate.h +++ b/engines/titanic/game/arboretum_gate.h @@ -47,30 +47,30 @@ private: int _seasonNum; CString _viewName1; int _fieldF0; - int _winterOffStartFrame; - int _winterOffEndFrame; - int _springOffStartFrame; - int _springOffEndFrame; - int _summerOffStartFrame2; - int _summerOffEndFrame2; - int _summerOffStartFrame1; - int _summerOffEndFrame1; - int _autumnOffStartFrame2; - int _autumnOffEndFrame2; - int _autumnOffStartFrame1; - int _autumnOffEndFrame1; - int _winterOnStartFrame; - int _winterOnEndFrame; - int _springOnStartFrame; - int _springOnEndFrame; - int _summerOnStartFrame1; - int _summerOnEndFrame1; - int _summerOnStartFrame2; - int _summerOnEndFrame2; - int _autumnOnStartFrame1; - int _autumnOnEndFrame1; - int _autumnOnStartFrame2; - int _autumnOnEndFrame2; + int _startFrameSpringOff; + int _endFrameSpringOff; + int _startFrameSummerOff; + int _endFrameSummerOff; + int _startFrameAutumnOff2; + int _endFrameAutumnOff2; + int _startFrameAutumnOff1; + int _endFrameAutumnOff1; + int _startFrameWinterOff2; + int _endFrameWinterOff2; + int _startFrameWinterOff1; + int _endFrameWinterOff1; + int _startFrameSpringOn; + int _endFrameSpringOn; + int _startFrameSummerOn; + int _endFrameSummerOn; + int _startFrameAutumnOn1; + int _endFrameAutumnOn1; + int _startFrameAutumnOn2; + int _endFrameAutumnOn2; + int _startFrameWinterOn1; + int _endFrameWinterOn1; + int _startFrameWinterOn2; + int _endFrameWinterOn2; CString _viewName2; public: CLASSDEF; diff --git a/engines/titanic/game/bar_bell.cpp b/engines/titanic/game/bar_bell.cpp index 207644a00e..5f17dffda1 100644 --- a/engines/titanic/game/bar_bell.cpp +++ b/engines/titanic/game/bar_bell.cpp @@ -116,7 +116,7 @@ bool CBarBell::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { } ++_fieldBC; - return 2; + return true; } bool CBarBell::ActMsg(CActMsg *msg) { diff --git a/engines/titanic/game/computer.cpp b/engines/titanic/game/computer.cpp index 90574997b1..3077b46178 100644 --- a/engines/titanic/game/computer.cpp +++ b/engines/titanic/game/computer.cpp @@ -46,7 +46,7 @@ void CComputer::load(SimpleFile *file) { bool CComputer::ActMsg(CActMsg *msg) { if (_state) { - playSound("a#35.wav", 100, 0, 0); + playSound("a#35.wav"); playMovie(32, 42, 0); if (msg->_action == "CD1") @@ -66,11 +66,11 @@ bool CComputer::ActMsg(CActMsg *msg) { bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { if (_currentCD == "None") { if (_state) { - playSound("a#35.wav", 100, 0, 0); + playSound("a#35.wav"); playMovie(11, 21, 0); _state = 0; } else { - playSound("a#34.wav", 100, 0, 0); + playSound("a#34.wav"); playMovie(0, 10, 0); _state = 1; } @@ -81,7 +81,7 @@ bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { actMsg.execute(_currentCD); _currentCD = "None"; } else { - playSound("a#34.wav", 100, 0, 0); + playSound("a#34.wav"); playMovie(21, 31, 0); _state = 1; } @@ -92,10 +92,10 @@ bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { bool CComputer::MovieEndMsg(CMovieEndMsg *msg) { if (msg->_endFrame == 90) { - playSound("a#32.wav", 100, 0, 0); - playSound("a#33.wav", 100, 0, 0); - playSound("a#31.wav", 100, 0, 0); - playSound("a#0.wav", 100, 0, 0); + playSound("a#32.wav"); + playSound("a#33.wav"); + playSound("a#31.wav"); + playSound("a#0.wav"); gotoView("Home.Node 4.E", "_TRACK,3,e-cu,4,E"); } diff --git a/engines/titanic/game/computer_screen.cpp b/engines/titanic/game/computer_screen.cpp index 3e5172219d..9a7ac4b34e 100644 --- a/engines/titanic/game/computer_screen.cpp +++ b/engines/titanic/game/computer_screen.cpp @@ -57,7 +57,7 @@ bool CComputerScreen::ActMsg(CActMsg *msg) { } bool CComputerScreen::MovieEndMsg(CMovieEndMsg *msg) { - playSound("z#47.wav", 100, 0, 0); + playSound("z#47.wav"); addTimer(0, 3000, 0); for (int idx = 0; idx < 10; ++idx) @@ -111,7 +111,7 @@ bool CComputerScreen::TimerMsg(CTimerMsg *msg) { playSound("a#29.wav"); stopSound(handle); - playSound("y#662.wav"); + handle = playSound("y#662.wav"); setSoundVolume(handle, 10, 2); playClip(392, 450); startTalking("Doorbot", 0x3611A); diff --git a/engines/titanic/game/fan_noises.cpp b/engines/titanic/game/fan_noises.cpp index c6e6d203dd..9144f523f4 100644 --- a/engines/titanic/game/fan_noises.cpp +++ b/engines/titanic/game/fan_noises.cpp @@ -34,7 +34,7 @@ BEGIN_MESSAGE_MAP(CFanNoises, CGameObject) END_MESSAGE_MAP() CFanNoises::CFanNoises() : CGameObject(), _state(-1), - _soundHandle(0), _soundPercent(70), _soundV3(-1), _soundSeconds(0), + _soundHandle(0), _soundPercent(70), _soundBalance(0), _soundSeconds(0), _stopSeconds(0), _startFlag(true) { } @@ -43,7 +43,7 @@ void CFanNoises::save(SimpleFile *file, int indent) { file->writeNumberLine(_state, indent); file->writeNumberLine(_soundHandle, indent); file->writeNumberLine(_soundPercent, indent); - file->writeNumberLine(_soundV3, indent); + file->writeNumberLine(_soundBalance, indent); file->writeNumberLine(_soundSeconds, indent); file->writeNumberLine(_stopSeconds, indent); file->writeNumberLine(_startFlag, indent); @@ -56,7 +56,7 @@ void CFanNoises::load(SimpleFile *file) { _state = file->readNumber(); _soundHandle = file->readNumber(); _soundPercent = file->readNumber(); - _soundV3 = file->readNumber(); + _soundBalance = file->readNumber(); _soundSeconds = file->readNumber(); _stopSeconds = file->readNumber(); _startFlag = file->readNumber(); @@ -75,12 +75,12 @@ bool CFanNoises::EnterRoomMsg(CEnterRoomMsg *msg) { switch (_state) { case 1: - _soundHandle = playSound("b#60.wav", 0, _soundV3, true); + _soundHandle = playSound("b#60.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; case 2: - _soundHandle = playSound("b#58.wav", 0, _soundV3, true); + _soundHandle = playSound("b#58.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; @@ -122,7 +122,7 @@ bool CFanNoises::StatusChangeMsg(CStatusChangeMsg *msg) { switch (oldState) { case 1: case 2: - playSound("b#59.wav", _soundPercent, _soundV3); + playSound("b#59.wav", _soundPercent, _soundBalance); break; default: break; @@ -140,7 +140,7 @@ bool CFanNoises::StatusChangeMsg(CStatusChangeMsg *msg) { switch (oldState) { case 1: case 2: - _soundHandle = playSound("b#60.wav", _soundPercent, _soundV3); + _soundHandle = playSound("b#60.wav", _soundPercent, _soundBalance); break; default: break; @@ -156,7 +156,7 @@ bool CFanNoises::StatusChangeMsg(CStatusChangeMsg *msg) { } if (oldState == 1) { - _soundHandle = playSound("b#58.wav", _soundPercent, _soundV3); + _soundHandle = playSound("b#58.wav", _soundPercent, _soundBalance); } break; @@ -184,13 +184,13 @@ bool CFanNoises::LoadSuccessMsg(CLoadSuccessMsg *msg) { switch (_state) { case 1: - playSound("b#60.wav", 0, _soundV3, true); + playSound("b#60.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; case 2: - playSound("b#58.wav", 0, _soundV3, true); + playSound("b#58.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; diff --git a/engines/titanic/game/fan_noises.h b/engines/titanic/game/fan_noises.h index 56c80c0764..488d42e79e 100644 --- a/engines/titanic/game/fan_noises.h +++ b/engines/titanic/game/fan_noises.h @@ -39,7 +39,7 @@ private: int _state; int _soundHandle; int _soundPercent; - int _soundV3; + int _soundBalance; int _soundSeconds; int _stopSeconds; bool _startFlag; diff --git a/engines/titanic/game/head_smash_lever.cpp b/engines/titanic/game/head_smash_lever.cpp index d5c2eaf8c4..dabed26478 100644 --- a/engines/titanic/game/head_smash_lever.cpp +++ b/engines/titanic/game/head_smash_lever.cpp @@ -32,13 +32,13 @@ BEGIN_MESSAGE_MAP(CHeadSmashLever, CBackground) END_MESSAGE_MAP() CHeadSmashLever::CHeadSmashLever() : CBackground(), - _enabled(false), _fieldE4(false), _ticksCount(0) {} + _enabled(false), _fieldE4(false), _ticks(0) {} void CHeadSmashLever::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_enabled, indent); file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_ticksCount, indent); + file->writeNumberLine(_ticks, indent); CBackground::save(file, indent); } @@ -47,7 +47,7 @@ void CHeadSmashLever::load(SimpleFile *file) { file->readNumber(); _enabled = file->readNumber(); _fieldE4 = file->readNumber(); - _ticksCount = file->readNumber(); + _ticks = file->readNumber(); CBackground::load(file); } @@ -58,7 +58,7 @@ bool CHeadSmashLever::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { playSound("z#54.wav"); int soundHandle = playSound("z#45.wav"); queueSound("z#49.wav", soundHandle); - _ticksCount = getTicksCount(); + _ticks = getTicksCount(); _fieldE4 = true; } else { playMovie(0); @@ -78,7 +78,7 @@ bool CHeadSmashLever::ActMsg(CActMsg *msg) { } bool CHeadSmashLever::FrameMsg(CFrameMsg *msg) { - if (_fieldE4 && msg->_ticks > (_ticksCount + 750)) { + if (_fieldE4 && msg->_ticks > (_ticks + 750)) { CActMsg actMsg1("CreatorsChamber.Node 1.S"); actMsg1.execute("MoveToCreators"); CActMsg actMsg2("PlayToEnd"); @@ -93,7 +93,7 @@ bool CHeadSmashLever::FrameMsg(CFrameMsg *msg) { bool CHeadSmashLever::LoadSuccessMsg(CLoadSuccessMsg *msg) { if (_fieldE4) - _ticksCount = getTicksCount(); + _ticks = getTicksCount(); return true; } diff --git a/engines/titanic/game/head_smash_lever.h b/engines/titanic/game/head_smash_lever.h index e2426b68da..19de07922a 100644 --- a/engines/titanic/game/head_smash_lever.h +++ b/engines/titanic/game/head_smash_lever.h @@ -36,7 +36,7 @@ class CHeadSmashLever : public CBackground { public: bool _enabled; bool _fieldE4; - int _ticksCount; + uint _ticks; public: CLASSDEF; CHeadSmashLever(); diff --git a/engines/titanic/game/maitred/maitred_prod_receptor.cpp b/engines/titanic/game/maitred/maitred_prod_receptor.cpp index 66533a542f..95e029af44 100644 --- a/engines/titanic/game/maitred/maitred_prod_receptor.cpp +++ b/engines/titanic/game/maitred/maitred_prod_receptor.cpp @@ -80,8 +80,8 @@ bool CMaitreDProdReceptor::MouseMoveMsg(CMouseMoveMsg *msg) { else if (isEquals("Perch")) prodMsg._value = 125; - CMaitreD *maitreD = static_cast<CMaitreD *>(findRoomObject("MaitreD")); - if (maitreD->_field100 <= 0) + CMaitreD *maitreD = dynamic_cast<CMaitreD *>(findRoomObject("MaitreD")); + if (maitreD && maitreD->_field100 <= 0) prodMsg.execute(this); return true; diff --git a/engines/titanic/game/music_console_button.cpp b/engines/titanic/game/music_console_button.cpp index 9cf385e3a7..dc86765476 100644 --- a/engines/titanic/game/music_console_button.cpp +++ b/engines/titanic/game/music_console_button.cpp @@ -22,7 +22,7 @@ #include "titanic/game/music_console_button.h" #include "titanic/core/room_item.h" -#include "titanic/sound/music_handler.h" +#include "titanic/sound/music_room_handler.h" #include "titanic/titanic.h" namespace Titanic { @@ -84,48 +84,48 @@ bool CMusicConsoleButton::SetMusicControlsMsg(CSetMusicControlsMsg *msg) { CQueryMusicControlSettingMsg queryMsg; queryMsg.execute("Bells Mute Control"); - musicRoom->setItem5(BELLS, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(BELLS, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Bells Pitch Control"); - musicRoom->setItem2(BELLS, queryMsg._value); + musicRoom->setPitchControl(BELLS, queryMsg._value); queryMsg.execute("Bells Speed Control"); - musicRoom->setItem1(BELLS, queryMsg._value); + musicRoom->setSpeedControl(BELLS, queryMsg._value); queryMsg.execute("Bells Inversion Control"); - musicRoom->setItem4(BELLS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(BELLS, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Bells Direction Control"); - musicRoom->setItem3(BELLS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(BELLS, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Snake Mute Control"); - musicRoom->setItem5(SNAKE, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(SNAKE, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Snake Pitch Control"); - musicRoom->setItem2(SNAKE, queryMsg._value); + musicRoom->setPitchControl(SNAKE, queryMsg._value); queryMsg.execute("Snake Speed Control"); - musicRoom->setItem1(SNAKE, queryMsg._value); + musicRoom->setSpeedControl(SNAKE, queryMsg._value); queryMsg.execute("Snake Inversion Control"); - musicRoom->setItem4(SNAKE, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(SNAKE, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Snake Direction Control"); - musicRoom->setItem3(SNAKE, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(SNAKE, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Piano Mute Control"); - musicRoom->setItem5(PIANO, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(PIANO, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Piano Pitch Control"); - musicRoom->setItem2(PIANO, queryMsg._value); + musicRoom->setPitchControl(PIANO, queryMsg._value); queryMsg.execute("Piano Speed Control"); - musicRoom->setItem1(PIANO, queryMsg._value); + musicRoom->setSpeedControl(PIANO, queryMsg._value); queryMsg.execute("Piano Inversion Control"); - musicRoom->setItem4(PIANO, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(PIANO, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Piano Direction Control"); - musicRoom->setItem3(PIANO, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(PIANO, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Bass Mute Control"); - musicRoom->setItem5(BASS, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(BASS, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Bass Pitch Control"); - musicRoom->setItem2(BASS, queryMsg._value); + musicRoom->setPitchControl(BASS, queryMsg._value); queryMsg.execute("Bass Speed Control"); - musicRoom->setItem1(BASS, queryMsg._value); + musicRoom->setSpeedControl(BASS, queryMsg._value); queryMsg.execute("Bass Inversion Control"); - musicRoom->setItem4(BASS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(BASS, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Bass Direction Control"); - musicRoom->setItem3(BASS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(BASS, queryMsg._value == 0 ? 1 : 0); return true; } diff --git a/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp b/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp index 9dfc866c0e..2654042967 100644 --- a/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp +++ b/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp @@ -79,7 +79,7 @@ bool CParrotNutBowlActor::BowlStateChangeMsg(CBowlStateChangeMsg *msg) { return true; } -bool CParrotNutBowlActor::CParrotNutBowlActor::IsEarBowlPuzzleDone(CIsEarBowlPuzzleDone *msg) { +bool CParrotNutBowlActor::IsEarBowlPuzzleDone(CIsEarBowlPuzzleDone *msg) { msg->_value = _puzzleDone; return true; } diff --git a/engines/titanic/game/placeholder/tv_on_bar.cpp b/engines/titanic/game/placeholder/tv_on_bar.cpp index e17fb7833d..710b5a346e 100644 --- a/engines/titanic/game/placeholder/tv_on_bar.cpp +++ b/engines/titanic/game/placeholder/tv_on_bar.cpp @@ -24,16 +24,30 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CTVOnBar, CPlaceHolder) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + void CTVOnBar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writePoint(_pos1, indent); + file->writePoint(_tvPos, indent); CPlaceHolder::save(file, indent); } void CTVOnBar::load(SimpleFile *file) { file->readNumber(); - _pos1 = file->readPoint(); + _tvPos = file->readPoint(); CPlaceHolder::load(file); } +bool CTVOnBar::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + if (msg->_visible) + setPosition(_tvPos); + else + setPosition(Point(0, 0)); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/tv_on_bar.h b/engines/titanic/game/placeholder/tv_on_bar.h index bb5381fb5d..0157bc8764 100644 --- a/engines/titanic/game/placeholder/tv_on_bar.h +++ b/engines/titanic/game/placeholder/tv_on_bar.h @@ -28,8 +28,10 @@ namespace Titanic { class CTVOnBar : public CPlaceHolder { + DECLARE_MESSAGE_MAP; + bool VisibleMsg(CVisibleMsg *msg); private: - Point _pos1; + Point _tvPos; public: CLASSDEF; diff --git a/engines/titanic/game/play_music_button.cpp b/engines/titanic/game/play_music_button.cpp index 93416911b8..21fd3c336a 100644 --- a/engines/titanic/game/play_music_button.cpp +++ b/engines/titanic/game/play_music_button.cpp @@ -64,7 +64,7 @@ bool CPlayMusicButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CPlayMusicButton::FrameMsg(CFrameMsg *msg) { - if (_flag && !CMusicRoom::_musicHandler->isBusy()) { + if (_flag && !CMusicRoom::_musicHandler->poll()) { CMusicRoom *musicRoom = getMusicRoom(); musicRoom->stopMusic(); stopMovie(); diff --git a/engines/titanic/game/record_phonograph_button.cpp b/engines/titanic/game/record_phonograph_button.cpp index f022957dbb..1ffaec4228 100644 --- a/engines/titanic/game/record_phonograph_button.cpp +++ b/engines/titanic/game/record_phonograph_button.cpp @@ -24,16 +24,44 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CRecordPhonographButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(PhonographStopMsg) +END_MESSAGE_MAP() + void CRecordPhonographButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_active, indent); CBackground::save(file, indent); } void CRecordPhonographButton::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _active = file->readNumber(); CBackground::load(file); } +bool CRecordPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CPhonographRecordMsg recordMsg; + recordMsg.execute(getParent()); + + if (recordMsg._value) { + playSound("z#58.wav"); + loadFrame(1); + _active = true; + } + + return true; +} + +bool CRecordPhonographButton::PhonographStopMsg(CPhonographStopMsg *msg) { + if (_active) { + playSound("z#57.wav"); + loadFrame(0); + _active = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/record_phonograph_button.h b/engines/titanic/game/record_phonograph_button.h index 3383c01e31..985a4c4576 100644 --- a/engines/titanic/game/record_phonograph_button.h +++ b/engines/titanic/game/record_phonograph_button.h @@ -28,11 +28,14 @@ namespace Titanic { class CRecordPhonographButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool PhonographStopMsg(CPhonographStopMsg *msg); public: - int _value; + bool _active; public: CLASSDEF; - CRecordPhonographButton() : CBackground(), _value(0) {} + CRecordPhonographButton() : CBackground(), _active(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/replacement_ear.cpp b/engines/titanic/game/replacement_ear.cpp index 1f9960365d..e8bd384207 100644 --- a/engines/titanic/game/replacement_ear.cpp +++ b/engines/titanic/game/replacement_ear.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CReplacementEar, CBackground) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + void CReplacementEar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +38,11 @@ void CReplacementEar::load(SimpleFile *file) { CBackground::load(file); } +bool CReplacementEar::VisibleMsg(CVisibleMsg *msg) { + setVisible(true); + playMovie(MOVIE_GAMESTATE); + playSound("z#64.wav"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/replacement_ear.h b/engines/titanic/game/replacement_ear.h index 0d282b7fb4..7775a9631a 100644 --- a/engines/titanic/game/replacement_ear.h +++ b/engines/titanic/game/replacement_ear.h @@ -28,6 +28,8 @@ namespace Titanic { class CReplacementEar : public CBackground { + DECLARE_MESSAGE_MAP; + bool VisibleMsg(CVisibleMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/reserved_table.cpp b/engines/titanic/game/reserved_table.cpp index a600190709..734d53af45 100644 --- a/engines/titanic/game/reserved_table.cpp +++ b/engines/titanic/game/reserved_table.cpp @@ -21,22 +21,55 @@ */ #include "titanic/game/reserved_table.h" +#include "titanic/core/room_item.h" +#include "titanic/core/view_item.h" +#include "titanic/npcs/maitre_d.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CReservedTable, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(PlayerTriesRestaurantTableMsg) +END_MESSAGE_MAP() + void CReservedTable::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value1, indent); - file->writeNumberLine(_value2, indent); + file->writeNumberLine(_flag, indent); + file->writeNumberLine(_tableId, indent); CGameObject::save(file, indent); } void CReservedTable::load(SimpleFile *file) { file->readNumber(); - _value1 = file->readNumber(); - _value2 = file->readNumber(); + _flag = file->readNumber(); + _tableId = file->readNumber(); CGameObject::load(file); } +bool CReservedTable::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_flag) { + CPlayerTriesRestaurantTableMsg tryMsg(_tableId, 0); + tryMsg.execute(findRoom(), CReservedTable::_type, MSGFLAG_CLASS_DEF | MSGFLAG_SCAN); + } + + return true; +} + +bool CReservedTable::PlayerTriesRestaurantTableMsg(CPlayerTriesRestaurantTableMsg *msg) { + if (msg->_tableId == _tableId) { + if (!msg->_result) { + CMaitreD *maitreD = dynamic_cast<CMaitreD *>(findRoomObject("MaitreD")); + startTalking(maitreD, 118, maitreD->findView()); + msg->_result = true; + } + + _cursorId = CURSOR_INVALID; + _flag = true; + return true; + } else { + return false; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/game/reserved_table.h b/engines/titanic/game/reserved_table.h index a3532c7d14..bc037ae3d9 100644 --- a/engines/titanic/game/reserved_table.h +++ b/engines/titanic/game/reserved_table.h @@ -28,11 +28,15 @@ namespace Titanic { class CReservedTable : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool PlayerTriesRestaurantTableMsg(CPlayerTriesRestaurantTableMsg *msg); public: - int _value1, _value2; + bool _flag; + int _tableId; public: CLASSDEF; - CReservedTable() : CGameObject(), _value1(0), _value2(0) {} + CReservedTable() : CGameObject(), _flag(false), _tableId(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/restaurant_cylinder_holder.cpp b/engines/titanic/game/restaurant_cylinder_holder.cpp index d70009f151..8726d1a925 100644 --- a/engines/titanic/game/restaurant_cylinder_holder.cpp +++ b/engines/titanic/game/restaurant_cylinder_holder.cpp @@ -24,20 +24,29 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CRestaurantCylinderHolder, CDropTarget) + ON_MESSAGE(EjectCylinderMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(QueryCylinderHolderMsg) + ON_MESSAGE(QueryCylinderNameMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + CRestaurantCylinderHolder::CRestaurantCylinderHolder() : CDropTarget(), _field118(0), _field11C(0), _field12C(0), _field130(0), - _string6("z#61.wav"), _field140(1) { + _ejectSoundName("z#61.wav"), _defaultCursorId(CURSOR_ARROW) { } void CRestaurantCylinderHolder::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_field118, indent); file->writeNumberLine(_field11C, indent); - file->writeQuotedLine(_string5, indent); + file->writeQuotedLine(_target, indent); file->writeNumberLine(_field12C, indent); file->writeNumberLine(_field130, indent); - file->writeQuotedLine(_string6, indent); - file->writeNumberLine(_field140, indent); + file->writeQuotedLine(_ejectSoundName, indent); + file->writeNumberLine(_defaultCursorId, indent); CDropTarget::save(file, indent); } @@ -46,13 +55,98 @@ void CRestaurantCylinderHolder::load(SimpleFile *file) { file->readNumber(); _field118 = file->readNumber(); _field11C = file->readNumber(); - _string5 = file->readString(); + _target = file->readString(); _field12C = file->readNumber(); _field130 = file->readNumber(); - _string6 = file->readString(); - _field140 = file->readNumber(); + _ejectSoundName = file->readString(); + _defaultCursorId = (CursorId)file->readNumber(); CDropTarget::load(file); } +bool CRestaurantCylinderHolder::EjectCylinderMsg(CEjectCylinderMsg *msg) { + _field11C = true; + bool hasCylinder = findByName("Phonograph Cylinder") != nullptr; + + if (_field118) { + playClip(hasCylinder ? "CloseHolder_Full" : "CloseHolder_Empty", + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _fieldF4 = 1; + } else { + playClip(hasCylinder ? "OpenHolder_Full" : "OpenHolder_Empty", + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + playSound(_ejectSoundName, 50); + return true; +} + +bool CRestaurantCylinderHolder::EnterViewMsg(CEnterViewMsg *msg) { + if (_field118) { + CTreeItem *cylinder = findByName("Phonograph Cylinder", true); + if (cylinder) { + loadFrame(_dropFrame); + _cursorId = _dropCursorId; + } else { + loadFrame(_dragFrame); + _cursorId = _dragCursorId; + } + } else { + loadFrame(_field130); + _cursorId = _defaultCursorId; + } + + return true; +} + +bool CRestaurantCylinderHolder::MovieEndMsg(CMovieEndMsg *msg) { + _field11C = false; + if (_field118) { + _field118 = false; + _cursorId = _defaultCursorId; + + CPhonographReadyToPlayMsg readyMsg; + readyMsg.execute(_target); + } else { + _field118 = true; + _fieldF4 = false; + _cursorId = findByName("Phonograph Cylinder") ? _dropCursorId : _dragCursorId; + } + + CCylinderHolderReadyMsg holderMsg; + holderMsg.execute(_target); + return true; +} + +bool CRestaurantCylinderHolder::QueryCylinderHolderMsg(CQueryCylinderHolderMsg *msg) { + CNamedItem *cylinder = findByName("Phonograph Cylinder", true); + + msg->_value1 = _field118; + if (cylinder) { + msg->_value2 = 1; + msg->_target = cylinder; + } + + return true; +} + +bool CRestaurantCylinderHolder::QueryCylinderNameMsg(CQueryCylinderNameMsg *msg) { + CNamedItem *cylinder = findByName("Phonograph Cylinder", true); + + if (cylinder) { + CQueryCylinderMsg queryMsg; + queryMsg.execute(cylinder); + msg->_name = queryMsg._name; + } + + return true; +} + +bool CRestaurantCylinderHolder::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (_field118) + return CDropTarget::MouseDragStartMsg(msg); + else + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/restaurant_cylinder_holder.h b/engines/titanic/game/restaurant_cylinder_holder.h index 3aa979b0a5..cd0b0783bd 100644 --- a/engines/titanic/game/restaurant_cylinder_holder.h +++ b/engines/titanic/game/restaurant_cylinder_holder.h @@ -28,14 +28,21 @@ namespace Titanic { class CRestaurantCylinderHolder : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool EjectCylinderMsg(CEjectCylinderMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool QueryCylinderHolderMsg(CQueryCylinderHolderMsg *msg); + bool QueryCylinderNameMsg(CQueryCylinderNameMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); private: int _field118; int _field11C; - CString _string5; + CString _target; int _field12C; int _field130; - CString _string6; - int _field140; + CString _ejectSoundName; + CursorId _defaultCursorId; public: CLASSDEF; CRestaurantCylinderHolder(); 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 diff --git a/engines/titanic/game/restaurant_phonograph.h b/engines/titanic/game/restaurant_phonograph.h index 710a2edd73..9661df0dfb 100644 --- a/engines/titanic/game/restaurant_phonograph.h +++ b/engines/titanic/game/restaurant_phonograph.h @@ -28,9 +28,17 @@ namespace Titanic { class CRestaurantPhonograph : public CPhonograph { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool PhonographPlayMsg(CPhonographPlayMsg *msg); + bool PhonographStopMsg(CPhonographStopMsg *msg); + bool PhonographReadyToPlayMsg(CPhonographReadyToPlayMsg *msg); + bool EjectCylinderMsg(CEjectCylinderMsg *msg); + bool QueryPhonographState(CQueryPhonographState *msg); + bool LockPhonographMsg(CLockPhonographMsg *msg); private: int _fieldF8; - CString _string2; + CString _ejectSoundName; CString _string3; int _field114; public: diff --git a/engines/titanic/game/sauce_dispensor.cpp b/engines/titanic/game/sauce_dispensor.cpp index 8dc818d917..fda7082ba6 100644 --- a/engines/titanic/game/sauce_dispensor.cpp +++ b/engines/titanic/game/sauce_dispensor.cpp @@ -21,9 +21,20 @@ */ #include "titanic/game/sauce_dispensor.h" +#include "titanic/carry/chicken.h" +#include "titanic/carry/glass.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSauceDispensor, CBackground) + ON_MESSAGE(Use) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(StatusChangeMsg) +END_MESSAGE_MAP() + CSauceDispensor::CSauceDispensor() : CBackground(), _fieldEC(0), _fieldF0(0), _field104(0), _field108(0) { } @@ -54,4 +65,105 @@ void CSauceDispensor::load(SimpleFile *file) { CBackground::load(file); } +bool CSauceDispensor::Use(CUse *msg) { + CVisibleMsg visibleMsg(true); + + if (msg->_item->isEquals("Chicken")) { + CChicken *chicken = static_cast<CChicken *>(msg->_item); + _field104 = true; + if (_fieldF0) { + playSound("b#15.wav", 50); + + if (chicken->_string6 != "None") { + petDisplayMessage(1, "This foodstuff is already sufficiently garnished."); + msg->execute("Chicken"); + } else { + setVisible(true); + if (chicken->_field12C) { + playMovie(_pos1.x, _pos1.y, MOVIE_NOTIFY_OBJECT); + } else { + CActMsg actMsg(_string3); + actMsg.execute("Chicken"); + playMovie(_pos2.x, _pos2.y, MOVIE_NOTIFY_OBJECT); + } + } + + if (_fieldF0) + return true; + } + + CMovieEndMsg endMsg(0, 0); + endMsg.execute(this); + playSound("z#120.wav"); + + petDisplayMessage(1, "Sadly, this dispenser is currently empty."); + } else if (msg->_item->isEquals("BeerGlass")) { + CGlass *glass = dynamic_cast<CGlass *>(msg->_item); + _field108 = true; + + if (_field104 || _fieldF0) { + petAddToInventory(); + } else if (glass->_string6 != "None") { + visibleMsg.execute("BeerGlass"); + } else if (_fieldEC) { + glass->setPosition(Point( + _bounds.left + (_bounds.width() / 2) - (glass->_bounds.width() / 2), + 300)); + setVisible(true); + + CActMsg actMsg(_string3); + actMsg.execute("BeerGlass"); + } + } + + return true; +} + +bool CSauceDispensor::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + _fieldEC = false; + + CActMsg actMsg("GoToPET"); + if (_field104) + actMsg.execute("Chicken"); + if (_field108) + actMsg.execute("BeerGlass"); + + _field104 = false; + _field108 = false; + return true; +} + +bool CSauceDispensor::ActMsg(CActMsg *msg) { + if (msg->_action == "StarlingsDead") + _fieldF0 = true; + + return true; +} + +bool CSauceDispensor::LeaveViewMsg(CLeaveViewMsg *msg) { + setVisible(false); + loadFrame(0); + + if (_field108) { + CGameObject *glass = findRoomObject("Beerglass"); + if (glass) + glass->petAddToInventory(); + } + + _field104 = false; + _field108 = false; + return true; +} + +bool CSauceDispensor::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + petDisplayMessage(1, "Please place food source beneath dispenser for sauce delivery."); + return true; +} + +bool CSauceDispensor::StatusChangeMsg(CStatusChangeMsg *msg) { + petDisplayMessage(1, "Please place food source beneath dispenser for sauce delivery."); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sauce_dispensor.h b/engines/titanic/game/sauce_dispensor.h index aa177050d5..f8021f368b 100644 --- a/engines/titanic/game/sauce_dispensor.h +++ b/engines/titanic/game/sauce_dispensor.h @@ -28,6 +28,13 @@ namespace Titanic { class CSauceDispensor : public CBackground { + DECLARE_MESSAGE_MAP; + bool Use(CUse *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool ActMsg(CActMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); public: CString _string3; int _fieldEC; diff --git a/engines/titanic/game/search_point.cpp b/engines/titanic/game/search_point.cpp index f60a3132b7..bbe923267a 100644 --- a/engines/titanic/game/search_point.cpp +++ b/engines/titanic/game/search_point.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSearchPoint, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CSearchPoint::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); @@ -36,4 +40,21 @@ void CSearchPoint::load(SimpleFile *file) { CGameObject::load(file); } +bool CSearchPoint::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_value > 0) { + CGameObject *child = dynamic_cast<CGameObject *>(getFirstChild()); + if (child) { + child->petAddToInventory(); + CVisibleMsg visibleMsg(true); + visibleMsg.execute(child->getName()); + playSound("z#47.wav"); + } + + if (--_value == 0) + _cursorId = CURSOR_ARROW; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/search_point.h b/engines/titanic/game/search_point.h index 3c5639b104..421f272804 100644 --- a/engines/titanic/game/search_point.h +++ b/engines/titanic/game/search_point.h @@ -28,6 +28,8 @@ namespace Titanic { class CSearchPoint : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: int _value; public: diff --git a/engines/titanic/game/season_background.cpp b/engines/titanic/game/season_background.cpp index 1c63f3d892..20ad6aca1d 100644 --- a/engines/titanic/game/season_background.cpp +++ b/engines/titanic/game/season_background.cpp @@ -24,28 +24,113 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSeasonBackground, CBackground) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + CSeasonBackground::CSeasonBackground() : CBackground(), - _fieldE0(0), _fieldE4(0), _fieldE8(46), _fieldEC(0) { + _seasonNum(SEASON_SUMMER), _flag(false), _defaultFrame(46), _unused(0) { } void CSeasonBackground::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); - file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_seasonNum, indent); + file->writeNumberLine(_flag, indent); + file->writeNumberLine(_defaultFrame, indent); + file->writeNumberLine(_unused, indent); CBackground::save(file, indent); } void CSeasonBackground::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); - _fieldEC = file->readNumber(); + _seasonNum = (Season)file->readNumber(); + _flag = file->readNumber(); + _defaultFrame = file->readNumber(); + _unused = file->readNumber(); CBackground::load(file); } +bool CSeasonBackground::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_defaultFrame); + return true; +} + +bool CSeasonBackground::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _seasonNum = (Season)(((int)_seasonNum + 1) % 4); + + switch (_seasonNum) { + case SEASON_SUMMER: + playMovie(0, 45, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 45; + break; + + case SEASON_AUTUMN: + if (_flag) { + playMovie(232, 278, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 278; + } else { + playMovie(45, 91, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 91; + } + break; + + case SEASON_WINTER: + if (_flag) { + playMovie(278, 326, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 326; + } else { + CStatusChangeMsg changeMsg; + changeMsg._newStatus = 0; + changeMsg.execute("PickUpSpeechCentre"); + playMovie(91, 139, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 139; + } + break; + + case SEASON_SPRING: + if (_flag) { + playMovie(326, 417, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 417; + } else { + playMovie(139, 228, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 228; + } + break; + + default: + break; + } + + return true; +} + +bool CSeasonBackground::MovieEndMsg(CMovieEndMsg *msg) { + if (msg->_endFrame == _defaultFrame) { + CTurnOn onMsg; + onMsg.execute("SeasonalAdjust"); + } + + if (msg->_endFrame == 91 && !_flag) { + CStatusChangeMsg changeMsg; + changeMsg.execute("PickUpSpeechCentre"); + } + + return true; +} + +bool CSeasonBackground::ActMsg(CActMsg *msg) { + if (msg->_action == "PlayerGetsSpeechCentre") { + loadFrame(278); + _defaultFrame = 278; + _flag = true; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/season_background.h b/engines/titanic/game/season_background.h index f0fd2cdc63..d30fd7aedc 100644 --- a/engines/titanic/game/season_background.h +++ b/engines/titanic/game/season_background.h @@ -28,11 +28,16 @@ namespace Titanic { class CSeasonBackground : public CBackground { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool ActMsg(CActMsg *msg); public: - int _fieldE0; - int _fieldE4; - int _fieldE8; - int _fieldEC; + Season _seasonNum; + bool _flag; + int _defaultFrame; + int _unused; public: CLASSDEF; CSeasonBackground(); diff --git a/engines/titanic/game/season_barrel.cpp b/engines/titanic/game/season_barrel.cpp index 9594396885..e08cdf323b 100644 --- a/engines/titanic/game/season_barrel.cpp +++ b/engines/titanic/game/season_barrel.cpp @@ -24,19 +24,38 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSeasonBarrel, CBackground) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + void CSeasonBarrel::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_unused, indent); + file->writeNumberLine(_startFrame, indent); CBackground::save(file, indent); } void CSeasonBarrel::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _unused = file->readNumber(); + _startFrame = file->readNumber(); CBackground::load(file); } +bool CSeasonBarrel::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + if (_startFrame >= 28) + _startFrame = 0; + + playMovie(_startFrame, _startFrame + 7, 0); + _startFrame += 7; + return true; +} + +bool CSeasonBarrel::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_startFrame); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/season_barrel.h b/engines/titanic/game/season_barrel.h index f77864599d..6296b6f7b1 100644 --- a/engines/titanic/game/season_barrel.h +++ b/engines/titanic/game/season_barrel.h @@ -28,12 +28,15 @@ namespace Titanic { class CSeasonBarrel : public CBackground { + DECLARE_MESSAGE_MAP; + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: - int _fieldE0; - int _fieldE4; + int _unused; + int _startFrame; public: CLASSDEF; - CSeasonBarrel() : CBackground(), _fieldE0(0), _fieldE4(7) {} + CSeasonBarrel() : CBackground(), _unused(0), _startFrame(7) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/seasonal_adjustment.cpp b/engines/titanic/game/seasonal_adjustment.cpp index 33a0ae89c5..1f1cb88afb 100644 --- a/engines/titanic/game/seasonal_adjustment.cpp +++ b/engines/titanic/game/seasonal_adjustment.cpp @@ -21,9 +21,20 @@ */ #include "titanic/game/seasonal_adjustment.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSeasonalAdjustment, CBackground) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + void CSeasonalAdjustment::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); @@ -40,4 +51,86 @@ void CSeasonalAdjustment::load(SimpleFile *file) { CBackground::load(file); } +bool CSeasonalAdjustment::StatusChangeMsg(CStatusChangeMsg *msg) { + CChangeSeasonMsg changeMsg; + switch (stateGetSeason()) { + case SEASON_SUMMER: + changeMsg._season = "Summer"; + break; + case SEASON_AUTUMN: + changeMsg._season = "Autumn"; + break; + case SEASON_WINTER: + changeMsg._season = "Winter"; + break; + case SEASON_SPRING: + changeMsg._season = "Spring"; + break; + default: + break; + } + + changeMsg.execute(getRoot(), nullptr, MSGFLAG_SCAN); + return true; +} + +bool CSeasonalAdjustment::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CSeasonalAdjustment::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + playSound("z#42.wav"); + if (!_fieldE4) { + petDisplayMessage(1, "The Seasonal Adjustment switch is not operational at the present time."); + } else if (!_fieldE0) { + playMovie(0, 6, MOVIE_NOTIFY_OBJECT); + playMovie(6, 18, 0); + } + + return true; +} + +bool CSeasonalAdjustment::MovieEndMsg(CMovieEndMsg *msg) { + if (msg->_endFrame == 6) { + stateChangeSeason(); + CStatusChangeMsg changeMsg; + changeMsg.execute(this); + CTurnOff offMsg; + offMsg.execute(this); + offMsg.execute("LeftPanExit"); + offMsg.execute("RightPanExit"); + } + + return true; +} + +bool CSeasonalAdjustment::TurnOn(CTurnOn *msg) { + if (_fieldE0) { + _fieldE0 = false; + CTurnOn onMsg; + onMsg.execute("LeftPanExit"); + onMsg.execute("RightPanExit"); + } + + return true; +} + +bool CSeasonalAdjustment::TurnOff(CTurnOff *msg) { + _fieldE0 = true; + return true; +} + +bool CSeasonalAdjustment::ActMsg(CActMsg *msg) { + if (msg->_action == "PlayerGetsSpeechCentre") { + msg->execute("SeasonBackground"); + msg->execute("ArbGate"); + } else if (msg->_action == "EnableObject") { + _fieldE4 = true; + } else if (msg->_action == "DisableObject") { + _fieldE4 = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/seasonal_adjustment.h b/engines/titanic/game/seasonal_adjustment.h index f96c13619d..4b7ef3d4f6 100644 --- a/engines/titanic/game/seasonal_adjustment.h +++ b/engines/titanic/game/seasonal_adjustment.h @@ -27,15 +27,16 @@ namespace Titanic { -enum Season { - SPRING = 0, - SUMMER = 1, - AUTUMN = 2, - WINTER = 3 -}; - class CSeasonalAdjustment : public CBackground { -public: + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool ActMsg(CActMsg *msg); +private: int _fieldE0; int _fieldE4; public: diff --git a/engines/titanic/game/service_elevator_window.cpp b/engines/titanic/game/service_elevator_window.cpp index 95b2735b37..b0cc53abb4 100644 --- a/engines/titanic/game/service_elevator_window.cpp +++ b/engines/titanic/game/service_elevator_window.cpp @@ -21,9 +21,19 @@ */ #include "titanic/game/service_elevator_window.h" +#include "titanic/core/room_item.h" +#include "titanic/npcs/doorbot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CServiceElevatorWindow, CBackground) + ON_MESSAGE(ServiceElevatorFloorChangeMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +static const int FACTORS[4] = { 0, 20, 100, 0 }; + CServiceElevatorWindow::CServiceElevatorWindow() : CBackground(), _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0) { } @@ -48,4 +58,57 @@ void CServiceElevatorWindow::load(SimpleFile *file) { CBackground::load(file); } +bool CServiceElevatorWindow::ServiceElevatorFloorChangeMsg(CServiceElevatorFloorChangeMsg *msg) { + if (getView() == findView()) { + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + int val = (_fieldE8 && doorbot) ? 65 : 15; + CMovieClip *clip = _movieClips.findByName("Going Up"); + + if (!clip) + return true; + + int count = _endFrame - _startFrame; + setMovieFrameRate(1.0 * count / val); + + int startFrame = clip->_startFrame + count * FACTORS[msg->_value1] / 100; + int endFrame = clip->_startFrame + count * FACTORS[msg->_value2] / 100; + + if (_fieldE4) { + playMovie(startFrame, endFrame, MOVIE_NOTIFY_OBJECT); + } else { + playMovie(startFrame, endFrame, 0); + if (_fieldEC) + playClip("Into Space"); + } + } + + _fieldE0 = msg->_value2; + return true; +} + +bool CServiceElevatorWindow::MovieEndMsg(CMovieEndMsg *msg) { + CServiceElevatorMsg elevMsg(5); + elevMsg.execute(findRoom()->findByName("Service Elevator Entity")); + return true; +} + +bool CServiceElevatorWindow::EnterViewMsg(CEnterViewMsg *msg) { + if (_fieldEC) { + playClip("Fade Up"); + playMovie(1, 2, 0); + } else { + CMovieClip *clip = _movieClips.findByName("Going Up"); + + if (clip) { + int frameNum = clip->_startFrame + (clip->_endFrame - clip->_startFrame) + * FACTORS[_fieldE0] / 100; + loadFrame(frameNum); + } else { + loadFrame(0); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/service_elevator_window.h b/engines/titanic/game/service_elevator_window.h index 4233b8405a..88e1663aba 100644 --- a/engines/titanic/game/service_elevator_window.h +++ b/engines/titanic/game/service_elevator_window.h @@ -28,6 +28,10 @@ namespace Titanic { class CServiceElevatorWindow : public CBackground { + DECLARE_MESSAGE_MAP; + bool ServiceElevatorFloorChangeMsg(CServiceElevatorFloorChangeMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: int _fieldE0; int _fieldE4; diff --git a/engines/titanic/game/sgt/bedhead.cpp b/engines/titanic/game/sgt/bedhead.cpp index f911a83ae3..216d22ee71 100644 --- a/engines/titanic/game/sgt/bedhead.cpp +++ b/engines/titanic/game/sgt/bedhead.cpp @@ -43,7 +43,7 @@ void BedheadEntry::load(Common::SeekableReadStream *s) { void BedheadEntries::load(Common::SeekableReadStream *s, int count) { resize(count); - for (uint idx = 0; idx < count; ++idx) + for (int idx = 0; idx < count; ++idx) (*this)[idx].load(s); } diff --git a/engines/titanic/game/sgt/sgt_doors.cpp b/engines/titanic/game/sgt/sgt_doors.cpp index 516b0f1351..71eae9800c 100644 --- a/engines/titanic/game/sgt/sgt_doors.cpp +++ b/engines/titanic/game/sgt/sgt_doors.cpp @@ -21,13 +21,21 @@ */ #include "titanic/game/sgt/sgt_doors.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTDoors, CGameObject) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + void CSGTDoors::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value1, indent); - file->writeNumberLine(_value2, indent); + file->writeNumberLine(_open, indent); CGameObject::save(file, indent); } @@ -35,9 +43,58 @@ void CSGTDoors::save(SimpleFile *file, int indent) { void CSGTDoors::load(SimpleFile *file) { file->readNumber(); _value1 = file->readNumber(); - _value2 = file->readNumber(); + _open = file->readNumber(); CGameObject::load(file); } +bool CSGTDoors::EnterViewMsg(CEnterViewMsg *msg) { + setVisible(true); + _open = true; + CPetControl *pet = getPetControl(); + + if (pet) { + int roomNum = pet->getRoomsRoomNum(); + static const int START_FRAMES[7] = { 0, 26, 30, 34, 38, 42, 46 }; + static const int END_FRAMES[7] = { 12, 29, 33, 37, 41, 45, 49 }; + + if (pet->getRooms1CC() == 1) + playMovie(START_FRAMES[roomNum], END_FRAMES[roomNum], + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + else + playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + +bool CSGTDoors::LeaveViewMsg(CLeaveViewMsg *msg) { + return true; +} + +bool CSGTDoors::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(!_open); + return true; +} + +bool CSGTDoors::LeaveRoomMsg(CLeaveRoomMsg *msg) { + setVisible(true); + _open = false; + CPetControl *pet = getPetControl(); + + if (pet) { + int roomNum = pet->getRoomsRoomNum(); + static const int START_FRAMES[7] = { 12, 69, 65, 61, 57, 53, 49 }; + static const int END_FRAMES[7] = { 25, 72, 68, 64, 60, 56, 52 }; + + if (pet->getRooms1CC() == 1) + playMovie(START_FRAMES[roomNum], END_FRAMES[roomNum], + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + else + playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_doors.h b/engines/titanic/game/sgt/sgt_doors.h index 4b4f4a3153..b19c5860af 100644 --- a/engines/titanic/game/sgt/sgt_doors.h +++ b/engines/titanic/game/sgt/sgt_doors.h @@ -28,11 +28,17 @@ namespace Titanic { class CSGTDoors : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); public: - int _value1, _value2; + int _value1; + bool _open; public: CLASSDEF; - CSGTDoors() : CGameObject(), _value1(0), _value2(0) {} + CSGTDoors() : CGameObject(), _value1(0), _open(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sgt/sgt_nav.cpp b/engines/titanic/game/sgt/sgt_nav.cpp index f98e486fd0..c004f947d2 100644 --- a/engines/titanic/game/sgt/sgt_nav.cpp +++ b/engines/titanic/game/sgt/sgt_nav.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(SGTNav, CSGTStateRoom) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseMoveMsg) +END_MESSAGE_MAP() + void SGTNav::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +39,43 @@ void SGTNav::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool SGTNav::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTurnOn onMsg; + CTurnOff offMsg; + + if (_statics->_v6 == "Open" && _statics->_v1 == "Open") { + if (_statics->_v3 == "Open") + offMsg.execute("Vase"); + if (_statics->_v4 == "Closed") + onMsg.execute("SGTTV"); + if (_statics->_v7 == "Open") + offMsg.execute("Drawer"); + if (_statics->_v8 == "Open") + offMsg.execute("Armchair"); + if (_statics->_v9 == "Open") + offMsg.execute("Deskchair"); + if (_statics->_v12 == "Open") + offMsg.execute("Toilet"); + + changeView("SGTState.Node 2.E"); + } else if (_statics->_v1 == "Open") { + petDisplayMessage(1, "This is your stateroom. It is for sleeping. If you desire " + "entertainment or relaxation, please visit your local leisure lounge."); + } else if (_statics->_v6 == "Closed") { + petDisplayMessage(1, "The bed will not currently support your weight." + " We are working on this problem but are unlikely to be able to fix it."); + } + + return true; +} + +bool SGTNav::MouseMoveMsg(CMouseMoveMsg *msg) { + if (_statics->_v6 == "Open" && _statics->_v1 == "Open") + _cursorId = CURSOR_MOVE_FORWARD; + else + _cursorId = CURSOR_ARROW; + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_nav.h b/engines/titanic/game/sgt/sgt_nav.h index 40fdc4eff1..78f6417229 100644 --- a/engines/titanic/game/sgt/sgt_nav.h +++ b/engines/titanic/game/sgt/sgt_nav.h @@ -28,6 +28,9 @@ namespace Titanic { class SGTNav : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseMoveMsg(CMouseMoveMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/sgt_navigation.cpp b/engines/titanic/game/sgt/sgt_navigation.cpp index 7bb64f934d..031226226f 100644 --- a/engines/titanic/game/sgt/sgt_navigation.cpp +++ b/engines/titanic/game/sgt/sgt_navigation.cpp @@ -21,9 +21,16 @@ */ #include "titanic/game/sgt/sgt_navigation.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTNavigation, CGameObject) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + CSGTNavigationStatics *CSGTNavigation::_statics; void CSGTNavigation::init() { @@ -36,7 +43,7 @@ void CSGTNavigation::deinit() { void CSGTNavigation::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_statics->_changeViewFlag, indent); + file->writeNumberLine(_statics->_changeViewNum, indent); file->writeQuotedLine(_statics->_destView, indent); file->writeQuotedLine(_statics->_destRoom, indent); @@ -45,11 +52,79 @@ void CSGTNavigation::save(SimpleFile *file, int indent) { void CSGTNavigation::load(SimpleFile *file) { file->readNumber(); - _statics->_changeViewFlag = file->readNumber(); + _statics->_changeViewNum = file->readNumber(); _statics->_destView = file->readString(); _statics->_destRoom = file->readString(); CGameObject::load(file); } +bool CSGTNavigation::StatusChangeMsg(CStatusChangeMsg *msg) { + CPetControl *pet = getPetControl(); + + if (isEquals("SGTLL")) { + static const int FRAMES[7] = { 0, 149, 112, 74, 0, 36, 74 }; + _statics->_changeViewNum = msg->_newStatus; + if (pet->getRooms1CC() != _statics->_changeViewNum) { + changeView("SGTLittleLift.Node 1.N"); + } + + int startVal = pet->getRooms1CC(); + if (startVal > _statics->_changeViewNum) + playMovie(FRAMES[startVal], FRAMES[_statics->_changeViewNum], MOVIE_GAMESTATE); + else + playMovie(FRAMES[startVal + 3], FRAMES[_statics->_changeViewNum + 3], MOVIE_GAMESTATE); + + _cursorId = _statics->_changeViewNum != 1 ? CURSOR_MOVE_FORWARD : CURSOR_INVALID; + + pet->setRooms1CC(_statics->_changeViewNum); + pet->resetRoomsHighlight(); + } + + return true; +} + +bool CSGTNavigation::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (compareRoomNameTo("SgtLobby")) { + _statics->_destView = getRoomNodeName(); + _statics->_destRoom = "SgtLobby"; + changeView("SGTState.Node 1.S"); + } else if (compareRoomNameTo("SGTLittleLift")) { + if (_statics->_changeViewNum != 1) { + _statics->_destRoom = "SGTLittleLift"; + changeView("SGTState.Node 1.S"); + } + } else if (compareRoomNameTo("SGTState")) { + if (_statics->_destRoom == "SgtLobby") { + if (compareViewNameTo("SGTState.Node 2.N")) { + changeView("SGTState.Node 1.N"); + _statics->_destView += ".S"; + } else { + _statics->_destView += ".N"; + } + + changeView(_statics->_destView); + } else if (_statics->_destRoom == "SGTLittleLift") { + if (compareViewNameTo("SGTState.Node 1.S")) { + changeView("SGTLittleLift.Node 1.N"); + } else { + changeView("SGTState.Node 1.N"); + changeView("SGTLittleLift.Node 1.S"); + } + } + } + + return true; +} + +bool CSGTNavigation::EnterViewMsg(CEnterViewMsg *msg) { + if (isEquals("SGTLL")) { + static const int FRAMES[3] = { 0, 36, 74 }; + CPetControl *pet = getPetControl(); + loadFrame(FRAMES[pet->getRooms1CC() - 1]); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_navigation.h b/engines/titanic/game/sgt/sgt_navigation.h index ed58d918e9..69ecd1267a 100644 --- a/engines/titanic/game/sgt/sgt_navigation.h +++ b/engines/titanic/game/sgt/sgt_navigation.h @@ -28,12 +28,16 @@ namespace Titanic { struct CSGTNavigationStatics { - bool _changeViewFlag; + int _changeViewNum; CString _destView; CString _destRoom; }; class CSGTNavigation : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); protected: static CSGTNavigationStatics *_statics; public: diff --git a/engines/titanic/game/sgt/sgt_restaurant_doors.cpp b/engines/titanic/game/sgt/sgt_restaurant_doors.cpp index 74a71e75b2..5c36ceb0ff 100644 --- a/engines/titanic/game/sgt/sgt_restaurant_doors.cpp +++ b/engines/titanic/game/sgt/sgt_restaurant_doors.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTRestaurantDoors, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CSGTRestaurantDoors::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldBC, indent); @@ -36,4 +40,10 @@ void CSGTRestaurantDoors::load(SimpleFile *file) { CGameObject::load(file); } +bool CSGTRestaurantDoors::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTurnOff offMsg; + offMsg.execute("ChickenDispenser"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_restaurant_doors.h b/engines/titanic/game/sgt/sgt_restaurant_doors.h index 2a10d8f059..bcaaa71014 100644 --- a/engines/titanic/game/sgt/sgt_restaurant_doors.h +++ b/engines/titanic/game/sgt/sgt_restaurant_doors.h @@ -28,6 +28,8 @@ namespace Titanic { class CSGTRestaurantDoors : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); private: int _fieldBC; public: diff --git a/engines/titanic/game/sgt/sgt_state_control.cpp b/engines/titanic/game/sgt/sgt_state_control.cpp index 07c1f5efc0..9617f2f127 100644 --- a/engines/titanic/game/sgt/sgt_state_control.cpp +++ b/engines/titanic/game/sgt/sgt_state_control.cpp @@ -24,16 +24,59 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTStateControl, CBackground) + ON_MESSAGE(PETUpMsg) + ON_MESSAGE(PETDownMsg) + ON_MESSAGE(PETActivateMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CSGTStateControl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_state, indent); CBackground::save(file, indent); } void CSGTStateControl::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); + _state = file->readNumber(); CBackground::load(file); } +bool CSGTStateControl::PETUpMsg(CPETUpMsg *msg) { + // WORKAROUND: Redundant code in original not included + return true; +} + +bool CSGTStateControl::PETDownMsg(CPETDownMsg *msg) { + // WORKAROUND: Redundant code in original not included + return true; +} + +bool CSGTStateControl::PETActivateMsg(CPETActivateMsg *msg) { + if (msg->_name == "SGTSelector") { + static const char *const TARGETS[] = { + "Vase", "Bedfoot", "Toilet", "Drawer", "SGTTV", "Armchair", "BedHead", + "WashStand", "Desk", "DeskChair", "Basin", "ChestOfDrawers" + }; + _state = msg->_numValue; + CActMsg actMsg; + actMsg.execute(TARGETS[_state]); + } + + return true; +} + +bool CSGTStateControl::EnterViewMsg(CEnterViewMsg *msg) { + _state = 1; + petSetRemoteTarget(); + return true; +} + +bool CSGTStateControl::LeaveViewMsg(CLeaveViewMsg *msg) { + petClear(); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_state_control.h b/engines/titanic/game/sgt/sgt_state_control.h index 49fd5113cd..6f96359761 100644 --- a/engines/titanic/game/sgt/sgt_state_control.h +++ b/engines/titanic/game/sgt/sgt_state_control.h @@ -24,15 +24,22 @@ #define TITANIC_SGT_STATE_CONTROL_H #include "titanic/core/background.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CSGTStateControl : public CBackground { + DECLARE_MESSAGE_MAP; + bool PETUpMsg(CPETUpMsg *msg); + bool PETDownMsg(CPETDownMsg *msg); + bool PETActivateMsg(CPETActivateMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); private: - int _fieldE0; + int _state; public: CLASSDEF; - CSGTStateControl() : CBackground(), _fieldE0(1) {} + CSGTStateControl() : CBackground(), _state(1) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sgt/sgt_tv.cpp b/engines/titanic/game/sgt/sgt_tv.cpp index ae4c59e2f9..08ed381b2b 100644 --- a/engines/titanic/game/sgt/sgt_tv.cpp +++ b/engines/titanic/game/sgt/sgt_tv.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTTV, CSGTStateRoom) + ON_MESSAGE(TurnOff) + ON_MESSAGE(TurnOn) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CSGTTV::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,35 @@ void CSGTTV::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CSGTTV::TurnOff(CTurnOff *msg) { + if (CSGTStateRoom::_statics->_v4 == "Open") { + CSGTStateRoom::_statics->_v4 = "Closed"; + _fieldE0 = true; + _startFrame = 6; + _endFrame = 12; + playMovie(6, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + +bool CSGTTV::TurnOn(CTurnOn *msg) { + if (CSGTStateRoom::_statics->_v4 == "Closed" && + CSGTStateRoom::_statics->_v2 == "Closed") { + CSGTStateRoom::_statics->_v4 = "Open"; + setVisible(true); + _fieldE0 = false; + _startFrame = 1; + _endFrame = 6; + playMovie(1, 6, MOVIE_GAMESTATE); + } + + return true; +} + +bool CSGTTV::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_tv.h b/engines/titanic/game/sgt/sgt_tv.h index 90fed90efe..e5de38e84b 100644 --- a/engines/titanic/game/sgt/sgt_tv.h +++ b/engines/titanic/game/sgt/sgt_tv.h @@ -28,6 +28,10 @@ namespace Titanic { class CSGTTV : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOff(CTurnOff *msg); + bool TurnOn(CTurnOn *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/toilet.cpp b/engines/titanic/game/sgt/toilet.cpp index 799abd6c76..b8e87b645a 100644 --- a/engines/titanic/game/sgt/toilet.cpp +++ b/engines/titanic/game/sgt/toilet.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CToilet, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CToilet::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,42 @@ void CToilet::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CToilet::TurnOn(CTurnOn *msg) { + if (CSGTStateRoom::_statics->_v12 == "Closed" + && CSGTStateRoom::_statics->_v10 == "Open" + && CSGTStateRoom::_statics->_v8 == "Closed") { + setVisible(true); + CSGTStateRoom::_statics->_v12 = "Open"; + + _fieldE0 = false; + _startFrame = 0; + _endFrame = 11; + playMovie(0, 11, MOVIE_GAMESTATE); + playSound("b#1.wav"); + } + + return true; +} + +bool CToilet::TurnOff(CTurnOff *msg) { + if (CSGTStateRoom::_statics->_v12 == "Open") { + CSGTStateRoom::_statics->_v12 = "Closed"; + + _fieldE0 = true; + _startFrame = 11; + _endFrame = 18; + playMovie(11, 18, MOVIE_GAMESTATE); + playSound("b#1.wav"); + } + + return true; +} + +bool CToilet::MovieEndMsg(CMovieEndMsg *msg) { + if (CSGTStateRoom::_statics->_v12 == "Closed") + setVisible(false); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/toilet.h b/engines/titanic/game/sgt/toilet.h index d87531ad7a..a4bc318fb2 100644 --- a/engines/titanic/game/sgt/toilet.h +++ b/engines/titanic/game/sgt/toilet.h @@ -28,6 +28,10 @@ namespace Titanic { class CToilet : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/vase.cpp b/engines/titanic/game/sgt/vase.cpp index 3e04b5db9e..2d37818340 100644 --- a/engines/titanic/game/sgt/vase.cpp +++ b/engines/titanic/game/sgt/vase.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CVase, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CVase::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,38 @@ void CVase::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CVase::TurnOn(CTurnOn *msg) { + if (CSGTStateRoom::_statics->_v3 == "Closed") { + CSGTStateRoom::_statics->_v3 = "Open"; + setVisible(true); + _fieldE0 = false; + _startFrame = 1; + _endFrame = 12; + playMovie(1, 12, MOVIE_GAMESTATE); + } + + return true; +} + +bool CVase::TurnOff(CTurnOff *msg) { + if (CSGTStateRoom::_statics->_v3 == "Open" + && CSGTStateRoom::_statics->_v1 != "RestingV" + && CSGTStateRoom::_statics->_v1 != "RestingUV") { + CSGTStateRoom::_statics->_v3 = "Closed"; + _fieldE0 = true; + _startFrame = 12; + _endFrame = 25; + playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + +bool CVase::MovieEndMsg(CMovieEndMsg *msg) { + if (CSGTStateRoom::_statics->_v3 == "Closed") + setVisible(false); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/vase.h b/engines/titanic/game/sgt/vase.h index 8aa35acdf5..e07d9efb80 100644 --- a/engines/titanic/game/sgt/vase.h +++ b/engines/titanic/game/sgt/vase.h @@ -28,6 +28,10 @@ namespace Titanic { class CVase : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/washstand.cpp b/engines/titanic/game/sgt/washstand.cpp index 8127a59a59..afdc74414d 100644 --- a/engines/titanic/game/sgt/washstand.cpp +++ b/engines/titanic/game/sgt/washstand.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWashstand, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CWashstand::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,36 @@ void CWashstand::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CWashstand::TurnOn(CTurnOn *msg) { + if (_statics->_v10 == "Closed" && _statics->_v2 == "NotOnWashstand") { + setVisible(true); + _statics->_v10 = "Open"; + _fieldE0 = false; + _startFrame = 0; + _endFrame = 14; + playMovie(0, 14, MOVIE_GAMESTATE); + playSound("b#14.wav"); + } + + return true; +} + +bool CWashstand::TurnOff(CTurnOff *msg) { + if (_statics->_v10 == "Open" && _statics->_v11 == "Closed" + && _statics->_v12 == "Closed" && _statics->_v2 == "Open") { + _statics->_v10 = "Closed"; + _fieldE0 = true; + _startFrame = 14; + _endFrame = 28; + playMovie(14, 28, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playSound("b#14.wav"); + } + + return true; +} + +bool CWashstand::MovieEndMsg(CMovieEndMsg *msg) { + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/washstand.h b/engines/titanic/game/sgt/washstand.h index f140b17f49..1b72cfa1c4 100644 --- a/engines/titanic/game/sgt/washstand.h +++ b/engines/titanic/game/sgt/washstand.h @@ -28,6 +28,10 @@ namespace Titanic { class CWashstand : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/ship_setting.cpp b/engines/titanic/game/ship_setting.cpp index 462f396501..93800e899b 100644 --- a/engines/titanic/game/ship_setting.cpp +++ b/engines/titanic/game/ship_setting.cpp @@ -21,35 +21,109 @@ */ #include "titanic/game/ship_setting.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CShipSetting, CBackground) + ON_MESSAGE(AddHeadPieceMsg) + ON_MESSAGE(SetFrameMsg) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + CShipSetting::CShipSetting() : CBackground(), - _string4("NULL"), _string5("NULL") { + _itemName("NULL"), _frameTarget("NULL") { } void CShipSetting::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string3, indent); + file->writeQuotedLine(_target, indent); file->writePoint(_pos1, indent); - file->writeQuotedLine(_string4, indent); - file->writeQuotedLine(_string5, indent); + file->writeQuotedLine(_itemName, indent); + file->writeQuotedLine(_frameTarget, indent); CBackground::save(file, indent); } void CShipSetting::load(SimpleFile *file) { file->readNumber(); - _string3 = file->readString(); + _target = file->readString(); _pos1 = file->readPoint(); - _string4 = file->readString(); - _string5 = file->readString(); + _itemName = file->readString(); + _frameTarget = file->readString(); CBackground::load(file); } +bool CShipSetting::AddHeadPieceMsg(CAddHeadPieceMsg *msg) { + _cursorId = CURSOR_HAND; + + if (msg->_value == "Enable") { + CTurnOn onMsg; + onMsg.execute(_target); + + if (isEquals("ChickenSetting")) { + CActMsg actMsg("DecreaseQuantity"); + actMsg.execute("ChickenDispenser"); + } + } else { + CTurnOff offMsg; + offMsg.execute(_target); + } + + return true; +} + +bool CShipSetting::SetFrameMsg(CSetFrameMsg *msg) { + msg->execute(_frameTarget); + return true; +} + bool CShipSetting::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CShipSetting::handleEvent"); + CSetFrameMsg frameMsg; + + if (_itemName == "ChickenBridge") + frameMsg._frameNumber = 1; + else if (_itemName == "FanBridge") + frameMsg._frameNumber = 2; + else if (_itemName == "SeasonBridge") + frameMsg._frameNumber = 3; + else if (_itemName == "BeamBridge") + frameMsg._frameNumber = 4; + + frameMsg.execute(this); + return true; +} + +bool CShipSetting::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) + return false; + if (_itemName == "NULL") + return true; + + CTurnOff offMsg; + offMsg.execute(_target); + + if (isEquals("ChickenSetting") || _itemName == "ChickenBridge") { + CActMsg actMsg("IncreaseQuantity"); + actMsg.execute("ChickenDispenser"); + } + + if (_itemName != "NULL") { + CPassOnDragStartMsg passMsg(msg->_mousePos, 1); + passMsg.execute(_itemName); + + msg->_dragItem = getRoot()->findByName(_itemName); + + CVisibleMsg visibleMsg(true); + visibleMsg.execute(_itemName); + } + + CSetFrameMsg frameMsg(0); + frameMsg.execute(_frameTarget); + _itemName = "NULL"; + _cursorId = CURSOR_ARROW; return true; } diff --git a/engines/titanic/game/ship_setting.h b/engines/titanic/game/ship_setting.h index 4fcc10a424..198d97d250 100644 --- a/engines/titanic/game/ship_setting.h +++ b/engines/titanic/game/ship_setting.h @@ -29,12 +29,16 @@ namespace Titanic { class CShipSetting : public CBackground { + DECLARE_MESSAGE_MAP; + bool AddHeadPieceMsg(CAddHeadPieceMsg *msg); + bool SetFrameMsg(CSetFrameMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: - CString _string3; + CString _target; Point _pos1; - CString _string4; - CString _string5; + CString _itemName; + CString _frameTarget; public: CLASSDEF; CShipSetting(); diff --git a/engines/titanic/game/ship_setting_button.cpp b/engines/titanic/game/ship_setting_button.cpp index 7dc2cabac0..d485e06668 100644 --- a/engines/titanic/game/ship_setting_button.cpp +++ b/engines/titanic/game/ship_setting_button.cpp @@ -24,25 +24,69 @@ namespace Titanic { -CShipSettingButton::CShipSettingButton() : CGameObject(), _fieldC8(0), _fieldCC(0) { +BEGIN_MESSAGE_MAP(CShipSettingButton, CGameObject) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CShipSettingButton::CShipSettingButton() : CGameObject(), _pressed(false), _enabled(false) { } void CShipSettingButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); - file->writeNumberLine(_fieldC8, indent); - file->writeNumberLine(_fieldCC, indent); + file->writeQuotedLine(_target, indent); + file->writeNumberLine(_pressed, indent); + file->writeNumberLine(_enabled, indent); CGameObject::save(file, indent); } void CShipSettingButton::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); - _fieldC8 = file->readNumber(); - _fieldCC = file->readNumber(); + _target = file->readString(); + _pressed = file->readNumber(); + _enabled = file->readNumber(); CGameObject::load(file); } +bool CShipSettingButton::TurnOn(CTurnOn *msg) { + _pressed = true; + return true; +} + +bool CShipSettingButton::TurnOff(CTurnOff *msg) { + _pressed = false; + return true; +} + +bool CShipSettingButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_pressed) { + if (_enabled) + playMovie(8, 16, 0); + else + playMovie(0, 8, 0); + + _enabled = !_enabled; + CActMsg actMsg(_enabled ? "EnableObject" : "DisableObject"); + actMsg.execute(_target); + } else { + if (_enabled) { + playMovie(8, 16, 0); + playMovie(0, 8, 0); + } else { + playMovie(0, 16, 0); + } + } + + return true; +} + +bool CShipSettingButton::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_enabled ? 8 : 16); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/ship_setting_button.h b/engines/titanic/game/ship_setting_button.h index e152e8e2c3..e5457fa532 100644 --- a/engines/titanic/game/ship_setting_button.h +++ b/engines/titanic/game/ship_setting_button.h @@ -28,10 +28,15 @@ namespace Titanic { class CShipSettingButton : public CGameObject { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); private: - CString _string1; - int _fieldC8; - int _fieldCC; + CString _target; + bool _pressed; + bool _enabled; public: CLASSDEF; CShipSettingButton(); diff --git a/engines/titanic/game/show_cell_points.cpp b/engines/titanic/game/show_cell_points.cpp index 7d54401a02..985cb93734 100644 --- a/engines/titanic/game/show_cell_points.cpp +++ b/engines/titanic/game/show_cell_points.cpp @@ -21,21 +21,50 @@ */ #include "titanic/game/show_cell_points.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CShowCellpoints, CGameObject) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CShowCellpoints::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_strValue, indent); - file->writeNumberLine(_numValue, indent); + file->writeQuotedLine(_npcName, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CShowCellpoints::load(SimpleFile *file) { file->readNumber(); - _strValue = file->readString(); - _numValue = file->readNumber(); + _npcName = file->readString(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CShowCellpoints::EnterViewMsg(CEnterViewMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) { + petSetArea(PET_CONVERSATION); + pet->setActiveNPC(_npcName); + pet->incAreaLocks(); + _flag = true; + } + + return true; +} + +bool CShowCellpoints::LeaveViewMsg(CLeaveViewMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet && _flag) { + pet->resetDials0(); + pet->decAreaLocks(); + _flag = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/show_cell_points.h b/engines/titanic/game/show_cell_points.h index 9de2e06dca..205547d7c2 100644 --- a/engines/titanic/game/show_cell_points.h +++ b/engines/titanic/game/show_cell_points.h @@ -28,12 +28,15 @@ namespace Titanic { class CShowCellpoints : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: - CString _strValue; - int _numValue; + CString _npcName; + bool _flag; public: CLASSDEF; - CShowCellpoints() : CGameObject(), _numValue(0) {} + CShowCellpoints() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/speech_dispensor.cpp b/engines/titanic/game/speech_dispensor.cpp index f9cc019672..20ff3c69e0 100644 --- a/engines/titanic/game/speech_dispensor.cpp +++ b/engines/titanic/game/speech_dispensor.cpp @@ -24,15 +24,26 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSpeechDispensor, CBackground) + ON_MESSAGE(FrameMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(ChangeSeasonMsg) +END_MESSAGE_MAP() + +CSpeechDispensor::CSpeechDispensor() : CBackground(), _dragItem(nullptr), + _fieldE0(0), _state(0), _fieldEC(0), _fieldF8(0), _seasonNum(SEASON_SUMMER) { +} + void CSpeechDispensor::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_state, indent); file->writeNumberLine(_fieldEC, indent); - file->writeNumberLine(_fieldF0, indent); - file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_itemPos.x, indent); + file->writeNumberLine(_itemPos.y, indent); file->writeNumberLine(_fieldF8, indent); - file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_seasonNum, indent); CBackground::save(file, indent); } @@ -40,14 +51,93 @@ void CSpeechDispensor::save(SimpleFile *file, int indent) { void CSpeechDispensor::load(SimpleFile *file) { file->readNumber(); _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _state = file->readNumber(); _fieldEC = file->readNumber(); - _fieldF0 = file->readNumber(); - _fieldF4 = file->readNumber(); + _itemPos.x = file->readNumber(); + _itemPos.y = file->readNumber(); _fieldF8 = file->readNumber(); - _fieldFC = file->readNumber(); + _seasonNum = (Season)file->readNumber(); CBackground::load(file); } +bool CSpeechDispensor::FrameMsg(CFrameMsg *msg) { + if (_fieldEC || _seasonNum == SEASON_SUMMER || _seasonNum == SEASON_SPRING) + return true; + + CGameObject *dragObject = getDraggingObject(); + if (!_dragItem && dragObject && getView() == findView()) { + if (dragObject->isEquals("Perch")) { + petDisplayMessage(1, "This stick is too short to reach the branches."); + return true; + } + + if (dragObject->isEquals("LongStick")) + _dragItem = dragObject; + } + + if (_dragItem) { + Point pt(_itemPos.x + _dragItem->_bounds.left, + _itemPos.y + _dragItem->_bounds.top); + if (!checkPoint(pt, true)) + return true; + + switch (_state) { + case 0: + playSound("z#93.wav"); + if (_seasonNum == SEASON_WINTER) { + petDisplayMessage(1, "You cannot get this, it is frozen to the branch."); + _fieldE0 = false; + _state = 1; + } else { + if (++_fieldE0 >= 5) { + CActMsg actMsg("PlayerGetsSpeechCentre"); + actMsg.execute("SeasonalAdjust"); + CSpeechFallsFromTreeMsg fallMsg(pt); + fallMsg.execute("SpeechCentre"); + + _fieldEC = true; + _fieldE0 = false; + } + + _state = 1; + } + break; + + case 2: + _state = 0; + ++_fieldE0; + break; + + default: + break; + } + } + + return true; +} + +bool CSpeechDispensor::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!_fieldEC) { + playSound("z#93.wav"); + if (_fieldF8) { + petDisplayMessage(1, "Sadly, this is out of your reach."); + } else { + petDisplayMessage(1, "You can't pick this up on account of it being stuck to the branch."); + } + } + + return true; +} + +bool CSpeechDispensor::StatusChangeMsg(CStatusChangeMsg *msg) { + _fieldF8 = msg->_newStatus == 1; + return true; +} + +bool CSpeechDispensor::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _seasonNum = (Season)(((int)_seasonNum + 1) % 4); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/speech_dispensor.h b/engines/titanic/game/speech_dispensor.h index 3b877e8d99..038cc024cc 100644 --- a/engines/titanic/game/speech_dispensor.h +++ b/engines/titanic/game/speech_dispensor.h @@ -28,17 +28,22 @@ namespace Titanic { class CSpeechDispensor : public CBackground { + DECLARE_MESSAGE_MAP; + bool FrameMsg(CFrameMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); private: int _fieldE0; - int _fieldE4; - int _fieldE8; + int _state; + CGameObject *_dragItem; int _fieldEC; - int _fieldF0; - int _fieldF4; + Point _itemPos; int _fieldF8; - int _fieldFC; + Season _seasonNum; public: CLASSDEF; + CSpeechDispensor(); /** * Save the data for the class to file diff --git a/engines/titanic/game/starling_puret.cpp b/engines/titanic/game/starling_puret.cpp index 359ad774df..2f1909d963 100644 --- a/engines/titanic/game/starling_puret.cpp +++ b/engines/titanic/game/starling_puret.cpp @@ -24,16 +24,56 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CStarlingPuret, CGameObject) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CStarlingPuret::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CStarlingPuret::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CStarlingPuret::StatusChangeMsg(CStatusChangeMsg *msg) { + _flag = msg->_newStatus == 1; + if (_flag) { + CStatusChangeMsg changeMsg; + changeMsg._newStatus = 1; + changeMsg.execute("StarlingLoop01"); + } + + return true; +} + +bool CStarlingPuret::EnterViewMsg(CEnterViewMsg *msg) { + if (_flag) { + CStatusChangeMsg changeMsg; + changeMsg._newStatus = 1; + changeMsg.execute("PromDeckStarlings"); + + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + CSignalObject signalMsg; + signalMsg._numValue = 4; + signalMsg.execute("PromDeckStarlings"); + _flag = false; + } + + return true; +} + +bool CStarlingPuret::MovieEndMsg(CMovieEndMsg *msg) { + CActMsg actMsg("StarlingsDead"); + actMsg.execute("FanController"); + actMsg.execute("BirdSauceDisp"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/starling_puret.h b/engines/titanic/game/starling_puret.h index fcd3319958..62a6173093 100644 --- a/engines/titanic/game/starling_puret.h +++ b/engines/titanic/game/starling_puret.h @@ -28,11 +28,15 @@ namespace Titanic { class CStarlingPuret : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); private: - int _value; + bool _flag; public: CLASSDEF; - CStarlingPuret() : CGameObject(), _value(0) {} + CStarlingPuret() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/stop_phonograph_button.cpp b/engines/titanic/game/stop_phonograph_button.cpp index d18f4713ac..75e0ca9337 100644 --- a/engines/titanic/game/stop_phonograph_button.cpp +++ b/engines/titanic/game/stop_phonograph_button.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CStopPhonographButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CStopPhonographButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +38,19 @@ void CStopPhonographButton::load(SimpleFile *file) { CBackground::load(file); } +bool CStopPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CQueryPhonographState queryMsg; + queryMsg.execute(getParent()); + + if (!queryMsg._value) { + playMovie(0, 1, 0); + playMovie(1, 0, 0); + + CPhonographStopMsg stopMsg; + stopMsg.execute(getParent()); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/stop_phonograph_button.h b/engines/titanic/game/stop_phonograph_button.h index b469375e20..d416c4f8fe 100644 --- a/engines/titanic/game/stop_phonograph_button.h +++ b/engines/titanic/game/stop_phonograph_button.h @@ -28,6 +28,8 @@ namespace Titanic { class CStopPhonographButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sub_glass.cpp b/engines/titanic/game/sub_glass.cpp index f1349f06ea..041f49097d 100644 --- a/engines/titanic/game/sub_glass.cpp +++ b/engines/titanic/game/sub_glass.cpp @@ -24,17 +24,25 @@ namespace Titanic { -CSUBGlass::CSUBGlass() : _fieldBC(0), _fieldC0(0), _fieldC4(1), _fieldC8(0) { +BEGIN_MESSAGE_MAP(CSUBGlass, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(SignalObject) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + +CSUBGlass::CSUBGlass() : _fieldBC(0), _startFrame(0), _endFrame(1), _signalStartFrame(0) { } void CSUBGlass::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldBC, indent); - file->writeNumberLine(_fieldC0, indent); - file->writeNumberLine(_fieldC4, indent); - file->writeNumberLine(_fieldC8, indent); - file->writeNumberLine(_fieldCC, indent); - file->writeQuotedLine(_string, indent); + file->writeNumberLine(_startFrame, indent); + file->writeNumberLine(_endFrame, indent); + file->writeNumberLine(_signalStartFrame, indent); + file->writeNumberLine(_signalEndFrame, indent); + file->writeQuotedLine(_target, indent); CGameObject::save(file, indent); } @@ -42,13 +50,58 @@ void CSUBGlass::save(SimpleFile *file, int indent) { void CSUBGlass::load(SimpleFile *file) { file->readNumber(); _fieldBC = file->readNumber(); - _fieldC0 = file->readNumber(); - _fieldC4 = file->readNumber(); - _fieldC8 = file->readNumber(); - _fieldCC = file->readNumber(); - _string = file->readString(); + _startFrame = file->readNumber(); + _endFrame = file->readNumber(); + _signalStartFrame = file->readNumber(); + _signalEndFrame = file->readNumber(); + _target = file->readString(); CGameObject::load(file); } +bool CSUBGlass::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CSUBGlass::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!_fieldBC && _startFrame >= 0) { + _fieldBC = true; + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT); + playSound("z#30.wav"); + } + + return true; +} + +bool CSUBGlass::MovieEndMsg(CMovieEndMsg *msg) { + if (msg->_endFrame == _endFrame) { + _fieldBC = true; + CSignalObject signalMsg(getName(), 1); + signalMsg.execute(_target); + } + + return true; +} + +bool CSUBGlass::SignalObject(CSignalObject *msg) { + if (msg->_numValue == 1) { + setVisible(true); + + if (_signalStartFrame >= 0) { + playMovie(_signalStartFrame, _signalEndFrame, MOVIE_GAMESTATE); + playSound("z#30.wav"); + _fieldBC = false; + } + } + + return true; +} + +bool CSUBGlass::LeaveViewMsg(CLeaveViewMsg *msg) { + _fieldBC = false; + setVisible(true); + loadFrame(0); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sub_glass.h b/engines/titanic/game/sub_glass.h index aab5c8400e..22d16ff4d5 100644 --- a/engines/titanic/game/sub_glass.h +++ b/engines/titanic/game/sub_glass.h @@ -28,13 +28,19 @@ namespace Titanic { class CSUBGlass : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool SignalObject(CSignalObject *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); private: int _fieldBC; - int _fieldC0; - int _fieldC4; - int _fieldC8; - int _fieldCC; - CString _string; + int _startFrame; + int _endFrame; + int _signalStartFrame; + int _signalEndFrame; + CString _target; public: CLASSDEF; CSUBGlass(); diff --git a/engines/titanic/game/sub_wrapper.cpp b/engines/titanic/game/sub_wrapper.cpp index dcc489316b..4080487d6d 100644 --- a/engines/titanic/game/sub_wrapper.cpp +++ b/engines/titanic/game/sub_wrapper.cpp @@ -24,16 +24,56 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSUBWrapper, CGameObject) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(SignalObject) +END_MESSAGE_MAP() + void CSUBWrapper::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CSUBWrapper::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CSUBWrapper::MovieEndMsg(CMovieEndMsg *msg) { + if (_flag) { + stopMovie(); + setVisible(false); + _flag = false; + } + + return true; +} + +bool CSUBWrapper::SignalObject(CSignalObject *msg) { + switch (msg->_numValue) { + case 1: + if (!_flag) { + loadFrame(0); + setVisible(true); + playMovie(MOVIE_NOTIFY_OBJECT); + _flag = true; + } + break; + + case 2: + if (!_flag) { + setVisible(true); + _flag = true; + } + break; + + default: + break; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sub_wrapper.h b/engines/titanic/game/sub_wrapper.h index 81f8fdc941..1094a2e677 100644 --- a/engines/titanic/game/sub_wrapper.h +++ b/engines/titanic/game/sub_wrapper.h @@ -28,11 +28,14 @@ namespace Titanic { class CSUBWrapper : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool SignalObject(CSignalObject *msg); public: - int _value; + bool _flag; public: CLASSDEF; - CSUBWrapper() : CGameObject(), _value(0) {} + CSUBWrapper() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sweet_bowl.cpp b/engines/titanic/game/sweet_bowl.cpp index e14f900e77..d0a2525bc4 100644 --- a/engines/titanic/game/sweet_bowl.cpp +++ b/engines/titanic/game/sweet_bowl.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSweetBowl, CGameObject) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + void CSweetBowl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +40,28 @@ void CSweetBowl::load(SimpleFile *file) { CGameObject::load(file); } +bool CSweetBowl::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + return true; +} + +bool CSweetBowl::EnterViewMsg(CEnterViewMsg *msg) { + setVisible(false); + loadSound("b#43.wav"); + playSound("b#42.wav"); + return true; +} + +bool CSweetBowl::ActMsg(CActMsg *msg) { + if (msg->_action == "Jiggle") { + setVisible(true); + playMovie(MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playSound(getRandomNumber(1) == 1 ? "b#42.wav" : "b#43.wav"); + } + + petDisplayMessage(isEquals("BowlNutsRustler") ? + "A bowl of pistachio nuts." : "Not a bowl of pistachio nuts."); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sweet_bowl.h b/engines/titanic/game/sweet_bowl.h index cf3d0023a4..53433c8c08 100644 --- a/engines/titanic/game/sweet_bowl.h +++ b/engines/titanic/game/sweet_bowl.h @@ -28,6 +28,10 @@ namespace Titanic { class CSweetBowl : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool ActMsg(CActMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp index ba30fbe281..780f92b5ad 100644 --- a/engines/titanic/game/television.cpp +++ b/engines/titanic/game/television.cpp @@ -237,8 +237,8 @@ bool CTelevision::MovieEndMsg(CMovieEndMsg *msg) { } if (_fieldE0 == 3 && compareRoomNameTo("SGTState") && !getPassengerClass()) { - playSound("z#47.wav", 100, 0, 0); - _soundHandle = playSound("b#20.wav", 100, 0, 0); + playSound("z#47.wav"); + _soundHandle = playSound("b#20.wav"); CMagazine *magazine = dynamic_cast<CMagazine *>(getRoot()->findByName("Magazine")); if (magazine) { diff --git a/engines/titanic/game/third_class_canal.cpp b/engines/titanic/game/third_class_canal.cpp index 6b0a101f7b..97b559e35d 100644 --- a/engines/titanic/game/third_class_canal.cpp +++ b/engines/titanic/game/third_class_canal.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CThirdClassCanal, CBackground) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CThirdClassCanal::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +38,9 @@ void CThirdClassCanal::load(SimpleFile *file) { CBackground::load(file); } +bool CThirdClassCanal::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + petDisplayMessage("This area is off limits to passengers."); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/third_class_canal.h b/engines/titanic/game/third_class_canal.h index f6fc471444..d0be8c05aa 100644 --- a/engines/titanic/game/third_class_canal.h +++ b/engines/titanic/game/third_class_canal.h @@ -28,6 +28,8 @@ namespace Titanic { class CThirdClassCanal : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/throw_tv_down_well.cpp b/engines/titanic/game/throw_tv_down_well.cpp index c8a9fc7c9e..9de028cbde 100644 --- a/engines/titanic/game/throw_tv_down_well.cpp +++ b/engines/titanic/game/throw_tv_down_well.cpp @@ -24,18 +24,73 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CThrowTVDownWell, CGameObject) + ON_MESSAGE(ActMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(MovieFrameMsg) +END_MESSAGE_MAP() + void CThrowTVDownWell::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_strValue, indent); - file->writeNumberLine(_numValue, indent); + file->writeQuotedLine(_viewName, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CThrowTVDownWell::load(SimpleFile *file) { file->readNumber(); - _strValue = file->readString(); - _numValue = file->readNumber(); + _viewName = file->readString(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CThrowTVDownWell::ActMsg(CActMsg *msg) { + if (msg->_action == "ThrowTVDownWell" && !_flag) { + CString viewName = getFullViewName(); + lockMouse(); + addTimer(1, 8000, 0); + + CActMsg actMsg("ThrownTVDownWell"); + actMsg.execute("BOWTelevisionMonitor"); + } + + return true; +} + +bool CThrowTVDownWell::EnterViewMsg(CEnterViewMsg *msg) { + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + movieEvent(49); + return true; +} + +bool CThrowTVDownWell::MovieEndMsg(CMovieEndMsg *msg) { + sleep(2000); + changeView("ParrotLobby.Node 11.N"); + playSound("z#471.wav"); + addTimer(2, 7000, 0); + return true; +} + +bool CThrowTVDownWell::TimerMsg(CTimerMsg *msg) { + if (msg->_actionVal == 1) { + changeView("ParrotLobby.Node 10.N"); + } else if (msg->_actionVal == 2) { + playSound("z#468.wav", 50); + sleep(1500); + changeView(_viewName); + _viewName = "NULL"; + unlockMouse(); + playSound("z#47.wav"); + } + + return true; +} + +bool CThrowTVDownWell::MovieFrameMsg(CMovieFrameMsg *msg) { + playSound("z#470.wav"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/throw_tv_down_well.h b/engines/titanic/game/throw_tv_down_well.h index b6003aa3ef..c9e8fd57a9 100644 --- a/engines/titanic/game/throw_tv_down_well.h +++ b/engines/titanic/game/throw_tv_down_well.h @@ -28,12 +28,18 @@ namespace Titanic { class CThrowTVDownWell : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool MovieFrameMsg(CMovieFrameMsg *msg); public: - CString _strValue; - int _numValue; + CString _viewName; + bool _flag; public: CLASSDEF; - CThrowTVDownWell() : CGameObject(), _numValue(0) {} + CThrowTVDownWell() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/titania_still_control.cpp b/engines/titanic/game/titania_still_control.cpp index 67866ecdcb..1ce0a85b4e 100644 --- a/engines/titanic/game/titania_still_control.cpp +++ b/engines/titanic/game/titania_still_control.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CTitaniaStillControl, CGameObject) + ON_MESSAGE(SetFrameMsg) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + void CTitaniaStillControl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +39,15 @@ void CTitaniaStillControl::load(SimpleFile *file) { CGameObject::load(file); } +bool CTitaniaStillControl::SetFrameMsg(CSetFrameMsg *msg) { + loadFrame(msg->_frameNumber); + setVisible(true); + return true; +} + +bool CTitaniaStillControl::VisibleMsg(CVisibleMsg *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/titania_still_control.h b/engines/titanic/game/titania_still_control.h index 66c3045187..b77227a539 100644 --- a/engines/titanic/game/titania_still_control.h +++ b/engines/titanic/game/titania_still_control.h @@ -28,6 +28,9 @@ namespace Titanic { class CTitaniaStillControl : public CGameObject { + DECLARE_MESSAGE_MAP; + bool SetFrameMsg(CSetFrameMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/tow_parrot_nav.cpp b/engines/titanic/game/tow_parrot_nav.cpp index 9361808870..57f1649add 100644 --- a/engines/titanic/game/tow_parrot_nav.cpp +++ b/engines/titanic/game/tow_parrot_nav.cpp @@ -21,9 +21,14 @@ */ #include "titanic/game/tow_parrot_nav.h" +#include "titanic/npcs/parrot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CTOWParrotNav, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CTOWParrotNav::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +39,16 @@ void CTOWParrotNav::load(SimpleFile *file) { CGameObject::load(file); } +bool CTOWParrotNav::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CActMsg actMsg("EnteringFromTOW"); + actMsg.execute("PerchedParrot"); + + CString clipString = "_EXIT,36,1,N,9,3,N"; + if (CParrot::_v4) + clipString += 'a'; + changeView("ParrotLobby.Node 3.N", clipString); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/tow_parrot_nav.h b/engines/titanic/game/tow_parrot_nav.h index 17618ff6de..252d9b631d 100644 --- a/engines/titanic/game/tow_parrot_nav.h +++ b/engines/titanic/game/tow_parrot_nav.h @@ -28,6 +28,8 @@ namespace Titanic { class CTOWParrotNav : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/transport/exit_pellerator.cpp b/engines/titanic/game/transport/exit_pellerator.cpp index 400214a140..12ea9c3906 100644 --- a/engines/titanic/game/transport/exit_pellerator.cpp +++ b/engines/titanic/game/transport/exit_pellerator.cpp @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #include "titanic/game/transport/pellerator.h" diff --git a/engines/titanic/game/transport/exit_pellerator.h b/engines/titanic/game/transport/exit_pellerator.h index 53056c7417..794f162b03 100644 --- a/engines/titanic/game/transport/exit_pellerator.h +++ b/engines/titanic/game/transport/exit_pellerator.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_PELLERATOR_H #define TITANIC_PELLERATOR_H diff --git a/engines/titanic/game/transport/lift.h b/engines/titanic/game/transport/lift.h index c45d2b64d0..c69f7a02e6 100644 --- a/engines/titanic/game/transport/lift.h +++ b/engines/titanic/game/transport/lift.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_LIFT_H #define TITANIC_LIFT_H diff --git a/engines/titanic/game/transport/pellerator.cpp b/engines/titanic/game/transport/pellerator.cpp index 5bc2423478..e4af40c334 100644 --- a/engines/titanic/game/transport/pellerator.cpp +++ b/engines/titanic/game/transport/pellerator.cpp @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #include "titanic/game/transport/pellerator.h" #include "titanic/core/room_item.h" diff --git a/engines/titanic/game/transport/pellerator.h b/engines/titanic/game/transport/pellerator.h index c634f435cc..2ba4a1347a 100644 --- a/engines/titanic/game/transport/pellerator.h +++ b/engines/titanic/game/transport/pellerator.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_PELLERATOR_H #define TITANIC_PELLERATOR_H diff --git a/engines/titanic/game/transport/service_elevator.cpp b/engines/titanic/game/transport/service_elevator.cpp index 1ea8d14e36..1980825cb6 100644 --- a/engines/titanic/game/transport/service_elevator.cpp +++ b/engines/titanic/game/transport/service_elevator.cpp @@ -21,15 +21,27 @@ */ #include "titanic/game/transport/service_elevator.h" +#include "titanic/core/room_item.h" +#include "titanic/npcs/doorbot.h" -namespace Titanic { +namespace Titanic { -int CServiceElevator::_v1; +BEGIN_MESSAGE_MAP(CServiceElevator, CTransport) + ON_MESSAGE(BodyInBilgeRoomMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ServiceElevatorMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(ServiceElevatorFloorRequestMsg) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(OpeningCreditsMsg) +END_MESSAGE_MAP() + +bool CServiceElevator::_v1; int CServiceElevator::_v2; int CServiceElevator::_v3; CServiceElevator::CServiceElevator() : CTransport(), - _fieldF8(0), _fieldFC(0), _field100(0), _field104(0) { + _fieldF8(0), _soundHandle1(0), _timerId(0), _soundHandle2(0) { } void CServiceElevator::save(SimpleFile *file, int indent) { @@ -38,9 +50,9 @@ void CServiceElevator::save(SimpleFile *file, int indent) { file->writeNumberLine(_v2, indent); file->writeNumberLine(_v3, indent); file->writeNumberLine(_fieldF8, indent); - file->writeNumberLine(_fieldFC, indent); - file->writeNumberLine(_field100, indent); - file->writeNumberLine(_field104, indent); + file->writeNumberLine(_soundHandle1, indent); + file->writeNumberLine(_timerId, indent); + file->writeNumberLine(_soundHandle2, indent); CTransport::save(file, indent); } @@ -51,11 +63,208 @@ void CServiceElevator::load(SimpleFile *file) { _v2 = file->readNumber(); _v3 = file->readNumber(); _fieldF8 = file->readNumber(); - _fieldFC = file->readNumber(); - _field100 = file->readNumber(); - _field104 = file->readNumber(); + _soundHandle1 = file->readNumber(); + _timerId = file->readNumber(); + _soundHandle2 = file->readNumber(); CTransport::load(file); } +bool CServiceElevator::BodyInBilgeRoomMsg(CBodyInBilgeRoomMsg *msg) { + _v2 = true; + _string1 = "BilgeRoomWith.Node 2.N"; + return true; +} + +bool CServiceElevator::EnterViewMsg(CEnterViewMsg *msg) { + petShow(); + return true; +} + +bool CServiceElevator::ServiceElevatorMsg(CServiceElevatorMsg *msg) { + switch (msg->_value) { + case 1: + case 2: + case 3: { + switch (msg->_value) { + case 1: + _v3 = 0; + break; + case 2: + _v3 = 1; + break; + case 3: + _v3 = 2; + break; + } + + CServiceElevatorFloorRequestMsg requestMsg; + requestMsg.execute(this); + break; + } + + case 4: + if (!_string1.empty()) { + if (_string1 == "DeepSpace") { + disableMouse(); + _soundHandle1 = playSound("z#413.wav", 50); + _timerId = addTimer(1, 1000, 500); + } else { + changeView(_string1); + } + } + break; + + case 5: + _fieldF8 = false; + _fieldDC = _v3; + loadSound("z#423.wav"); + stopSound(_soundHandle2); + _soundHandle2 = playSound("z#423.wav", 80); + + switch (_fieldDC) { + case 0: + _string1 = "DeepSpace"; + _string2 = "a#2.wav"; + queueSound("z#416.wav", _soundHandle2, 50); + break; + + case 1: + _string1 = _v2 ? "BilgeRoomWith.Node 2.N" : "BilgeRoom.Node 1.N"; + queueSound("z#421.wav", _soundHandle2, 50); + break; + + case 2: + _string1 = _v1 ? "MoonEmbLobby.Node 1.NE" : "EmbLobby.Node 1.NE"; + queueSound("z#411.wav", _soundHandle2, 50); + break; + + default: + break; + } + + enableMouse(); + if (findRoom()->findByName("Doorbot")) + addTimer(3, 3000, 0); + break; + + default: + break; + } + + return true; +} + +bool CServiceElevator::TimerMsg(CTimerMsg *msg) { + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + + switch (msg->_actionVal) { + case 0: + case 1: + if (!isSoundActive(_soundHandle1)) { + stopAnimTimer(_timerId); + if (msg->_actionVal == 0) { + _fieldF8 = true; + CServiceElevatorFloorChangeMsg changeMsg(_fieldDC, _v3); + changeMsg.execute(getRoom()); + _soundHandle2 = playSound("z#424.wav"); + + if (doorbot) { + CActMsg actMsg("DoorbotPlayerPressedTopButton"); + actMsg.execute(doorbot); + } + } else { + enableMouse(); + if (doorbot) { + CActMsg actMsg; + if (_v3 == 0) + actMsg._action = "DoorbotPlayerPressedBottomButton"; + else if (_v3 == 1) + actMsg._action = "DoorbotPlayerPressedMiddleButton"; + + actMsg.execute(doorbot); + } + } + } + break; + + case 3: { + CActMsg actMsg("DoorbotReachedEmbLobby"); + actMsg.execute(doorbot); + break; + } + + default: + break; + } + + return true; +} + +bool CServiceElevator::ServiceElevatorFloorRequestMsg(CServiceElevatorFloorRequestMsg *msg) { + disableMouse(); + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + + if (doorbot && _v3 == 0) { + _soundHandle1 = playSound("z#415.wav", 50); + addTimer(1, 1000, 500); + } else if (doorbot && _v3 == 1) { + _soundHandle1 = playSound("z#417.wav", 50); + addTimer(1, 1000, 500); + } else if (_fieldDC == _v3) { + switch (_v3) { + case 0: + _soundHandle1 = playSound("z#415.wav", 50); + break; + case 1: + _soundHandle1 = playSound("z#420.wav", 50); + break; + case 2: + _soundHandle1 = playSound("z#410.wav", 50); + break; + default: + break; + } + + addTimer(1, 1000, 500); + } else { + switch (_v3) { + case 0: + _soundHandle1 = playSound("z#414.wav", 50); + break; + case 1: + _soundHandle1 = playSound(_fieldDC ? "z#419.wav" : "z#418.wav", 50); + break; + case 2: + _soundHandle1 = playSound("z#414.wav", 50); + break; + default: + break; + } + + addTimer(0, 1000, 500); + } + + return true; +} + +bool CServiceElevator::LeaveRoomMsg(CLeaveRoomMsg *msg) { + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + + if (doorbot) { + CPutBotBackInHisBoxMsg boxMsg(0); + boxMsg.execute("Doorbot"); + doorbot->performAction(false); + enableMouse(); + } + + return true; +} + +bool CServiceElevator::OpeningCreditsMsg(COpeningCreditsMsg *msg) { + _v1 = false; + _string1 = "EmbLobby.Node 1.NE"; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/transport/service_elevator.h b/engines/titanic/game/transport/service_elevator.h index b2c135021a..5cf1f6f0d5 100644 --- a/engines/titanic/game/transport/service_elevator.h +++ b/engines/titanic/game/transport/service_elevator.h @@ -28,15 +28,23 @@ namespace Titanic { class CServiceElevator : public CTransport { + DECLARE_MESSAGE_MAP; + bool BodyInBilgeRoomMsg(CBodyInBilgeRoomMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool ServiceElevatorMsg(CServiceElevatorMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool ServiceElevatorFloorRequestMsg(CServiceElevatorFloorRequestMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool OpeningCreditsMsg(COpeningCreditsMsg *msg); private: - static int _v1; + static bool _v1; static int _v2; static int _v3; int _fieldF8; - int _fieldFC; - int _field100; - int _field104; + int _soundHandle1; + int _timerId; + int _soundHandle2; public: CLASSDEF; CServiceElevator(); diff --git a/engines/titanic/game/up_lighter.cpp b/engines/titanic/game/up_lighter.cpp index f03b8f37a0..d133a7e9df 100644 --- a/engines/titanic/game/up_lighter.cpp +++ b/engines/titanic/game/up_lighter.cpp @@ -21,9 +21,21 @@ */ #include "titanic/game/up_lighter.h" +#include "titanic/core/project_item.h" +#include "titanic/npcs/parrot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CUpLighter, CDropTarget) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(PumpingMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + CUpLighter::CUpLighter() : CDropTarget(), _field118(0), _field11C(0), _field120(0), _field124(0) { } @@ -48,8 +60,61 @@ void CUpLighter::load(SimpleFile *file) { CDropTarget::load(file); } +bool CUpLighter::MovieEndMsg(CMovieEndMsg *msg) { + if (_field118) { + playSound("z#47.wav"); + _field124 = true; + + CVisibleMsg visibleMsg(true); + visibleMsg.execute("NoseHolder"); + CDropZoneLostObjectMsg lostMsg(nullptr); + lostMsg.execute(this); + _clipName.clear(); + _itemMatchName = "Nothing"; + _field118 = 0; + } + + return true; +} + +bool CUpLighter::PumpingMsg(CPumpingMsg *msg) { + _field118 = msg->_value; + _clipName = (_field118 && !_field124) ? "WholeSequence" : "HoseToNose"; + return true; +} + +bool CUpLighter::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTrueTalkTriggerActionMsg triggerMsg(280245, 0, 0); + triggerMsg.execute(getRoot(), CParrot::_type, + MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_CLASS_DEF | MSGFLAG_SCAN); + return true; +} + bool CUpLighter::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CUpLighter::handleEvent"); + _field11C = true; + addTimer(5000 + getRandomNumber(15000), 0); + return true; +} + +bool CUpLighter::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _field120 = msg->_season == "Spring"; + if (_field120) + addTimer(5000 + getRandomNumber(15000), 0); + return true; +} + +bool CUpLighter::TimerMsg(CTimerMsg *msg) { + if (_field120 && _field11C & !_field118) { + CActMsg actMsg("Sneeze"); + actMsg.execute(findRoom()->findByName("NoseHolder")); + addTimer(1000 + getRandomNumber(19000), 0); + } + + return true; +} + +bool CUpLighter::LeaveRoomMsg(CLeaveRoomMsg *msg) { + _field11C = false; return true; } diff --git a/engines/titanic/game/up_lighter.h b/engines/titanic/game/up_lighter.h index 2367e41314..e6a53cf7bd 100644 --- a/engines/titanic/game/up_lighter.h +++ b/engines/titanic/game/up_lighter.h @@ -29,7 +29,14 @@ namespace Titanic { class CUpLighter : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool PumpingMsg(CPumpingMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); private: int _field118; int _field11C; diff --git a/engines/titanic/game/useless_lever.cpp b/engines/titanic/game/useless_lever.cpp index e48ad55a71..82d8983710 100644 --- a/engines/titanic/game/useless_lever.cpp +++ b/engines/titanic/game/useless_lever.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CUselessLever, CToggleButton) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + void CUselessLever::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CToggleButton::save(file, indent); @@ -34,4 +39,23 @@ void CUselessLever::load(SimpleFile *file) { CToggleButton::load(file); } +bool CUselessLever::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_fieldE0) { + playMovie(15, 30, 0); + playSound("z#56.wav"); + _fieldE0 = false; + } else { + playMovie(0, 14, 0); + playSound("z#56.wav"); + _fieldE0 = true; + } + + return true; +} + +bool CUselessLever::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_fieldE0 ? 15 : 0); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/useless_lever.h b/engines/titanic/game/useless_lever.h index 27397de216..33ed94b2ac 100644 --- a/engines/titanic/game/useless_lever.h +++ b/engines/titanic/game/useless_lever.h @@ -28,6 +28,9 @@ namespace Titanic { class CUselessLever : public CToggleButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/wheel_button.cpp b/engines/titanic/game/wheel_button.cpp index 19c42a8807..730a5d9005 100644 --- a/engines/titanic/game/wheel_button.cpp +++ b/engines/titanic/game/wheel_button.cpp @@ -24,14 +24,20 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWheelButton, CBackground) + ON_MESSAGE(SignalObject) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + CWheelButton::CWheelButton() : CBackground(), - _fieldE0(0), _fieldE4(0), _fieldE8(0) { + _fieldE0(false), _timerId(0), _fieldE8(0) { } void CWheelButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_timerId, indent); file->writeNumberLine(_fieldE8, indent); CBackground::save(file, indent); @@ -40,10 +46,43 @@ void CWheelButton::save(SimpleFile *file, int indent) { void CWheelButton::load(SimpleFile *file) { file->readNumber(); _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _timerId = file->readNumber(); _fieldE8 = file->readNumber(); CBackground::load(file); } +bool CWheelButton::SignalObject(CSignalObject *msg) { + bool oldFlag = _fieldE0; + _fieldE0 = msg->_numValue != 0; + + if (oldFlag != _fieldE0) { + if (_fieldE0) { + _timerId = addTimer(500, 500); + } else { + stopAnimTimer(_timerId); + _timerId = 0; + setVisible(false); + } + } + + return true; +} + +bool CWheelButton::TimerMsg(CTimerMsg *msg) { + setVisible(!_visible); + makeDirty(); + return true; +} + +bool CWheelButton::LeaveViewMsg(CLeaveViewMsg *msg) { + if (_timerId) { + stopAnimTimer(_timerId); + _timerId = 0; + setVisible(false); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/wheel_button.h b/engines/titanic/game/wheel_button.h index cb089a660f..2725e60622 100644 --- a/engines/titanic/game/wheel_button.h +++ b/engines/titanic/game/wheel_button.h @@ -28,9 +28,13 @@ namespace Titanic { class CWheelButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool SignalObject(CSignalObject *msg); + bool TimerMsg(CTimerMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: - int _fieldE0; - int _fieldE4; + bool _fieldE0; + int _timerId; int _fieldE8; public: CLASSDEF; diff --git a/engines/titanic/game/wheel_hotspot.cpp b/engines/titanic/game/wheel_hotspot.cpp index f9af594cd5..544e6f5470 100644 --- a/engines/titanic/game/wheel_hotspot.cpp +++ b/engines/titanic/game/wheel_hotspot.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWheelHotSpot, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(SignalObject) +END_MESSAGE_MAP() + void CWheelHotSpot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); @@ -40,4 +45,39 @@ void CWheelHotSpot::load(SimpleFile *file) { CBackground::load(file); } +bool CWheelHotSpot::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_fieldE0) { + CActMsg actMsg; + + switch (_fieldE4) { + case 1: + actMsg._action = "Stop"; + actMsg.execute("CaptainsWheel"); + break; + + case 2: + actMsg._action = "Cruise"; + actMsg.execute("CaptainsWheel"); + break; + + case 3: + actMsg._action = "Go"; + actMsg.execute("CaptainsWheel"); + break; + + default: + break; + } + } else if (_fieldE4 == 3) { + petDisplayMessage("Go where?"); + } + + return true; +} + +bool CWheelHotSpot::SignalObject(CSignalObject *msg) { + _fieldE0 = msg->_numValue != 0; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/wheel_hotspot.h b/engines/titanic/game/wheel_hotspot.h index 364fe9a060..e9071a2fa4 100644 --- a/engines/titanic/game/wheel_hotspot.h +++ b/engines/titanic/game/wheel_hotspot.h @@ -28,6 +28,9 @@ namespace Titanic { class CWheelHotSpot : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool SignalObject(CSignalObject *msg); public: int _fieldE0; int _fieldE4; diff --git a/engines/titanic/game/wheel_spin.cpp b/engines/titanic/game/wheel_spin.cpp index daa9918e29..79f83873e1 100644 --- a/engines/titanic/game/wheel_spin.cpp +++ b/engines/titanic/game/wheel_spin.cpp @@ -24,16 +24,36 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWheelSpin, CBackground) + ON_MESSAGE(SignalObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CWheelSpin::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_active, indent); CBackground::save(file, indent); } void CWheelSpin::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _active = file->readNumber(); CBackground::load(file); } +bool CWheelSpin::SignalObject(CSignalObject *msg) { + _active = msg->_numValue != 0; + setVisible(_active); + return true; +} + +bool CWheelSpin::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_active) { + CActMsg actMsg("Spin"); + actMsg.execute("CaptainsWheel"); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/wheel_spin.h b/engines/titanic/game/wheel_spin.h index 509db1a4bf..f7993f0188 100644 --- a/engines/titanic/game/wheel_spin.h +++ b/engines/titanic/game/wheel_spin.h @@ -28,11 +28,14 @@ namespace Titanic { class CWheelSpin : public CBackground { + DECLARE_MESSAGE_MAP; + bool SignalObject(CSignalObject *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: - int _value; + bool _active; public: CLASSDEF; - CWheelSpin() : CBackground(), _value(0) {} + CWheelSpin() : CBackground(), _active(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 73ec5de993..7d9dc37a10 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -164,7 +164,7 @@ void CGameManager::update() { frameMessage(getRoom()); _timers.update(g_vm->_events->getTicksCount()); _trueTalkManager.removeCompleted(); - _trueTalkManager.update2(); + CScreenManager::_screenManagerPtr->_mouseCursor->update(); CViewItem *view = getView(); diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp index 5628161558..8814dba831 100644 --- a/engines/titanic/game_state.cpp +++ b/engines/titanic/game_state.cpp @@ -47,7 +47,7 @@ bool CGameStateMovieList::clear() { CGameState::CGameState(CGameManager *gameManager) : _gameManager(gameManager), _gameLocation(this), _passengerClass(0), _priorClass(0), _mode(GSMODE_NONE), - _field14(0), _petActive(false), _field1C(false), _quitGame(false), + _seasonNum(SEASON_SUMMER), _petActive(false), _field1C(false), _quitGame(false), _field24(0), _nodeChangeCtr(0), _nodeEnterTicks(0), _field38(0) { } @@ -55,7 +55,7 @@ void CGameState::save(SimpleFile *file) const { file->writeNumber(_petActive); file->writeNumber(_passengerClass); file->writeNumber(_priorClass); - file->writeNumber(_field14); + file->writeNumber(_seasonNum); file->writeNumber(_field24); file->writeNumber(_field38); _gameLocation.save(file); @@ -66,7 +66,7 @@ void CGameState::load(SimpleFile *file) { _petActive = file->readNumber() != 0; _passengerClass = file->readNumber(); _priorClass = file->readNumber(); - _field14 = file->readNumber(); + _seasonNum = (Season)file->readNumber(); _field24 = file->readNumber(); _field38 = file->readNumber(); _gameLocation.load(file); diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h index 0bfa0d5b31..70d47b55c1 100644 --- a/engines/titanic/game_state.h +++ b/engines/titanic/game_state.h @@ -35,7 +35,14 @@ class CGameManager; enum GameStateMode { GSMODE_NONE = 0, GSMODE_INTERACTIVE = 1, GSMODE_CUTSCENE = 2, - GSMODE_3 = 3, GSMODE_4 = 4, GSMODE_5 = 5, GSMODE_PENDING_LOAD = 6 + GSMODE_3 = 3, GSMODE_4 = 4, GSMODE_INSERT_CD = 5, GSMODE_PENDING_LOAD = 6 +}; + +enum Season { + SEASON_SUMMER = 0, + SEASON_AUTUMN = 1, + SEASON_WINTER = 2, + SEASON_SPRING = 3 }; PTR_LIST_ITEM(CMovie); @@ -60,7 +67,7 @@ public: int _passengerClass; int _priorClass; GameStateMode _mode; - int _field14; + Season _seasonNum; bool _petActive; bool _field1C; bool _quitGame; @@ -127,7 +134,13 @@ public: */ void addMovie(CMovie *movie); - void inc14() { _field14 = (_field14 + 1) & 3; } + /** + * Change to the next season + */ + void changeSeason() { + _seasonNum = (Season)(((int)_seasonNum + 1) & 3); + } + void set24(int v) { _field24 = v; } int get24() const { return _field24; } int getNodeChangedCtr() const { return _nodeChangeCtr; } diff --git a/engines/titanic/gfx/chev_switch.cpp b/engines/titanic/gfx/chev_switch.cpp deleted file mode 100644 index 177f0ada76..0000000000 --- a/engines/titanic/gfx/chev_switch.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "titanic/gfx/chev_switch.h" - -namespace Titanic { - -BEGIN_MESSAGE_MAP(CChevSwitch, CToggleSwitch) - ON_MESSAGE(MouseButtonUpMsg) - ON_MESSAGE(SetChevButtonImageMsg) - ON_MESSAGE(MouseButtonDownMsg) -END_MESSAGE_MAP() - -CChevSwitch::CChevSwitch() : CToggleSwitch(), _value(0) { -} - -void CChevSwitch::save(SimpleFile *file, int indent) { - file->writeNumberLine(1, indent); - CToggleSwitch::save(file, indent); -} - -void CChevSwitch::load(SimpleFile *file) { - file->readNumber(); - CToggleSwitch::load(file); -} - -bool CChevSwitch::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { - return true; -} - -bool CChevSwitch::SetChevButtonImageMsg(CSetChevButtonImageMsg *msg) { - if (msg->_value2 && getParent()) { - error("TODO: Don't know parent type"); - } - - _fieldBC = msg->_value1; - if (_fieldBC) { - loadImage((_value & 1) ? "on_odd.tga" : "on_even.tga"); - } else { - loadImage((_value & 1) ? "off_odd.tga" : "off_even.tga"); - } - - return true; -} - -bool CChevSwitch::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - _fieldBC ^= 1; - if (getParent()) { - CSetChevPanelBitMsg bitMsg(_value, _fieldBC); - bitMsg.execute(getParent()); - } - - CSetChevButtonImageMsg chevMsg(_fieldBC, 0); - chevMsg.execute(this); - - return true; -} - -} // End of namespace Titanic diff --git a/engines/titanic/gfx/chev_switch.h b/engines/titanic/gfx/chev_switch.h deleted file mode 100644 index 01da53c854..0000000000 --- a/engines/titanic/gfx/chev_switch.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef TITANIC_CHEV_SWITCH_H -#define TITANIC_CHEV_SWITCH_H - -#include "titanic/gfx/toggle_switch.h" - -namespace Titanic { - -class CChevSwitch : public CToggleSwitch { - DECLARE_MESSAGE_MAP; - bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); - bool SetChevButtonImageMsg(CSetChevButtonImageMsg *msg); - bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); -public: - int _value; -public: - CLASSDEF; - CChevSwitch(); - - /** - * Save the data for the class to file - */ - virtual void save(SimpleFile *file, int indent); - - /** - * Load the data for the class from file - */ - virtual void load(SimpleFile *file); -}; - -} // End of namespace Titanic - -#endif /* TITANIC_CHEV_SWITCH_H */ diff --git a/engines/titanic/gfx/music_slider_speed.h b/engines/titanic/gfx/music_slider_speed.h index 2d54f4487c..ce7b4d3b1c 100644 --- a/engines/titanic/gfx/music_slider_speed.h +++ b/engines/titanic/gfx/music_slider_speed.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_MUSIC_SLIDER_SPEED_H #define TITANIC_MUSIC_SLIDER_SPEED_H diff --git a/engines/titanic/gfx/music_switch_reverse.h b/engines/titanic/gfx/music_switch_reverse.h index c101f19d25..40e36a8663 100644 --- a/engines/titanic/gfx/music_switch_reverse.h +++ b/engines/titanic/gfx/music_switch_reverse.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_MUSIC_SWITCH_REVERSE_H #define TITANIC_MUSIC_SWITCH_REVERSE_H diff --git a/engines/titanic/gfx/music_voice_mute.cpp b/engines/titanic/gfx/music_voice_mute.cpp index ff59edc988..034cb4f6a6 100644 --- a/engines/titanic/gfx/music_voice_mute.cpp +++ b/engines/titanic/gfx/music_voice_mute.cpp @@ -36,7 +36,7 @@ bool CMusicVoiceMute::MusicSettingChangedMsg(CMusicSettingChangedMsg *msg) { _controlVal = 0; CMusicRoom *musicRoom = getMusicRoom(); - musicRoom->setItem5(_controlArea, _controlVal == 1 ? 1 : 0); + musicRoom->setMuteControl(_controlArea, _controlVal == 1 ? 1 : 0); loadFrame(1 - _controlVal); playSound("z#55.wav", 50); @@ -46,7 +46,7 @@ bool CMusicVoiceMute::MusicSettingChangedMsg(CMusicSettingChangedMsg *msg) { bool CMusicVoiceMute::EnterViewMsg(CEnterViewMsg *msg) { loadFrame(1 - _controlVal); CMusicRoom *musicRoom = getMusicRoom(); - musicRoom->setItem5(_controlArea, _controlVal == 1 ? 1 : 0); + musicRoom->setMuteControl(_controlArea, _controlVal == 1 ? 1 : 0); return true; } diff --git a/engines/titanic/gfx/slider_button.cpp b/engines/titanic/gfx/slider_button.cpp index 0633158e97..b3dbbed08f 100644 --- a/engines/titanic/gfx/slider_button.cpp +++ b/engines/titanic/gfx/slider_button.cpp @@ -24,6 +24,14 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSliderButton, CSTButton) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDragMoveMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + CSliderButton::CSliderButton() : CSTButton(), _field114(0), _field118(0), _field11C(0) { } @@ -48,4 +56,39 @@ void CSliderButton::load(SimpleFile *file) { CSTButton::load(file); } +bool CSliderButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + _pos1 = msg->_mousePos; + CStatusChangeMsg changeMsg; + changeMsg.execute(this); + return true; +} + +bool CSliderButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + _pos1 = msg->_mousePos; + return true; +} + +bool CSliderButton::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + _pos1 = msg->_mousePos; + if (_field118) { + CStatusChangeMsg changeMsg; + changeMsg.execute(this); + } + + return true; +} + +bool CSliderButton::StatusChangeMsg(CStatusChangeMsg *msg) { + CStatusChangeMsg changeMsg; + changeMsg._oldStatus = _currentStatus; + _currentStatus = (_pos1.y - _bounds.top) / _field11C; + changeMsg._newStatus = _currentStatus; + changeMsg.execute(_actionTarget); + return true; +} + +bool CSliderButton::EnterViewMsg(CEnterViewMsg *msg) { + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/slider_button.h b/engines/titanic/gfx/slider_button.h index 398290bb05..18ebbae3db 100644 --- a/engines/titanic/gfx/slider_button.h +++ b/engines/titanic/gfx/slider_button.h @@ -28,6 +28,12 @@ namespace Titanic { class CSliderButton : public CSTButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); private: int _field114; int _field118; diff --git a/engines/titanic/gfx/st_button.cpp b/engines/titanic/gfx/st_button.cpp index 6fc31f4c64..d735796bd6 100644 --- a/engines/titanic/gfx/st_button.cpp +++ b/engines/titanic/gfx/st_button.cpp @@ -68,7 +68,7 @@ void CSTButton::load(SimpleFile *file) { bool CSTButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { playMovie(0); - playSound(_soundName, 100, 0, 0); + playSound(_soundName); return true; } diff --git a/engines/titanic/gfx/status_change_button.cpp b/engines/titanic/gfx/status_change_button.cpp index 6644247ff2..e38f1ee07e 100644 --- a/engines/titanic/gfx/status_change_button.cpp +++ b/engines/titanic/gfx/status_change_button.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CStatusChangeButton, CSTButton) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + CStatusChangeButton::CStatusChangeButton() : CSTButton() { } @@ -37,4 +41,11 @@ void CStatusChangeButton::load(SimpleFile *file) { CSTButton::load(file); } +bool CStatusChangeButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CStatusChangeMsg changeMsg; + changeMsg._newStatus = _statusInc; + changeMsg.execute(_actionTarget); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/status_change_button.h b/engines/titanic/gfx/status_change_button.h index 9e410c66f2..9d187493a7 100644 --- a/engines/titanic/gfx/status_change_button.h +++ b/engines/titanic/gfx/status_change_button.h @@ -28,6 +28,8 @@ namespace Titanic { class CStatusChangeButton : public CSTButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; CStatusChangeButton(); diff --git a/engines/titanic/gfx/toggle_button.h b/engines/titanic/gfx/toggle_button.h index 5328072982..4fb7cdfaba 100644 --- a/engines/titanic/gfx/toggle_button.h +++ b/engines/titanic/gfx/toggle_button.h @@ -29,7 +29,7 @@ namespace Titanic { class CToggleButton : public CBackground { DECLARE_MESSAGE_MAP; -private: +protected: int _fieldE0; public: CLASSDEF; diff --git a/engines/titanic/gfx/toggle_switch.cpp b/engines/titanic/gfx/toggle_switch.cpp index 20cbb863ee..815f96cb5a 100644 --- a/engines/titanic/gfx/toggle_switch.cpp +++ b/engines/titanic/gfx/toggle_switch.cpp @@ -24,12 +24,18 @@ namespace Titanic { -CToggleSwitch::CToggleSwitch() : CGameObject(), _fieldBC(0) { +BEGIN_MESSAGE_MAP(CToggleSwitch, CGameObject) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(ChildDragStartMsg) + ON_MESSAGE(ChildDragMoveMsg) +END_MESSAGE_MAP() + +CToggleSwitch::CToggleSwitch() : CGameObject(), _pressed(false) { } void CToggleSwitch::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_pressed, indent); file->writePoint(_pos1, indent); CGameObject::save(file, indent); @@ -37,10 +43,30 @@ void CToggleSwitch::save(SimpleFile *file, int indent) { void CToggleSwitch::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); + _pressed = file->readNumber(); _pos1 = file->readPoint(); CGameObject::load(file); } +bool CToggleSwitch::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + _pressed = !_pressed; + if (_pressed) + fn10(0, 0, 0); + else + fn10(0xff, 0xff, 0xff); + return true; +} + +bool CToggleSwitch::ChildDragStartMsg(CChildDragStartMsg *msg) { + _pos1.x = msg->_mousePos.x - _bounds.left; + _pos1.y = msg->_mousePos.y - _bounds.top; + return true; +} + +bool CToggleSwitch::ChildDragMoveMsg(CChildDragMoveMsg *msg) { + setPosition(Point(msg->_mousePos.x - _pos1.x, msg->_mousePos.y - _pos1.y)); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/toggle_switch.h b/engines/titanic/gfx/toggle_switch.h index 8e7d057d8c..69b8c50eec 100644 --- a/engines/titanic/gfx/toggle_switch.h +++ b/engines/titanic/gfx/toggle_switch.h @@ -28,8 +28,12 @@ namespace Titanic { class CToggleSwitch : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool ChildDragStartMsg(CChildDragStartMsg *msg); + bool ChildDragMoveMsg(CChildDragMoveMsg *msg); protected: - int _fieldBC; + bool _pressed; Point _pos1; public: CLASSDEF; diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp index 7c35a5d855..2c51f3ece7 100644 --- a/engines/titanic/input_handler.cpp +++ b/engines/titanic/input_handler.cpp @@ -150,7 +150,7 @@ CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) { // Scan through the view items to find the item being dropped on CGameObject *target = nullptr; for (CTreeItem *treeItem = view->scan(view); treeItem; treeItem = treeItem->scan(view)) { - CGameObject *gameObject = static_cast<CGameObject *>(treeItem); + CGameObject *gameObject = dynamic_cast<CGameObject *>(treeItem); if (gameObject && gameObject != dragItem) { if (gameObject->checkPoint(pt)) target = gameObject; diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp index 486bc417d7..690acdc25f 100644 --- a/engines/titanic/main_game_window.cpp +++ b/engines/titanic/main_game_window.cpp @@ -49,19 +49,24 @@ CMainGameWindow::CMainGameWindow(TitanicEngine *vm): _vm(vm), CMainGameWindow::~CMainGameWindow() { } -bool CMainGameWindow::Create() { - Image image; - image.load("TITANIC"); - - // TODO: Stuff - return true; -} - void CMainGameWindow::applicationStarting() { // Set the video mode CScreenManager *screenManager = CScreenManager::setCurrent(); screenManager->setMode(640, 480, 16, 0, true); +#if 0 + // Show the initial copyright & info screen for the game + if (gDebugLevel <= 0) { + Image image; + image.load("Bitmap/TITANIC"); + _vm->_screen->blitFrom(image, Point( + SCREEN_WIDTH / 2 - image.w / 2, + SCREEN_HEIGHT / 2 - image.h / 2 + )); + _vm->_events->sleep(5000); + } +#endif + // Set up the game project, and get game slot int saveSlot = getSavegameSlot(); if (saveSlot == -2) @@ -77,8 +82,6 @@ void CMainGameWindow::applicationStarting() { _inputAllowed = true; _gameManager->_gameState.setMode(GSMODE_INTERACTIVE); - // TODO: Cursor/image - // Generate starting messages for entering the view, node, and room. // Note the old fields are nullptr, since there's no previous view/node/room CViewItem *view = _gameManager->_gameState._gameLocation.getView(); @@ -157,8 +160,9 @@ void CMainGameWindow::draw() { scrManager->drawCursors(); break; - case GSMODE_5: - g_vm->_filesManager->debug(scrManager); + case GSMODE_INSERT_CD: + scrManager->drawCursors(); + _vm->_filesManager->insertCD(scrManager); break; case GSMODE_PENDING_LOAD: @@ -216,7 +220,7 @@ void CMainGameWindow::drawViewContents(CScreenManager *screenManager) { } void CMainGameWindow::mouseChanged() { - if (_gameManager->_gameState._mode != GSMODE_5) + if (_gameManager->_gameState._mode != GSMODE_INSERT_CD) _gameManager->update(); } diff --git a/engines/titanic/main_game_window.h b/engines/titanic/main_game_window.h index 82e24e250e..7bd918df04 100644 --- a/engines/titanic/main_game_window.h +++ b/engines/titanic/main_game_window.h @@ -40,7 +40,6 @@ private: TitanicEngine *_vm; int _pendingLoadSlot; uint _specialButtons; - uint32 _priorFrameTime; uint32 _priorLeftDownTime; uint32 _priorMiddleDownTime; uint32 _priorRightDownTime; @@ -104,11 +103,6 @@ public: virtual void keyUp(Common::KeyState keyState); /** - * Creates the window - */ - bool Create(); - - /** * Called when the application starts */ void applicationStarting(); @@ -136,7 +130,9 @@ public: /* * Return whether a given special key is currently pressed */ - bool isSpecialPressed(SpecialButtons btn) const { return _specialButtons; } + bool isSpecialPressed(SpecialButtons btn) const { + return (_specialButtons & btn) != 0; + } /** * Returns the bitset of the currently pressed special buttons diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 7ce92d190f..4fc4067a1a 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -252,9 +252,9 @@ MESSAGE2(CMovieFrameMsg, int, frameNumber, 0, int, value2, 0); MESSAGE0(CMusicHasStartedMsg); MESSAGE0(CMusicHasStoppedMsg); MESSAGE0(CMusicSettingChangedMsg); -MESSAGE2(CNPCPlayAnimationMsg, const char *const *, names, nullptr, int, value2, 0); +MESSAGE2(CNPCPlayAnimationMsg, const char *const *, names, nullptr, int, maxDuration, 0); MESSAGE1(CNPCPlayIdleAnimationMsg, const char *const *, names, 0); -MESSAGE3(CNPCPlayTalkingAnimationMsg, int, value1, 0, int, value2, 0, const char *const *, names, nullptr); +MESSAGE3(CNPCPlayTalkingAnimationMsg, uint, speechDuration, 0, int, value2, 0, const char *const *, names, nullptr); MESSAGE0(CNPCQueueIdleAnimMsg); MESSAGE1(CNutPuzzleMsg, CString, value, ""); MESSAGE1(COnSummonBotMsg, int, value, 0); @@ -267,7 +267,7 @@ MESSAGE0(CPhonographReadyToPlayMsg); MESSAGE1(CPhonographRecordMsg, int, value, 0); MESSAGE3(CPhonographStopMsg, int, value1, 0, int, value2, 0, int, value3, 0); MESSAGE2(CPlayRangeMsg, int, value1, 0, int, value2, 0); -MESSAGE2(CPlayerTriesRestaurantTableMsg, int, value1, 0, int, value2, 0); +MESSAGE2(CPlayerTriesRestaurantTableMsg, int, tableId, 0, bool, result, false); MESSAGE1(CPreSaveMsg, int, value, 0); MESSAGE1(CProdMaitreDMsg, int, value, 0); MESSAGE2(CPumpingMsg, int, value, 0, CGameObject *, object, nullptr); @@ -303,7 +303,7 @@ MESSAGE2(CSetVolumeMsg, int, volume, 70, int, secondsTransition, 0); MESSAGE2(CShipSettingMsg, int, value, 0, CString, name, ""); MESSAGE1(CShowTextMsg, CString, value, "NO TEXT INCLUDED!!!"); MESSAGE2(CSignalObject, CString, strValue, "", int, numValue, 0); -MESSAGE2(CSpeechFallsFromTreeMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CSpeechFallsFromTreeMsg, Point, pos, Point()); MESSAGE1(CStartMusicMsg, CMusicPlayer *, musicPlayer, (CMusicPlayer *)nullptr); MESSAGE3(CStatusChangeMsg, int, oldStatus, 0, int, newStatus, 0, bool, success, false); MESSAGE1(CStopMusicMsg, CMusicPlayer *, musicPlayer, (CMusicPlayer *)nullptr); @@ -327,8 +327,8 @@ MESSAGE1(CTriggerNPCEvent, int, value, 0); MESSAGE4(CTrueTalkGetAnimSetMsg, int, value1, 0, uint, index, 0, uint, startFrame, 0, uint, endFrame, 0); MESSAGE2(CTrueTalkGetAssetDetailsMsg, CString, filename, "", int, numValue, 0); MESSAGE2(CTrueTalkGetStateValueMsg, int, stateNum, 0, int, stateVal, -1000); -MESSAGE2(CTrueTalkNotifySpeechEndedMsg, int, value1, 0, int, dialogueId, 0); -MESSAGE3(CTrueTalkNotifySpeechStartedMsg, uint, soundId, 0, uint, dialogueId, 0, int, value, 0); +MESSAGE2(CTrueTalkNotifySpeechEndedMsg, int, endState, 0, int, dialogueId, 0); +MESSAGE3(CTrueTalkNotifySpeechStartedMsg, uint, speechDuration, 0, uint, dialogueId, 0, int, value, 0); MESSAGE1(CTrueTalkQueueUpAnimSetMsg, int, value, 0); MESSAGE0(CTrueTalkSelfQueueAnimSetMsg); MESSAGE3(CTrueTalkTriggerActionMsg, int, action, 0, int, param1, 0, int, param2, 0); diff --git a/engines/titanic/messages/service_elevator_door.cpp b/engines/titanic/messages/service_elevator_door.cpp index 748790e4aa..7011b1ad44 100644 --- a/engines/titanic/messages/service_elevator_door.cpp +++ b/engines/titanic/messages/service_elevator_door.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CServiceElevatorDoor, CDoorAutoSoundEvent) + ON_MESSAGE(PreEnterNodeMsg) +END_MESSAGE_MAP() + CServiceElevatorDoor::CServiceElevatorDoor() : CDoorAutoSoundEvent() { _string1 = "z#31.wav"; _string2 = "z#32.wav"; @@ -45,4 +49,10 @@ void CServiceElevatorDoor::load(SimpleFile *file) { CDoorAutoSoundEvent::load(file); } +bool CServiceElevatorDoor::PreEnterNodeMsg(CPreEnterNodeMsg *msg) { + if (!findRoom()->isEquals("BilgeRoomWith")) + CDoorAutoSoundEvent::PreEnterNodeMsg(msg); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/messages/service_elevator_door.h b/engines/titanic/messages/service_elevator_door.h index cc8da0917d..69ad1e15b9 100644 --- a/engines/titanic/messages/service_elevator_door.h +++ b/engines/titanic/messages/service_elevator_door.h @@ -28,6 +28,8 @@ namespace Titanic { class CServiceElevatorDoor : public CDoorAutoSoundEvent { + DECLARE_MESSAGE_MAP; + bool PreEnterNodeMsg(CPreEnterNodeMsg *msg); public: CLASSDEF; CServiceElevatorDoor(); diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 90d010b57b..01ad617d6c 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -277,7 +277,6 @@ MODULE_OBJS := \ gfx/chev_right_off.o \ gfx/chev_right_on.o \ gfx/chev_send_rec_switch.o \ - gfx/chev_switch.o \ gfx/edit_control.o \ gfx/elevator_button.o \ gfx/get_from_succ.o \ @@ -406,8 +405,8 @@ MODULE_OBJS := \ sound/dome_from_top_of_well.o \ sound/enter_view_toggles_other_music.o \ sound/gondolier_song.o \ - sound/music_handler.o \ sound/music_room.o \ + sound/music_room_handler.o \ sound/music_player.o \ sound/music_wave.o \ sound/node_auto_sound_player.o \ diff --git a/engines/titanic/moves/enter_exit_mini_lift.cpp b/engines/titanic/moves/enter_exit_mini_lift.cpp index e626d70a9e..3caa674ab8 100644 --- a/engines/titanic/moves/enter_exit_mini_lift.cpp +++ b/engines/titanic/moves/enter_exit_mini_lift.cpp @@ -56,7 +56,7 @@ bool CEnterExitMiniLift::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { if (pet) pet->setRoomsRoomNum(_destRoomNum); } else if (compareRoomNameTo("SGTLittleLift")) { - if (_statics->_changeViewFlag) { + if (_statics->_changeViewNum) { changeView(_statics->_destView); } } @@ -65,7 +65,7 @@ bool CEnterExitMiniLift::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CEnterExitMiniLift::EnterViewMsg(CEnterViewMsg *msg) { - _cursorId = _statics->_changeViewFlag ? CURSOR_MOVE_FORWARD : CURSOR_INVALID; + _cursorId = _statics->_changeViewNum ? CURSOR_MOVE_FORWARD : CURSOR_INVALID; return true; } diff --git a/engines/titanic/moves/exit_arboretum.cpp b/engines/titanic/moves/exit_arboretum.cpp index e0c2ab9c9d..ba162843b5 100644 --- a/engines/titanic/moves/exit_arboretum.cpp +++ b/engines/titanic/moves/exit_arboretum.cpp @@ -57,7 +57,7 @@ void CExitArboretum::load(SimpleFile *file) { bool CExitArboretum::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { if (_enabled) { CActMsg actMsg; - if (_seasonNum == AUTUMN) { + if (_seasonNum == SEASON_WINTER) { switch (_fieldCC) { case 0: actMsg._action = "ExitLFrozen"; diff --git a/engines/titanic/moves/restaurant_pan_handler.cpp b/engines/titanic/moves/restaurant_pan_handler.cpp index 92f55b46cc..d93e331254 100644 --- a/engines/titanic/moves/restaurant_pan_handler.cpp +++ b/engines/titanic/moves/restaurant_pan_handler.cpp @@ -24,24 +24,40 @@ namespace Titanic { -int CRestaurantPanHandler::_v1; +BEGIN_MESSAGE_MAP(CRestaurantPanHandler, CMovePlayerTo) + ON_MESSAGE(ArmPickedUpFromTableMsg) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + +bool CRestaurantPanHandler::_armPickedUp; void CRestaurantPanHandler::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_v1, indent); - file->writeQuotedLine(_string1, indent); - file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_armPickedUp, indent); + file->writeQuotedLine(_armlessDestination, indent); + file->writeQuotedLine(_armDestination, indent); CMovePlayerTo::save(file, indent); } void CRestaurantPanHandler::load(SimpleFile *file) { file->readNumber(); - _v1 = file->readNumber(); - _string1 = file->readString(); - _string2 = file->readString(); + _armPickedUp = file->readNumber(); + _armlessDestination = file->readString(); + _armDestination = file->readString(); CMovePlayerTo::load(file); } +bool CRestaurantPanHandler::ArmPickedUpFromTableMsg(CArmPickedUpFromTableMsg *msg) { + _armPickedUp = true; + return true; +} + +bool CRestaurantPanHandler::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + _destination = _armPickedUp ? _armDestination : _armlessDestination; + changeView(_destination); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/restaurant_pan_handler.h b/engines/titanic/moves/restaurant_pan_handler.h index 4925aa685b..9684fd07f5 100644 --- a/engines/titanic/moves/restaurant_pan_handler.h +++ b/engines/titanic/moves/restaurant_pan_handler.h @@ -28,11 +28,14 @@ namespace Titanic { class CRestaurantPanHandler : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool ArmPickedUpFromTableMsg(CArmPickedUpFromTableMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); protected: - static int _v1; - - CString _string1; - CString _string2; + CString _armDestination; + CString _armlessDestination; +public: + static bool _armPickedUp; public: CLASSDEF; diff --git a/engines/titanic/moves/restricted_move.cpp b/engines/titanic/moves/restricted_move.cpp index 5f18dab8ff..37cb1c46dc 100644 --- a/engines/titanic/moves/restricted_move.cpp +++ b/engines/titanic/moves/restricted_move.cpp @@ -24,21 +24,59 @@ namespace Titanic { -CRestrictedMove::CRestrictedMove() : CMovePlayerTo(), _fieldC8(0) { +BEGIN_MESSAGE_MAP(CRestrictedMove, CMovePlayerTo) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CRestrictedMove::CRestrictedMove() : CMovePlayerTo(), _classNum(0) { } void CRestrictedMove::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_classNum, indent); CMovePlayerTo::save(file, indent); } void CRestrictedMove::load(SimpleFile *file) { file->readNumber(); - _fieldC8 = file->readNumber(); + _classNum = file->readNumber(); CMovePlayerTo::load(file); } +bool CRestrictedMove::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + int classNum = getPassengerClass(); + if (classNum <= _classNum) { + // Okay to change to the given destination + changeView(_destination); + } else if (classNum != 4) { + petDisplayMessage(1, "Passengers of your class are not permitted to enter this area."); + } else if (compareRoomNameTo("EmbLobby")) { + playSound("a#17.wav"); + petDisplayMessage(1, "Please check in at the reception desk."); + } else if (compareViewNameTo("Titania.Node 1.S")) { + playSound("z#226.wav"); + changeView(_destination); + } + + return true; +} + +bool CRestrictedMove::EnterViewMsg(CEnterViewMsg *msg) { + int classNum = getPassengerClass(); + bool flag = classNum > _classNum; + + if (classNum == 4) { + if (compareRoomNameTo("EmbLobby")) + flag = false; + else if (compareViewNameTo("Titania.Node 1.S")) + flag = true; + } + + _cursorId = flag ? CURSOR_MOVE_FORWARD : CURSOR_INVALID; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/restricted_move.h b/engines/titanic/moves/restricted_move.h index bdf093c353..639b024701 100644 --- a/engines/titanic/moves/restricted_move.h +++ b/engines/titanic/moves/restricted_move.h @@ -28,8 +28,11 @@ namespace Titanic { class CRestrictedMove : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); protected: - int _fieldC8; + int _classNum; public: CLASSDEF; CRestrictedMove(); diff --git a/engines/titanic/moves/scraliontis_table.cpp b/engines/titanic/moves/scraliontis_table.cpp index 77d2f9df60..8d39e2104f 100644 --- a/engines/titanic/moves/scraliontis_table.cpp +++ b/engines/titanic/moves/scraliontis_table.cpp @@ -24,15 +24,21 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CScraliontisTable, CRestaurantPanHandler) + ON_MESSAGE(MouseMoveMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MaitreDDefeatedMsg) +END_MESSAGE_MAP() + CScraliontisTable::CScraliontisTable() : CRestaurantPanHandler(), - _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0) { + _fieldE0(false), _counter(0), _ticks(0), _fieldEC(false) { } void CScraliontisTable::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_counter, indent); + file->writeNumberLine(_ticks, indent); file->writeNumberLine(_fieldEC, indent); CRestaurantPanHandler::save(file, indent); @@ -41,11 +47,42 @@ void CScraliontisTable::save(SimpleFile *file, int indent) { void CScraliontisTable::load(SimpleFile *file) { file->readNumber(); _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); + _counter = file->readNumber(); + _ticks = file->readNumber(); _fieldEC = file->readNumber(); CRestaurantPanHandler::load(file); } +bool CScraliontisTable::MouseMoveMsg(CMouseMoveMsg *msg) { + if (!_fieldEC && !_fieldE0) { + if (++_counter > 20) { + CTriggerNPCEvent triggerMsg; + triggerMsg.execute("MaitreD"); + _fieldE0 = true; + } + } + + return true; +} + +bool CScraliontisTable::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_fieldEC) { + changeView(_destination, _armPickedUp ? _armDestination : _armlessDestination); + } + else if (!_ticks || (getTicksCount() - _ticks) >= 5000) { + CTriggerNPCEvent triggerMsg(119); + triggerMsg.execute("MaitreD"); + _ticks = getTicksCount(); + } + + return true; +} + +bool CScraliontisTable::MaitreDDefeatedMsg(CMaitreDDefeatedMsg *msg) { + _cursorId = CURSOR_MOVE_FORWARD; + _fieldEC = true; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/scraliontis_table.h b/engines/titanic/moves/scraliontis_table.h index 2ce3745654..b0d8c6b5af 100644 --- a/engines/titanic/moves/scraliontis_table.h +++ b/engines/titanic/moves/scraliontis_table.h @@ -28,11 +28,15 @@ namespace Titanic { class CScraliontisTable : public CRestaurantPanHandler { + DECLARE_MESSAGE_MAP; + bool MouseMoveMsg(CMouseMoveMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MaitreDDefeatedMsg(CMaitreDDefeatedMsg *msg); private: - int _fieldE0; - int _fieldE4; - int _fieldE8; - int _fieldEC; + bool _fieldE0; + int _counter; + uint _ticks; + bool _fieldEC; public: CLASSDEF; CScraliontisTable(); diff --git a/engines/titanic/moves/trip_down_canal.cpp b/engines/titanic/moves/trip_down_canal.cpp index c8051dda03..e9818fa96d 100644 --- a/engines/titanic/moves/trip_down_canal.cpp +++ b/engines/titanic/moves/trip_down_canal.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CTripDownCanal, CMovePlayerTo) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + CTripDownCanal::CTripDownCanal() : CMovePlayerTo() { } @@ -37,4 +41,14 @@ void CTripDownCanal::load(SimpleFile *file) { CMovePlayerTo::load(file); } +bool CTripDownCanal::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (stateGetSeason() == SEASON_WINTER) { + petDisplayMessage("Sadly, the Grand Canal transport system is closed for the winter."); + } else if (getGameManager()) { + changeView(_destination); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/trip_down_canal.h b/engines/titanic/moves/trip_down_canal.h index 736caf4131..f43fb05de1 100644 --- a/engines/titanic/moves/trip_down_canal.h +++ b/engines/titanic/moves/trip_down_canal.h @@ -28,6 +28,8 @@ namespace Titanic { class CTripDownCanal : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; CTripDownCanal(); diff --git a/engines/titanic/npcs/bellbot.cpp b/engines/titanic/npcs/bellbot.cpp index ac6881a45c..0170491270 100644 --- a/engines/titanic/npcs/bellbot.cpp +++ b/engines/titanic/npcs/bellbot.cpp @@ -135,8 +135,7 @@ bool CBellBot::MovieEndMsg(CMovieEndMsg *msg) { } bool CBellBot::Use(CUse *msg) { - error("TODO: Figure out what msg->_item points to"); - // msg->_item = "Bellbot"; + dynamic_cast<CCarry *>(msg->_item)->_string1 = "Bellbot"; return true; } diff --git a/engines/titanic/npcs/deskbot.cpp b/engines/titanic/npcs/deskbot.cpp index d11b135983..5b6364f1cb 100644 --- a/engines/titanic/npcs/deskbot.cpp +++ b/engines/titanic/npcs/deskbot.cpp @@ -113,7 +113,7 @@ bool CDeskbot::MovieEndMsg(CMovieEndMsg *msg) { petSetArea(PET_ROOMS); dec54(); unlockMouse(); - playSound("z#47.wav", 100, 0, 0); + playSound("z#47.wav"); _classNum = false; } diff --git a/engines/titanic/npcs/doorbot.cpp b/engines/titanic/npcs/doorbot.cpp index 4a5f3690c0..41ef2b2366 100644 --- a/engines/titanic/npcs/doorbot.cpp +++ b/engines/titanic/npcs/doorbot.cpp @@ -288,7 +288,7 @@ bool CDoorbot::TimerMsg(CTimerMsg *msg) { case 6: CMouseButtonDownMsg::generate(); - mouseSaveState(200, 430, 2500); + mouseSetPosition(Point(200, 430), 2500); _timerId = addTimer(7, 2500, 0); break; @@ -476,7 +476,7 @@ bool CDoorbot::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) case 10568: mouseLockE4(); - mouseSaveState(600, 250, 2500); + mouseSetPosition(Point(600, 250), 2500); _timerId = addTimer(6, 2500, 0); break; @@ -488,7 +488,7 @@ bool CDoorbot::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) break; case 10570: - mouseSaveState(200, 430, 2500); + mouseSetPosition(Point(200, 430), 2500); _timerId = addTimer(7, 3000, 0); break; diff --git a/engines/titanic/npcs/mobile.h b/engines/titanic/npcs/mobile.h index 68e74a5afe..2ad939afa6 100644 --- a/engines/titanic/npcs/mobile.h +++ b/engines/titanic/npcs/mobile.h @@ -29,7 +29,7 @@ namespace Titanic { class CMobile : public CCharacter { DECLARE_MESSAGE_MAP; -private: +protected: Point _pos1; int _fieldDC; public: diff --git a/engines/titanic/npcs/parrot.cpp b/engines/titanic/npcs/parrot.cpp index 53e6884415..6e7aa4ec57 100644 --- a/engines/titanic/npcs/parrot.cpp +++ b/engines/titanic/npcs/parrot.cpp @@ -386,7 +386,7 @@ bool CParrot::MouseDragStartMsg(CMouseDragStartMsg *msg) { startTalking(this, 280129); performAction(true); - CCarry *item = static_cast<CCarry *>(getRoot()->findByName(_string2)); + CCarry *item = dynamic_cast<CCarry *>(getRoot()->findByName(_string2)); if (item) { item->_fieldE0 = 1; CPassOnDragStartMsg passMsg; diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp index 5ba68aafbe..c677687b27 100644 --- a/engines/titanic/npcs/true_talk_npc.cpp +++ b/engines/titanic/npcs/true_talk_npc.cpp @@ -40,7 +40,7 @@ BEGIN_MESSAGE_MAP(CTrueTalkNPC, CCharacter) END_MESSAGE_MAP() CTrueTalkNPC::CTrueTalkNPC() : _assetName("z451.dlg"), - _assetNumber(0x11170), _fieldE4(0), _npcFlags(0), _soundId(0), _fieldF0(0), + _assetNumber(0x11170), _fieldE4(0), _npcFlags(0), _speechDuration(0), _startTicks(0), _fieldF4(0), _fieldF8(0), _speechTimerId(0), _field100(0), _field104(0) { } @@ -50,8 +50,8 @@ void CTrueTalkNPC::save(SimpleFile *file, int indent) { file->writeQuotedLine(_assetName, indent); file->writeNumberLine(_fieldE4, indent); file->writeNumberLine(_npcFlags, indent); - file->writeNumberLine(_soundId, indent); - file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_speechDuration, indent); + file->writeNumberLine(_startTicks, indent); file->writeNumberLine(_fieldF4, indent); file->writeNumberLine(_fieldF8, indent); file->writeNumberLine(_speechTimerId, indent); @@ -67,8 +67,8 @@ void CTrueTalkNPC::load(SimpleFile *file) { _assetName = file->readString(); _fieldE4 = file->readNumber(); _npcFlags = file->readNumber(); - _soundId = file->readNumber(); - _fieldF0 = file->readNumber(); + _speechDuration = file->readNumber(); + _startTicks = file->readNumber(); _fieldF4 = file->readNumber(); _fieldF8 = file->readNumber(); _speechTimerId = file->readNumber(); @@ -102,18 +102,18 @@ bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMs if (_speechTimerId) stopTimer(_speechTimerId); - _soundId = msg->_soundId; - _fieldF0 = getTicksCount(); + _speechDuration = msg->_speechDuration; + _startTicks = getTicksCount(); if (hasActiveMovie() || (_npcFlags & NPCFLAG_2)) { _npcFlags &= ~NPCFLAG_2; stopMovie(); - CNPCPlayTalkingAnimationMsg msg1(_soundId, 0, 0); + CNPCPlayTalkingAnimationMsg msg1(_speechDuration, 0, 0); msg1.execute(this); if (msg1._names) { - CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1); + CNPCPlayAnimationMsg msg2(msg1._names, msg1._speechDuration); msg2.execute(this); } } @@ -125,7 +125,7 @@ bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMs bool CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) { _npcFlags &= ~NPCFLAG_SPEAKING; --_field100; - _soundId = 0; + _speechDuration = 0; if (!(_npcFlags & NPCFLAG_8)) { CNPCPlayTalkingAnimationMsg msg1(0, 2, 0); @@ -147,13 +147,13 @@ bool CTrueTalkNPC::MovieEndMsg(CMovieEndMsg *msg) { return false; } - int diff = getTicksCount() - _fieldF0; - int ticks = MAX((int)_soundId - diff, 0); + int diff = getTicksCount() - _startTicks; + int ticks = MAX((int)_speechDuration - diff, 0); CNPCPlayTalkingAnimationMsg msg1(ticks, ticks > 1000 ? 2 : 1, 0); msg1.execute(this); if (msg1._names) { - CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1); + CNPCPlayAnimationMsg msg2(msg1._names, ticks); msg2.execute(this); } @@ -188,7 +188,34 @@ bool CTrueTalkNPC::TimerMsg(CTimerMsg *msg) { } bool CTrueTalkNPC::NPCPlayAnimationMsg(CNPCPlayAnimationMsg *msg) { - warning("CTrueTalkNPC::NPCPlayAnimationMsg"); +// const char *const *nameP = msg->_names; + int count; + for (count = 0; msg->_names[count]; ++count) + ; + + if (msg->_maxDuration) { + // Randomly pick a clip that's less than the allowed maximum + int tries = 10, index; + do { + index = getRandomNumber(count - 1); + } while (getClipDuration(msg->_names[index]) > msg->_maxDuration && --tries); + + if (tries) { + // Sequentially go through the clips to find any below the maximum + index = 0; + for (int idx = 0; idx < count; ++idx) { + if (getClipDuration(msg->_names[idx]) < msg->_maxDuration) { + index = idx; + break; + } + } + } + + playClip(msg->_names[index], MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + } else { + playClip(msg->_names[getRandomNumber(count - 1)]); + } + return true; } diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h index 2eea9bdf3d..1e06e9c690 100644 --- a/engines/titanic/npcs/true_talk_npc.h +++ b/engines/titanic/npcs/true_talk_npc.h @@ -57,19 +57,14 @@ protected: CString _assetName; int _fieldE4; uint _npcFlags; - uint _soundId; - int _fieldF0; + uint _speechDuration; + uint _startTicks; int _fieldF4; int _fieldF8; int _speechTimerId; int _field104; protected: void processInput(CTextInputMsg *msg, CViewItem *view); - - /** - * Perform an action - */ - void performAction(bool startTalking, CViewItem *view = nullptr); public: int _field100; public: @@ -95,6 +90,11 @@ public: * Start the talker in the given view */ void startTalker(CViewItem *view); + + /** + * Perform an action + */ + void performAction(bool startTalking, CViewItem *view = nullptr); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index b32a7907a4..7ab76ddc1d 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -152,7 +152,7 @@ void CPetControl::postLoad() { if (!_activeNPCName.empty() && root) _activeNPC = root->findByName(_activeNPCName); if (!_remoteTargetName.empty() && root) - _remoteTarget = static_cast<CGameObject *>(root->findByName(_remoteTargetName)); + _remoteTarget = dynamic_cast<CGameObject *>(root->findByName(_remoteTargetName)); setArea(_currentArea); loaded(); @@ -194,6 +194,10 @@ void CPetControl::setActiveNPC(CTrueTalkNPC *npc) { } } +void CPetControl::setActiveNPC(const CString &name) { + _conversations.setActiveNPC(name); +} + void CPetControl::refreshNPC() { _conversations.setNPC(_activeNPCName); } @@ -251,7 +255,7 @@ CRoomItem *CPetControl::getHiddenRoom() { CGameObject *CPetControl::getHiddenObject(const CString &name) { CRoomItem *room = getHiddenRoom(); - return room ? static_cast<CGameObject *>(findUnder(room, name)) : nullptr; + return room ? dynamic_cast<CGameObject *>(findUnder(room, name)) : nullptr; } bool CPetControl::containsPt(const Common::Point &pt) const { @@ -355,7 +359,8 @@ bool CPetControl::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { } bool CPetControl::TimerMsg(CTimerMsg *msg) { - warning("TODO: CPetControl::CTimerMsg"); + if (_timers[msg->_actionVal]._target) + _timers[msg->_actionVal]._target->timerExpired(msg->_actionVal); return true; } @@ -376,21 +381,21 @@ void CPetControl::displayMessage(const CString &msg) const { } CGameObject *CPetControl::getFirstObject() const { - return static_cast<CGameObject *>(getFirstChild()); + return dynamic_cast<CGameObject *>(getFirstChild()); } CGameObject *CPetControl::getNextObject(CGameObject *prior) const { if (!prior || prior->getParent() != this) return nullptr; - return static_cast<CGameObject *>(prior->getNextSibling()); + return dynamic_cast<CGameObject *>(prior->getNextSibling()); } void CPetControl::addToInventory(CGameObject *item) { item->detach(); if (item->getName() == "CarryParcel") { - CCarry *child = static_cast<CCarry *>(getLastChild()); + CCarry *child = dynamic_cast<CCarry *>(getLastChild()); if (child) child->detach(); @@ -541,7 +546,7 @@ bool CPetControl::isBotInView(const CString &name) const { // Iterate to find NPC for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) { - CGameObject *gameObject = static_cast<CGameObject *>(child); + CGameObject *gameObject = dynamic_cast<CGameObject *>(child); if (gameObject) { if (!gameObject->getName().compareToIgnoreCase(name)) return true; @@ -609,7 +614,7 @@ bool CPetControl::isDoorOrBellbotPresent() const { for (CTreeItem *treeItem = view->getFirstChild(); treeItem; treeItem = treeItem->scan(view)) { CString name = treeItem->getName(); - if (static_cast<CGameObject *>(treeItem) && + if (dynamic_cast<CGameObject *>(treeItem) && (name.contains("Doorbot") || name.contains("BellBot"))) return true; } @@ -638,7 +643,7 @@ void CPetControl::setTimerPersisent(int id, bool flag) { CGameObject *CPetControl::findBot(const CString &name, CTreeItem *root) { for (CTreeItem *item = root; item; item = item->scan(root)) { if (!item->getName().compareToIgnoreCase(name)) { - CGameObject *obj = static_cast<CGameObject *>(item); + CGameObject *obj = dynamic_cast<CGameObject *>(item); if (obj) return obj; } @@ -660,6 +665,10 @@ void CPetControl::convResetDials(int flag) { _conversations.resetDials(_activeNPCName); } +void CPetControl::resetDials0() { + _conversations.resetDials0(); +} + int CPetControl::getMailDest(const CRoomFlags &roomFlags) const { if (!roomFlags.isSuccUBusRoomFlags()) return roomFlags.getPassengerClassNum(); diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index a86d110458..439a94e2d3 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -358,9 +358,7 @@ public: /** * Sets the active NPC */ - void setActiveNPC(const CString &name) { - _conversations.setActiveNPC(name); - } + void setActiveNPC(const CString &name); /** * Sets the actie NPC @@ -387,7 +385,7 @@ public: /** * Resets the conversation dials back to 0 position */ - void resetDials0() { _conversations.resetDials0(); } + void resetDials0(); /** * Resets the dial display in the conversation tab to reflect new values diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h index 9e8b093d62..3333bdc523 100644 --- a/engines/titanic/pet_control/pet_conversations.h +++ b/engines/titanic/pet_control/pet_conversations.h @@ -100,16 +100,6 @@ private: void summonBot(const CString &name); /** - * Starts the NPC timer - */ - void startNPCTimer(); - - /** - * Stops the NPC timer - */ - void stopNPCTimer(); - - /** * Get the TrueTalk script associated with a given NPC */ TTnpcScript *getNPCScript(const CString &name) const; @@ -260,6 +250,16 @@ public: * Adds a line to the log */ void addLine(const CString &line); + + /** + * Starts the NPC timer + */ + void startNPCTimer(); + + /** + * Stops the NPC timer + */ + void stopNPCTimer(); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_drag_chev.cpp b/engines/titanic/pet_control/pet_drag_chev.cpp index d437d43799..7816570a23 100644 --- a/engines/titanic/pet_control/pet_drag_chev.cpp +++ b/engines/titanic/pet_control/pet_drag_chev.cpp @@ -55,7 +55,7 @@ bool CPetDragChev::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) { if (msg->_dropTarget) { - CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_dropTarget); + CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_dropTarget); if (succubus) { CSetChevRoomBits chevMsg(_id); diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp index 55176d8b0e..88310459c6 100644 --- a/engines/titanic/pet_control/pet_inventory.cpp +++ b/engines/titanic/pet_control/pet_inventory.cpp @@ -28,7 +28,7 @@ namespace Titanic { CPetInventory::CPetInventory() : CPetSection(), - _movie(nullptr), _field290(false), _field294(0), _field298(0) { + _movie(nullptr), _isLoading(false), _field298(0) { for (int idx = 0; idx < TOTAL_ITEMS; ++idx) { _itemBackgrounds[idx] = _itemGlyphs[idx] = nullptr; } @@ -109,9 +109,9 @@ void CPetInventory::load(SimpleFile *file, int param) { void CPetInventory::postLoad() { reset(); - _field290 = 1; + _isLoading = true; itemsChanged(); - _field290 = 0; + _isLoading = false; } void CPetInventory::save(SimpleFile *file, int indent) { @@ -179,7 +179,7 @@ void CPetInventory::itemsChanged() { while (item) { CPetInventoryGlyph *glyph = new CPetInventoryGlyph(); glyph->setup(_petControl, &_items); - glyph->setItem(item, _field290); + glyph->setItem(item, _isLoading); _items.push_back(glyph); item = _petControl->getNextObject(item); diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h index 17649546ce..184bb20385 100644 --- a/engines/titanic/pet_control/pet_inventory.h +++ b/engines/titanic/pet_control/pet_inventory.h @@ -40,8 +40,7 @@ private: CGameObject *_itemBackgrounds[46]; CGameObject *_itemGlyphs[46]; CGameObject *_movie; - bool _field290; - int _field294; + bool _isLoading; int _field298; private: /** diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp index ae306649a2..03293eb453 100644 --- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp +++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp @@ -165,7 +165,7 @@ void CPetInventoryGlyph::getTooltip(CPetText *text) { bool CPetInventoryGlyph::doAction(CGlyphAction *action) { CInventoryGlyphAction *invAction = static_cast<CInventoryGlyphAction *>(action); - CPetInventoryGlyphs *owner = static_cast<CPetInventoryGlyphs *>(_owner); + CPetInventoryGlyphs *owner = dynamic_cast<CPetInventoryGlyphs *>(_owner); if (!invAction) return false; @@ -198,17 +198,17 @@ bool CPetInventoryGlyph::doAction(CGlyphAction *action) { return true; } -void CPetInventoryGlyph::setItem(CGameObject *item, int val) { +void CPetInventoryGlyph::setItem(CGameObject *item, bool isLoading) { _item = item; if (_owner && item) { - int v1 = populateItem(item, val); + int v1 = populateItem(item, isLoading); _background = static_cast<CPetInventoryGlyphs *>(_owner)->getBackground(v1); _image = static_cast<CPetInventory *>(getPetSection())->getImage(v1); } } -int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { +int CPetInventoryGlyph::populateItem(CGameObject *item, bool isLoading) { // Scan the master item names list CString itemName = item->getName(); int itemIndex = -1; @@ -221,7 +221,7 @@ int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { switch (ITEM_MODES[itemIndex]) { case 0: - switch (subMode(item, val)) { + switch (subMode(item, isLoading)) { case 0: case 1: return 0; @@ -233,7 +233,7 @@ int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { } case 2: - switch (subMode(item, val)) { + switch (subMode(item, isLoading)) { case 0: return 2; default: @@ -242,7 +242,7 @@ int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { break; case 15: - switch (subMode(item, val)) { + switch (subMode(item, isLoading)) { case 0: case 1: return 14; @@ -260,7 +260,7 @@ int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { break; case 26: - switch (subMode(item, val)) { + switch (subMode(item, isLoading)) { case 0: return 26; case 1: @@ -281,11 +281,11 @@ int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { return ITEM_MODES[itemIndex]; } -int CPetInventoryGlyph::subMode(CGameObject *item, int val) { +int CPetInventoryGlyph::subMode(CGameObject *item, bool isLoading) { int frameNum = item->getFrameNumber(); int movieFrame = item->getMovieFrame(); - if (val && frameNum != -1 && frameNum != movieFrame) + if (isLoading && frameNum != -1 && frameNum != movieFrame) item->loadFrame(frameNum); return frameNum; @@ -293,7 +293,7 @@ int CPetInventoryGlyph::subMode(CGameObject *item, int val) { void CPetInventoryGlyph::startBackgroundMovie() { if (_owner) { - CPetInventory *section = static_cast<CPetInventory *>(_owner->getOwner()); + CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner()); if (section) section->playMovie(_background, 1); } @@ -301,7 +301,7 @@ void CPetInventoryGlyph::startBackgroundMovie() { void CPetInventoryGlyph::startForegroundMovie() { if (_owner) { - CPetInventory *section = static_cast<CPetInventory *>(_owner->getOwner()); + CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner()); if (section) section->playMovie(_image, 1); } @@ -309,7 +309,7 @@ void CPetInventoryGlyph::startForegroundMovie() { void CPetInventoryGlyph::stopMovie() { if (_owner) { - CPetInventory *section = static_cast<CPetInventory *>(_owner->getOwner()); + CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner()); if (section) section->playMovie(nullptr, 1); } diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h index 716c9d1ad1..0d167c4c98 100644 --- a/engines/titanic/pet_control/pet_inventory_glyphs.h +++ b/engines/titanic/pet_control/pet_inventory_glyphs.h @@ -34,9 +34,9 @@ private: /** * Populate the details for an item */ - int populateItem(CGameObject *item, int val); + int populateItem(CGameObject *item, bool isLoading); - int subMode(CGameObject *item, int val); + int subMode(CGameObject *item, bool isLoading); /** * Start any movie for the background @@ -126,7 +126,7 @@ public: /** * Set the inventory item */ - void setItem(CGameObject *item, int val); + void setItem(CGameObject *item, bool isLoading); }; class CInventoryGlyphAction : public CGlyphAction { diff --git a/engines/titanic/pet_control/pet_load_save.h b/engines/titanic/pet_control/pet_load_save.h index dd1c907ef1..26ddec0ff9 100644 --- a/engines/titanic/pet_control/pet_load_save.h +++ b/engines/titanic/pet_control/pet_load_save.h @@ -38,11 +38,6 @@ private: Rect getSlotBounds(int index); /** - * Highlight one of the slots - */ - void highlightSlot(int index); - - /** * Called when savegame slot highlight changes or the view is reset */ void highlightChange(); @@ -67,6 +62,11 @@ protected: * Reset the slot names list */ void resetSlots(); + + /** + * Highlight one of the slots + */ + void highlightSlot(int index); public: /** * Setup the glyph diff --git a/engines/titanic/pet_control/pet_remote_glyphs.cpp b/engines/titanic/pet_control/pet_remote_glyphs.cpp index 6b7c8cb4ae..953428ff0c 100644 --- a/engines/titanic/pet_control/pet_remote_glyphs.cpp +++ b/engines/titanic/pet_control/pet_remote_glyphs.cpp @@ -29,7 +29,7 @@ namespace Titanic { CPetRemote *CPetRemoteGlyphs::getOwner() const { - return static_cast<CPetRemote *>(_owner); + return dynamic_cast<CPetRemote *>(_owner); } void CPetRemoteGlyphs::generateMessage(RemoteMessage msgNum, const CString &name, int num) { @@ -44,7 +44,7 @@ void CPetRemoteGlyph::setDefaults(const CString &name, CPetControl *petControl) } CPetRemoteGlyphs *CPetRemoteGlyph::getOwner() const { - return static_cast<CPetRemoteGlyphs *>(_owner); + return dynamic_cast<CPetRemoteGlyphs *>(_owner); } CPetGfxElement *CPetRemoteGlyph::getElement(uint id) const { diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp index 2415c96966..fb92f2692d 100644 --- a/engines/titanic/pet_control/pet_rooms.cpp +++ b/engines/titanic/pet_control/pet_rooms.cpp @@ -304,7 +304,7 @@ CPetRoomsGlyph *CPetRooms::addRoom(uint roomFlags, bool highlight_) { // Do a preliminary scan of the glyph list for any glyph that is // no longer valid, and thus can be removed for (CPetRoomsGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) { - CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i); + CPetRoomsGlyph *glyph = dynamic_cast<CPetRoomsGlyph *>(*i); if (!glyph->isAssigned()) { _glyphs.erase(i); break; diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp index d9e19b1f67..e89e8072dc 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp +++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp @@ -236,7 +236,7 @@ void CPetRoomsGlyphs::saveGlyphs(SimpleFile *file, int indent) { CPetRoomsGlyph *CPetRoomsGlyphs::findAssignedRoom() const { for (const_iterator i = begin(); i != end(); ++i) { - CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i); + CPetRoomsGlyph *glyph = dynamic_cast<CPetRoomsGlyph *>(*i); if (glyph->isCurrentlyAssigned()) return glyph; } diff --git a/engines/titanic/pet_control/pet_save.cpp b/engines/titanic/pet_control/pet_save.cpp index b5e16736bc..9305759117 100644 --- a/engines/titanic/pet_control/pet_save.cpp +++ b/engines/titanic/pet_control/pet_save.cpp @@ -22,6 +22,7 @@ #include "titanic/pet_control/pet_save.h" #include "titanic/pet_control/pet_control.h" +#include "titanic/core/project_item.h" namespace Titanic { @@ -58,15 +59,28 @@ void CPetSave::getTooltip(CPetText *text) { } void CPetSave::highlightSave(int index) { - warning("TODO: CPetSave::highlightSave"); + if (index >= 0) + _slotNames[index].showCursor(-2); } void CPetSave::unhighlightSave(int index) { - warning("TODO: CPetSave::unhighlightSave"); + if (index >= 0) + _slotNames[index].hideCursor(); } void CPetSave::execute() { - warning("TODO: CPetSave::execute"); + CPetControl *pet = getPetControl(); + if (_savegameSlotNum >= 0) { + highlightSlot(-1); + CProjectItem *project = pet ? pet->getRoot() : nullptr; + + if (project) { + project->saveGame(_savegameSlotNum, _slotNames[_savegameSlotNum].getText()); + pet->displayMessage(""); + } + } else if (pet) { + pet->displayMessage("You must select a game to save first."); + } } } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index 6813095626..32a6a9af57 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -26,11 +26,11 @@ namespace Titanic { CPetText::CPetText(uint count) : _stringsMerged(false), _maxCharsPerLine(-1), _lineCount(0), - _linesStart(-1), _field3C(0), _field40(0), _field44(0), + _linesStart(-1), _unused1(0), _unused2(0), _unused3(0), _backR(0xff), _backG(0xff), _backB(0xff), _textR(0), _textG(0), _textB(200), - _fontNumber(0), _field64(0), _field68(0), _field6C(0), - _hasBorder(true), _scrollTop(0), _textCursor(nullptr), _field7C(0) { + _fontNumber(0), _npcFlag(0), _npcId(0), _hasBorder(true), + _scrollTop(0), _textCursor(nullptr) { setupArrays(count); } @@ -86,9 +86,9 @@ void CPetText::load(SimpleFile *file, int param) { uint charsPerLine = file->readNumber(); uint count = file->readNumber(); _bounds = file->readRect(); - _field3C = file->readNumber(); - _field40 = file->readNumber(); - _field44 = file->readNumber(); + _unused1 = file->readNumber(); + _unused2 = file->readNumber(); + _unused3 = file->readNumber(); _backR = file->readNumber(); _backG = file->readNumber(); _backB = file->readNumber(); @@ -118,9 +118,9 @@ void CPetText::save(SimpleFile *file, int indent) { file->writeNumberLine(numLines, indent); file->writeRect(_bounds, indent); - file->writeNumberLine(_field3C, indent); - file->writeNumberLine(_field40, indent); - file->writeNumberLine(_field44, indent); + file->writeNumberLine(_unused1, indent); + file->writeNumberLine(_unused2, indent); + file->writeNumberLine(_unused3, indent); file->writeNumberLine(_backR, indent); file->writeNumberLine(_backG, indent); file->writeNumberLine(_backB, indent); @@ -266,16 +266,16 @@ void CPetText::setMaxCharsPerLine(int maxChars) { } void CPetText::updateStr3(int lineNum) { - if (_field64 > 0 && _field68 > 0) { + if (_npcFlag > 0 && _npcId > 0) { char line[5]; line[0] = line[3] = TEXTCMD_NPC; - line[1] = _field64; - line[2] = _field68; + line[1] = _npcFlag; + line[2] = _npcId; line[4] = '\0'; _array[lineNum]._string3 = CString(line); _stringsMerged = false; - _field64 = _field68 = 0; + _npcFlag = _npcId = 0; } } @@ -304,9 +304,9 @@ void CPetText::deleteLastChar() { } } -void CPetText::setNPC(int val1, int npcId) { - _field64 = val1; - _field68 = npcId; +void CPetText::setNPC(int npcFlag, int npcId) { + _npcFlag = npcFlag; + _npcId = npcId; } void CPetText::scrollUp(CScreenManager *screenManager) { diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h index f5d4235690..ba199a3ae5 100644 --- a/engines/titanic/pet_control/pet_text.h +++ b/engines/titanic/pet_control/pet_text.h @@ -44,9 +44,9 @@ private: int _maxCharsPerLine; int _lineCount; int _linesStart; - int _field3C; - int _field40; - int _field44; + int _unused1; + int _unused2; + int _unused3; int _backR; int _backG; int _backB; @@ -54,13 +54,11 @@ private: int _textG; int _textB; int _fontNumber; - int _field64; - int _field68; - int _field6C; + int _npcFlag; + int _npcId; bool _hasBorder; int _scrollTop; CTextCursor *_textCursor; - int _field7C; private: void setupArrays(int count); @@ -167,7 +165,10 @@ public: */ void deleteLastChar(); - void setNPC(int val1, int npcId); + /** + * Sets the current NPC text is being added for + */ + void setNPC(int npcFlag, int npcId); /** * Get the index into _lines where on-screen text starts diff --git a/engines/titanic/sound/auto_sound_player.cpp b/engines/titanic/sound/auto_sound_player.cpp index 8267d65037..4a3a1fe7f8 100644 --- a/engines/titanic/sound/auto_sound_player.cpp +++ b/engines/titanic/sound/auto_sound_player.cpp @@ -33,7 +33,7 @@ BEGIN_MESSAGE_MAP(CAutoSoundPlayer, CGameObject) END_MESSAGE_MAP() CAutoSoundPlayer::CAutoSoundPlayer() : CGameObject(), - _fieldBC(0), _volume(70), _fieldD0(0), _repeated(false), _soundHandle(-1), + _fieldBC(0), _volume(70), _balance(0), _repeated(false), _soundHandle(-1), _stopSeconds(0), _startSeconds(-1), _active(false), _fieldE8(0) { } @@ -42,7 +42,7 @@ void CAutoSoundPlayer::save(SimpleFile *file, int indent) { file->writeNumberLine(_fieldBC, indent); file->writeQuotedLine(_filename, indent); file->writeNumberLine(_volume, indent); - file->writeNumberLine(_fieldD0, indent); + file->writeNumberLine(_balance, indent); file->writeNumberLine(_repeated, indent); file->writeNumberLine(_soundHandle, indent); file->writeNumberLine(_stopSeconds, indent); @@ -58,7 +58,7 @@ void CAutoSoundPlayer::load(SimpleFile *file) { _fieldBC = file->readNumber(); _filename = file->readString(); _volume = file->readNumber(); - _fieldD0 = file->readNumber(); + _balance = file->readNumber(); _repeated = file->readNumber(); _soundHandle = file->readNumber(); _stopSeconds = file->readNumber(); @@ -72,7 +72,7 @@ void CAutoSoundPlayer::load(SimpleFile *file) { bool CAutoSoundPlayer::TurnOn(CTurnOn *msg) { if (_soundHandle == -1) { CProximity prox; - prox._fieldC = _fieldD0; + prox._balance = _balance; prox._repeated = _repeated; if (_fieldE8) prox._positioningMode = POSMODE_VECTOR; diff --git a/engines/titanic/sound/auto_sound_player.h b/engines/titanic/sound/auto_sound_player.h index c8f1d3480e..9f4d11ee06 100644 --- a/engines/titanic/sound/auto_sound_player.h +++ b/engines/titanic/sound/auto_sound_player.h @@ -38,7 +38,7 @@ public: int _fieldBC; CString _filename; int _volume; - int _fieldD0; + int _balance; bool _repeated; int _soundHandle; int _stopSeconds; diff --git a/engines/titanic/sound/auto_sound_player_adsr.cpp b/engines/titanic/sound/auto_sound_player_adsr.cpp index f9f045759b..d900ca0792 100644 --- a/engines/titanic/sound/auto_sound_player_adsr.cpp +++ b/engines/titanic/sound/auto_sound_player_adsr.cpp @@ -48,12 +48,12 @@ void CAutoSoundPlayerADSR::load(SimpleFile *file) { bool CAutoSoundPlayerADSR::TurnOn(CTurnOn *msg) { if (_soundHandle == -1) { if (!_soundName1.empty()) { - _soundHandle = playSound(_soundName1, _volume, _fieldD0); + _soundHandle = playSound(_soundName1, _volume, _balance); if (!_soundName2.empty()) - _soundHandle = queueSound(_soundName2, _soundHandle, _volume, _fieldD0); + _soundHandle = queueSound(_soundName2, _soundHandle, _volume, _balance); - _soundHandle = queueSound(_filename, _soundHandle, _volume, _fieldD0); + _soundHandle = queueSound(_filename, _soundHandle, _volume, _balance); _active = true; } } @@ -64,7 +64,7 @@ bool CAutoSoundPlayerADSR::TurnOn(CTurnOn *msg) { bool CAutoSoundPlayerADSR::TurnOff(CTurnOff *msg) { if (_soundHandle != -1) { if (!_soundName3.empty()) - queueSound(_soundName3, _soundHandle, _volume, _fieldD0); + queueSound(_soundName3, _soundHandle, _volume, _balance); if (isSoundActive(_soundHandle)) stopSound(_soundHandle); diff --git a/engines/titanic/sound/gondolier_song.cpp b/engines/titanic/sound/gondolier_song.cpp index 5c96718723..541ef7142f 100644 --- a/engines/titanic/sound/gondolier_song.cpp +++ b/engines/titanic/sound/gondolier_song.cpp @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #include "titanic/sound/gondolier_song.h" @@ -49,9 +49,9 @@ bool CGondolierSong::TurnOn(CTurnOn *msg) { int volume = _value * _volume / 100; if (_startSeconds == -1) { - _soundHandle = playSound(_filename, volume, _fieldD0, _repeated); + _soundHandle = playSound(_filename, volume, _balance, _repeated); } else { - _soundHandle = playSound(_filename, 0, _fieldD0, _repeated); + _soundHandle = playSound(_filename, 0, _balance, _repeated); setSoundVolume(_soundHandle, _volume, _startSeconds); } diff --git a/engines/titanic/sound/music_handler.cpp b/engines/titanic/sound/music_handler.cpp deleted file mode 100644 index 07c3994334..0000000000 --- a/engines/titanic/sound/music_handler.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "titanic/sound/music_handler.h" -#include "titanic/sound/sound_manager.h" -#include "titanic/core/project_item.h" - -namespace Titanic { - -CMusicHandler::CMusicHandler(CProjectItem *project, CSoundManager *soundManager) : - _project(project), _soundManager(soundManager), _stopWaves(false), - _soundHandle(-1), _waveFile(nullptr) { - Common::fill(&_musicWaves[0], &_musicWaves[4], (CMusicWave *)nullptr); -} - -CMusicHandler::~CMusicHandler() { - stop(); -} - -CMusicWave *CMusicHandler::createMusicWave(int waveIndex, int count) { - switch (waveIndex) { - case 0: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 2); - break; - case 1: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 3); - break; - case 2: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 0); - break; - case 3: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 1); - break; - default: - return nullptr; - } - - _musicWaves[waveIndex]->setSize(count); - return _musicWaves[waveIndex]; -} - -bool CMusicHandler::isBusy() { - // TODO - return false; -} - -void CMusicHandler::stop() { - if (_waveFile) { - _soundManager->stopSound(_soundHandle); - delete _waveFile; - _waveFile = nullptr; - _soundHandle = -1; - } - - for (int idx = 0; idx < 4; ++idx) { - if (_stopWaves && _musicWaves[idx]) - _musicWaves[idx]->stop(); - } -} - -bool CMusicHandler::checkSound(int index) const { - // TODO - return false; -} - -} // End of namespace Titanic diff --git a/engines/titanic/sound/music_player.cpp b/engines/titanic/sound/music_player.cpp index cd764c7f93..a1aaf8ff8b 100644 --- a/engines/titanic/sound/music_player.cpp +++ b/engines/titanic/sound/music_player.cpp @@ -97,7 +97,7 @@ bool CMusicPlayer::StopMusicMsg(CStopMusicMsg *msg) { } bool CMusicPlayer::FrameMsg(CFrameMsg *msg) { - if (_isActive && !CMusicRoom::_musicHandler->isBusy()) { + if (_isActive && !CMusicRoom::_musicHandler->poll()) { getMusicRoom()->stopMusic(); _isActive = false; @@ -124,7 +124,7 @@ bool CMusicPlayer::CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg) { return true; } - CMusicHandler *musicHandler = getMusicRoom()->createMusicHandler(); + CMusicRoomHandler *musicHandler = getMusicRoom()->createMusicHandler(); CMusicWave *wave; if (musicHandler) { diff --git a/engines/titanic/sound/music_room.cpp b/engines/titanic/sound/music_room.cpp index 2e4ad904fa..9586f55c58 100644 --- a/engines/titanic/sound/music_room.cpp +++ b/engines/titanic/sound/music_room.cpp @@ -27,23 +27,23 @@ namespace Titanic { -CMusicHandler *CMusicRoom::_musicHandler; +CMusicRoomHandler *CMusicRoom::_musicHandler; CMusicRoom::CMusicRoom(CGameManager *gameManager) : _gameManager(gameManager) { _sound = &_gameManager->_sound; - _items.resize(4); + _controls.resize(4); } CMusicRoom::~CMusicRoom() { destroyMusicHandler(); } -CMusicHandler *CMusicRoom::createMusicHandler() { +CMusicRoomHandler *CMusicRoom::createMusicHandler() { if (_musicHandler) destroyMusicHandler(); - _musicHandler = new CMusicHandler(_gameManager->_project, &_sound->_soundManager); + _musicHandler = new CMusicRoomHandler(_gameManager->_project, &_sound->_soundManager); return _musicHandler; } @@ -52,8 +52,40 @@ void CMusicRoom::destroyMusicHandler() { _musicHandler = nullptr; } -void CMusicRoom::startMusic(int musicId) { - // TODO +void CMusicRoom::startMusic(int volume) { + if (_musicHandler) { + _musicHandler->setSpeedControl2(BELLS, 0); + _musicHandler->setSpeedControl2(SNAKE, 1); + _musicHandler->setSpeedControl2(PIANO, -1); + _musicHandler->setSpeedControl2(BASS, -2); + + _musicHandler->setPitchControl2(BELLS, 1); + _musicHandler->setPitchControl2(SNAKE, 2); + _musicHandler->setPitchControl2(PIANO, 0); + _musicHandler->setPitchControl2(BELLS, 1); + + _musicHandler->setInversionControl2(BELLS, 1); + _musicHandler->setInversionControl2(SNAKE, 0); + _musicHandler->setInversionControl2(PIANO, 1); + _musicHandler->setInversionControl2(BASS, 0); + + _musicHandler->setDirectionControl2(BELLS, 0); + _musicHandler->setDirectionControl2(SNAKE, 0); + _musicHandler->setDirectionControl2(PIANO, 1); + _musicHandler->setDirectionControl2(BASS, 1); + + for (MusicControlArea idx = BELLS; idx <= BASS; + idx = (MusicControlArea)((int)idx + 1)) { + Controls &controls = _controls[idx]; + _musicHandler->setSpeedControl(idx, controls._speedControl); + _musicHandler->setPitchControl(idx, controls._pitchControl); + _musicHandler->setDirectionControl(idx, controls._directionControl); + _musicHandler->setInversionControl(idx, controls._inversionControl); + _musicHandler->setMuteControl(idx, controls._muteControl); + } + + _musicHandler->createWaveFile(volume); + } } void CMusicRoom::stopMusic() { diff --git a/engines/titanic/sound/music_room.h b/engines/titanic/sound/music_room.h index 5f0b271ab3..4b584a0dd4 100644 --- a/engines/titanic/sound/music_room.h +++ b/engines/titanic/sound/music_room.h @@ -24,29 +24,28 @@ #define TITANIC_MUSIC_ROOM_H #include "common/array.h" -#include "titanic/sound/music_handler.h" +#include "titanic/sound/music_room_handler.h" namespace Titanic { class CGameManager; class CSound; -enum MusicControlArea { BELLS = 0, SNAKE = 1, PIANO = 2, BASS = 3 }; - class CMusicRoom { - struct Entry { - uint _val1; - uint _val2; - uint _val3; - uint _val4; - uint _val5; + struct Controls { + int _speedControl; + int _pitchControl; + int _directionControl; + int _inversionControl; + int _muteControl; - Entry() : _val1(0), _val2(0), _val3(0), _val4(0), _val5(0) {} + Controls() : _speedControl(0), _pitchControl(0), _directionControl(0), + _inversionControl(0), _muteControl(0) {} }; private: - Common::Array<Entry> _items; + Common::Array<Controls> _controls; public: - static CMusicHandler *_musicHandler; + static CMusicRoomHandler *_musicHandler; public: CGameManager *_gameManager; CSound *_sound; @@ -57,23 +56,23 @@ public: /** * Creates a music handler */ - CMusicHandler *createMusicHandler(); + CMusicRoomHandler *createMusicHandler(); /** * Destroys and currently active music handler */ void destroyMusicHandler(); - void setItem1(MusicControlArea index, int val) { _items[index]._val1 = val; } - void setItem2(MusicControlArea index, int val) { _items[index]._val2 = val; } - void setItem3(MusicControlArea index, int val) { _items[index]._val3 = val; } - void setItem4(MusicControlArea index, int val) { _items[index]._val4 = val; } - void setItem5(MusicControlArea index, int val) { _items[index]._val5 = val; } + void setSpeedControl(MusicControlArea index, int val) { _controls[index]._speedControl = val; } + void setPitchControl(MusicControlArea index, int val) { _controls[index]._pitchControl = val; } + void setDirectionControl(MusicControlArea index, int val) { _controls[index]._directionControl = val; } + void setInversionControl(MusicControlArea index, int val) { _controls[index]._inversionControl = val; } + void setMuteControl(MusicControlArea index, int val) { _controls[index]._muteControl = val; } /** * Start playing a given music number */ - void startMusic(int musicId); + void startMusic(int volume = 100); /** * Stop playing music diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp new file mode 100644 index 0000000000..ca37485eab --- /dev/null +++ b/engines/titanic/sound/music_room_handler.cpp @@ -0,0 +1,138 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/music_room_handler.h" +#include "titanic/sound/sound_manager.h" +#include "titanic/core/project_item.h" + +namespace Titanic { + +CMusicRoomHandler::CMusicRoomHandler(CProjectItem *project, CSoundManager *soundManager) : + _project(project), _soundManager(soundManager), _stopWaves(false), + _soundHandle(-1), _waveFile(nullptr), _soundVolume(100), _ticks(0), + _field108(0) { + Common::fill(&_musicWaves[0], &_musicWaves[4], (CMusicWave *)nullptr); +} + +CMusicRoomHandler::~CMusicRoomHandler() { + stop(); + for (int idx = 0; idx < 4; ++idx) + delete _musicWaves[idx]; +} + +CMusicWave *CMusicRoomHandler::createMusicWave(int waveIndex, int count) { + switch (waveIndex) { + case 0: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 2); + break; + case 1: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 3); + break; + case 2: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 0); + break; + case 3: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 1); + break; + default: + return nullptr; + } + + _musicWaves[waveIndex]->setSize(count); + return _musicWaves[waveIndex]; +} + +void CMusicRoomHandler::createWaveFile(int musicVolume) { + _soundVolume = musicVolume; +// _waveFile = _soundManager->loadMusic() +} + +bool CMusicRoomHandler::poll() { + // TODO + return false; +} + +void CMusicRoomHandler::stop() { + if (_waveFile) { + _soundManager->stopSound(_soundHandle); + delete _waveFile; + _waveFile = nullptr; + _soundHandle = -1; + } + + for (int idx = 0; idx < 4; ++idx) { + if (_stopWaves && _musicWaves[idx]) + _musicWaves[idx]->stop(); + } +} + +bool CMusicRoomHandler::checkSound(int index) const { + // TODO + return false; +} + +void CMusicRoomHandler::setSpeedControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._speedControl = value; +} + +void CMusicRoomHandler::setPitchControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._pitchControl = value * 3; +} + +void CMusicRoomHandler::setInversionControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._inversionControl = value; +} + +void CMusicRoomHandler::setDirectionControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._directionControl = value; +} + +void CMusicRoomHandler::setPitchControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._pitchControl = value; +} + +void CMusicRoomHandler::setSpeedControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._speedControl = value; +} + +void CMusicRoomHandler::setDirectionControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._directionControl = value; +} + +void CMusicRoomHandler::setInversionControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._inversionControl = value; +} + +void CMusicRoomHandler::setMuteControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._muteControl = value; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/music_handler.h b/engines/titanic/sound/music_room_handler.h index 6792844cb5..61b332dc7a 100644 --- a/engines/titanic/sound/music_handler.h +++ b/engines/titanic/sound/music_room_handler.h @@ -20,8 +20,8 @@ * */ -#ifndef TITANIC_MUSIC_HANDLER_H -#define TITANIC_MUSIC_HANDLER_H +#ifndef TITANIC_MUSIC_ROOM_HANDLER_H +#define TITANIC_MUSIC_ROOM_HANDLER_H #include "titanic/sound/music_wave.h" #include "titanic/sound/wave_file.h" @@ -31,17 +31,39 @@ namespace Titanic { class CProjectItem; class CSoundManager; -class CMusicHandler { +enum MusicControlArea { BELLS = 0, SNAKE = 1, PIANO = 2, BASS = 3 }; + +class CMusicRoomHandler { + struct Controls { + int _pitchControl; + int _speedControl; + int _directionControl; + int _inversionControl; + int _muteControl; + Controls() : _pitchControl(0), _speedControl(0), _directionControl(0), + _inversionControl(0), _muteControl(0) {} + }; + struct Array5Entry { + int _v1; + int _v2; + Array5Entry() : _v1(0), _v2(0) {} + }; private: CProjectItem *_project; CSoundManager *_soundManager; CMusicWave *_musicWaves[4]; + Controls _array1[4]; + Controls _array2[4]; + Array5Entry _array5[4]; bool _stopWaves; CWaveFile *_waveFile; int _soundHandle; + int _soundVolume; + uint _ticks; + int _field108; public: - CMusicHandler(CProjectItem *project, CSoundManager *soundManager); - ~CMusicHandler(); + CMusicRoomHandler(CProjectItem *project, CSoundManager *soundManager); + ~CMusicRoomHandler(); /** * Creates a new music wave class instance, and assigns it to a slot @@ -51,7 +73,12 @@ public: */ CMusicWave *createMusicWave(int waveIndex, int count); - bool isBusy(); + void createWaveFile(int musicVolume); + + /** + * Handles regular polling the music handler + */ + bool poll(); /** * Flags whether the loaded music waves will be stopped when the @@ -65,8 +92,34 @@ public: void stop(); bool checkSound(int index) const; + + /** + * Set a setting + */ + void setSpeedControl2(MusicControlArea area, int value); + + /** + * Set a setting + */ + void setPitchControl2(MusicControlArea area, int value); + + /** + * Set a setting + */ + void setInversionControl2(MusicControlArea area, int value); + + /** + * Set a setting + */ + void setDirectionControl2(MusicControlArea area, int value); + + void setPitchControl(MusicControlArea area, int value); + void setSpeedControl(MusicControlArea area, int value); + void setDirectionControl(MusicControlArea area, int value); + void setInversionControl(MusicControlArea area, int value); + void setMuteControl(MusicControlArea area, int value); }; } // End of namespace Titanic -#endif /* TITANIC_MUSIC_HANDLER_H */ +#endif /* TITANIC_MUSIC_ROOM_HANDLER_H */ diff --git a/engines/titanic/sound/proximity.cpp b/engines/titanic/sound/proximity.cpp index 7f4e6784f2..ee1cd3e741 100644 --- a/engines/titanic/sound/proximity.cpp +++ b/engines/titanic/sound/proximity.cpp @@ -25,13 +25,14 @@ namespace Titanic { -CProximity::CProximity() : _field4(0), _channelVolume(100), _fieldC(0), - _priorSoundHandle(-1), _field14(0), _frequencyMultiplier(0.0), _field1C(1.875), - _repeated(false), _channel(10), _positioningMode(POSMODE_NONE), _azimuth(0.0), - _range(0.5), _elevation(0), _posX(0.0), _posY(0.0), _posZ(0.0), +CProximity::CProximity() : _channelVolume(100), _balance(0), + _priorSoundHandle(-1), _frequencyMultiplier(0.0), _frequencyAdjust(1.875), + _repeated(false), _channelMode(10), _positioningMode(POSMODE_NONE), + _azimuth(0.0), _range(0.5), _elevation(0), + _posX(0.0), _posY(0.0), _posZ(0.0), _hasVelocity(false), _velocityX(0), _velocityY(0), _velocityZ(0), - _field54(0), _field58(0), _field5C(0), _freeSoundFlag(false), _endTalkerFn(nullptr), - _talker(nullptr), _field6C(0) { + _disposeAfterUse(DisposeAfterUse::NO), _endTalkerFn(nullptr), _talker(nullptr), + _soundDuration(0), _soundType(Audio::Mixer::kPlainSoundType) { } } // End of namespace Titanic diff --git a/engines/titanic/sound/proximity.h b/engines/titanic/sound/proximity.h index b728f22c26..2f0745240d 100644 --- a/engines/titanic/sound/proximity.h +++ b/engines/titanic/sound/proximity.h @@ -23,6 +23,7 @@ #ifndef TITANIC_PROXIMITY_H #define TITANIC_PROXIMITY_H +#include "audio/mixer.h" #include "common/scummsys.h" namespace Titanic { @@ -35,15 +36,13 @@ typedef void (*CEndTalkerFn)(TTtalker *talker); class CProximity { public: - int _field4; int _channelVolume; - int _fieldC; + int _balance; int _priorSoundHandle; - int _field14; double _frequencyMultiplier; - double _field1C; + double _frequencyAdjust; bool _repeated; - int _channel; + int _channelMode; PositioningMode _positioningMode; double _azimuth; double _range; @@ -55,13 +54,11 @@ public: double _velocityX; double _velocityY; double _velocityZ; - int _field54; - int _field58; - int _field5C; - bool _freeSoundFlag; + DisposeAfterUse::Flag _disposeAfterUse; CEndTalkerFn _endTalkerFn; TTtalker *_talker; - int _field6C; + uint _soundDuration; + Audio::Mixer::SoundType _soundType; public: CProximity(); }; diff --git a/engines/titanic/sound/qmixer.cpp b/engines/titanic/sound/qmixer.cpp index 145d142b2d..c095b84e17 100644 --- a/engines/titanic/sound/qmixer.cpp +++ b/engines/titanic/sound/qmixer.cpp @@ -20,6 +20,7 @@ * */ +#include "common/system.h" #include "titanic/sound/qmixer.h" namespace Titanic { @@ -63,11 +64,22 @@ void QMixer::qsWaveMixFlushChannel(int iChannel, uint flags) { } void QMixer::qsWaveMixSetPanRate(int iChannel, uint flags, uint rate) { - // Not currently implemented in ScummVM + ChannelEntry &channel = _channels[iChannel]; + channel._panRate = rate; + channel._volumeChangeStart = channel._volumeChangeEnd = 0; } void QMixer::qsWaveMixSetVolume(int iChannel, uint flags, uint volume) { - // Not currently implemented in ScummVM + ChannelEntry &channel = _channels[iChannel]; + + // QMixer volumes go from 0-32767, but we need to convert to 0-255 for ScummVM + assert(volume <= 32767); + byte newVolume = (volume >= 32700) ? 255 : volume * 255 / 32767; + + channel._volumeStart = newVolume; + channel._volumeEnd = volume * 255 / 100; // Convert from 0-100 (percent) to 0-255 + channel._volumeChangeStart = g_system->getMillis(); + channel._volumeChangeEnd = channel._volumeChangeStart + channel._panRate; } void QMixer::qsWaveMixSetSourcePosition(int iChannel, uint flags, const QSVECTOR &position) { @@ -133,6 +145,28 @@ void QMixer::qsWaveMixPump() { for (uint iChannel = 0; iChannel < _channels.size(); ++iChannel) { ChannelEntry &channel = _channels[iChannel]; + // If there's a transition in sound volume in progress, handle it + if (channel._volumeChangeEnd) { + byte oldVolume = channel._volume; + uint currentTicks = g_system->getMillis(); + + if (currentTicks >= channel._volumeChangeEnd) { + // Reached end of transition period + channel._volume = channel._volumeEnd; + channel._volumeChangeStart = channel._volumeChangeEnd = 0; + } else { + // Transition in progress, so figure out new volume + channel._volume = (int)channel._volumeStart + + ((int)channel._volumeEnd - (int)channel._volumeStart) * + (int)(currentTicks - channel._volumeChangeStart) / (int)channel._panRate; + } + + if (channel._volume != oldVolume && !channel._sounds.empty() + && channel._sounds.front()._started) { + _mixer->setChannelVolume(channel._sounds.front()._soundHandle, channel._volume); + } + } + // If the playing sound on the channel is finished, then call // the callback registered for it, and remove it from the list if (!channel._sounds.empty()) { @@ -143,7 +177,7 @@ void QMixer::qsWaveMixPump() { sound._waveFile->_stream->rewind(); _mixer->playStream(sound._waveFile->_soundType, &sound._soundHandle, sound._waveFile->_stream, - -1, 0xff, 0, DisposeAfterUse::NO); + -1, channel._volume, 0, DisposeAfterUse::NO); } else { // Sound is finished if (sound._callback) @@ -163,11 +197,11 @@ void QMixer::qsWaveMixPump() { if (!sound._started) { _mixer->playStream(sound._waveFile->_soundType, &sound._soundHandle, sound._waveFile->_stream, - -1, 0xff, 0, DisposeAfterUse::NO); + -1, channel._volume, 0, DisposeAfterUse::NO); sound._started = true; } } } } -} // End of namespace Titanic z +} // End of namespace Titanic diff --git a/engines/titanic/sound/qmixer.h b/engines/titanic/sound/qmixer.h index 4ba76a8969..6a25484c29 100644 --- a/engines/titanic/sound/qmixer.h +++ b/engines/titanic/sound/qmixer.h @@ -186,7 +186,20 @@ class QMixer { _started(false), _waveFile(waveFile), _callback(callback), _loops(loops), _userData(userData) {} }; struct ChannelEntry { + // Currently playing and any following queued sounds for the channel Common::List<SoundEntry> _sounds; + // Current channel volume + byte _volume; + // Current time in milliseconds for paning (volume) changes + uint _panRate; + // Fields used to transition between volume levels + uint _volumeChangeStart; + uint _volumeChangeEnd; + byte _volumeStart; + byte _volumeEnd; + + ChannelEntry() : _volume(0), _panRate(0), _volumeChangeStart(0), + _volumeChangeEnd(0), _volumeStart(0), _volumeEnd(0) {} }; private: Audio::Mixer *_mixer; diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index 7e791c2ba5..3288c4f4dd 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -68,15 +68,16 @@ void CSound::setVolume(uint handle, uint volume, uint seconds) { _soundManager.setVolume(handle, volume, seconds); } -void CSound::activateSound(CWaveFile *waveFile, bool freeFlag) { +void CSound::activateSound(CWaveFile *waveFile, DisposeAfterUse::Flag disposeAfterUse) { for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { CSoundItem *sound = *i; if (sound->_waveFile == waveFile) { sound->_active = true; - sound->_freeFlag = freeFlag; + sound->_disposeAfterUse = disposeAfterUse; - if (!freeFlag && waveFile->size() > 51200) - sound->_freeFlag = true; + // Anything bigger than 50Kb is automatically flagged to be free when finished + if (waveFile->size() > (50 * 1024)) + sound->_disposeAfterUse = DisposeAfterUse::YES; break; } } @@ -87,14 +88,18 @@ void CSound::stopChannel(int channel) { } void CSound::checkSounds() { - for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { + for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ) { CSoundItem *soundItem = *i; - if (soundItem->_active && soundItem->_freeFlag) { - if (_soundManager.isActive(soundItem->_waveFile)) { - _sounds.remove(soundItem); + + if (soundItem->_active && soundItem->_disposeAfterUse == DisposeAfterUse::YES) { + if (!_soundManager.isActive(soundItem->_waveFile)) { + i = _sounds.erase(i); delete soundItem; + continue; } } + + ++i; } } @@ -154,8 +159,11 @@ int CSound::playSound(const CString &name, CProximity &prox) { if (!waveFile) return -1; - prox._field6C = waveFile->fn1(); - activateSound(waveFile, prox._freeSoundFlag); + prox._soundDuration = waveFile->getDuration(); + if (prox._soundType != Audio::Mixer::kPlainSoundType) + waveFile->_soundType = prox._soundType; + + activateSound(waveFile, prox._disposeAfterUse); return _soundManager.playSound(*waveFile, prox); } @@ -201,8 +209,8 @@ int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &pr if (!waveFile) return -1; - prox._field6C = waveFile->fn1(); - activateSound(waveFile, prox._freeSoundFlag); + prox._soundDuration = waveFile->getDuration(); + activateSound(waveFile, prox._disposeAfterUse); return _soundManager.playSound(*waveFile, prox); } diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h index de95f9edf1..21f2a93f24 100644 --- a/engines/titanic/sound/sound.h +++ b/engines/titanic/sound/sound.h @@ -41,15 +41,17 @@ public: CWaveFile *_waveFile; File *_dialogueFileHandle; int _speechId; - bool _freeFlag; + DisposeAfterUse::Flag _disposeAfterUse; bool _active; public: CSoundItem() : ListItem(), _waveFile(nullptr), _dialogueFileHandle(nullptr), - _speechId(0), _freeFlag(false), _active(false) {} + _speechId(0), _disposeAfterUse(DisposeAfterUse::NO), _active(false) {} CSoundItem(const CString &name) : ListItem(), _name(name), _waveFile(nullptr), - _dialogueFileHandle(nullptr), _speechId(0), _freeFlag(false), _active(false) {} + _dialogueFileHandle(nullptr), _disposeAfterUse(DisposeAfterUse::NO), + _speechId(0), _active(false) {} CSoundItem(File *dialogueFile, int speechId) : ListItem(), _waveFile(nullptr), - _dialogueFileHandle(dialogueFile), _speechId(speechId), _freeFlag(false), _active(false) {} + _dialogueFileHandle(dialogueFile), _speechId(speechId), _active(false), + _disposeAfterUse(DisposeAfterUse::NO) {} }; class CSoundItemList : public List<CSoundItem> { @@ -126,7 +128,8 @@ public: /** * Flags a sound about to be played as activated */ - void activateSound(CWaveFile *waveFile, bool freeFlag); + void activateSound(CWaveFile *waveFile, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO); /** * Stops any sounds attached to a given channel diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp index ae806feb52..1fb0c7341c 100644 --- a/engines/titanic/sound/sound_manager.cpp +++ b/engines/titanic/sound/sound_manager.cpp @@ -171,7 +171,7 @@ int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) { } } - if (channel >= 0 || (channel = resetChannel(prox._channel)) != -1) { + if (channel >= 0 || (channel = resetChannel(prox._channelMode)) != -1) { return playWave(&waveFile, channel, flags, prox); } @@ -272,6 +272,7 @@ void QSoundManager::setVolume(int handle, uint volume, uint seconds) { for (uint idx = 0; idx < _slots.size(); ++idx) { Slot &slot = _slots[idx]; if (slot._handle == handle) { + assert(slot._channel >= 0); _channelsVolume[slot._channel] = volume; updateVolume(slot._channel, seconds * 1000); @@ -370,12 +371,15 @@ int QSoundManager::playWave(CWaveFile *waveFile, int iChannel, uint flags, CProx return 0; prox._channelVolume = CLIP(prox._channelVolume, 0, 100); - prox._fieldC = CLIP(prox._fieldC, -100, 100); + prox._balance = CLIP(prox._balance, -100, 100); int slotIndex = findFreeSlot(); if (slotIndex == -1) return -1; + // Set the volume + setChannelVolume(iChannel, prox._channelVolume, prox._channelMode); + switch (prox._positioningMode) { case POSMODE_POLAR: qsWaveMixSetPolarPosition(iChannel, 8, QSPOLAR(prox._azimuth, prox._range, prox._elevation)); @@ -395,7 +399,7 @@ int QSoundManager::playWave(CWaveFile *waveFile, int iChannel, uint flags, CProx break; } - if (prox._frequencyMultiplier || prox._field1C != 1.875) { + if (prox._frequencyMultiplier || prox._frequencyAdjust != 1.875) { uint freq = (uint)(waveFile->getFrequency() * prox._frequencyMultiplier); qsWaveMixSetFrequency(iChannel, 8, freq); } @@ -415,7 +419,7 @@ int QSoundManager::playWave(CWaveFile *waveFile, int iChannel, uint flags, CProx return slot._handle; } else { _sounds.flushChannel(waveFile, iChannel); - if (prox._freeSoundFlag) + if (prox._disposeAfterUse == DisposeAfterUse::YES) delete waveFile; return 0; } @@ -426,7 +430,7 @@ void QSoundManager::soundFreed(Audio::SoundHandle &handle) { } void QSoundManager::updateVolume(int channel, uint panRate) { - uint volume = _channelsVolume[channel] * 327; + double volume = _channelsVolume[channel] * 327; switch (_channelsMode[channel]) { case 0: @@ -451,7 +455,7 @@ void QSoundManager::updateVolume(int channel, uint panRate) { volume = (_musicPercent * volume) / 100; qsWaveMixSetPanRate(channel, 0, panRate); - qsWaveMixSetVolume(channel, 0, volume); + qsWaveMixSetVolume(channel, 0, (uint)volume); } void QSoundManager::updateVolumes() { diff --git a/engines/titanic/sound/titania_speech.cpp b/engines/titanic/sound/titania_speech.cpp index a07cc79334..d0ff423342 100644 --- a/engines/titanic/sound/titania_speech.cpp +++ b/engines/titanic/sound/titania_speech.cpp @@ -59,7 +59,7 @@ bool CTitaniaSpeech::ActMsg(CActMsg *msg) { movieSetAudioTiming(true); loadSound("a#12.wav"); sleep(1000); - playMovie(0, 187, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(0, 187, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); movieEvent(0); break; @@ -78,7 +78,7 @@ bool CTitaniaSpeech::ActMsg(CActMsg *msg) { visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#10.wav"); - playMovie(585, 706, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(585, 706, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); playSound("a#10.wav"); break; @@ -86,7 +86,7 @@ bool CTitaniaSpeech::ActMsg(CActMsg *msg) { visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#9.wav"); - playMovie(707, 905, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(707, 905, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); playSound("a#9.wav"); break; @@ -94,7 +94,7 @@ bool CTitaniaSpeech::ActMsg(CActMsg *msg) { visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#8.wav"); - playMovie(906, 938, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(906, 938, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); playSound("a#8.wav"); break; diff --git a/engines/titanic/sound/water_lapping_sounds.cpp b/engines/titanic/sound/water_lapping_sounds.cpp index 7616c4b43b..2dd4d7b7b6 100644 --- a/engines/titanic/sound/water_lapping_sounds.cpp +++ b/engines/titanic/sound/water_lapping_sounds.cpp @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #include "titanic/sound/water_lapping_sounds.h" @@ -49,7 +49,7 @@ void CWaterLappingSounds::load(SimpleFile *file) { _repeated = file->readNumber(); _startSeconds = file->readNumber(); _value = file->readNumber(); - + CRoomAutoSoundPlayer::load(file); } diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index 8c00637d73..3f855cd053 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -43,9 +43,8 @@ CWaveFile::~CWaveFile() { } } -int CWaveFile::fn1() { - // TODO - return 0; +uint CWaveFile::getDuration() const { + return _stream ? _stream->getLength().secs() : 0; } bool CWaveFile::loadSound(const CString &name) { diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h index aede0c9328..4237f1a203 100644 --- a/engines/titanic/sound/wave_file.h +++ b/engines/titanic/sound/wave_file.h @@ -45,7 +45,10 @@ public: CWaveFile(QSoundManager *owner); ~CWaveFile(); - int fn1(); + /** + * Returns the duration of the wave file in seconds + */ + uint getDuration() const; /** * Return the size of the wave file diff --git a/engines/titanic/star_control/surface_fader.cpp b/engines/titanic/star_control/surface_fader.cpp index 089ad51717..0ee03673a4 100644 --- a/engines/titanic/star_control/surface_fader.cpp +++ b/engines/titanic/star_control/surface_fader.cpp @@ -29,9 +29,9 @@ namespace Titanic { CSurfaceFader::CSurfaceFader() : CSurfaceFaderBase() { _dataP = new byte[_count]; - for (int idx = 0; idx < _count; ++idx) { - // TODO: Setup data bytes - } + for (int idx = 0; idx < _count; ++idx) + _dataP[idx] = (byte)(pow((double)idx / (double)_count, 1.299999952316284) + * (double)_count + 0.5); } CSurfaceFader::~CSurfaceFader() { diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp index c37bd83616..d4ebd5cef1 100644 --- a/engines/titanic/support/avi_surface.cpp +++ b/engines/titanic/support/avi_surface.cpp @@ -20,19 +20,20 @@ * */ -#include "titanic/support/avi_surface.h" -#include "titanic/support/screen_manager.h" -#include "titanic/support/video_surface.h" #include "common/system.h" #include "graphics/pixelformat.h" #include "video/avi_decoder.h" +#include "titanic/support/avi_surface.h" +#include "titanic/support/screen_manager.h" +#include "titanic/support/video_surface.h" +#include "titanic/titanic.h" namespace Titanic { Video::AVIDecoder::AVIVideoTrack &AVIDecoder::getVideoTrack() { for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++) if ((*it)->getTrackType() == Track::kTrackTypeVideo) - return *static_cast<AVIVideoTrack *>(*it); + return *dynamic_cast<AVIVideoTrack *>(*it); error("Could not find video track"); } @@ -338,9 +339,9 @@ bool AVISurface::addEvent(int frameNumber, CGameObject *obj) { } void AVISurface::setFrameRate(double rate) { - _decoders[0]->setRate(Common::Rational(rate)); + _decoders[0]->setRate(Common::Rational((int)rate)); if (_decoders[1]) - _decoders[1]->setRate(Common::Rational(rate)); + _decoders[1]->setRate(Common::Rational((int)rate)); } Graphics::ManagedSurface *AVISurface::getSecondarySurface() { @@ -358,4 +359,36 @@ Graphics::ManagedSurface *AVISurface::duplicateSecondaryFrame() const { } } +void AVISurface::playCutscene(const Rect &r, uint startFrame, uint endFrame) { + bool isDifferent = _movieFrameSurface[0]->w != r.width() || + _movieFrameSurface[0]->h != r.height(); + + startAtFrame(startFrame); + while (_currentFrame < (int)endFrame && !g_vm->shouldQuit()) { + if (isNextFrame()) { + renderFrame(); + _currentFrame = _decoders[0]->getCurFrame(); + + if (isDifferent) { + // Clear the destination area, and use the transBlitFrom method, + // which supports arbitrary scaling, to reduce to the desired size + g_vm->_screen->fillRect(r, 0); + g_vm->_screen->transBlitFrom(*_movieFrameSurface[0], + Common::Rect(0, 0, _movieFrameSurface[0]->w, _movieFrameSurface[0]->h), r); + } else { + g_vm->_screen->blitFrom(*_movieFrameSurface[0], Common::Point(r.left, r.top)); + } + + g_vm->_screen->update(); + g_vm->_events->pollEvents(); + } + + // Brief wait, and check at the same time for clicks to abort the clip + if (g_vm->_events->waitForPress(10)) + break; + } + + stop(); +} + } // End of namespace Titanic diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h index d21182bca9..54b0155bdd 100644 --- a/engines/titanic/support/avi_surface.h +++ b/engines/titanic/support/avi_surface.h @@ -176,6 +176,11 @@ public: * Returns true if it's time for the next */ bool isNextFrame() const; + + /** + * Plays an interruptable cutscene + */ + void playCutscene(const Rect &r, uint startFrame, uint endFrame); }; } // End of namespace Titanic diff --git a/engines/titanic/support/credit_text.cpp b/engines/titanic/support/credit_text.cpp index 0e9715aaa6..009c3f4944 100644 --- a/engines/titanic/support/credit_text.cpp +++ b/engines/titanic/support/credit_text.cpp @@ -28,7 +28,7 @@ namespace Titanic { CCreditText::CCreditText() : _screenManagerP(nullptr), _field14(0), _ticks(0), _fontHeight(1), _objectP(nullptr), _totalHeight(0), _field40(0), _field44(0), _field48(0), _field4C(0), _field50(0), - _field54(0), _field58(0), _field5C(0) { + _field54(0), _field58(0), _counter(0) { } void CCreditText::clear() { @@ -52,7 +52,7 @@ void CCreditText::load(CGameObject *obj, CScreenManager *screenManager, _field50 = 0; _field54 = 0; _field58 = 0; - _field5C = 0; + _counter = 0; } void CCreditText::setup() { @@ -87,8 +87,11 @@ void CCreditText::setup() { } _groups.push_back(group); + if (hasDots) + handleDots(group); } + _screenManagerP->setFontNumber(oldFontNumber); _groupIt = _groups.begin(); _lineIt = (*_groupIt)->_lines.begin(); _totalHeight = _objectP->getBounds().height() + _fontHeight * 2; @@ -147,7 +150,108 @@ void CCreditText::handleDots(CCreditLineGroup *group) { } bool CCreditText::draw() { - return false; + if (_groupIt == _groups.end()) + return false; + + if (++_counter > 200) { + _field44 += _field50; + _field48 += _field54; + _field4C += _field58; + _field50 = g_vm->getRandomNumber(63) + 192 - _field44; + _field54 = g_vm->getRandomNumber(63) + 192 - _field48; + _field58 = g_vm->getRandomNumber(63) + 192 - _field4C; + _counter = 0; + } + + // Positioning adjustment, changing lines and/or group if necessary + int yDiff = (int)(g_vm->_events->getTicksCount() - _ticks) / 22 - _field40; + while (yDiff > 0) { + if (_totalHeight > 0) { + if (yDiff < _totalHeight) { + _totalHeight -= yDiff; + _field40 += yDiff; + yDiff = 0; + } else { + yDiff -= _totalHeight; + _field40 += _totalHeight; + _totalHeight = 0; + } + } else { + if (yDiff < _fontHeight) + break; + + ++_lineIt; + yDiff -= _fontHeight; + _field40 += _fontHeight; + + if (_lineIt == (*_groupIt)->_lines.end()) { + // Move to next line group + ++_groupIt; + if (_groupIt == _groups.end()) + // Reached end of groups + return false; + + _lineIt = (*_groupIt)->_lines.begin(); + _totalHeight = _fontHeight * 3 / 2; + } + } + } + + int oldFontNumber = _screenManagerP->setFontNumber(3); + CCreditLineGroups::iterator groupIt = _groupIt; + CCreditLines::iterator lineIt = _lineIt; + + Point textPos; + for (textPos.y = _rect.top + _totalHeight; textPos.y <= _rect.bottom; + textPos.y += _fontHeight) { + int textR = _field44 + _field50 * _counter / 200; + int textG = _field48 + _field54 * _counter / 200; + int textB = _field4C + _field58 * _counter / 200; + + // Single iteration loop to figure out RGB values for the line + do { + int percent = 0; + if (textPos.y < (_rect.top + 2 * _fontHeight)) { + percent = (textPos.y - _rect.top) * 100 / (_fontHeight * 2); + if (percent < 0) + percent = 0; + } else { + int bottom = _rect.bottom - 2 * _fontHeight; + if (textPos.y < bottom) + break; + + percent = (_rect.bottom - textPos.y) * 100 + / (_fontHeight * 2); + } + + // Adjust the RGB to the specified percentage intensity + textR = textR * percent / 100; + textG = textG * percent / 100; + textB = textB * percent / 100; + } while (0); + + // Write out the line + _screenManagerP->setFontColor(textR, textG, textB); + textPos.x = _rect.left + (_rect.width() - (*lineIt)->_lineWidth) / 2; + _screenManagerP->writeString(SURFACE_BACKBUFFER, textPos, + _rect, (*lineIt)->_line, (*lineIt)->_lineWidth); + + // Move to next line + ++lineIt; + if (lineIt == (*groupIt)->_lines.end()) { + ++groupIt; + if (groupIt == _groups.end()) + // Finished all lines + break; + + lineIt = (*groupIt)->_lines.begin(); + textPos.y += _fontHeight * 3 / 2; + } + } + + _objectP->makeDirty(); + _screenManagerP->setFontNumber(oldFontNumber); + return true; } } // End of namespace Titanic diff --git a/engines/titanic/support/credit_text.h b/engines/titanic/support/credit_text.h index ec8fc22cda..3e5bfca0c2 100644 --- a/engines/titanic/support/credit_text.h +++ b/engines/titanic/support/credit_text.h @@ -68,11 +68,11 @@ public: int _field14; CCreditLineGroups _groups; uint _ticks; - uint _fontHeight; + int _fontHeight; CGameObject *_objectP; CCreditLineGroups::iterator _groupIt; CCreditLines::iterator _lineIt; - uint _totalHeight; + int _totalHeight; int _field40; int _field44; int _field48; @@ -80,7 +80,7 @@ public: int _field50; int _field54; int _field58; - int _field5C; + int _counter; public: CCreditText(); diff --git a/engines/titanic/support/direct_draw.cpp b/engines/titanic/support/direct_draw.cpp index 6958896077..8e510861ae 100644 --- a/engines/titanic/support/direct_draw.cpp +++ b/engines/titanic/support/direct_draw.cpp @@ -28,9 +28,8 @@ namespace Titanic { -DirectDraw::DirectDraw(TitanicEngine *vm) : _vm(vm), - _windowed(false), _fieldC(0), _width(0), _height(0), - _bpp(0), _numBackSurfaces(0), _field24(0) { +DirectDraw::DirectDraw() : _windowed(false), _width(0), _height(0), + _bpp(0), _numBackSurfaces(0) { } void DirectDraw::setDisplayMode(int width, int height, int bpp, int refreshRate) { @@ -55,7 +54,7 @@ DirectDrawSurface *DirectDraw::createSurfaceFromDesc(const DDSurfaceDesc &desc) /*------------------------------------------------------------------------*/ -DirectDrawManager::DirectDrawManager(TitanicEngine *vm, bool windowed) : _directDraw(vm) { +DirectDrawManager::DirectDrawManager(TitanicEngine *vm, bool windowed) { _mainSurface = nullptr; _backSurfaces[0] = _backSurfaces[1] = nullptr; _directDraw._windowed = windowed; @@ -75,18 +74,6 @@ void DirectDrawManager::initVideo(int width, int height, int bpp, int numBackSur } } -void DirectDrawManager::setResolution() { - // TODO -} - -void DirectDrawManager::proc2() { - -} - -void DirectDrawManager::proc3() { - -} - void DirectDrawManager::initFullScreen() { debugC(ERROR_BASIC, kDebugGraphics, "Creating surfaces"); _directDraw.setDisplayMode(_directDraw._width, _directDraw._height, diff --git a/engines/titanic/support/direct_draw.h b/engines/titanic/support/direct_draw.h index 85c344c600..a7e9cc8d93 100644 --- a/engines/titanic/support/direct_draw.h +++ b/engines/titanic/support/direct_draw.h @@ -32,18 +32,14 @@ namespace Titanic { class TitanicEngine; class DirectDraw { -private: - TitanicEngine *_vm; public: bool _windowed; - int _fieldC; int _width; int _height; int _bpp; int _numBackSurfaces; - int _field24; public: - DirectDraw(TitanicEngine *vm); + DirectDraw(); /** * Sets a new display mode @@ -78,12 +74,6 @@ public: */ void initVideo(int width, int height, int bpp, int numBackSurfaces); - void setResolution(); - - void proc2(); - - void proc3(); - /** * Initializes the surfaces in windowed mode */ diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp index 89e0a1d10e..ee3a3e1cde 100644 --- a/engines/titanic/support/files_manager.cpp +++ b/engines/titanic/support/files_manager.cpp @@ -28,7 +28,7 @@ namespace Titanic { CFilesManager::CFilesManager() : _gameManager(nullptr), _assetsPath("Assets"), - _field0(0), _drive(-1), _field18(0), _field1C(0), _field3C(0) { + _drive(-1) { loadResourceIndex(); } @@ -104,8 +104,9 @@ void CFilesManager::loadDrive() { resetView(); } -void CFilesManager::debug(CScreenManager *screenManager) { - warning("TODO: CFilesManager::debug"); +void CFilesManager::insertCD(CScreenManager *screenManager) { + // We not support running game directly from the original CDs, + // so this method can remain stubbed } void CFilesManager::resetView() { @@ -115,10 +116,6 @@ void CFilesManager::resetView() { } } -void CFilesManager::fn4(const CString &name) { - warning("TODO: CFilesManager::fn4"); -} - void CFilesManager::preload(const CString &name) { // We don't currently do any preloading of resources } diff --git a/engines/titanic/support/files_manager.h b/engines/titanic/support/files_manager.h index ec0c7fc008..6f56327968 100644 --- a/engines/titanic/support/files_manager.h +++ b/engines/titanic/support/files_manager.h @@ -48,13 +48,7 @@ private: Common::File _datFile; ResourceHash _resources; CFilesManagerList _list; - CString _string1; - CString _string2; - int _field0; int _drive; - int _field18; - int _field1C; - int _field3C; const CString _assetsPath; private: void loadResourceIndex(); @@ -84,15 +78,16 @@ public: */ void loadDrive(); - void debug(CScreenManager *screenManager); + /** + * Shows a dialog for inserting a new CD + */ + void insertCD(CScreenManager *screenManager); /** * Resets the view being displayed */ void resetView(); - void fn4(const CString &name); - /** * Preloads and caches a file for access shortly */ diff --git a/engines/titanic/support/font.cpp b/engines/titanic/support/font.cpp index 69c0efe504..e519237c3b 100644 --- a/engines/titanic/support/font.cpp +++ b/engines/titanic/support/font.cpp @@ -179,6 +179,67 @@ int STFont::writeString(CVideoSurface *surface, const Rect &rect1, const Rect &d return endP ? endP - str.c_str() : 0; } +void STFont::writeString(CVideoSurface *surface, const Point &destPos, Rect &clipRect, + const CString &str, int lineWidth) { + if (!_fontHeight || !_dataPtr || str.empty()) + return; + if (!lineWidth) + // No line width specified, so get in the width + lineWidth = stringWidth(str); + + Rect textRect(0, 0, lineWidth, _fontHeight); + Point textPt = destPos; + + // Perform clipping as necessary if the text will fall outside clipping area + if (textPt.y > clipRect.bottom) + return; + + if ((textPt.y + textRect.height()) > clipRect.bottom) + textRect.bottom = textRect.top - textPt.y + clipRect.bottom; + + if (textPt.y < clipRect.top) { + if ((textPt.y + textRect.height()) < clipRect.top) + return; + + textRect.top += clipRect.top - textPt.y; + textPt.y = clipRect.top; + } + + // Iterate through each character of the string + for (const byte *srcP = (const byte *)str.c_str(); *srcP; ++srcP) { + byte c = *srcP; + if (c == 0xE9) + c = '$'; + + // Form a rect of the area of the next character to draw + Rect charRect(_chars[c]._offset, textRect.top, + _chars[c]._offset + _chars[c]._width, textRect.bottom); + + if (textPt.x < clipRect.left) { + // Character is either partially or entirely left off-screen + if ((textPt.x + charRect.width()) < clipRect.left) { + textPt.x += _chars[c]._width; + continue; + } + + // Partially clipped on left-hand side + charRect.left = clipRect.left - textPt.x; + textPt.x = clipRect.left; + } else if ((textPt.x + charRect.width()) > clipRect.right) { + if (textPt.x > clipRect.right) + // Now entirely off right-hand side, so stop drawing + break; + + // Partially clipped on right-hand side + charRect.right += clipRect.right - textPt.x - charRect.width(); + } + + // At this point, we know we've got to draw at least part of a character, + // and have figured out the area of the character to draw + copyRect(surface, textPt, charRect); + } +} + WriteCharacterResult STFont::writeChar(CVideoSurface *surface, unsigned char c, const Point &pt, const Rect &destRect, const Rect *srcRect) { if (c == 233) diff --git a/engines/titanic/support/font.h b/engines/titanic/support/font.h index 591fb4661c..6c4fe8e9c3 100644 --- a/engines/titanic/support/font.h +++ b/engines/titanic/support/font.h @@ -99,6 +99,12 @@ public: int yOffset, const CString &str, CTextCursor *textCursor); /** + * Write a string to the specified surface + */ + void writeString(CVideoSurface *surface, const Point &destPos, Rect &clipRect, + const CString &str, int lineWidth = 0); + + /** * Get the text area a string will fit into * @param str String * @param maxWidth Maximum width in pixels diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp index 068267cb18..d342e6cccb 100644 --- a/engines/titanic/support/mouse_cursor.cpp +++ b/engines/titanic/support/mouse_cursor.cpp @@ -67,7 +67,6 @@ CMouseCursor::~CMouseCursor() { void CMouseCursor::loadCursorImages() { const CResourceKey key("ycursors.avi"); - g_vm->_filesManager->fn4(key.getString()); // Iterate through getting each cursor for (int idx = 0; idx < NUM_CURSORS; ++idx) { @@ -128,8 +127,11 @@ void CMouseCursor::unlockE4() { CScreenManager::_screenManagerPtr->_inputHandler->decLockCount(); } -void CMouseCursor::saveState(int v1, int v2, int v3) { - // TODO +void CMouseCursor::setPosition(const Point &pt, double rate) { + assert(rate >= 0.0 && rate <= 1.0); + + // TODO: Figure out use of the rate parameter + g_system->warpMouse(pt.x, pt.y); } } // End of namespace Titanic diff --git a/engines/titanic/support/mouse_cursor.h b/engines/titanic/support/mouse_cursor.h index 7a81ad43fa..74fb1f6113 100644 --- a/engines/titanic/support/mouse_cursor.h +++ b/engines/titanic/support/mouse_cursor.h @@ -24,8 +24,8 @@ #define TITANIC_MOUSE_CURSOR_H #include "common/scummsys.h" -#include "common/rect.h" #include "graphics/managed_surface.h" +#include "titanic/support/rect.h" namespace Titanic { @@ -105,7 +105,10 @@ public: void lockE4(); void unlockE4(); - void saveState(int v1, int v2, int v3); + /** + * Sets the mouse to a new position + */ + void setPosition(const Point &pt, double rate); }; diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp index 50a55c8218..e863185f84 100644 --- a/engines/titanic/support/movie.cpp +++ b/engines/titanic/support/movie.cpp @@ -133,22 +133,14 @@ void OSMovie::playCutscene(const Rect &drawRect, uint startFrame, uint endFrame) drawRect.top + (heightLess ? CLIP_HEIGHT_REDUCED : CLIP_HEIGHT) ); - uint timePerFrame = (uint)(1000.0 / _aviSurface._frameRate); + // Set a new event target whilst the clip plays, so standard scene drawing isn't called + CEventTarget eventTarget; + g_vm->_events->addTarget(&eventTarget); - for (; startFrame < endFrame; ++startFrame) { - // Set the frame - _aviSurface.setFrame(startFrame); + _aviSurface.setFrame(startFrame); + _aviSurface.playCutscene(r, startFrame, endFrame); - // TODO: See if we need to do anything further here. The original had a bunch - // of calls and using of the _movieSurface; perhaps to allow scaling down - // videos to half-size - if (widthLess || heightLess) - warning("Not properly reducing clip size: %d %d", r.width(), r.height()); - - // Wait for the next frame, unless the user interrupts the clip - if (g_vm->_events->waitForPress(timePerFrame)) - break; - } + g_vm->_events->removeTarget(); } void OSMovie::stop() { diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp index b0d852104c..bcf43fc8cb 100644 --- a/engines/titanic/support/screen_manager.cpp +++ b/engines/titanic/support/screen_manager.cpp @@ -239,10 +239,25 @@ int OSScreenManager::writeString(int surfaceNum, const Rect &destRect, yOffset, str, textCursor); } -int OSScreenManager::writeString(int surfaceNum, const Rect &srcRect, - const Rect &destRect, const CString &str, CTextCursor *textCursor) { - // TODO - return 0; +void OSScreenManager::writeString(int surfaceNum, const Point &destPos, + const Rect &clipRect, const CString &str, int lineWidth) { + CVideoSurface *surface; + Rect bounds; + + if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) { + surface = _backSurfaces[surfaceNum]._surface; + bounds = _backSurfaces[surfaceNum]._bounds; + } else if (surfaceNum == -1) { + surface = _frontRenderSurface; + bounds = Rect(0, 0, surface->getWidth(), surface->getHeight()); + } else { + return; + } + + Rect destRect = clipRect; + destRect.constrain(bounds); + + _fonts[_fontNumber].writeString(surface, destPos, destRect, str, lineWidth); } void OSScreenManager::setFontColor(byte r, byte g, byte b) { diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h index 0736f1393c..cad6901b02 100644 --- a/engines/titanic/support/screen_manager.h +++ b/engines/titanic/support/screen_manager.h @@ -140,13 +140,13 @@ public: /** * Write a string * @param surfaceNum Destination surface - * @param srcRect Drawing area - * @param destRect Bounds of dest surface + * @param destPos Position to start writing text at + * @param clipRect Clipping area to constrain text to * @param str Line or lines to write - * @param textCursor Optional text cursor pointer + * @param maxWidth Maximum allowed line width */ - virtual int writeString(int surfaceNum, const Rect &srcRect, - const Rect &destRect, const CString &str, CTextCursor *textCursor) = 0; + virtual void writeString(int surfaceNum, const Point &destPos, + const Rect &clipRect, const CString &str, int maxWidth) = 0; /** * Set the font color @@ -322,13 +322,13 @@ public: /** * Write a string * @param surfaceNum Destination surface - * @param srcRect Drawing area - * @param destRect Bounds of dest surface + * @param destPos Position to start writing text at + * @param clipRect Clipping area to constrain text to * @param str Line or lines to write - * @param textCursor Optional text cursor pointer + * @param lineWidth Width in pixels of the string, if known. */ - virtual int writeString(int surfaceNum, const Rect &srcRect, - const Rect &destRect, const CString &str, CTextCursor *textCursor); + virtual void writeString(int surfaceNum, const Point &destPos, + const Rect &clipRect, const CString &str, int lineWidth = 0); /** * Set the font color diff --git a/engines/titanic/support/simple_file.h b/engines/titanic/support/simple_file.h index f5d0bc7c1b..01aaa86925 100644 --- a/engines/titanic/support/simple_file.h +++ b/engines/titanic/support/simple_file.h @@ -278,7 +278,7 @@ public: * Set up a stream for write access */ virtual void open(Common::OutSaveFile *stream) { - SimpleFile::open(Common::wrapCompressedWriteStream(stream)); + SimpleFile::open(new Common::OutSaveFile(Common::wrapCompressedWriteStream(stream))); } }; diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp index 594f660937..b5f668793a 100644 --- a/engines/titanic/support/video_surface.cpp +++ b/engines/titanic/support/video_surface.cpp @@ -163,7 +163,19 @@ void CVideoSurface::blitRect2(const Rect &srcRect, const Rect &destRect, CVideoS } void CVideoSurface::movieBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) { - // TODO + if (lock()) { + if (src->lock()) { + Graphics::ManagedSurface *srcSurface = src->_rawSurface; + Graphics::ManagedSurface *destSurface = _rawSurface; + + // TODO: Handle the transparency mode correctly + destSurface->blitFrom(*srcSurface, srcRect, Point(srcRect.left, srcRect.top)); + + src->unlock(); + } + + unlock(); + } } uint CVideoSurface::getTransparencyColor() { diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp index 7da2ab6201..b773e8af30 100644 --- a/engines/titanic/true_talk/bellbot_script.cpp +++ b/engines/titanic/true_talk/bellbot_script.cpp @@ -44,8 +44,7 @@ static const RoomDialogueId ROOM_DIALOGUE_IDS[] = { BellbotScript::BellbotScript(int val1, const char *charClass, int v2, const char *charName, int v3, int val2) : TTnpcScript(val1, charClass, v2, charName, v3, val2, -1, -1, -1, 0), - _field2D0(0), _field2D4(0), _field2D8(0), _field2DC(0), - _room107First(false) { + _responseFlag(false), _room107First(false) { CTrueTalkManager::setFlags(25, 0); CTrueTalkManager::setFlags(24, 0); CTrueTalkManager::setFlags(40, 0); @@ -72,7 +71,7 @@ void BellbotScript::setupSentences() { for (int idx = 1; idx < 20; ++idx) _sentences[idx].load(CString::format("Sentences/Bellbot/%d", idx)); - _field2DC = 0; + _responseFlag = false; _field68 = 0; _entryCount = 0; } @@ -370,7 +369,7 @@ ScriptChangedResult BellbotScript::scriptChanged(const TTroomScript *roomScript, break; case 157: - _field2DC = 1; + _responseFlag = true; break; case 158: @@ -378,7 +377,7 @@ ScriptChangedResult BellbotScript::scriptChanged(const TTroomScript *roomScript, break; case 3: - if (_field2DC) { + if (_responseFlag) { if (randomResponse0(roomScript, id)) return SCR_2; } else { @@ -386,7 +385,7 @@ ScriptChangedResult BellbotScript::scriptChanged(const TTroomScript *roomScript, applyResponse(); } - _field2DC = 0; + _responseFlag = false; CTrueTalkManager::_v9 = 0; // Deliberate fall-through default: diff --git a/engines/titanic/true_talk/bellbot_script.h b/engines/titanic/true_talk/bellbot_script.h index 3080b56902..6f57ee718f 100644 --- a/engines/titanic/true_talk/bellbot_script.h +++ b/engines/titanic/true_talk/bellbot_script.h @@ -35,10 +35,7 @@ private: TTsentenceEntries _sentences[20]; TTcommonPhraseArray _phrases; int _array[150]; - int _field2D0; - int _field2D4; - int _field2D8; - int _field2DC; + bool _responseFlag; bool _room107First; private: /** diff --git a/engines/titanic/true_talk/dialogue_file.cpp b/engines/titanic/true_talk/dialogue_file.cpp index 34eb164779..cbd3685315 100644 --- a/engines/titanic/true_talk/dialogue_file.cpp +++ b/engines/titanic/true_talk/dialogue_file.cpp @@ -60,7 +60,7 @@ DialogueResource *CDialogueFile::addToCache(int index) { // Scan cache for a free slot uint cacheIndex = 0; - while (cacheIndex < _cache.size() && !_cache[cacheIndex]._active) + while (cacheIndex < _cache.size() && _cache[cacheIndex]._active) ++cacheIndex; if (cacheIndex == _cache.size()) return nullptr; diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp index 64e789a4b9..2741e6b640 100644 --- a/engines/titanic/true_talk/script_handler.cpp +++ b/engines/titanic/true_talk/script_handler.cpp @@ -33,9 +33,8 @@ namespace Titanic { CScriptHandler::CScriptHandler(CTitleEngine *owner, int val1, int val2) : _owner(owner), _script(owner->_script), _resources(g_vm->_exeResources), - _parser(this), _field10(0), _inputCtr(0), - _concept1P(nullptr), _concept2P(nullptr), _concept3P(nullptr), - _concept4P(nullptr), _field30(0) { + _parser(this), _inputCtr(0), _concept1P(nullptr), + _concept2P(nullptr), _concept3P(nullptr), _concept4P(nullptr) { g_vm->_scriptHandler = this; g_vm->_script = _script; g_vm->_exeResources.reset(this, val1, val2); @@ -60,19 +59,18 @@ ScriptChangedResult CScriptHandler::scriptChanged(TTroomScript *roomScript, TTnp if (result == SCR_1) result = npcScript->notifyScript(roomScript, dialogueId); - if (result != SCR_3 && result != SCR_4) - return result; + if (dialogueId == 3 || dialogueId == 4) { + delete _concept1P; + delete _concept2P; + delete _concept3P; + delete _concept4P; + _concept1P = nullptr; + _concept2P = nullptr; + _concept3P = nullptr; + _concept4P = nullptr; + } ++_inputCtr; - delete _concept1P; - delete _concept2P; - delete _concept3P; - delete _concept4P; - _concept1P = nullptr; - _concept2P = nullptr; - _concept3P = nullptr; - _concept4P = nullptr; - return result; } diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h index 193c60f719..01aa2ef1c5 100644 --- a/engines/titanic/true_talk/script_handler.h +++ b/engines/titanic/true_talk/script_handler.h @@ -39,9 +39,7 @@ class CScriptHandler { private: CTitleEngine *_owner; CExeResources &_resources; - int _field10; int _inputCtr; - int _field30; private: void handleWord1(const TTstring *str); void handleWord2(const TTstring *str); diff --git a/engines/titanic/true_talk/title_engine.cpp b/engines/titanic/true_talk/title_engine.cpp index 4dd45ba335..079067389d 100644 --- a/engines/titanic/true_talk/title_engine.cpp +++ b/engines/titanic/true_talk/title_engine.cpp @@ -40,8 +40,7 @@ void CTitleEngine::setup(int val1, int val2) { /*------------------------------------------------------------------------*/ -STtitleEngine::STtitleEngine(): CTitleEngine(), - _responseP(nullptr), _field58(0) { +STtitleEngine::STtitleEngine(): CTitleEngine(), _responseP(nullptr) { } STtitleEngine::~STtitleEngine() { @@ -49,7 +48,6 @@ STtitleEngine::~STtitleEngine() { } void STtitleEngine::reset() { - _field58 = 0; _indexes.clear(); } @@ -58,6 +56,7 @@ void STtitleEngine::setup(int val1, int val2) { } int STtitleEngine::setResponse(TTscriptBase *script, TTresponse *response) { + _responseP = response; _indexes.clear(); for (TTresponse *respP = response; respP; respP = respP->getNext()) { _indexes.push_back(respP->getDialogueId()); @@ -66,10 +65,6 @@ int STtitleEngine::setResponse(TTscriptBase *script, TTresponse *response) { return 0; } -void STtitleEngine::dump(int val1, int val2) { - // TODO -} - SimpleFile *STtitleEngine::open(const CString &name) { Common::SeekableReadStream *stream = g_vm->_filesManager->getResource( CString::format("TEXT/%s", name.c_str())); diff --git a/engines/titanic/true_talk/title_engine.h b/engines/titanic/true_talk/title_engine.h index afd2d3b92f..ca7a5dcd14 100644 --- a/engines/titanic/true_talk/title_engine.h +++ b/engines/titanic/true_talk/title_engine.h @@ -57,12 +57,6 @@ public: * Sets a conversation reponse */ virtual int setResponse(TTscriptBase *script, TTresponse *response) { return SS_4; } - - virtual int proc4(int unused) const = 0; - virtual int proc5(int64 unused) const = 0; - virtual int proc6(int64 unused) const = 0; - virtual int proc7(int64 unused) const = 0; - virtual int proc8() const = 0; /** * Open a designated file @@ -73,8 +67,7 @@ public: class STtitleEngine : public CTitleEngine { private: Common::SeekableReadStream *_stream; - TTresponse *_responseP; - int _field58; + const TTresponse *_responseP; public: Common::Array<uint> _indexes; Common::Array<byte> _data; @@ -94,14 +87,6 @@ public: */ virtual int setResponse(TTscriptBase *script, TTresponse *response); - virtual void dump(int val1, int val2); - - virtual int proc4(int unused) const { return 0; } - virtual int proc5(int64 unused) const { return 0; } - virtual int proc6(int64 unused) const { return 0; } - virtual int proc7(int64 unused) const { return 0; } - virtual int proc8() const { return 0; } - /** * Open a designated file */ diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp index 19beee9796..be9ca667de 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -219,10 +219,6 @@ void CTrueTalkManager::removeCompleted() { } } -void CTrueTalkManager::update2() { - //warning("CTrueTalkManager::update2"); -} - void CTrueTalkManager::start(CTrueTalkNPC *npc, uint id, CViewItem *view) { TTnpcScript *npcScript = getNpcScript(npc); TTroomScript *roomScript = getRoomScript(); @@ -351,14 +347,14 @@ void CTrueTalkManager::setDialogue(CTrueTalkNPC *npc, TTroomScript *roomScript, if (dialogueStr.empty()) return; - int soundId = readDialogSound(); + uint speechDuration = readDialogueSpeech(); TTtalker *talker = new TTtalker(this, npc); _talkers.push_back(talker); bool isParrot = npc->getName().contains("parrot"); triggerNPC(npc); playSpeech(talker, roomScript, view, isParrot); - talker->speechStarted(dialogueStr, _titleEngine._indexes[0], soundId); + talker->speechStarted(dialogueStr, _titleEngine._indexes[0], speechDuration); } #define STRING_BUFFER_SIZE 2048 @@ -404,30 +400,30 @@ CString CTrueTalkManager::readDialogueString() { return result; } -int CTrueTalkManager::readDialogSound() { - _field18 = 0; +uint CTrueTalkManager::readDialogueSpeech() { + _speechDuration = 0; for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) { CWaveFile *waveFile = _gameManager->_sound.getTrueTalkSound( _dialogueFile, _titleEngine._indexes[idx] - _dialogueId); if (waveFile) { - _field18 = waveFile->fn1(); + _speechDuration += waveFile->getDuration(); } } - return _field18; + return _speechDuration; } void CTrueTalkManager::triggerNPC(CTrueTalkNPC *npc) { CTrueTalkSelfQueueAnimSetMsg queueSetMsg; if (queueSetMsg.execute(npc)) { - if (_field18 > 300) { - CTrueTalkQueueUpAnimSetMsg upMsg(_field18); + if (_speechDuration > 300) { + CTrueTalkQueueUpAnimSetMsg upMsg(_speechDuration); upMsg.execute(npc); } } else { CTrueTalkGetAnimSetMsg getAnimMsg; - if (_field18 > 300) { + if (_speechDuration > 300) { do { getAnimMsg.execute(npc); if (!getAnimMsg._endFrame) @@ -439,10 +435,10 @@ void CTrueTalkManager::triggerNPC(CTrueTalkNPC *npc) { uint numFrames = getAnimMsg._endFrame - getAnimMsg._startFrame; int64 val = (numFrames * 1000) * 0x88888889; uint diff = (val >> (32 + 5)) - 500; - _field18 += diff; + _speechDuration += diff; getAnimMsg._index++; - } while (_field18 > 0); + } while (_speechDuration > 0); } } } @@ -494,13 +490,13 @@ void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CV // Setup proximities CProximity p1, p2, p3; if (isParrot) { - p1._channel = 3; - p2._channel = 5; - p3._channel = 4; + p1._channelMode = 3; + p2._channelMode = 5; + p3._channelMode = 4; } else { - p1._channel = 0; - p2._channel = 1; - p3._channel = 2; + p1._channelMode = 0; + p2._channelMode = 1; + p3._channelMode = 2; } if (milli > 0) { @@ -517,7 +513,7 @@ void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CV p2._elevation = 0; } - _gameManager->_sound.stopChannel(p1._channel); + _gameManager->_sound.stopChannel(p1._channelMode); if (view) { p1._positioningMode = POSMODE_VECTOR; view->getPosition(p1._posX, p1._posY, p1._posZ); @@ -589,9 +585,9 @@ int CTrueTalkManager::getPassengerClass() const { return gameState ? gameState->_passengerClass : 4; } -int CTrueTalkManager::getState14() const { +Season CTrueTalkManager::getCurrentSeason() const { CGameState *gameState = getGameState(); - return gameState ? gameState->_field14 : 0; + return gameState ? gameState->_seasonNum : SEASON_SUMMER; } } // End of namespace Titanic diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h index 8a8895917a..3abf4c181c 100644 --- a/engines/titanic/true_talk/true_talk_manager.h +++ b/engines/titanic/true_talk/true_talk_manager.h @@ -31,6 +31,7 @@ #include "titanic/true_talk/tt_quotes_tree.h" #include "titanic/true_talk/tt_scripts.h" #include "titanic/true_talk/tt_talker.h" +#include "titanic/game_state.h" namespace Titanic { @@ -49,7 +50,7 @@ private: int _currentCharId; CDialogueFile *_dialogueFile; int _dialogueId; - int _field18; + uint _speechDuration; TTtalkerList _talkers; private: /** @@ -95,9 +96,10 @@ private: CString readDialogueString(); /** - * Read in the sound from the dialogue file + * Read in the speech from the dialogue file + * @returns Duration of the speech in seconds */ - int readDialogSound(); + uint readDialogueSpeech(); /** * Triggers animation for the NPC @@ -200,8 +202,6 @@ public: */ CGameManager *getGameManager() const; - void update2(); - /** * Start a TrueTalk conversation */ @@ -237,7 +237,7 @@ public: */ int getPassengerClass() const; - int getState14() const; + Season getCurrentSeason() const; }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index 61c3b0e00c..74e2f4f66b 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -332,7 +332,7 @@ int TTnpcScript::handleQuote(const TTroomScript *roomScript, const TTsentence *s uint TTnpcScript::getRangeValue(uint id) { TTscriptRange *range = findRange(id); if (!range) - return 0; + return id; switch (range->_mode) { case SF_RANDOM: { @@ -579,14 +579,14 @@ int TTnpcScript::getValue(int testNum) const { case 4: if (g_vm->_trueTalkManager) { - switch (g_vm->_trueTalkManager->getState14()) { - case 1: + switch (g_vm->_trueTalkManager->getCurrentSeason()) { + case SEASON_AUTUMN: CTrueTalkManager::_v6 = 3; break; - case 2: + case SEASON_WINTER: CTrueTalkManager::_v6 = 0; break; - case 3: + case SEASON_SPRING: CTrueTalkManager::_v6 = 1; break; default: @@ -634,13 +634,12 @@ uint TTnpcScript::getDialogueId(uint tagId) { } } - uint oldTagId = tagId; tagId = getRangeValue(tagId); - if (tagId != oldTagId) + if (tagId != origId) tagId = getRangeValue(tagId); - oldTagId = getDialsBitset(); - uint newId = updateState(origId, tagId, oldTagId); + uint dialBits = getDialsBitset(); + uint newId = updateState(origId, tagId, dialBits); if (!newId) return 0; @@ -654,7 +653,7 @@ uint TTnpcScript::getDialogueId(uint tagId) { if (tableP->_id == newId) break; } - uint newVal = tableP->_values[oldTagId]; + uint newVal = tableP->_values[dialBits]; // First slot dialogue Ids idx = 0; diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp index 1d9c199054..95a302d53c 100644 --- a/engines/titanic/true_talk/tt_parser.cpp +++ b/engines/titanic/true_talk/tt_parser.cpp @@ -575,7 +575,7 @@ int TTparser::loadRequests(TTword *word) { if (_sentenceConcept) { if (_sentenceConcept->get18() == 0 || _sentenceConcept->get18() == 2) { - TTaction *action = static_cast<TTaction *>(word); + TTaction *action = dynamic_cast<TTaction *>(word); _sentenceConcept->set18(action->getVal()); } } @@ -1273,7 +1273,7 @@ int TTparser::considerRequests(TTword *word) { break; } - TTparserNode *nextP = static_cast<TTparserNode *>(nodeP->_nextP); + TTparserNode *nextP = dynamic_cast<TTparserNode *>(nodeP->_nextP); if (flag) delete nodeP; nodeP = nextP; @@ -1375,7 +1375,7 @@ void TTparser::removeConcept(TTconcept *concept) { void TTparser::removeNode(TTparserNode *node) { if (!node->_priorP) // Node is the head of the chain, so reset parser's nodes pointer - _nodesP = static_cast<TTparserNode *>(node->_nextP); + _nodesP = dynamic_cast<TTparserNode *>(node->_nextP); delete node; } @@ -1525,7 +1525,7 @@ int TTparser::fn2(TTword *word) { case 602: case 607: - return checkReferent(static_cast<TTpronoun *>(word)); + return checkReferent(dynamic_cast<TTpronoun *>(word)); case 608: return 1; diff --git a/engines/titanic/true_talk/tt_room_script.cpp b/engines/titanic/true_talk/tt_room_script.cpp index b8fbca7d39..a49a5a5bd1 100644 --- a/engines/titanic/true_talk/tt_room_script.cpp +++ b/engines/titanic/true_talk/tt_room_script.cpp @@ -34,7 +34,7 @@ TTroomScriptBase::TTroomScriptBase(int scriptId, /*------------------------------------------------------------------------*/ TTroomScript::TTroomScript(int scriptId) : - TTroomScriptBase(scriptId, "", "", 0, -1, -1, -1, 0, 0) { + TTroomScriptBase(scriptId, "", "", 0, -1, -1, -1, 0, 0), _field54(0) { } bool TTroomScript::proc8() const { diff --git a/engines/titanic/true_talk/tt_script_base.cpp b/engines/titanic/true_talk/tt_script_base.cpp index 4109134501..2f58ad1400 100644 --- a/engines/titanic/true_talk/tt_script_base.cpp +++ b/engines/titanic/true_talk/tt_script_base.cpp @@ -118,37 +118,41 @@ void TTscriptBase::applyResponse() { } void TTscriptBase::deleteResponses() { - while (_respTailP) { - _respHeadP = _respTailP; - _respTailP = _respHeadP->getLink(); - delete _respHeadP; + while (_respHeadP) { + _respTailP = _respHeadP; + _respHeadP = _respTailP->getLink(); + delete _respTailP; } } -void TTscriptBase::appendResponse(int val1, int *val2, int val3) { - if (!val2 || val1 <= *val2) { - if (_respHeadP) { - _respHeadP = new TTresponse(_respHeadP); +void TTscriptBase::appendResponse(int index, int *maxP, int id) { + if (id && (!maxP || index <= *maxP)) { + if (_respTailP) { + // Prior fragments already exist, so append to end of chain + _respTailP = new TTresponse(_respTailP); } else { - _respHeadP = new TTresponse(val3, 3); - if (_respTailP) - _respTailP->addLink(_respHeadP); + // Currently no tail + _respTailP = new TTresponse(id, 3); + if (_respHeadP) + _respHeadP->addLink(_respTailP); else - _respTailP = _respHeadP; + _respHeadP = _respTailP; } } } -void TTscriptBase::appendResponse(int val1, int *val2, const TTstring &str) { - if (!val2 || val1 <= *val2) { - if (_respHeadP) { - _respHeadP = new TTresponse(str); +void TTscriptBase::appendResponse(int index, int *maxP, const TTstring &str) { + if (!maxP || index <= *maxP) { + if (_respTailP) { + // Prior fragments already exist, so append to end of chain + _respTailP = new TTresponse(str); } else { - _respHeadP = new TTresponse(str); - if (_respTailP) - _respTailP->addLink(_respHeadP); + // Currently no tail + _respTailP = new TTresponse(str); + if (_respHeadP) + _respHeadP->addLink(_respTailP); else - _respTailP = _respHeadP; + _respHeadP = _respTailP; } } } diff --git a/engines/titanic/true_talk/tt_script_base.h b/engines/titanic/true_talk/tt_script_base.h index c489dcb0a7..869b0beb64 100644 --- a/engines/titanic/true_talk/tt_script_base.h +++ b/engines/titanic/true_talk/tt_script_base.h @@ -51,8 +51,8 @@ protected: int _state; TThist *_hist2P; int _field3C; - TTresponse *_respHeadP; TTresponse *_respTailP; + TTresponse *_respHeadP; TTresponse *_oldResponseP; int _status; protected: @@ -62,14 +62,21 @@ protected: void deleteResponses(); /** - * Creates and appends a new response to the script + * Creates and appends a new response fragment to the script specified by + * the given conversation Id */ - void appendResponse(int val1, int *val2, int val3); + void appendResponse(int index, int *maxP, int id); - void appendResponse(int val1, int *val2, const TTstring &str); + /** + * Creates and appends a new response fragment string to the script + */ + void appendResponse(int index, int *maxP, const TTstring &str); - void appendResponse2(int val1, int *val2, const TTstring &str) { - appendResponse(val1, val2, str); + /** + * Creates and appends a new response fragment string to the script + */ + void appendResponse2(int index, int *maxP, const TTstring &str) { + appendResponse(index, maxP, str); } /** diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp index 9588ee021e..3fae527770 100644 --- a/engines/titanic/true_talk/tt_sentence.cpp +++ b/engines/titanic/true_talk/tt_sentence.cpp @@ -28,7 +28,7 @@ namespace Titanic { TTsentenceConcept *TTsentenceConcept::addSibling() { - if (this == nullptr || _nextP != nullptr) + if (_nextP != nullptr) // This should never happen return nullptr; @@ -83,7 +83,7 @@ void TTsentence::copyFrom(const TTsentence &src) { if (src._nodesP) { // Source has processed nodes, so duplicate them for (TTsentenceNode *node = src._nodesP; node; - node = static_cast<TTsentenceNode *>(node->_nextP)) { + node = dynamic_cast<TTsentenceNode *>(node->_nextP)) { TTsentenceNode *newNode = new TTsentenceNode(node->_wordP); if (_nodesP) _nodesP->addToTail(newNode); @@ -319,7 +319,7 @@ bool TTsentence::localWord(const char *str) const { bool result = false; for (TTsentenceNode *nodeP = _nodesP; nodeP && !result; - nodeP = static_cast<TTsentenceNode *>(nodeP->_nextP)) { + nodeP = dynamic_cast<TTsentenceNode *>(nodeP->_nextP)) { TTsynonym syn; if (!nodeP->_wordP) continue; diff --git a/engines/titanic/true_talk/tt_string_node.cpp b/engines/titanic/true_talk/tt_string_node.cpp index 2bb0c5a74b..5a21d73a9b 100644 --- a/engines/titanic/true_talk/tt_string_node.cpp +++ b/engines/titanic/true_talk/tt_string_node.cpp @@ -55,7 +55,7 @@ void TTstringNode::initialize(TTstringNode *oldNode) { } TTstringNode *TTstringNode::findByName(const TTstring &str, int mode) { - for (TTstringNode *nodeP = this; nodeP; nodeP = static_cast<TTstringNode *>(nodeP->_nextP)) { + for (TTstringNode *nodeP = this; nodeP; nodeP = dynamic_cast<TTstringNode *>(nodeP->_nextP)) { if (nodeP->_mode == mode || (mode == 3 && nodeP->_mode < 3)) { if (nodeP->_string == str) return nodeP; diff --git a/engines/titanic/true_talk/tt_synonym.cpp b/engines/titanic/true_talk/tt_synonym.cpp index 0f56c5cb22..b476efefcb 100644 --- a/engines/titanic/true_talk/tt_synonym.cpp +++ b/engines/titanic/true_talk/tt_synonym.cpp @@ -60,7 +60,7 @@ TTsynonym *TTsynonym::copyFrom(const TTsynonym *src) { } int TTsynonym::save(SimpleFile *file) { - for (TTstringNode *synP = this; synP; synP = static_cast<TTstringNode *>(synP->_nextP)) { + for (TTstringNode *synP = this; synP; synP = dynamic_cast<TTstringNode *>(synP->_nextP)) { file->writeFormat("%s", " 0 "); synP->_string.save(file); file->writeFormat("%c", ' '); diff --git a/engines/titanic/true_talk/tt_talker.cpp b/engines/titanic/true_talk/tt_talker.cpp index 61443a4835..da7628f483 100644 --- a/engines/titanic/true_talk/tt_talker.cpp +++ b/engines/titanic/true_talk/tt_talker.cpp @@ -26,10 +26,10 @@ namespace Titanic { -void TTtalker::speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId) { +void TTtalker::speechStarted(const CString &dialogueStr, uint dialogueId, uint speechHandle) { _dialogueId = dialogueId; - CTrueTalkNotifySpeechStartedMsg msg(soundId, dialogueId, 0); + CTrueTalkNotifySpeechStartedMsg msg(speechHandle, dialogueId, 0); msg.execute(_npc, nullptr, MSGFLAG_BREAK_IF_HANDLED); } @@ -40,13 +40,13 @@ TTtalker::~TTtalker() { petControl->convAddLine(_line); // Notify the end of the speech - CTrueTalkNotifySpeechEndedMsg endedMsg(_field24, _dialogueId); + CTrueTalkNotifySpeechEndedMsg endedMsg(_talkEndState, _dialogueId); endedMsg.execute(_npc, nullptr, MSGFLAG_BREAK_IF_HANDLED); } void TTtalker::endSpeech(int val) { _done = true; - _field24 = val; + _talkEndState = val; } } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_talker.h b/engines/titanic/true_talk/tt_talker.h index 636eb0c022..a83bddd952 100644 --- a/engines/titanic/true_talk/tt_talker.h +++ b/engines/titanic/true_talk/tt_talker.h @@ -37,19 +37,19 @@ public: CTrueTalkNPC *_npc; CString _line; int _dialogueId; - int _field24; + int _talkEndState; int _done; public: TTtalker() : _owner(nullptr), _npc(nullptr), - _dialogueId(0), _field24(0), _done(0) {} + _dialogueId(0), _talkEndState(0), _done(0) {} TTtalker(CTrueTalkManager *owner, CTrueTalkNPC *npc) : - _owner(owner), _npc(npc), _dialogueId(0), _field24(0), _done(0) {} + _owner(owner), _npc(npc), _dialogueId(0), _talkEndState(0), _done(0) {} ~TTtalker(); /** * Start a new speech */ - void speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId); + void speechStarted(const CString &dialogueStr, uint dialogueId, uint speechHandle); /** * End the speech diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp index 08d6e9e1a7..062a6b65c0 100644 --- a/engines/titanic/true_talk/tt_vocab.cpp +++ b/engines/titanic/true_talk/tt_vocab.cpp @@ -32,8 +32,8 @@ namespace Titanic {
-TTvocab::TTvocab(int val): _headP(nullptr), _tailP(nullptr), _word(nullptr),
- _fieldC(0), _field10(0), _vocabMode(val) {
+TTvocab::TTvocab(int val): _headP(nullptr), _tailP(nullptr),
+ _word(nullptr), _vocabMode(val) {
load("STVOCAB.TXT");
}
@@ -288,7 +288,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) {
if (word->_wordClass == WC_ACTION) {
- static_cast<TTaction *>(word)->setVal(1);
+ dynamic_cast<TTaction *>(word)->setVal(1);
}
} else {
tempStr = str;
@@ -331,7 +331,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) {
if (word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = static_cast<TTadj *>(word);
+ TTadj *adj = dynamic_cast<TTadj *>(word);
int val1 = word->proc15();
int val2 = word->proc15();
@@ -350,7 +350,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { word = getPrimeWord(tempStr);
if (word && word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = static_cast<TTadj *>(word);
+ TTadj *adj = dynamic_cast<TTadj *>(word);
int val1 = word->proc15();
int val2 = word->proc15();
@@ -393,7 +393,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) {
if (word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = static_cast<TTadj *>(word);
+ TTadj *adj = dynamic_cast<TTadj *>(word);
int val1 = word->proc15();
int val2 = word->proc15();
@@ -412,7 +412,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { word = getPrimeWord(tempStr);
if (word) {
- TTadj *adj = static_cast<TTadj *>(word);
+ TTadj *adj = dynamic_cast<TTadj *>(word);
int val1 = word->proc15();
int val2 = word->proc15();
diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h index fc7ee2e102..614d1bbf02 100644 --- a/engines/titanic/true_talk/tt_vocab.h +++ b/engines/titanic/true_talk/tt_vocab.h @@ -34,8 +34,6 @@ private: TTword *_headP; TTword *_tailP; TTword *_word; - int _fieldC; - int _field10; int _vocabMode; private: /** diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp index df6ee5c7bc..c8676e4b1e 100644 --- a/engines/titanic/true_talk/tt_word.cpp +++ b/engines/titanic/true_talk/tt_word.cpp @@ -173,7 +173,7 @@ bool TTword::findSynByName(const TTstring &str, TTsynonym *dest, int mode) const if (!_synP) return false; - const TTsynonym *synP = static_cast<const TTsynonym *>(_synP->findByName(str, mode)); + const TTsynonym *synP = dynamic_cast<const TTsynonym *>(_synP->findByName(str, mode)); if (synP) { dest->copyFrom(synP); dest->_priorP = nullptr; |