aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control/pet_control.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-15 22:30:50 -0400
committerPaul Gilbert2016-07-10 16:11:11 -0400
commitbc716fda4b11b69eecfc0931afd3b12ef0afb589 (patch)
tree9d33925d2b042630bb7d6e1c8c324a64bed97ea0 /engines/titanic/pet_control/pet_control.cpp
parent95c885f877ac1fa243479d113b59e6f83a360c71 (diff)
downloadscummvm-rg350-bc716fda4b11b69eecfc0931afd3b12ef0afb589.tar.gz
scummvm-rg350-bc716fda4b11b69eecfc0931afd3b12ef0afb589.tar.bz2
scummvm-rg350-bc716fda4b11b69eecfc0931afd3b12ef0afb589.zip
TITANIC: Implemented CCarryParrot msg handlers and support methods
Diffstat (limited to 'engines/titanic/pet_control/pet_control.cpp')
-rw-r--r--engines/titanic/pet_control/pet_control.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index a955b085cc..bb320f29f4 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -21,7 +21,9 @@
*/
#include "titanic/pet_control/pet_control.h"
+#include "titanic/carry/carry.h"
#include "titanic/core/project_item.h"
+#include "titanic/messages/pet_messages.h"
#include "titanic/game_manager.h"
#include "titanic/game_state.h"
@@ -217,24 +219,9 @@ CRoomItem *CPetControl::getHiddenRoom() {
return _hiddenRoom;
}
-CGameObject *CPetControl::findItemInRoom(CRoomItem *room,
- const CString &name) const {
- if (!room)
- return nullptr;
-
- for (CTreeItem *treeItem = room->getFirstChild(); treeItem;
- treeItem = treeItem->scan(room)) {
- if (!treeItem->getName().compareTo(name)) {
- return dynamic_cast<CGameObject *>(treeItem);
- }
- }
-
- return nullptr;
-}
-
CGameObject *CPetControl::getHiddenObject(const CString &name) {
CRoomItem *room = getHiddenRoom();
- return room ? findItemInRoom(room, name) : nullptr;
+ return room ? findUnder(room, name) : nullptr;
}
bool CPetControl::containsPt(const Common::Point &pt) const {
@@ -369,6 +356,26 @@ void CPetControl::addToInventory(CCarry *item) {
_inventory.addItem(item);
}
+void CPetControl::removeFromInventory(CCarry *item, CTreeItem *newParent,
+ bool refreshUI, bool sendMsg) {
+ if (item && newParent) {
+ item->detach();
+ item->addUnder(newParent);
+
+ if (refreshUI)
+ _inventory.itemRemoved(item);
+ if (sendMsg) {
+ CPETLostObjectMsg lostMsg;
+ lostMsg.execute(item);
+ }
+ }
+}
+
+void CPetControl::removeFromInventory(CCarry *item, bool refreshUI, bool sendMsg) {
+ CViewItem *view = getGameManager()->getView();
+ removeFromInventory(item, view, refreshUI, sendMsg);
+}
+
void CPetControl::moveToHiddenRoom(CTreeItem *item) {
CRoomItem *room = getHiddenRoom();
if (room) {