From 4b7c75607a5d54d95c383fabf381d82d4ac77b94 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Mon, 2 Apr 2018 11:28:11 +0300 Subject: [PATCH] PINK: added onMouseOver method to LeadActor --- engines/pink/objects/actors/lead_actor.cpp | 6 ++++++ engines/pink/objects/actors/lead_actor.h | 2 ++ engines/pink/objects/inventory.cpp | 25 ++++++++++++++++++++++ engines/pink/objects/inventory.h | 6 ++++++ 4 files changed, 39 insertions(+) diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index e26b50a42c2..c583d9a7c47 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -201,6 +201,12 @@ void LeadActor::onLeftButtonClick(Common::Point point) { } } +void LeadActor::onMouseOver(Common::Point point, CursorMgr *mgr) { + if (_page->getModule()->getInventoryMgr()->isPinkOwnsAnyItems()) + _cursorMgr->setCursor(kClickableFirstFrameCursor, {0, 0}); + else Actor::onMouseOver(point, mgr); +} + void ParlSqPink::toConsole() { debug("ParlSqPink: _name = %s", _name.c_str()); for (int i = 0; i < _actions.size(); ++i) { diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index 3a648939918..208bfaad242 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -63,6 +63,8 @@ public: void onLeftButtonClick(Common::Point point); void onMouseMove(Common::Point point); + virtual void onMouseOver(Common::Point point, CursorMgr *mgr); + private: void updateCursor(Common::Point point); diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp index feed41a29b7..0f1b7115039 100644 --- a/engines/pink/objects/inventory.cpp +++ b/engines/pink/objects/inventory.cpp @@ -24,9 +24,15 @@ #include #include "inventory.h" #include "engines/pink/archive.h" +#include "pink/objects/actors/lead_actor.h" namespace Pink { +InventoryMgr::InventoryMgr() + : _lead(nullptr), _item(nullptr) +{ +} + void Pink::InventoryItem::deserialize(Archive &archive) { NamedObject::deserialize(archive); _initialOwner = archive.readString(); @@ -69,6 +75,25 @@ void InventoryMgr::toConsole() { } } +bool InventoryMgr::isPinkOwnsAnyItems() { + if (_item) + return true; + + for (int i = 0; i < _items.size(); ++i) { + if (_items[i]->getCurrentOwner() == _lead->getName()){ + _item = _items[i]; + return true; + } + } + + return false; +} + +void InventoryMgr::setItemOwner(const Common::String &owner, InventoryItem *item) { + item->_currentOwner = owner; + _item = item; +} + } // End of namespace Pink diff --git a/engines/pink/objects/inventory.h b/engines/pink/objects/inventory.h index ca1ef7fb696..908f2a8d2fc 100644 --- a/engines/pink/objects/inventory.h +++ b/engines/pink/objects/inventory.h @@ -38,6 +38,7 @@ public: Common::String &getCurrentOwner(); + friend class InventoryMgr; private: Common::String _initialOwner; Common::String _currentOwner; @@ -47,6 +48,7 @@ class LeadActor; class InventoryMgr : public Object { public: + InventoryMgr(); virtual ~InventoryMgr(); virtual void deserialize(Archive &archive); @@ -55,8 +57,12 @@ public: void setLeadActor(LeadActor *lead); InventoryItem* findInventoryItem(Common::String &name); + bool isPinkOwnsAnyItems(); + void setItemOwner(const Common::String &owner, InventoryItem *item); + private: LeadActor *_lead; + InventoryItem *_item; Common::Array _items; // other fields. haven't RE them yet };