PINK: added onMouseOver method to LeadActor

This commit is contained in:
whiterandrek 2018-04-02 11:28:11 +03:00 committed by Eugene Sandulenko
parent f6d620f683
commit 4b7c75607a
4 changed files with 39 additions and 0 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -24,9 +24,15 @@
#include <common/debug.h>
#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

View File

@ -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<InventoryItem*> _items;
// other fields. haven't RE them yet
};