aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwhiterandrek2018-06-12 19:45:03 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commit7b651e41c62c64a63ef012bdc8c0ee61b6448ccf (patch)
treef72b5f58acdb531a5cf2e80a0157adace8b0430c
parentdef6698164c5c9e7b790b11908a055fdf0f261b1 (diff)
downloadscummvm-rg350-7b651e41c62c64a63ef012bdc8c0ee61b6448ccf.tar.gz
scummvm-rg350-7b651e41c62c64a63ef012bdc8c0ee61b6448ccf.tar.bz2
scummvm-rg350-7b651e41c62c64a63ef012bdc8c0ee61b6448ccf.zip
PINK: move the same code to functions(getInventoryMgr and getActorByPoint)
-rw-r--r--engines/pink/objects/actors/actor.cpp4
-rw-r--r--engines/pink/objects/actors/actor.h2
-rw-r--r--engines/pink/objects/actors/lead_actor.cpp36
-rw-r--r--engines/pink/objects/actors/lead_actor.h3
-rw-r--r--engines/pink/objects/condition.cpp2
-rw-r--r--engines/pink/objects/inventory.cpp2
-rw-r--r--engines/pink/objects/side_effect.cpp2
7 files changed, 31 insertions, 20 deletions
diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp
index 25e2a85a0a..8954d6c594 100644
--- a/engines/pink/objects/actors/actor.cpp
+++ b/engines/pink/objects/actors/actor.cpp
@@ -134,4 +134,8 @@ void Actor::setAction(Action *newAction, bool unk) {
}
}
+InventoryMgr *Actor::getInventoryMgr() const {
+ return _page->getModule()->getInventoryMgr();
+}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h
index 668186217d..9d00f6a364 100644
--- a/engines/pink/objects/actors/actor.h
+++ b/engines/pink/objects/actors/actor.h
@@ -76,6 +76,8 @@ public:
Action *getAction() const { return _action; }
Page *getPage() const { return _page; }
+ InventoryMgr *getInventoryMgr() const;
+
virtual const Common::String &getLocation() const;
void setAction(const Common::String &name) { setAction(findAction(name)); }
diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp
index c4e41b12c8..2891682fca 100644
--- a/engines/pink/objects/actors/lead_actor.cpp
+++ b/engines/pink/objects/actors/lead_actor.cpp
@@ -89,7 +89,7 @@ void LeadActor::init(bool unk) {
if (_state == kUnk_Loading)
_state = kReady;
- _page->getModule()->getInventoryMgr()->setLeadActor(this);
+ getInventoryMgr()->setLeadActor(this);
_page->getGame()->setLeadActor(this);
Actor::init(unk);
}
@@ -100,14 +100,15 @@ void LeadActor::start(bool isHandler) {
_nextState = kReady;
}
+ InventoryMgr *mgr = getInventoryMgr();
switch (_state) {
case kInventory:
- _page->getModule()->getInventoryMgr()->start(0);
+ mgr->start(0);
_page->pause(true);
break;
case kPDA:
if (_stateBeforePDA == kInventory) {
- _page->getModule()->getInventoryMgr()->start(0);
+ mgr->start(0);
_page->pause(true);
}
loadPDA(_page->getGame()->getPdaMgr().getSavedPageName());
@@ -136,7 +137,7 @@ void LeadActor::update() {
}
break;
case kInventory:
- getPage()->getModule()->getInventoryMgr()->update();
+ getInventoryMgr()->update();
break;
case kPDA:
getPage()->getGame()->getPdaMgr().update();
@@ -213,12 +214,10 @@ void LeadActor::onKeyboardButtonClick(Common::KeyCode code) {
}
void LeadActor::onLeftButtonClick(const Common::Point point) {
- InventoryMgr *invMgr = _page->getModule()->getInventoryMgr();
-
switch (_state) {
case kReady:
case kMoving: {
- Actor *actor = _page->getGame()->getDirector()->getActorByPoint(point);
+ Actor *actor = getActorByPoint(point);
if (this == actor) {
onClick();
@@ -246,7 +245,7 @@ void LeadActor::onLeftButtonClick(const Common::Point point) {
_page->getGame()->getPdaMgr().onLeftButtonClick(point);
break;
case kInventory:
- invMgr->onClick(point);
+ getInventoryMgr()->onClick(point);
break;
default:
break;
@@ -260,7 +259,7 @@ void LeadActor::onMouseMove(Common::Point point) {
}
void LeadActor::onMouseOver(const Common::Point point, CursorMgr *mgr) {
- if (_page->getModule()->getInventoryMgr()->isPinkOwnsAnyItems())
+ if (getInventoryMgr()->isPinkOwnsAnyItems())
_cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
else
Actor::onMouseOver(point, mgr);
@@ -276,7 +275,7 @@ void LeadActor::onClick() {
_recipient = nullptr;
_nextState = kReady;
}
- if (_page->getModule()->getInventoryMgr()->start(1)) {
+ if (getInventoryMgr()->start(1)) {
_stateCopy = _state;
_state = kInventory;
_page->pause(true);
@@ -317,7 +316,7 @@ bool LeadActor::isInteractingWith(Actor *actor) {
if (!_isHaveItem)
return actor->isLeftClickHandlers();
- return actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem());
+ return actor->isUseClickHandlers(getInventoryMgr()->getCurrentItem());
}
void LeadActor::setNextExecutors(const Common::String &nextModule, const Common::String &nextPage) {
@@ -336,9 +335,8 @@ void LeadActor::updateCursor(const Common::Point point) {
switch (_state) {
case kReady:
case kMoving: {
- Director *director = _page->getGame()->getDirector();
- Actor *actor = director->getActorByPoint(point);
- InventoryItem *item = _page->getModule()->getInventoryMgr()->getCurrentItem();
+ Actor *actor = getActorByPoint(point);
+ InventoryItem *item = getInventoryMgr()->getCurrentItem();
if (_isHaveItem) {
if (actor) {
actor->onHover(point, item->getName(), _cursorMgr);
@@ -365,7 +363,7 @@ void LeadActor::updateCursor(const Common::Point point) {
}
bool LeadActor::sendUseClickMessage(Actor *actor) {
- InventoryMgr *mgr = _page->getModule()->getInventoryMgr();
+ InventoryMgr *mgr = getInventoryMgr();
_nextState = _state != kPlayingVideo ? kReady : kPlayingVideo;
_state = kInDialog1;
InventoryItem *item = mgr->getCurrentItem();
@@ -385,6 +383,10 @@ WalkLocation *LeadActor::getWalkDestination() {
return _walkMgr->findLocation(_recipient->getLocation());
}
+Actor *LeadActor::getActorByPoint(const Common::Point point) {
+ return _page->getGame()->getDirector()->getActorByPoint(point);
+}
+
void ParlSqPink::toConsole() {
debug("ParlSqPink: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
@@ -421,9 +423,9 @@ void PubPink::onVariableSet() {
void PubPink::updateCursor(const Common::Point point) {
if (playingMiniGame()) {
- Actor *actor = _page->getGame()->getDirector()->getActorByPoint(point);
+ Actor *actor = getActorByPoint(point);
assert(actor);
- if (_state == kReady && actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem())) {
+ if (_state == kReady && actor->isUseClickHandlers(getInventoryMgr()->getCurrentItem())) {
_cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
} else
_cursorMgr->setCursor(kDefaultCursor, point, Common::String());
diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h
index 5b2ea70b7c..22d783ede5 100644
--- a/engines/pink/objects/actors/lead_actor.h
+++ b/engines/pink/objects/actors/lead_actor.h
@@ -70,6 +70,7 @@ public:
void onKeyboardButtonClick(Common::KeyCode code);
void onLeftButtonClick(const Common::Point point);
+ void onRightButtonClick(const Common::Point point);
void onMouseMove(const Common::Point point);
@@ -87,6 +88,8 @@ public:
State getState() const { return _state; }
+ Actor *getActorByPoint(const Common::Point point);
+
protected:
void forceUpdateCursor();
diff --git a/engines/pink/objects/condition.cpp b/engines/pink/objects/condition.cpp
index abb955028b..1329556df6 100644
--- a/engines/pink/objects/condition.cpp
+++ b/engines/pink/objects/condition.cpp
@@ -79,7 +79,7 @@ void ConditionInventoryItemOwner::deserialize(Archive &archive) {
}
bool ConditionInventoryItemOwner::evaluate(Actor *actor) {
- InventoryMgr *mgr = actor->getPage()->getModule()->getInventoryMgr();
+ InventoryMgr *mgr = actor->getInventoryMgr();
InventoryItem *item = mgr->findInventoryItem(_item);
return item->getCurrentOwner() == _owner;
}
diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp
index 2082869232..bfbff3e653 100644
--- a/engines/pink/objects/inventory.cpp
+++ b/engines/pink/objects/inventory.cpp
@@ -142,7 +142,7 @@ void InventoryMgr::onClick(Common::Point point) {
if (_state != kReady)
return;
- Actor *actor = _lead->getPage()->getGame()->getDirector()->getActorByPoint(point);
+ Actor *actor = _lead->getActorByPoint(point);
if (actor == _itemActor || actor == _window) {
if (actor->getAction()->getName() == "WBook") {
_lead->loadPDA("TOC");
diff --git a/engines/pink/objects/side_effect.cpp b/engines/pink/objects/side_effect.cpp
index 3bf67e15f8..fe43261fd1 100644
--- a/engines/pink/objects/side_effect.cpp
+++ b/engines/pink/objects/side_effect.cpp
@@ -66,7 +66,7 @@ void SideEffectInventoryItemOwner::deserialize(Archive &archive) {
}
void SideEffectInventoryItemOwner::execute(Actor *actor) {
- InventoryMgr *mgr = actor->getPage()->getModule()->getInventoryMgr();
+ InventoryMgr *mgr = actor->getInventoryMgr();
InventoryItem *item = mgr->findInventoryItem(_item);
mgr->setItemOwner(_owner, item);
}