From 1f0b9cb68d02d956ec745bef16f0dbddaa743bec Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 25 Aug 2016 20:46:33 -0400 Subject: TITANIC: Implemented more game classes --- engines/titanic/carry/mouth.cpp | 40 ++++++++++++++++++++++ engines/titanic/carry/mouth.h | 4 +++ engines/titanic/core/multi_drop_target.cpp | 22 ++++++++++++ engines/titanic/core/multi_drop_target.h | 2 ++ engines/titanic/game/missiveomat_button.cpp | 30 ++++++++++++++-- engines/titanic/game/missiveomat_button.h | 8 +++-- engines/titanic/game/movie_tester.cpp | 26 +++++++++++--- engines/titanic/game/movie_tester.h | 6 ++-- engines/titanic/gfx/move_object_button.cpp | 15 ++++++++ engines/titanic/gfx/move_object_button.h | 2 ++ .../titanic/moves/move_player_in_parrot_room.cpp | 21 ++++++++++++ engines/titanic/moves/move_player_in_parrot_room.h | 3 ++ engines/titanic/moves/move_player_to.cpp | 19 ++++++++++ engines/titanic/moves/move_player_to.h | 3 ++ engines/titanic/moves/move_player_to_from.cpp | 21 +++++++++++- engines/titanic/moves/move_player_to_from.h | 6 ++-- 16 files changed, 215 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/titanic/carry/mouth.cpp b/engines/titanic/carry/mouth.cpp index 8c3791fa9c..e48929a391 100644 --- a/engines/titanic/carry/mouth.cpp +++ b/engines/titanic/carry/mouth.cpp @@ -21,9 +21,16 @@ */ #include "titanic/carry/mouth.h" +#include "titanic/game/head_slot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMouth, CHeadPiece) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(PETGainedObjectMsg) +END_MESSAGE_MAP() + CMouth::CMouth() : CHeadPiece() { } @@ -37,4 +44,37 @@ void CMouth::load(SimpleFile *file) { CHeadPiece::load(file); } +bool CMouth::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CHeadSlot *slot = dynamic_cast(msg->_other); + if (!slot) + return CHeadPiece::UseWithOtherMsg(msg); + + _flag = true; + setVisible(false); + setPosition(Point(0, 0)); + petMoveToHiddenRoom(); + + CAddHeadPieceMsg addMsg(getName()); + if (addMsg._value != "NULL") + addMsg.execute("MouthSlot"); + + return true; +} + +bool CMouth::MovieEndMsg(CMovieEndMsg *msg) { + return true; +} + +bool CMouth::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + _visibleFrame = 2; + loadFrame(2); + setVisible(true); + if (!_field13C) { + stateInc38(); + _field13C = true; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/mouth.h b/engines/titanic/carry/mouth.h index e394330494..f5f0f53b45 100644 --- a/engines/titanic/carry/mouth.h +++ b/engines/titanic/carry/mouth.h @@ -28,6 +28,10 @@ namespace Titanic { class CMouth : public CHeadPiece { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); public: CLASSDEF; CMouth(); diff --git a/engines/titanic/core/multi_drop_target.cpp b/engines/titanic/core/multi_drop_target.cpp index f2998199b1..ad709fe38b 100644 --- a/engines/titanic/core/multi_drop_target.cpp +++ b/engines/titanic/core/multi_drop_target.cpp @@ -21,9 +21,14 @@ */ #include "titanic/core/multi_drop_target.h" +#include "titanic/support/string_parser.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMultiDropTarget, CDropTarget) + ON_MESSAGE(DropObjectMsg) +END_MESSAGE_MAP() + void CMultiDropTarget::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeQuotedLine(_string5, indent); @@ -40,4 +45,21 @@ void CMultiDropTarget::load(SimpleFile *file) { CDropTarget::load(file); } +bool CMultiDropTarget::DropObjectMsg(CDropObjectMsg *msg) { + CStringParser parser1(_string5); + CStringParser parser2(_string6); + CString seperatorChars = ","; + int dropFrame = _dropFrame; + + while (parser2.parse(_itemMatchName, seperatorChars)) { + _dropFrame = parser1.readInt(); + CDropTarget::DropObjectMsg(msg); + + parser1.skipSeperators(seperatorChars); + parser2.skipSeperators(seperatorChars); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/multi_drop_target.h b/engines/titanic/core/multi_drop_target.h index c004b9bece..ab552f96e1 100644 --- a/engines/titanic/core/multi_drop_target.h +++ b/engines/titanic/core/multi_drop_target.h @@ -28,6 +28,8 @@ namespace Titanic { class CMultiDropTarget : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool DropObjectMsg(CDropObjectMsg *msg); public: CString _string5; CString _string6; diff --git a/engines/titanic/game/missiveomat_button.cpp b/engines/titanic/game/missiveomat_button.cpp index d5ae75dbc2..b7ad7f8f6f 100644 --- a/engines/titanic/game/missiveomat_button.cpp +++ b/engines/titanic/game/missiveomat_button.cpp @@ -21,21 +21,47 @@ */ #include "titanic/game/missiveomat_button.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMissiveOMatButton, CEditControl) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(VisibleMsg) + ON_MESSAGE(MouseDoubleClickMsg) +END_MESSAGE_MAP() + void CMissiveOMatButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_buttonId, indent); CEditControl::save(file, indent); } void CMissiveOMatButton::load(SimpleFile *file) { file->readNumber(); - _fieldFC = file->readNumber(); + _buttonId = file->readNumber(); CEditControl::load(file); } +bool CMissiveOMatButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CMissiveOMatActionMsg actionMsg; + actionMsg._action = _buttonId; + actionMsg.execute(findRoom()->findByName("MissiveOMat")); + return true; +} + +bool CMissiveOMatButton::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + return true; +} + +bool CMissiveOMatButton::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + CMissiveOMatActionMsg actionMsg; + actionMsg._action = _buttonId; + actionMsg.execute(findRoom()->findByName("MissiveOMat")); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/missiveomat_button.h b/engines/titanic/game/missiveomat_button.h index d36f5bd958..6dbfd4cd56 100644 --- a/engines/titanic/game/missiveomat_button.h +++ b/engines/titanic/game/missiveomat_button.h @@ -28,11 +28,15 @@ namespace Titanic { class CMissiveOMatButton : public CEditControl { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); + bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); public: - int _fieldFC; + int _buttonId; public: CLASSDEF; - CMissiveOMatButton() : CEditControl(), _fieldFC(2) {} + CMissiveOMatButton() : CEditControl(), _buttonId(2) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/movie_tester.cpp b/engines/titanic/game/movie_tester.cpp index 1b266d9c7e..bbd66a9bce 100644 --- a/engines/titanic/game/movie_tester.cpp +++ b/engines/titanic/game/movie_tester.cpp @@ -24,18 +24,36 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMovieTester, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CMovieTester::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value1, indent); - file->writeNumberLine(_value2, indent); + file->writeNumberLine(_movieNumFrames, indent); + file->writeNumberLine(_movieFrameNum, indent); CGameObject::save(file, indent); } void CMovieTester::load(SimpleFile *file) { file->readNumber(); - _value1 = file->readNumber(); - _value2 = file->readNumber(); + _movieNumFrames = file->readNumber(); + _movieFrameNum = file->readNumber(); CGameObject::load(file); } +bool CMovieTester::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (msg->_buttons == MB_RIGHT) { + if (--_movieFrameNum < 0) { + _movieFrameNum = _movieNumFrames - 1; + } + } else { + if (++_movieFrameNum >= _movieNumFrames) + _movieFrameNum = 0; + } + + loadFrame(_movieFrameNum); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/movie_tester.h b/engines/titanic/game/movie_tester.h index de2ef2cc5e..17a7d489d8 100644 --- a/engines/titanic/game/movie_tester.h +++ b/engines/titanic/game/movie_tester.h @@ -28,11 +28,13 @@ namespace Titanic { class CMovieTester : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: - int _value1, _value2; + int _movieNumFrames, _movieFrameNum; public: CLASSDEF; - CMovieTester() : CGameObject(), _value1(0), _value2(0) {} + CMovieTester() : CGameObject(), _movieNumFrames(0), _movieFrameNum(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/gfx/move_object_button.cpp b/engines/titanic/gfx/move_object_button.cpp index bdc90a673c..bcd2b2bd76 100644 --- a/engines/titanic/gfx/move_object_button.cpp +++ b/engines/titanic/gfx/move_object_button.cpp @@ -21,9 +21,14 @@ */ #include "titanic/gfx/move_object_button.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMoveObjectButton, CSTButton) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + CMoveObjectButton::CMoveObjectButton() : CSTButton(), _field11C(1) { } @@ -43,4 +48,14 @@ void CMoveObjectButton::load(SimpleFile *file) { CSTButton::load(file); } +bool CMoveObjectButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + CGameObject *obj = dynamic_cast(getRoot()->findByName(_actionTarget)); + if (obj) { + obj->petAddToInventory(); + obj->setVisible(_field11C); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/move_object_button.h b/engines/titanic/gfx/move_object_button.h index eb2fdc4ff2..46c49c36e2 100644 --- a/engines/titanic/gfx/move_object_button.h +++ b/engines/titanic/gfx/move_object_button.h @@ -28,6 +28,8 @@ namespace Titanic { class CMoveObjectButton : public CSTButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); private: Point _pos1; int _field11C; diff --git a/engines/titanic/moves/move_player_in_parrot_room.cpp b/engines/titanic/moves/move_player_in_parrot_room.cpp index df38c63cd4..1ef2e96e92 100644 --- a/engines/titanic/moves/move_player_in_parrot_room.cpp +++ b/engines/titanic/moves/move_player_in_parrot_room.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMovePlayerInParrotRoom, CMovePlayerTo) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + CMovePlayerInParrotRoom::CMovePlayerInParrotRoom() : CMovePlayerTo() { } @@ -37,4 +42,20 @@ void CMovePlayerInParrotRoom::load(SimpleFile *file) { CMovePlayerTo::load(file); } +bool CMovePlayerInParrotRoom::ActMsg(CActMsg *msg) { + if (msg->_action == "PanAwayFromParrot") { + unlockMouse(); + changeView(_destination); + } + + return true; +} + +bool CMovePlayerInParrotRoom::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + lockMouse(); + CPanningAwayFromParrotMsg awayMsg(this); + awayMsg.execute("PerchedParrot"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_in_parrot_room.h b/engines/titanic/moves/move_player_in_parrot_room.h index de693fe2e2..54dc2eb992 100644 --- a/engines/titanic/moves/move_player_in_parrot_room.h +++ b/engines/titanic/moves/move_player_in_parrot_room.h @@ -28,6 +28,9 @@ namespace Titanic { class CMovePlayerInParrotRoom : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; CMovePlayerInParrotRoom(); diff --git a/engines/titanic/moves/move_player_to.cpp b/engines/titanic/moves/move_player_to.cpp index 9b6000c4f8..a91215b539 100644 --- a/engines/titanic/moves/move_player_to.cpp +++ b/engines/titanic/moves/move_player_to.cpp @@ -21,9 +21,15 @@ */ #include "titanic/moves/move_player_to.h" +#include "titanic/game_manager.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMovePlayerTo, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + CMovePlayerTo::CMovePlayerTo() : CGameObject() { } @@ -41,4 +47,17 @@ void CMovePlayerTo::load(SimpleFile *file) { CGameObject::load(file); } +bool CMovePlayerTo::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + changeView(_destination); + + return true; +} + +bool CMovePlayerTo::ActMsg(CActMsg *msg) { + _destination = msg->_action; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_to.h b/engines/titanic/moves/move_player_to.h index 4bfffcb0b2..822df69422 100644 --- a/engines/titanic/moves/move_player_to.h +++ b/engines/titanic/moves/move_player_to.h @@ -28,6 +28,9 @@ namespace Titanic { class CMovePlayerTo : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool ActMsg(CActMsg *msg); protected: CString _destination; public: diff --git a/engines/titanic/moves/move_player_to_from.cpp b/engines/titanic/moves/move_player_to_from.cpp index 1a67dc8505..c57cc2cf51 100644 --- a/engines/titanic/moves/move_player_to_from.cpp +++ b/engines/titanic/moves/move_player_to_from.cpp @@ -21,10 +21,16 @@ */ #include "titanic/moves/move_player_to_from.h" +#include "titanic/core/view_item.h" +#include "titanic/core/link_item.h" namespace Titanic { -CMovePlayerToFrom::CMovePlayerToFrom() : CGameObject() { +BEGIN_MESSAGE_MAP(CMovePlayerToFrom, CMovePlayerTo) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + +CMovePlayerToFrom::CMovePlayerToFrom() : CMovePlayerTo() { } void CMovePlayerToFrom::save(SimpleFile *file, int indent) { @@ -41,4 +47,17 @@ void CMovePlayerToFrom::load(SimpleFile *file) { CGameObject::load(file); } +bool CMovePlayerToFrom::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_string2.empty()) { + changeView(_destination); + } else { + CViewItem *view = parseView(_string2); + CViewItem *destView = parseView(_destination); + CLinkItem *link = view->findLink(destView); + changeView(_destination, link->getName()); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_to_from.h b/engines/titanic/moves/move_player_to_from.h index c9eefe532f..fde4e94ab5 100644 --- a/engines/titanic/moves/move_player_to_from.h +++ b/engines/titanic/moves/move_player_to_from.h @@ -23,11 +23,13 @@ #ifndef TITANIC_MOVE_PLAYER_TO_FROM_H #define TITANIC_MOVE_PLAYER_TO_FROM_H -#include "titanic/core/game_object.h" +#include "titanic/moves/move_player_to.h" namespace Titanic { -class CMovePlayerToFrom : public CGameObject { +class CMovePlayerToFrom : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); private: CString _string2; public: -- cgit v1.2.3