Skip to content

Commit

Permalink
PINK: started inventory implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
voltya authored and sev- committed Jun 28, 2018
1 parent cad72b1 commit c29b1d1
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 25 deletions.
3 changes: 1 addition & 2 deletions engines/pink/director.h
Expand Up @@ -37,7 +37,7 @@ class CelDecoder;
class Director {
public:
Director(OSystem *system);
//CActor *getActorByCoords()
Actor *getActorByPoint(Common::Point point);

void draw();
void update();
Expand All @@ -51,7 +51,6 @@ class Director {

void clear();

Actor *getActorByPoint(Common::Point point);
bool showBounds;

private:
Expand Down
26 changes: 20 additions & 6 deletions engines/pink/objects/actors/lead_actor.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion engines/pink/objects/actors/lead_actor.h
Expand Up @@ -66,6 +66,7 @@ class LeadActor : public Actor {
void onLeftButtonClick(Common::Point point);
void onMouseMove(Common::Point point);
void onWalkEnd();
void onClick();

virtual void onMouseOver(Common::Point point, CursorMgr *mgr);

Expand All @@ -75,10 +76,11 @@ class LeadActor : public Actor {
bool sendUseClickMessage(SupportingActor *actor);
bool sendLeftClickMessage(SupportingActor *actor);


State _state;
State _nextState;

bool _isHaveItem;

SupportingActor *_recipient;

CursorMgr *_cursorMgr;
Expand Down
4 changes: 2 additions & 2 deletions engines/pink/objects/actors/supporting_actor.cpp
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion engines/pink/objects/actors/supporting_actor.h
Expand Up @@ -28,6 +28,9 @@

namespace Pink {

class InventoryItem;
class InventoryMgr;

class SupportingActor : public Actor {
public:
virtual void deserialize(Archive &archive);
Expand All @@ -40,7 +43,7 @@ class SupportingActor : public Actor {

void onTimerMessage();
bool onLeftClickMessage();
bool onUseClickMessage();
bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr);

const Common::String &getLocation() const;

Expand Down
4 changes: 0 additions & 4 deletions engines/pink/objects/handlers/handler.cpp
Expand Up @@ -152,8 +152,4 @@ void HandlerUseClick::toConsole() {
}
}

void HandlerUseClick::execute(Sequence *sequence) {

}

} // End of namespace Pink
5 changes: 4 additions & 1 deletion engines/pink/objects/handlers/handler.h
Expand Up @@ -83,8 +83,11 @@ class HandlerUseClick : public HandlerSequences {
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;
Expand Down
15 changes: 9 additions & 6 deletions engines/pink/objects/handlers/handler_mgr.cpp
Expand Up @@ -7,6 +7,7 @@
#include "handler_timer.h"
#include <pink/archive.h>
#include <common/debug.h>
#include <pink/objects/inventory.h>

namespace Pink {

Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion engines/pink/objects/handlers/handler_mgr.h
Expand Up @@ -28,10 +28,14 @@

namespace Pink {

class InventoryItem;
class InventoryMgr;

class Handler;
class HandlerLeftClick;
class HandlerUseClick;
class HandlerTimer;

class Actor;

class HandlerMgr : public Object {
Expand All @@ -44,7 +48,7 @@ class HandlerMgr : public Object {

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);
Expand Down
9 changes: 8 additions & 1 deletion engines/pink/objects/inventory.cpp
Expand Up @@ -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
Expand Down

0 comments on commit c29b1d1

Please sign in to comment.