aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/core
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-26 12:39:44 -0400
committerPaul Gilbert2016-07-15 19:25:09 -0400
commit6f063c4703e5705edbba7ad39ef9c0656b74bc75 (patch)
tree64cb04d4e3f3a327f6a080ffef8e7af6c0f12152 /engines/titanic/core
parent0146a3c6b6bdb16eef6f46e116b0d9fe9883858f (diff)
downloadscummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.tar.gz
scummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.tar.bz2
scummvm-rg350-6f063c4703e5705edbba7ad39ef9c0656b74bc75.zip
TITANIC: Fleshing out CGameObject and CPetControl methods
Diffstat (limited to 'engines/titanic/core')
-rw-r--r--engines/titanic/core/game_object.cpp182
-rw-r--r--engines/titanic/core/game_object.h159
2 files changed, 228 insertions, 113 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 95024b9dae..a90318961c 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -501,12 +501,6 @@ bool CGameObject::checkStartDragging(CMouseDragStartMsg *msg) {
}
}
-void CGameObject::setPetArea(PetArea newArea) const {
- CPetControl *pet = getPetControl();
- if (pet)
- pet->setArea(newArea);
-}
-
bool CGameObject::hasActiveMovie() const {
if (_surface && _surface->_movie)
return _surface->_movie->isActive();
@@ -684,16 +678,6 @@ int CGameObject::compareRoomNameTo(const CString &name) {
return room->getName().compareToIgnoreCase(name);
}
-void CGameObject::petDisplayMsg(const CString &msg) const {
- CPetControl *pet = getPetControl();
- if (pet)
- pet->displayMessage(msg);
-}
-
-void CGameObject::displayMessage(const CString &msg) const {
- petDisplayMsg(msg);
-}
-
CGameObject *CGameObject::getMailManFirstObject() const {
CMailMan *mailMan = getMailMan();
return mailMan ? mailMan->getFirstObject() : nullptr;
@@ -764,14 +748,6 @@ Found CGameObject::find(const CString &name, CGameObject **item, int findAreas)
return FOUND_NONE;
}
-void CGameObject::moveToHiddenRoom() {
- CPetControl *pet = getPetControl();
- if (pet) {
- makeDirty();
- pet->moveToHiddenRoom(this);
- }
-}
-
void CGameObject::moveToView() {
CViewItem *view = getGameManager()->getView();
detach();
@@ -806,24 +782,6 @@ void CGameObject::unlockMouse() {
gameMan->unlockInputHandler();
}
-void CGameObject::startTalking(const CString &npcName, uint id, CViewItem *view) {
- CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(npcName));
- startTalking(npc, id, view);
-}
-
-void CGameObject::startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) {
- CGameManager *gameManager = getGameManager();
- if (gameManager) {
- CTrueTalkManager *talkManager = gameManager->getTalkManager();
- if (talkManager)
- talkManager->start(npc, id, view);
- }
-}
-
-void CGameObject::endTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) {
- warning("TODO: CGameObject::endTalking");
-}
-
void CGameObject::loadSurface() {
if (!_surface && !_resource.empty()) {
loadResource(_resource);
@@ -869,6 +827,10 @@ Point CGameObject::getControid() const {
_bounds.top + _bounds.height() / 2);
}
+void CGameObject::performAction(int actionNum, CViewItem *view) {
+ // TODO
+}
+
bool CGameObject::clipExistsByStart(const CString &name, int startFrame) const {
return _clipList1.existsByStart(name, startFrame);
}
@@ -888,7 +850,7 @@ void CGameObject::checkPlayMovie(const CString &name, int flags) {
}
}
-void CGameObject::clearPet() const {
+void CGameObject::petClear() const {
CPetControl *petControl = getPetControl();
if (petControl)
petControl->resetActiveNPC();
@@ -1002,12 +964,20 @@ int CGameObject::getClipDuration(const CString &name, int frameRate) const {
return clip ? (clip->_endFrame - clip->_startFrame) * 1000 / frameRate : 0;
}
-void CGameObject::petLockInput() {
- getPetControl()->incInputLocks();
-}
+bool CGameObject::compareRoomFlags(int mode, uint flags1, uint flags2) {
+ switch (mode) {
+ case 1:
+ return CRoomFlags::compareLocation(flags1, flags2);
-void CGameObject::petUnlockInput() {
- getPetControl()->decInputLocks();
+ case 2:
+ return CRoomFlags::compareClassElevator(flags1, flags2);
+
+ case 3:
+ return CRoomFlags::isTitania(flags1, flags2);
+
+ default:
+ return false;
+ }
}
void CGameObject::setState1C(bool flag) {
@@ -1051,10 +1021,48 @@ void CGameObject::resetMail() {
mailMan->resetValue();
}
-void CGameObject::petSetRooms1D0(int val) {
- CPetControl *petControl = getPetControl();
- if (petControl)
- petControl->setRooms1D0(val);
+void CGameObject::petAddToCarryParcel(CGameObject *obj) {
+ CPetControl *pet = getPetControl();
+ if (pet) {
+ CGameObject *parcel = pet->getHiddenObject("CarryParcel");
+ if (parcel)
+ parcel->moveUnder(obj);
+ }
+}
+
+void CGameObject::petAddToInventory() {
+ CPetControl *pet = getPetControl();
+ if (pet) {
+ makeDirty();
+ pet->addToInventory(this);
+ }
+}
+
+CTreeItem *CGameObject::petContainerRemove(CGameObject *obj) {
+ CPetControl *pet = getPetControl();
+ if (!obj || !pet)
+ return nullptr;
+ if (!obj->compareRoomNameTo("CarryParcel"))
+ return obj;
+
+ CGameObject *item = static_cast<CGameObject *>(pet->getLastChild());
+ if (item)
+ item->detach();
+
+ pet->moveToHiddenRoom(obj);
+ pet->removeFromInventory(item, false, false);
+
+ return item;
+}
+
+void CGameObject::petDisplayMessage(int unused, const CString &msg) {
+ petDisplayMessage(msg);
+}
+
+void CGameObject::petDisplayMessage(const CString &msg) {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->displayMessage(msg);
}
int CGameObject::petGetRooms1D0() const {
@@ -1062,10 +1070,78 @@ int CGameObject::petGetRooms1D0() const {
return petControl ? petControl->getRooms1D0() : 0;
}
-void CGameObject::reassignRoom(int passClassNum) {
+void CGameObject::petInvChange() {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->invChange(this);
+}
+
+void CGameObject::petLockInput() {
+ getPetControl()->incInputLocks();
+}
+
+void CGameObject::petMoveToHiddenRoom() {
+ CPetControl *pet = getPetControl();
+ if (pet) {
+ makeDirty();
+ pet->moveToHiddenRoom(this);
+ }
+}
+
+void CGameObject::petReassignRoom(int passClassNum) {
CPetControl *petControl = getPetControl();
if (petControl)
petControl->reassignRoom(passClassNum);
}
+void CGameObject::petSetArea(PetArea newArea) const {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->setArea(newArea);
+}
+
+void CGameObject::petSetRooms1D0(int val) {
+ CPetControl *petControl = getPetControl();
+ if (petControl)
+ petControl->setRooms1D0(val);
+}
+
+void CGameObject::petOnSummonBot(const CString &name, int val) {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->summonBot(name, val);
+}
+
+void CGameObject::petUnlockInput() {
+ getPetControl()->decInputLocks();
+}
+
+/*------------------------------------------------------------------------*/
+
+void CGameObject::startTalking(const CString &npcName, uint id, CViewItem *view) {
+ CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(npcName));
+ startTalking(npc, id, view);
+}
+
+void CGameObject::startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) {
+ CGameManager *gameManager = getGameManager();
+ if (gameManager) {
+ CTrueTalkManager *talkManager = gameManager->getTalkManager();
+ if (talkManager)
+ talkManager->start(npc, id, view);
+ }
+}
+
+void CGameObject::endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view) {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->setActiveNPC(npc);
+
+ if (viewFlag)
+ npc->setView(view);
+
+ if (pet)
+ pet->refreshNPC();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 7a12abe76c..4ca8061d75 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -111,11 +111,6 @@ protected:
bool checkStartDragging(CMouseDragStartMsg *msg);
/**
- * Sets a new area in the PET
- */
- void setPetArea(PetArea newArea) const;
-
- /**
* Goto a new view
*/
void gotoView(const CString &viewName, const CString &clipName);
@@ -126,26 +121,6 @@ protected:
*/
CViewItem * parseView(const CString &viewString);
- /**
- * Highlights a glyph in the currently active PET section
- */
- void petHighlightGlyph(int id);
-
- /**
- * Hides the text cursor in the current section, if applicable
- */
- void petHideCursor();
-
- /**
- * Shows the text cursor in the current section, if applicable
- */
- void petShowCursor();
-
- /**
- * Set the remote target in the PET to this object
- */
- void petSetRemoteTarget();
-
void incState38();
void inc54();
void dec54();
@@ -221,11 +196,6 @@ protected:
int compareRoomNameTo(const CString &name);
/**
- * Display a message in the PET
- */
- void petDisplayMsg(const CString &msg) const;
-
- /**
* Display a message
*/
void displayMessage(const CString &msg) const;
@@ -256,21 +226,6 @@ protected:
void moveToView();
/**
- * Start a conversation with the NPC
- */
- void startTalking(const CString &name, uint id, CViewItem *view = nullptr);
-
- /**
- * Start a conversation with the NPC
- */
- void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr);
-
- /**
- * Stop a conversation with the NPC
- */
- void endTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr);
-
- /**
* Change the view
*/
bool changeView(const CString &viewName, const CString &clipName);
@@ -317,7 +272,12 @@ protected:
/**
* Clear the PET display
*/
- void clearPet() const;
+ void petClear() const;
+
+ /**
+ * Perform an action
+ */
+ void performAction(int actionNum, CViewItem *view = nullptr);
/**
* Returns the MailMan
@@ -463,11 +423,6 @@ public:
* Returns true if the item is the PET control
*/
virtual bool isPet() const;
-
- /**
- * Returns the PET control
- */
- CPetControl *getPetControl() const;
/**
* Play the movie specified in _resource
@@ -475,11 +430,6 @@ public:
void playMovie(uint startFrame, uint endFrame, uint flags);
/**
- * Moves the item from it's original position to be under the hidden room
- */
- void moveToHiddenRoom();
-
- /**
* Checks the passed point is validly in the object,
* with extra checking of object flags status
*/
@@ -567,19 +517,108 @@ public:
*/
void createCredits();
- void petSetRooms1D0(int val);
+ /**
+ * Support function for drag moving
+ */
+ void dragMove(const Point &pt);
+
+ bool compareRoomFlags(int mode, uint flags1, uint flags2);
+
+ /*--- CPetControl Methods ---*/
+
+ /**
+ * Returns the PET control
+ */
+ CPetControl *getPetControl() const;
+
+ /**
+ * Moves a specified item to the carry parcel
+ */
+ void petAddToCarryParcel(CGameObject *obj);
+
+ /**
+ * Add the item to the inventory
+ */
+ void petAddToInventory();
+
+ CTreeItem *petContainerRemove(CGameObject *obj);
+
+ /**
+ * Display a message in the PET
+ */
+ void petDisplayMessage(int unused, const CString &msg);
+
+ /**
+ * Display a message in the PET
+ */
+ void petDisplayMessage(const CString &msg);
int petGetRooms1D0() const;
/**
+ * Hides the text cursor in the current section, if applicable
+ */
+ void petHideCursor();
+
+ /**
+ * Highlights a glyph in the currently active PET section
+ */
+ void petHighlightGlyph(int id);
+
+ /**
+ * Called when the status of an item in the inventory has changed
+ */
+ void petInvChange();
+
+ /**
+ * Moves the item from it's original position to be under the hidden room
+ */
+ void petMoveToHiddenRoom();
+
+ /**
* Gives the player a new assigned room in the specified passenger class
*/
- void reassignRoom(int passClassNum);
+ void petReassignRoom(int passClassNum);
/**
- * Support function for drag moving
+ * Sets a new area in the PET
*/
- void dragMove(const Point &pt);
+ void petSetArea(PetArea newArea) const;
+
+ /**
+ * Set the remote target in the PET to this object
+ */
+ void petSetRemoteTarget();
+
+ void petSetRooms1D0(int val);
+
+ /**
+ * Shows the text cursor in the current section, if applicable
+ */
+ void petShowCursor();
+
+ /**
+ * Summon a bot
+ */
+ void petOnSummonBot(const CString &name, int val);
+
+ /*--- CTrueTalkManager Methods ---*/
+
+ /**
+ * Stop a conversation with the NPC
+ */
+ void endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view = nullptr);
+
+ /**
+ * Start a conversation with the NPC
+ */
+ void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr);
+
+ /**
+ * Start a conversation with the NPC
+ */
+ void startTalking(const CString &name, uint id, CViewItem *view = nullptr);
+
};
} // End of namespace Titanic