diff options
author | Paul Gilbert | 2016-08-19 20:48:05 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-19 20:48:05 -0400 |
commit | a5a1a08c503d9e32352f67b90650bc604959ea5a (patch) | |
tree | be608ff67f5c7150f69c61510e9ff4349ad575e2 /engines | |
parent | 5ec6f572c1b7888b4111566fcf6727ade3f043ea (diff) | |
download | scummvm-rg350-a5a1a08c503d9e32352f67b90650bc604959ea5a.tar.gz scummvm-rg350-a5a1a08c503d9e32352f67b90650bc604959ea5a.tar.bz2 scummvm-rg350-a5a1a08c503d9e32352f67b90650bc604959ea5a.zip |
TITANIC: Implemented more game classes
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/core/drop_target.cpp | 172 | ||||
-rw-r--r-- | engines/titanic/core/drop_target.h | 30 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.h | 5 | ||||
-rw-r--r-- | engines/titanic/game/doorbot_elevator_handler.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/game/doorbot_elevator_handler.h | 3 | ||||
-rw-r--r-- | engines/titanic/game/doorbot_home_handler.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/game/doorbot_home_handler.h | 2 | ||||
-rw-r--r-- | engines/titanic/game/ear_sweet_bowl.cpp | 33 | ||||
-rw-r--r-- | engines/titanic/game/ear_sweet_bowl.h | 3 | ||||
-rw-r--r-- | engines/titanic/game/eject_phonograph_button.cpp | 49 | ||||
-rw-r--r-- | engines/titanic/game/eject_phonograph_button.h | 13 | ||||
-rw-r--r-- | engines/titanic/game/sgt/drawer.cpp | 41 | ||||
-rw-r--r-- | engines/titanic/game/sgt/drawer.h | 4 |
14 files changed, 329 insertions, 64 deletions
diff --git a/engines/titanic/core/drop_target.cpp b/engines/titanic/core/drop_target.cpp index 05ea6445c3..cdd1d351fb 100644 --- a/engines/titanic/core/drop_target.cpp +++ b/engines/titanic/core/drop_target.cpp @@ -21,30 +21,40 @@ */ #include "titanic/core/drop_target.h" +#include "titanic/carry/carry.h" namespace Titanic { -CDropTarget::CDropTarget() : CGameObject(), _fieldC4(0), - _fieldD4(0), _fieldE4(0), _fieldF4(0), _fieldF8(0), - _fieldFC(0), _field10C(1), _field110(8), _field114(20) { +BEGIN_MESSAGE_MAP(CDropTarget, CGameObject) + ON_MESSAGE(DropObjectMsg) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(VisibleMsg) + ON_MESSAGE(DropZoneLostObjectMsg) +END_MESSAGE_MAP() + +CDropTarget::CDropTarget() : CGameObject(), _itemFrame(0), + _itemMatchSize(0), _showItem(false), _fieldF4(0), _dropFrame(0), + _dragFrame(0), _dragCursorId(CURSOR_ARROW), _dropCursorId(CURSOR_HAND), + _clipFlags(20) { } void CDropTarget::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writePoint(_pos1, indent); - file->writeNumberLine(_fieldC4, indent); - file->writeQuotedLine(_string1, indent); - file->writeNumberLine(_fieldD4, indent); - file->writeQuotedLine(_string2, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_itemFrame, indent); + file->writeQuotedLine(_itemMatchName, indent); + file->writeNumberLine(_itemMatchSize, indent); + file->writeQuotedLine(_soundName, indent); + file->writeNumberLine(_showItem, indent); + file->writeQuotedLine(_itemName, indent); file->writeNumberLine(_fieldF4, indent); - file->writeNumberLine(_fieldF8, indent); - file->writeNumberLine(_fieldFC, indent); - file->writeQuotedLine(_string4, indent); - file->writeNumberLine(_field10C, indent); - file->writeNumberLine(_field110, indent); - file->writeNumberLine(_field114, indent); + file->writeNumberLine(_dropFrame, indent); + file->writeNumberLine(_dragFrame, indent); + file->writeQuotedLine(_clipName, indent); + file->writeNumberLine(_dragCursorId, indent); + file->writeNumberLine(_dropCursorId, indent); + file->writeNumberLine(_clipFlags, indent); CGameObject::save(file, indent); } @@ -52,21 +62,129 @@ void CDropTarget::save(SimpleFile *file, int indent) { void CDropTarget::load(SimpleFile *file) { file->readNumber(); _pos1 = file->readPoint(); - _fieldC4 = file->readNumber(); - _string1 = file->readString(); - _fieldD4 = file->readNumber(); - _string2 = file->readString(); - _fieldE4 = file->readNumber(); - _string3 = file->readString(); + _itemFrame = file->readNumber(); + _itemMatchName = file->readString(); + _itemMatchSize = file->readNumber(); + _soundName = file->readString(); + _showItem = file->readNumber(); + _itemName = file->readString(); _fieldF4 = file->readNumber(); - _fieldF8 = file->readNumber(); - _fieldFC = file->readNumber(); - _string4 = file->readString(); - _field10C = file->readNumber(); - _field110 = file->readNumber(); - _field114 = file->readNumber(); + _dropFrame = file->readNumber(); + _dragFrame = file->readNumber(); + _clipName = file->readString(); + _dragCursorId = (CursorId)file->readNumber(); + _dropCursorId = (CursorId)file->readNumber(); + _clipFlags = file->readNumber(); CGameObject::load(file); } +bool CDropTarget::DropObjectMsg(CDropObjectMsg *msg) { + if (!_itemName.empty()) { + if (msg->_item->getName() != _itemName) { + if (findByName(_itemName, true)) + return false; + } + } + + if (!msg->_item->isEquals(_itemMatchName, _itemMatchSize)) + return false; + + msg->_item->detach(); + msg->_item->addUnder(this); + msg->_item->setPosition(Point(_bounds.left, _bounds.top)); + + msg->_item->loadFrame(_itemFrame); + if (_showItem) + msg->_item->setVisible(false); + + CDropZoneGotObjectMsg gotMsg(this); + gotMsg.execute(msg->_item); + playSound(_soundName); + + if (_clipName.empty()) { + loadFrame(_dropFrame); + } else { + playClip(_clipName, _clipFlags); + } + + _cursorId = _dropCursorId; + return true; +} + +bool CDropTarget::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) + return false; + msg->_dragItem = msg->_dragItem; + + CGameObject *obj = dynamic_cast<CGameObject *>(findByName(_itemName)); + if (_itemName.empty() || _fieldF4 || !obj) + return false; + + CDropZoneLostObjectMsg lostMsg; + lostMsg._object = this; + lostMsg.execute(obj); + + loadFrame(_dragFrame); + _cursorId = _dragCursorId; + + if (obj->_visible) { + msg->execute(obj); + } else { + msg->_dragItem = obj; + CPassOnDragStartMsg passMsg(msg->_mousePos, 1); + passMsg.execute(obj); + setVisible(true); + } + + return true; +} + +bool CDropTarget::EnterViewMsg(CEnterViewMsg *msg) { + if (!_itemName.empty()) { + CGameObject *obj = dynamic_cast<CGameObject *>(findByName(_itemName)); + if (!obj) { + loadFrame(_dragFrame); + _cursorId = _dragCursorId; + } else if (_clipName.empty()) { + loadFrame(_dropFrame); + } else { + playClip(_clipName, _clipFlags); + } + + _cursorId = _dropCursorId; + } + + return true; +} + +bool CDropTarget::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + _fieldF4 = !msg->_visible; + return true; +} + +bool CDropTarget::DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg) { + if (!_itemName.empty()) { + CGameObject *obj = dynamic_cast<CGameObject *>(findByName(_itemName)); + if (obj) { + if (msg->_object) { + obj->detach(); + obj->addUnder(msg->_object); + } else if (dynamic_cast<CCarry *>(obj)) { + obj->petAddToInventory(); + } + + setVisible(true); + CDropZoneLostObjectMsg lostMsg(this); + lostMsg.execute(obj); + } + + loadFrame(_dragFrame); + _cursorId = _dragCursorId; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/drop_target.h b/engines/titanic/core/drop_target.h index 4bd0ae448c..8c497b6bc2 100644 --- a/engines/titanic/core/drop_target.h +++ b/engines/titanic/core/drop_target.h @@ -28,21 +28,27 @@ namespace Titanic { class CDropTarget : public CGameObject { + DECLARE_MESSAGE_MAP; + bool DropObjectMsg(CDropObjectMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); + bool DropZoneLostObjectMsg(CDropZoneLostObjectMsg *msg); private: Point _pos1; - int _fieldC4; - CString _string1; - int _fieldD4; - CString _string2; - int _fieldE4; - CString _string3; + int _itemFrame; + CString _itemMatchName; + int _itemMatchSize; + CString _soundName; + bool _showItem; + CString _itemName; int _fieldF4; - int _fieldF8; - int _fieldFC; - CString _string4; - int _field10C; - int _field110; - int _field114; + int _dropFrame; + int _dragFrame; + CString _clipName; + CursorId _dragCursorId; + CursorId _dropCursorId; + uint _clipFlags; public: CLASSDEF; CDropTarget(); diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index a10b8ef19d..870ee38016 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -265,19 +265,19 @@ void CTreeItem::attach(CTreeItem *item) { item->_parent->_firstChild = this; } -CNamedItem *CTreeItem::findByName(const CString &name, int maxLen) { +CNamedItem *CTreeItem::findByName(const CString &name, bool subMatch) { CString nameLower = name; nameLower.toLowercase(); for (CTreeItem *treeItem = this; treeItem; treeItem = treeItem->scan(this)) { - CString nodeName = treeItem->getName(); - nodeName.toLowercase(); + CString itemName = treeItem->getName(); + itemName.toLowercase(); - if (maxLen) { - if (nodeName.left(maxLen).compareTo(nameLower)) + if (subMatch) { + if (itemName.left(name.size()).compareTo(nameLower)) return dynamic_cast<CNamedItem *>(treeItem); } else { - if (!nodeName.compareTo(nameLower)) + if (!itemName.compareTo(nameLower)) return dynamic_cast<CNamedItem *>(treeItem); } } diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index b2d40daab9..e92f5cda49 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -253,8 +253,11 @@ public: /** * Finds a tree item by name + * @param name Name to find + * @param subMatch If false, does an exact name match. + * If false, matches any item that starts with the given name */ - CNamedItem *findByName(const CString &name, int maxLen = 0); + CNamedItem *findByName(const CString &name, bool subMatch = false); }; } // End of namespace Titanic diff --git a/engines/titanic/game/doorbot_elevator_handler.cpp b/engines/titanic/game/doorbot_elevator_handler.cpp index 13fc368137..39978e9ed7 100644 --- a/engines/titanic/game/doorbot_elevator_handler.cpp +++ b/engines/titanic/game/doorbot_elevator_handler.cpp @@ -24,24 +24,32 @@ namespace Titanic { -int CDoorbotElevatorHandler::_v1; +BEGIN_MESSAGE_MAP(CDoorbotElevatorHandler, CGameObject) + ON_MESSAGE(EnterNodeMsg) +END_MESSAGE_MAP() void CDoorbotElevatorHandler::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); - file->writeNumberLine(_v1, indent); + file->writeNumberLine(_called, indent); CGameObject::save(file, indent); } void CDoorbotElevatorHandler::load(SimpleFile *file) { file->readNumber(); _value = file->readNumber(); - _v1 = file->readNumber(); + _called = file->readNumber(); CGameObject::load(file); } bool CDoorbotElevatorHandler::EnterNodeMsg(CEnterNodeMsg *msg) { - warning("CDoorbotElevatorHandler::handleEvent"); + if (!_called) { + CDoorbotNeededInElevatorMsg elevatorMsg; + elevatorMsg._value = 0; + elevatorMsg.execute("Doorbot"); + _called = true; + } + return true; } diff --git a/engines/titanic/game/doorbot_elevator_handler.h b/engines/titanic/game/doorbot_elevator_handler.h index 7b39e727e3..f846273f14 100644 --- a/engines/titanic/game/doorbot_elevator_handler.h +++ b/engines/titanic/game/doorbot_elevator_handler.h @@ -29,9 +29,10 @@ namespace Titanic { class CDoorbotElevatorHandler : public CGameObject { + DECLARE_MESSAGE_MAP; bool EnterNodeMsg(CEnterNodeMsg *msg); private: - static int _v1; + bool _called; int _value; public: CLASSDEF; diff --git a/engines/titanic/game/doorbot_home_handler.cpp b/engines/titanic/game/doorbot_home_handler.cpp index b848308845..92898ca626 100644 --- a/engines/titanic/game/doorbot_home_handler.cpp +++ b/engines/titanic/game/doorbot_home_handler.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CDoorbotHomeHandler, CGameObject) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + CDoorbotHomeHandler::CDoorbotHomeHandler() { } @@ -37,4 +41,10 @@ void CDoorbotHomeHandler::load(SimpleFile *file) { CGameObject::load(file); } +bool CDoorbotHomeHandler::EnterViewMsg(CEnterViewMsg *msg) { + CDoorbotNeededInHomeMsg neededMsg; + neededMsg.execute("Doorbot"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/doorbot_home_handler.h b/engines/titanic/game/doorbot_home_handler.h index 99ba6d37a9..10552f2b87 100644 --- a/engines/titanic/game/doorbot_home_handler.h +++ b/engines/titanic/game/doorbot_home_handler.h @@ -28,6 +28,8 @@ namespace Titanic { class CDoorbotHomeHandler : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); public: CLASSDEF; CDoorbotHomeHandler(); diff --git a/engines/titanic/game/ear_sweet_bowl.cpp b/engines/titanic/game/ear_sweet_bowl.cpp index 0f7069356d..646b95f0b4 100644 --- a/engines/titanic/game/ear_sweet_bowl.cpp +++ b/engines/titanic/game/ear_sweet_bowl.cpp @@ -21,9 +21,16 @@ */ #include "titanic/game/ear_sweet_bowl.h" +#include "titanic/core/room_item.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CEarSweetBowl, CSweetBowl) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(ReplaceBowlAndNutsMsg) +END_MESSAGE_MAP() + void CEarSweetBowl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSweetBowl::save(file, indent); @@ -34,4 +41,30 @@ void CEarSweetBowl::load(SimpleFile *file) { CSweetBowl::load(file); } +bool CEarSweetBowl::MovieEndMsg(CMovieEndMsg *msg) { + CIsEarBowlPuzzleDone doneMsg; + doneMsg.execute(findRoom()); + + if (!doneMsg._value) { + CPetControl *pet = getPetControl(); + if (pet) + pet->hasRoomFlags(); + + CIsParrotPresentMsg parrotMsg; + parrotMsg.execute(findRoom()); + + if (parrotMsg._value) { + CNutPuzzleMsg nutMsg("Jiggle"); + nutMsg.execute("NutsParrotPlayer"); + } + } + + return true; +} + +bool CEarSweetBowl::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/ear_sweet_bowl.h b/engines/titanic/game/ear_sweet_bowl.h index 3f41950e47..1324ed224a 100644 --- a/engines/titanic/game/ear_sweet_bowl.h +++ b/engines/titanic/game/ear_sweet_bowl.h @@ -28,6 +28,9 @@ namespace Titanic { class CEarSweetBowl : public CSweetBowl { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/eject_phonograph_button.cpp b/engines/titanic/game/eject_phonograph_button.cpp index 4657f04126..b2ff441ef8 100644 --- a/engines/titanic/game/eject_phonograph_button.cpp +++ b/engines/titanic/game/eject_phonograph_button.cpp @@ -24,24 +24,57 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CEjectPhonographButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(CylinderHolderReadyMsg) +END_MESSAGE_MAP() + void CEjectPhonographButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeQuotedLine(_string3, indent); - file->writeQuotedLine(_string4, indent); + file->writeNumberLine(_ejected, indent); + file->writeNumberLine(_readyFlag, indent); + file->writeQuotedLine(_soundName, indent); + file->writeQuotedLine(_readySoundName, indent); CBackground::save(file, indent); } void CEjectPhonographButton::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _string3 = file->readString(); - _string4 = file->readString(); + _ejected = file->readNumber(); + _readyFlag = file->readNumber(); + _soundName = file->readString(); + _readySoundName = file->readString(); CBackground::load(file); } +bool CEjectPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CQueryPhonographState queryMsg; + queryMsg.execute(getParent(), nullptr, MSGFLAG_SCAN); + + if (!_ejected && !queryMsg._value) { + loadFrame(1); + playSound(_soundName); + _readyFlag = true; + + CEjectCylinderMsg ejectMsg; + ejectMsg.execute(getParent(), nullptr, MSGFLAG_SCAN); + _ejected = true; + } + + return true; +} + +bool CEjectPhonographButton::CylinderHolderReadyMsg(CCylinderHolderReadyMsg *msg) { + if (_readyFlag) { + loadFrame(0); + playSound(_readySoundName); + _readyFlag = 0; + } + + _ejected = false; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/eject_phonograph_button.h b/engines/titanic/game/eject_phonograph_button.h index 5f5da8053e..df8e602468 100644 --- a/engines/titanic/game/eject_phonograph_button.h +++ b/engines/titanic/game/eject_phonograph_button.h @@ -28,14 +28,17 @@ namespace Titanic { class CEjectPhonographButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool CylinderHolderReadyMsg(CCylinderHolderReadyMsg *msg); public: - int _fieldE0; - int _fieldE4; - CString _string3; - CString _string4; + bool _ejected; + bool _readyFlag; + CString _soundName; + CString _readySoundName; public: CLASSDEF; - CEjectPhonographButton() : CBackground(), _fieldE0(0), _fieldE4(0) {} + CEjectPhonographButton() : CBackground(), _ejected(false), _readyFlag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sgt/drawer.cpp b/engines/titanic/game/sgt/drawer.cpp index 03aa1b5358..b8e93c37a6 100644 --- a/engines/titanic/game/sgt/drawer.cpp +++ b/engines/titanic/game/sgt/drawer.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CDrawer, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + CDrawer::CDrawer() : CSGTStateRoom(), _fieldF4(0) { } @@ -39,4 +45,39 @@ void CDrawer::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CDrawer::TurnOn(CTurnOn *msg) { + if (_statics->_v7 == "Closed" && _statics->_v6 == "Open") { + _statics->_v7 = "Open"; + _fieldE0 = false; + _startFrame = 50; + _endFrame = 75; + setVisible(true); + _statics->_v7 = "Open"; + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playSound("b#10.wav"); + } + + return true; +} + +bool CDrawer::TurnOff(CTurnOff *msg) { + if (_statics->_v7 == "Open") { + _statics->_v7 = "Closed"; + _startFrame = 75; + _endFrame = 100; + _fieldE0 = true; + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playSound("b#10.wav"); + } + + return true; +} + +bool CDrawer::MovieEndMsg(CMovieEndMsg *msg) { + if (_statics->_v7 == "Closed") + setVisible(false); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/drawer.h b/engines/titanic/game/sgt/drawer.h index c079be389f..e8afe66068 100644 --- a/engines/titanic/game/sgt/drawer.h +++ b/engines/titanic/game/sgt/drawer.h @@ -28,6 +28,10 @@ namespace Titanic { class CDrawer : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); private: int _fieldF4; public: |