aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwhiterandrek2018-04-05 16:06:42 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commitc29b1d1112b70fcb017359f9a28eb8b7de49a5ab (patch)
tree952523c511905eeb9c7ae2df2039d141de0e3bef
parentcad72b1532faa96c68848392766f25a4a58398ab (diff)
downloadscummvm-rg350-c29b1d1112b70fcb017359f9a28eb8b7de49a5ab.tar.gz
scummvm-rg350-c29b1d1112b70fcb017359f9a28eb8b7de49a5ab.tar.bz2
scummvm-rg350-c29b1d1112b70fcb017359f9a28eb8b7de49a5ab.zip
PINK: started inventory implementation
-rw-r--r--engines/pink/director.h3
-rw-r--r--engines/pink/objects/actors/lead_actor.cpp26
-rw-r--r--engines/pink/objects/actors/lead_actor.h4
-rw-r--r--engines/pink/objects/actors/supporting_actor.cpp4
-rw-r--r--engines/pink/objects/actors/supporting_actor.h5
-rw-r--r--engines/pink/objects/handlers/handler.cpp4
-rw-r--r--engines/pink/objects/handlers/handler.h5
-rw-r--r--engines/pink/objects/handlers/handler_mgr.cpp15
-rw-r--r--engines/pink/objects/handlers/handler_mgr.h6
-rw-r--r--engines/pink/objects/inventory.cpp9
10 files changed, 56 insertions, 25 deletions
diff --git a/engines/pink/director.h b/engines/pink/director.h
index b03f22edd6..2fc042c228 100644
--- a/engines/pink/director.h
+++ b/engines/pink/director.h
@@ -37,7 +37,7 @@ class CelDecoder;
class Director {
public:
Director(OSystem *system);
- //CActor *getActorByCoords()
+ Actor *getActorByPoint(Common::Point point);
void draw();
void update();
@@ -51,7 +51,6 @@ public:
void clear();
- Actor *getActorByPoint(Common::Point point);
bool showBounds;
private:
diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp
index faa0d5aada..516569faed 100644
--- a/engines/pink/objects/actors/lead_actor.cpp
+++ b/engines/pink/objects/actors/lead_actor.cpp
@@ -184,16 +184,16 @@ void LeadActor::onLeftButtonClick(Common::Point point) {
Actor *actor = _page->getGame()->getDirector()->getActorByPoint(point);
if (this == actor){
- // inventory is not implemented
+ // inventory is not implemented
return;
}
_recipient = (SupportingActor*) actor;
if (actor->isClickable() &&
_recipient->isLeftClickHandlers()){
- _state = kMoving;
- _nextState = kInDialog1;
- _walkMgr->start(_walkMgr->findLocation(_recipient->getLocation()));
+ _state = kMoving;
+ _nextState = kInDialog1;
+ _walkMgr->start(_walkMgr->findLocation(_recipient->getLocation()));
}
break;
}
@@ -229,10 +229,24 @@ bool LeadActor::sendUseClickMessage(SupportingActor *actor) {
}
bool LeadActor::sendLeftClickMessage(SupportingActor *actor) {
- actor->onLeftClickMessage();
_nextState = _state != kPlayingVideo ? kReady : kPlayingVideo;
_state = kInDialog1;
- return false;
+ return actor->onLeftClickMessage();
+}
+
+void LeadActor::onClick() {
+ if (_isHaveItem) {
+ _isHaveItem = false;
+ _nextState = _state != kMoving ?
+ kUnk_Loading : kReady;
+ }
+ else {
+ if (_state == kMoving) {
+ this->_recipient = nullptr;
+ this->_nextState = nullptr;
+ }
+
+ }
}
void ParlSqPink::toConsole() {
diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h
index 261b5dcf25..a2c2ededab 100644
--- a/engines/pink/objects/actors/lead_actor.h
+++ b/engines/pink/objects/actors/lead_actor.h
@@ -66,6 +66,7 @@ public:
void onLeftButtonClick(Common::Point point);
void onMouseMove(Common::Point point);
void onWalkEnd();
+ void onClick();
virtual void onMouseOver(Common::Point point, CursorMgr *mgr);
@@ -75,10 +76,11 @@ private:
bool sendUseClickMessage(SupportingActor *actor);
bool sendLeftClickMessage(SupportingActor *actor);
-
State _state;
State _nextState;
+ bool _isHaveItem;
+
SupportingActor *_recipient;
CursorMgr *_cursorMgr;
diff --git a/engines/pink/objects/actors/supporting_actor.cpp b/engines/pink/objects/actors/supporting_actor.cpp
index d43f871c6f..e32c89ff84 100644
--- a/engines/pink/objects/actors/supporting_actor.cpp
+++ b/engines/pink/objects/actors/supporting_actor.cpp
@@ -65,8 +65,8 @@ bool SupportingActor::onLeftClickMessage() {
return _handlerMgr.onLeftClickMessage(this);
}
-bool SupportingActor::onUseClickMessage() {
- return _handlerMgr.onUseClickMessage(this);
+bool SupportingActor::onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) {
+ return _handlerMgr.onUseClickMessage(this, item, mgr);
}
const Common::String &SupportingActor::getLocation() const {
diff --git a/engines/pink/objects/actors/supporting_actor.h b/engines/pink/objects/actors/supporting_actor.h
index 2888582041..33b469f8aa 100644
--- a/engines/pink/objects/actors/supporting_actor.h
+++ b/engines/pink/objects/actors/supporting_actor.h
@@ -28,6 +28,9 @@
namespace Pink {
+class InventoryItem;
+class InventoryMgr;
+
class SupportingActor : public Actor {
public:
virtual void deserialize(Archive &archive);
@@ -40,7 +43,7 @@ public:
void onTimerMessage();
bool onLeftClickMessage();
- bool onUseClickMessage();
+ bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr);
const Common::String &getLocation() const;
diff --git a/engines/pink/objects/handlers/handler.cpp b/engines/pink/objects/handlers/handler.cpp
index 7c2bcaad8d..dd24925743 100644
--- a/engines/pink/objects/handlers/handler.cpp
+++ b/engines/pink/objects/handlers/handler.cpp
@@ -152,8 +152,4 @@ void HandlerUseClick::toConsole() {
}
}
-void HandlerUseClick::execute(Sequence *sequence) {
-
-}
-
} // End of namespace Pink
diff --git a/engines/pink/objects/handlers/handler.h b/engines/pink/objects/handlers/handler.h
index 47f9ab8df5..bf1f26b50c 100644
--- a/engines/pink/objects/handlers/handler.h
+++ b/engines/pink/objects/handlers/handler.h
@@ -83,8 +83,11 @@ public:
virtual void deserialize(Archive &archive);
virtual void toConsole();
+ const Common::String &getInventoryItem() const { return _inventoryItem; }
+ const Common::String &getRecepient() const { return _recepient; }
+
private:
- virtual void execute(Sequence *sequence);
+ virtual void execute(Sequence *sequence) {};
Common::String _inventoryItem;
Common::String _recepient;
diff --git a/engines/pink/objects/handlers/handler_mgr.cpp b/engines/pink/objects/handlers/handler_mgr.cpp
index 76c2cf6834..db53c6a5d2 100644
--- a/engines/pink/objects/handlers/handler_mgr.cpp
+++ b/engines/pink/objects/handlers/handler_mgr.cpp
@@ -7,6 +7,7 @@
#include "handler_timer.h"
#include <pink/archive.h>
#include <common/debug.h>
+#include <pink/objects/inventory.h>
namespace Pink {
@@ -46,18 +47,20 @@ bool HandlerMgr::onLeftClickMessage(Actor *actor) {
Handler *handler = findSuitableHandlerLeftClick(actor);
if (handler) {
handler->handle(actor);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-bool HandlerMgr::onUseClickMessage(Actor *actor) {
- Handler *handler = findSuitableHandlerUseClick(actor);
+bool HandlerMgr::onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr) {
+ HandlerUseClick *handler = (HandlerUseClick*) findSuitableHandlerUseClick(actor);
if (handler) {
handler->handle(actor);
- return 1;
+ mgr->setItemOwner(handler->getRecepient(), item);
+ handler->handle(actor);
+ return true;
}
- return 0;
+ return false;
}
Handler *HandlerMgr::findSuitableHandlerTimer(Actor *actor) {
diff --git a/engines/pink/objects/handlers/handler_mgr.h b/engines/pink/objects/handlers/handler_mgr.h
index 08160870da..7ff498ec7c 100644
--- a/engines/pink/objects/handlers/handler_mgr.h
+++ b/engines/pink/objects/handlers/handler_mgr.h
@@ -28,10 +28,14 @@
namespace Pink {
+class InventoryItem;
+class InventoryMgr;
+
class Handler;
class HandlerLeftClick;
class HandlerUseClick;
class HandlerTimer;
+
class Actor;
class HandlerMgr : public Object {
@@ -44,7 +48,7 @@ public:
void onTimerMessage(Actor *actor);
bool onLeftClickMessage(Actor *actor);
- bool onUseClickMessage(Actor *actor);
+ bool onUseClickMessage(Actor *actor, InventoryItem *item, InventoryMgr *mgr);
private:
Handler *findSuitableHandlerTimer(Actor *actor);
diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp
index 0f1b711503..9bbc279740 100644
--- a/engines/pink/objects/inventory.cpp
+++ b/engines/pink/objects/inventory.cpp
@@ -90,8 +90,15 @@ bool InventoryMgr::isPinkOwnsAnyItems() {
}
void InventoryMgr::setItemOwner(const Common::String &owner, InventoryItem *item) {
+ if (owner == item->getCurrentOwner())
+ return;
+
+ if (item == _item && _lead->getName() != owner)
+ _item = nullptr;
+ else if (_lead->getName() == owner)
+ _item = item;
+
item->_currentOwner = owner;
- _item = item;
}
} // End of namespace Pink