aboutsummaryrefslogtreecommitdiff
path: root/engines/pink
diff options
context:
space:
mode:
authorwhiterandrek2018-06-02 22:06:10 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commitb682ecb0ea63906b0ad1f735031a9f800d535eb8 (patch)
tree42acc6f5591c012d21c2ca960b96fee82f9f97a7 /engines/pink
parenta531381f2b80aa8f0bf8c10610eaad6a3256415f (diff)
downloadscummvm-rg350-b682ecb0ea63906b0ad1f735031a9f800d535eb8.tar.gz
scummvm-rg350-b682ecb0ea63906b0ad1f735031a9f800d535eb8.tar.bz2
scummvm-rg350-b682ecb0ea63906b0ad1f735031a9f800d535eb8.zip
PINK: refactor Actors to remove casts and improve readability
Diffstat (limited to 'engines/pink')
-rw-r--r--engines/pink/objects/actors/actor.cpp158
-rw-r--r--engines/pink/objects/actors/actor.h55
-rw-r--r--engines/pink/objects/actors/audio_info_pda_button.h4
-rw-r--r--engines/pink/objects/actors/cursor_actor.h2
-rw-r--r--engines/pink/objects/actors/inventory_actor.h2
-rw-r--r--engines/pink/objects/actors/lead_actor.cpp350
-rw-r--r--engines/pink/objects/actors/lead_actor.h79
-rw-r--r--engines/pink/objects/actors/pda_button_actor.cpp2
-rw-r--r--engines/pink/objects/actors/pda_button_actor.h6
-rw-r--r--engines/pink/objects/actors/supporting_actor.cpp26
-rw-r--r--engines/pink/objects/actors/supporting_actor.h23
-rw-r--r--engines/pink/objects/object.cpp20
-rw-r--r--engines/pink/objects/object.h17
-rw-r--r--engines/pink/objects/sequences/seq_timer.cpp7
14 files changed, 405 insertions, 346 deletions
diff --git a/engines/pink/objects/actors/actor.cpp b/engines/pink/objects/actors/actor.cpp
index cf87b57198..3fb2c4a786 100644
--- a/engines/pink/objects/actors/actor.cpp
+++ b/engines/pink/objects/actors/actor.cpp
@@ -29,33 +29,33 @@
namespace Pink {
+Actor::Actor()
+ : _page(nullptr), _action(nullptr),
+ _isActionEnded(1) {}
+
+Actor::~Actor() {
+ for (uint i = 0; i < _actions.size(); ++i) {
+ delete _actions[i];
+ }
+}
+
void Actor::deserialize(Archive &archive) {
NamedObject::deserialize(archive);
_page = static_cast<Page*>(archive.readObject());
_actions.deserialize(archive);
}
-void Actor::toConsole() {
- debug("Actor: _name = %s", _name.c_str());
- for (uint i = 0; i < _actions.size(); ++i) {
- _actions[i]->toConsole();
- }
+void Actor::loadState(Archive &archive) {
+ _action = findAction(archive.readString());
}
-Sequencer *Actor::getSequencer() const {
- return _page->getSequencer();
-}
+void Actor::saveState(Archive &archive) {
+ Common::String actionName;
-Action *Actor::findAction(const Common::String &name) {
- for (uint i = 0; i < _actions.size(); ++i) {
- if (_actions[i]->getName() == name)
- return _actions[i];
- }
- return nullptr;
-}
+ if (_action)
+ actionName = _action->getName();
-Page *Actor::getPage() const {
- return _page;
+ archive.writeString(actionName);
}
void Actor::init(bool unk) {
@@ -70,6 +70,30 @@ void Actor::init(bool unk) {
}
}
+bool Actor::initPallete(Director *director) {
+ for (uint i = 0; i < _actions.size(); ++i) {
+ if (_actions[i]->initPalette(director))
+ return true;
+ }
+ return false;
+}
+
+void Actor::toConsole() {
+ debug("Actor: _name = %s", _name.c_str());
+ for (uint i = 0; i < _actions.size(); ++i) {
+ _actions[i]->toConsole();
+ }
+}
+
+bool Actor::isPlaying() {
+ return !_isActionEnded;
+}
+
+void Actor::pause(bool paused) {
+ if (_action)
+ _action->pause(paused);
+}
+
void Actor::hide() {
setAction(kHideAction);
}
@@ -78,84 +102,84 @@ void Actor::endAction() {
_isActionEnded = 1;
}
-void Actor::setAction(const Common::String &name) {
- Action *newAction = findAction(name);
- setAction(newAction);
+bool Actor::isLeftClickHandlers() {
+ return false;
}
-void Actor::setAction(Action *newAction) {
- if (_action) {
- _isActionEnded = 1;
- _action->end();
- }
- _action = newAction;
- if (newAction) {
- _isActionEnded = 0;
- _action->start(0);
- }
+bool Actor::isUseClickHandlers(InventoryItem *item) {
+ return false;
}
-void Actor::setAction(Action *newAction, bool unk) {
- if (unk) {
- //assert(0); // want to see this
- _isActionEnded = 1;
- _action = newAction;
- } else {
- setAction(newAction);
- }
+void Actor::onMouseOver(const Common::Point point, CursorMgr *mgr) {
+ mgr->setCursor(kDefaultCursor, point, Common::String());
}
-Action *Actor::getAction() const {
- return _action;
+void Actor::onHover(const Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
+ cursorMgr->setCursor(kHoldingItemCursor, point, itemName);
}
-bool Actor::isPlaying() {
- return !_isActionEnded;
-}
+void Actor::onClick() {}
-bool Actor::initPallete(Director *director) {
- for (uint i = 0; i < _actions.size(); ++i) {
- if (_actions[i]->initPalette(director))
- return true;
- }
+void Actor::onTimerMessage() {}
+
+bool Actor::onLeftClickMessage() {
return false;
}
-void Actor::onMouseOver(Common::Point point, CursorMgr *mgr) {
- mgr->setCursor(kDefaultCursor, point, Common::String());
+bool Actor::onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) {
+ return false;
}
-Actor::~Actor() {
+Action *Actor::findAction(const Common::String &name) {
for (uint i = 0; i < _actions.size(); ++i) {
- delete _actions[i];
+ if (_actions[i]->getName() == name)
+ return _actions[i];
}
+ return nullptr;
}
-void Actor::loadState(Archive &archive) {
- _action = findAction(archive.readString());
+Action *Actor::getAction() const {
+ return _action;
}
-void Actor::saveState(Archive &archive) {
- Common::String actionName;
+Page *Actor::getPage() const {
+ return _page;
+}
- if (_action)
- actionName = _action->getName();
+Sequencer *Actor::getSequencer() const {
+ return _page->getSequencer();
+}
- archive.writeString(actionName);
+const Common::String &Actor::getLocation() const {
+ static const Common::String empty;
+ return empty;
}
-void Actor::pause() {
- if (_action)
- _action->pause();
+void Actor::setAction(const Common::String &name) {
+ Action *newAction = findAction(name);
+ setAction(newAction);
}
-void Actor::unpause() {
- if (_action)
- _action->unpause();
+void Actor::setAction(Action *newAction) {
+ if (_action) {
+ _isActionEnded = 1;
+ _action->end();
+ }
+ _action = newAction;
+ if (newAction) {
+ _isActionEnded = 0;
+ _action->start(0);
+ }
}
-void Actor::onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
- cursorMgr->setCursor(kHoldingItemCursor, point, itemName);
+void Actor::setAction(Action *newAction, bool unk) {
+ if (unk) {
+ //assert(0); // want to see this
+ _isActionEnded = 1;
+ _action = newAction;
+ } else {
+ setAction(newAction);
+ }
}
void Actor::setPage(Page *page) {
diff --git a/engines/pink/objects/actors/actor.h b/engines/pink/objects/actors/actor.h
index e39ce844e1..037b42e8b9 100644
--- a/engines/pink/objects/actors/actor.h
+++ b/engines/pink/objects/actors/actor.h
@@ -39,50 +39,57 @@ class InventoryMgr;
class Actor : public NamedObject {
public:
- Actor()
- : _page(nullptr), _action(nullptr),
- _isActionEnded(1) {};
+ Actor();
~Actor();
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
+ void deserialize(Archive &archive) override;
- Sequencer *getSequencer() const;
- Page *getPage() const;
- Action *getAction() const;
+ void loadState(Archive &archive);
+ void saveState(Archive &archive);
- bool isPlaying();
virtual void init(bool unk);
+ bool initPallete(Director *director);
+
+ void toConsole() override ;
+
+ bool isPlaying();
+ virtual void pause(bool paused);
+
void hide();
void endAction();
- Action *findAction(const Common::String &name);
- void setAction(const Common::String &name);
- void setAction(Action *newAction);
- void setAction(Action *newAction, bool unk);
+ virtual bool isLeftClickHandlers();
+ virtual bool isUseClickHandlers(InventoryItem *item);
- void setPage(Page *page);
+ virtual void onMouseOver(const Common::Point point, CursorMgr *mgr);
+ virtual void onHover(const Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr);
- void loadState(Archive &archive);
- void saveState(Archive &archive);
+ virtual void onClick();
- bool initPallete(Director *director);
+ virtual void onTimerMessage();
+ virtual bool onLeftClickMessage();
+ virtual bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr);
- virtual void update() {};
+ Action *findAction(const Common::String &name);
- virtual void onMouseOver(Common::Point point, CursorMgr *mgr);
- virtual void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr);
- virtual void onClick() {};
+ Action *getAction() const;
+ Page *getPage() const;
+ Sequencer *getSequencer() const;
- virtual bool isClickable() { return 0; }
+ virtual const Common::String &getLocation() const;
- virtual void pause();
- virtual void unpause();
+ void setAction(const Common::String &name);
+ void setAction(Action *newAction);
+ void setAction(Action *newAction, bool unk);
+
+ void setPage(Page *page);
protected:
Page *_page;
+
Action *_action;
Array<Action *> _actions;
+
bool _isActionEnded;
};
diff --git a/engines/pink/objects/actors/audio_info_pda_button.h b/engines/pink/objects/actors/audio_info_pda_button.h
index 05c8408fe5..f54edd66ee 100644
--- a/engines/pink/objects/actors/audio_info_pda_button.h
+++ b/engines/pink/objects/actors/audio_info_pda_button.h
@@ -34,8 +34,8 @@ namespace Pink {
class AudioInfoPDAButton : public Actor {
public:
- void toConsole() {
- debug("CursorActor: _name = %s", _name.c_str());
+ void toConsole() override {
+ debug("AudioInfoPDAButton: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
}
diff --git a/engines/pink/objects/actors/cursor_actor.h b/engines/pink/objects/actors/cursor_actor.h
index 897728c30c..8446b76e45 100644
--- a/engines/pink/objects/actors/cursor_actor.h
+++ b/engines/pink/objects/actors/cursor_actor.h
@@ -33,7 +33,7 @@ namespace Pink {
//same as actor
class CursorActor : public Actor {
public:
- void toConsole() {
+ void toConsole() override {
debug("CursorActor: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
diff --git a/engines/pink/objects/actors/inventory_actor.h b/engines/pink/objects/actors/inventory_actor.h
index 9fad7f6b06..d36b5f821e 100644
--- a/engines/pink/objects/actors/inventory_actor.h
+++ b/engines/pink/objects/actors/inventory_actor.h
@@ -32,7 +32,7 @@ namespace Pink {
class InventoryActor : public Actor {
public:
- void toConsole() {
+ void toConsole() override {
debug("CursorActor: _name = %s", _name.c_str());
for (uint i = 0; i < _actions.size(); ++i) {
_actions[i]->toConsole();
diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp
index 17ec0ee49c..578f77b89c 100644
--- a/engines/pink/objects/actors/lead_actor.cpp
+++ b/engines/pink/objects/actors/lead_actor.cpp
@@ -33,6 +33,11 @@
namespace Pink {
+LeadActor::LeadActor()
+ : _state(kReady), _nextState(kReady), _isHaveItem(false),
+ _recipient(nullptr), _cursorMgr(nullptr), _walkMgr(nullptr),
+ _sequencer(nullptr) {}
+
void LeadActor::deserialize(Archive &archive) {
_state = kReady;
Actor::deserialize(archive);
@@ -41,13 +46,42 @@ void LeadActor::deserialize(Archive &archive) {
_sequencer = static_cast<Sequencer*>(archive.readObject());
}
-void LeadActor::setNextExecutors(Common::String &nextModule, Common::String &nextPage) {
- if (_state == kReady || _state == kMoving || _state == kInDialog1 || _state == kInventory || _state == kPDA) {
- _state = kPlayingVideo;
- _page->getGame()->setNextExecutors(nextModule, nextPage);
+void LeadActor::toConsole() {
+ debug("LeadActor: _name = %s", _name.c_str());
+ for (uint i = 0; i < _actions.size(); ++i) {
+ _actions[i]->toConsole();
}
}
+void LeadActor::loadState(Archive &archive) {
+ _state = (State) archive.readByte();
+ _nextState = (State) archive.readByte();
+ _stateCopy = (State) archive.readByte();
+ _isHaveItem = archive.readByte();
+ Common::String recepient = archive.readString();
+ if (!recepient.empty())
+ _recipient = _page->findActor(recepient);
+ else
+ _recipient = nullptr;
+ _sequencer->loadState(archive);
+ _walkMgr->loadState(archive);
+
+ // load audioInfoMgr, PDAMgr
+}
+
+void LeadActor::saveState(Archive &archive) {
+ archive.writeByte(_state);
+ archive.writeByte(_nextState);
+ archive.writeByte(_stateCopy);
+ archive.writeByte(_isHaveItem);
+ if (_recipient)
+ archive.writeString(_recipient->getName());
+ else
+ archive.writeString(Common::String());
+ _sequencer->saveState(archive);
+ _walkMgr->saveState(archive);
+}
+
void LeadActor::init(bool unk) {
if (_state == kUnk_Loading)
_state = kReady;
@@ -57,15 +91,22 @@ void LeadActor::init(bool unk) {
Actor::init(unk);
}
-void LeadActor::toConsole() {
- debug("LeadActor: _name = %s", _name.c_str());
- for (uint i = 0; i < _actions.size(); ++i) {
- _actions[i]->toConsole();
+void LeadActor::start(bool isHandler) {
+ if (isHandler && _state != kPlayingVideo) {
+ _state = kInDialog1;
+ _nextState = kReady;
}
-}
-LeadActor::State LeadActor::getState() const {
- return _state;
+ switch (_state) {
+ case kInventory:
+ _page->getModule()->getInventoryMgr()->start(0);
+ _page->pause(true);
+ break;
+ case kPDA:
+
+ default:
+ forceUpdateCursor();
+ }
}
void LeadActor::update() {
@@ -106,7 +147,26 @@ void LeadActor::update() {
}
}
+void LeadActor::loadPDA(const Common::String &pageName) {
+ if (_state != kPDA) {
+ if (_state == kMoving) {
+ _recipient = nullptr;
+ _nextState = kReady;
+ }
+ _state = kPDA;
+ if (_state != kInventory)
+ _page->pause(true);
+ _page->getGame()->getDirector()->clear();
+ }
+ _page->getGame()->getPdaMgr().setLead(this);
+ _page->getGame()->getPdaMgr().goToPage(pageName);
+}
+
void LeadActor::onKeyboardButtonClick(Common::KeyCode code) {
+ if (code == Common::KEYCODE_g) {
+ loadPDA("TOC");
+ return;
+ }
switch (_state) {
case kMoving:
switch (code) {
@@ -142,63 +202,7 @@ void LeadActor::onKeyboardButtonClick(Common::KeyCode code) {
}
}
-void LeadActor::start(bool isHandler) {
- if (isHandler && _state != kPlayingVideo) {
- _state = kInDialog1;
- _nextState = kReady;
- }
-
- switch (_state) {
- case kInventory:
- _page->getModule()->getInventoryMgr()->start(0);
- _page->pause();
- break;
- case kPDA:
-
- default:
- forceUpdateCursor();
- }
-}
-
-void LeadActor::onMouseMove(Common::Point point) {
- if (_state != kPDA)
- updateCursor(point);
- else _page->getGame()->getPdaMgr().onMouseMove(point);
-}
-
-void LeadActor::updateCursor(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();
- if (_isHaveItem) {
- if (actor) {
- actor->onHover(point, item->getName(), _cursorMgr);
- } else
- _cursorMgr->setCursor(kHoldingItemCursor, point, item->getName());
- } else if (actor)
- actor->onMouseOver(point, _cursorMgr);
- else
- _cursorMgr->setCursor(kDefaultCursor, point, Common::String());
- break;
- }
- case kInDialog1:
- case kInDialog2:
- case kPlayingVideo:
- _cursorMgr->setCursor(kNotClickableCursor, point, Common::String());
- break;
- case kPDA:
- case kInventory:
- _cursorMgr->setCursor(kDefaultCursor, point, Common::String());
- break;
- default:
- break;
- }
-}
-
-void LeadActor::onLeftButtonClick(Common::Point point) {
+void LeadActor::onLeftButtonClick(const Common::Point point) {
InventoryMgr *invMgr = _page->getModule()->getInventoryMgr();
switch (_state) {
@@ -211,8 +215,8 @@ void LeadActor::onLeftButtonClick(Common::Point point) {
return;
}
- _recipient = dynamic_cast<SupportingActor *>(actor);
- if (actor->isClickable() && isInteractingWith(_recipient)) {
+ _recipient = actor;
+ if (isInteractingWith(_recipient)) {
WalkLocation *location = getWalkDestination();
if (location) {
_state = kMoving;
@@ -239,42 +243,19 @@ void LeadActor::onLeftButtonClick(Common::Point point) {
}
}
-void LeadActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
+void LeadActor::onMouseMove(Common::Point point) {
+ if (_state != kPDA)
+ updateCursor(point);
+ else _page->getGame()->getPdaMgr().onMouseMove(point);
+}
+
+void LeadActor::onMouseOver(const Common::Point point, CursorMgr *mgr) {
if (_page->getModule()->getInventoryMgr()->isPinkOwnsAnyItems())
_cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
else
Actor::onMouseOver(point, mgr);
}
-void LeadActor::onWalkEnd() {
- State oldNextState = _nextState;
- _state = kReady;
- _nextState = kUnk_Loading;
- if (_recipient && oldNextState == kInDialog1) {
- if (_isHaveItem)
- sendUseClickMessage(_recipient);
- else
- sendLeftClickMessage(_recipient);
- }
-}
-
-bool LeadActor::sendUseClickMessage(SupportingActor *actor) {
- InventoryMgr *mgr = _page->getModule()->getInventoryMgr();
- _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo;
- _state = kInDialog1;
- InventoryItem *item = mgr->getCurrentItem();
- actor->onUseClickMessage(mgr->getCurrentItem(), mgr);
- if (item->getCurrentOwner() != this->_name)
- _isHaveItem = false;
- return true;
-}
-
-bool LeadActor::sendLeftClickMessage(SupportingActor *actor) {
- _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo;
- _state = kInDialog1;
- return actor->onLeftClickMessage();
-}
-
void LeadActor::onClick() {
if (_isHaveItem) {
_isHaveItem = false;
@@ -288,82 +269,107 @@ void LeadActor::onClick() {
if (_page->getModule()->getInventoryMgr()->start(1)) {
_stateCopy = _state;
_state = kInventory;
- _page->pause();
+ _page->pause(true);
}
}
}
-LeadActor::LeadActor()
- : _state(kReady), _nextState(kReady), _isHaveItem(false),
- _recipient(nullptr), _cursorMgr(nullptr), _walkMgr(nullptr),
- _sequencer(nullptr) {}
+void LeadActor::onVariableSet() {}
void LeadActor::onInventoryClosed(bool isItemClicked) {
_isHaveItem = isItemClicked;
_state = _stateCopy;
_stateCopy = kUnk_Loading;
- _page->unpause();
+ _page->pause(false);
forceUpdateCursor();
}
-void LeadActor::forceUpdateCursor() {
- Common::Point point = _page->getGame()->getEventManager()->getMousePos();
- updateCursor(point);
-}
-
-WalkLocation *LeadActor::getWalkDestination() {
- return _walkMgr->findLocation(_recipient->getLocation());
+void LeadActor::onWalkEnd() {
+ State oldNextState = _nextState;
+ _state = kReady;
+ _nextState = kUnk_Loading;
+ if (_recipient && oldNextState == kInDialog1) {
+ if (_isHaveItem)
+ sendUseClickMessage(_recipient);
+ else
+ sendLeftClickMessage(_recipient);
+ }
}
-bool LeadActor::isInteractingWith(SupportingActor *actor) {
+bool LeadActor::isInteractingWith(Actor *actor) {
if (!_isHaveItem)
return actor->isLeftClickHandlers();
return actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem());
}
-void LeadActor::loadState(Archive &archive) {
- _state = (State) archive.readByte();
- _nextState = (State) archive.readByte();
- _stateCopy = (State) archive.readByte();
- _isHaveItem = archive.readByte();
- Common::String recepient = archive.readString();
- if (!recepient.empty())
- _recipient = (SupportingActor*) _page->findActor(recepient);
- else
- _recipient = nullptr;
- _sequencer->loadState(archive);
- _walkMgr->loadState(archive);
+void LeadActor::setNextExecutors(const Common::String &nextModule, const Common::String &nextPage) {
+ if (_state == kReady || _state == kMoving || _state == kInDialog1 || _state == kInventory || _state == kPDA) {
+ _state = kPlayingVideo;
+ _page->getGame()->setNextExecutors(nextModule, nextPage);
+ }
+}
- // load audioInfoMgr, PDAMgr
+LeadActor::State LeadActor::getState() const {
+ return _state;
}
-void LeadActor::saveState(Archive &archive) {
- archive.writeByte(_state);
- archive.writeByte(_nextState);
- archive.writeByte(_stateCopy);
- archive.writeByte(_isHaveItem);
- if (_recipient)
- archive.writeString(_recipient->getName());
- else
- archive.writeString(Common::String());
- _sequencer->saveState(archive);
- _walkMgr->saveState(archive);
+void LeadActor::forceUpdateCursor() {
+ const Common::Point point = _page->getGame()->getEventManager()->getMousePos();
+ updateCursor(point);
}
-void LeadActor::loadPDA(const Common::String &pageName) {
- if (_state != kPDA) {
- if (_state == kMoving) {
- _recipient = nullptr;
- _nextState = kReady;
- }
- _state = kPDA;
- if (_state != kInventory)
- _page->pause();
- _page->getGame()->getDirector()->clear();
+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();
+ if (_isHaveItem) {
+ if (actor) {
+ actor->onHover(point, item->getName(), _cursorMgr);
+ } else
+ _cursorMgr->setCursor(kHoldingItemCursor, point, item->getName());
+ } else if (actor)
+ actor->onMouseOver(point, _cursorMgr);
+ else
+ _cursorMgr->setCursor(kDefaultCursor, point, Common::String());
+ break;
}
- _page->getGame()->getPdaMgr().setLead(this);
- _page->getGame()->getPdaMgr().goToPage(pageName);
+ case kInDialog1:
+ case kInDialog2:
+ case kPlayingVideo:
+ _cursorMgr->setCursor(kNotClickableCursor, point, Common::String());
+ break;
+ case kPDA:
+ case kInventory:
+ _cursorMgr->setCursor(kDefaultCursor, point, Common::String());
+ break;
+ default:
+ break;
+ }
+}
+
+bool LeadActor::sendUseClickMessage(Actor *actor) {
+ InventoryMgr *mgr = _page->getModule()->getInventoryMgr();
+ _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo;
+ _state = kInDialog1;
+ InventoryItem *item = mgr->getCurrentItem();
+ actor->onUseClickMessage(mgr->getCurrentItem(), mgr);
+ if (item->getCurrentOwner() != this->_name)
+ _isHaveItem = false;
+ return true;
+}
+
+bool LeadActor::sendLeftClickMessage(Actor *actor) {
+ _nextState = _state != kPlayingVideo ? kReady : kPlayingVideo;
+ _state = kInDialog1;
+ return actor->onLeftClickMessage();
+}
+
+WalkLocation *LeadActor::getWalkDestination() {
+ return _walkMgr->findLocation(_recipient->getLocation());
}
void ParlSqPink::toConsole() {
@@ -390,21 +396,21 @@ void PubPink::toConsole() {
}
}
-bool PubPink::playingMiniGame() {
- return !(_page->checkValueOfVariable(kFoodPuzzle, "TRUE") ||
- _page->checkValueOfVariable(kFoodPuzzle, kUndefined));
-}
-
void PubPink::onClick() {
if (!playingMiniGame())
LeadActor::onClick();
}
-void PubPink::updateCursor(Common::Point point) {
+void PubPink::onVariableSet() {
+ if (playingMiniGame())
+ _isHaveItem = true;
+}
+
+void PubPink::updateCursor(const Common::Point point) {
if (playingMiniGame()) {
- SupportingActor *actor = dynamic_cast<SupportingActor*>(_page->getGame()->getDirector()->getActorByPoint(point));
- if (_state == kReady && actor &&
- actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem())) {
+ Actor *actor = _page->getGame()->getDirector()->getActorByPoint(point);
+ assert(actor);
+ if (_state == kReady && actor->isUseClickHandlers(_page->getModule()->getInventoryMgr()->getCurrentItem())) {
_cursorMgr->setCursor(kClickableFirstFrameCursor, point, Common::String());
} else
_cursorMgr->setCursor(kDefaultCursor, point, Common::String());
@@ -412,17 +418,7 @@ void PubPink::updateCursor(Common::Point point) {
else LeadActor::updateCursor(point);
}
-WalkLocation *PubPink::getWalkDestination() {
- if (playingMiniGame())
- return nullptr;
-
- if (_recipient->getName() == kJackson && !_page->checkValueOfVariable(kDrunkLocation, kBolted))
- return _walkMgr->findLocation(_page->findActor(kDrunk)->getName());
-
- return LeadActor::getWalkDestination();
-}
-
-bool PubPink::sendUseClickMessage(SupportingActor *actor) {
+bool PubPink::sendUseClickMessage(Actor *actor) {
if (!LeadActor::sendUseClickMessage(actor) && playingMiniGame()) {
_nextState = _state;
_state = kInDialog1;
@@ -451,9 +447,19 @@ bool PubPink::sendUseClickMessage(SupportingActor *actor) {
return true;
}
-void PubPink::onVariableSet() {
+WalkLocation *PubPink::getWalkDestination() {
if (playingMiniGame())
- _isHaveItem = true;
+ return nullptr;
+
+ if (_recipient->getName() == kJackson && !_page->checkValueOfVariable(kDrunkLocation, kBolted))
+ return _walkMgr->findLocation(_page->findActor(kDrunk)->getName());
+
+ return LeadActor::getWalkDestination();
+}
+
+bool PubPink::playingMiniGame() {
+ return !_page->checkValueOfVariable(kFoodPuzzle, "TRUE") ||
+ _page->checkValueOfVariable(kFoodPuzzle, kUndefined);
}
} // End of namespace Pink
diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h
index 0e480358b1..65eb89b717 100644
--- a/engines/pink/objects/actors/lead_actor.h
+++ b/engines/pink/objects/actors/lead_actor.h
@@ -41,6 +41,7 @@ class InventoryItem;
class LeadActor : public Actor {
public:
LeadActor();
+
enum State {
kReady = 0,
kMoving = 1,
@@ -52,83 +53,91 @@ public:
kUnk_Loading = 7// ????
};
+ void deserialize(Archive &archive) override;
- virtual void deserialize(Archive &archive);
+ void toConsole() override;
- virtual void toConsole();
+ void loadState(Archive &archive);
+ void saveState(Archive &archive);
- void setNextExecutors (Common::String &nextModule, Common::String &nextPage);
virtual void init(bool unk);
- State getState() const;
-
void start(bool isHandler);
+
void update();
+ void loadPDA(const Common::String &pageName);
+
void onKeyboardButtonClick(Common::KeyCode code);
- void onLeftButtonClick(Common::Point point);
- void onMouseMove(Common::Point point);
- void onWalkEnd();
- virtual void onClick();
- void onInventoryClosed(bool isItemClicked);
- virtual void onVariableSet() {};
+ void onLeftButtonClick(const Common::Point point);
+
+ void onMouseMove(const Common::Point point);
- virtual void onMouseOver(Common::Point point, CursorMgr *mgr);
+ void onMouseOver(const Common::Point point, CursorMgr *mgr) override;
- bool isInteractingWith(SupportingActor *actor);
+ virtual void onClick();
+ virtual void onVariableSet();
+ void onInventoryClosed(bool isItemClicked);
+ void onWalkEnd();
- virtual void loadState(Archive &archive);
+ bool isInteractingWith(Actor *actor);
- virtual void saveState(Archive &archive);
+ void setNextExecutors (const Common::String &nextModule, const Common::String &nextPage);
- void loadPDA(const Common::String &pageName);
+ State getState() const;
protected:
- virtual void updateCursor(Common::Point point);
void forceUpdateCursor();
- virtual bool sendUseClickMessage(SupportingActor *actor);
- bool sendLeftClickMessage(SupportingActor *actor);
+ virtual void updateCursor(const Common::Point point);
+
+ virtual bool sendUseClickMessage(Actor *actor);
+ bool sendLeftClickMessage(Actor *actor);
virtual WalkLocation *getWalkDestination();
+ Actor *_recipient;
+
+ CursorMgr *_cursorMgr;
+ WalkMgr *_walkMgr;
+ Sequencer *_sequencer;
+
State _state;
State _nextState;
State _stateCopy;
bool _isHaveItem;
-
- SupportingActor *_recipient;
-
- CursorMgr *_cursorMgr;
- WalkMgr *_walkMgr;
- Sequencer *_sequencer;
};
class ParlSqPink : public LeadActor {
public:
- virtual WalkLocation *getWalkDestination();
- void toConsole();
+ void toConsole() override;
+
+protected:
+ WalkLocation *getWalkDestination() override;
};
class PubPink : public LeadActor {
public:
PubPink();
- void toConsole();
+ void toConsole() override;
- virtual void onClick();
- virtual void onVariableSet();
+ void onClick() override;
+ void onVariableSet() override;
-private:
- int _round;
+protected:
+ void updateCursor(Common::Point point) override;
- virtual bool sendUseClickMessage(SupportingActor *actor);
- virtual void updateCursor(Common::Point point);
- virtual WalkLocation *getWalkDestination();
+ bool sendUseClickMessage(Actor *actor) override;
+
+ WalkLocation *getWalkDestination() override;
+private:
bool playingMiniGame();
+
+ int _round;
};
diff --git a/engines/pink/objects/actors/pda_button_actor.cpp b/engines/pink/objects/actors/pda_button_actor.cpp
index a54e04b8ca..6369394d72 100644
--- a/engines/pink/objects/actors/pda_button_actor.cpp
+++ b/engines/pink/objects/actors/pda_button_actor.cpp
@@ -52,7 +52,7 @@ void PDAButtonActor::onClick() {
}
}
-void PDAButtonActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
+void PDAButtonActor::onMouseOver(const Common::Point point, CursorMgr *mgr) {
if (_command.type == Command::Unk || !isActive())
mgr->setCursor(kPDADefaultCursor, point, Common::String());
else
diff --git a/engines/pink/objects/actors/pda_button_actor.h b/engines/pink/objects/actors/pda_button_actor.h
index 87db1c25c1..c7bfdd146a 100644
--- a/engines/pink/objects/actors/pda_button_actor.h
+++ b/engines/pink/objects/actors/pda_button_actor.h
@@ -41,10 +41,12 @@ struct Command {
class PDAButtonActor : public Actor {
public:
void deserialize(Archive &archive) override;
+
void toConsole() override;
- void onClick();
- void onMouseOver(Common::Point point, CursorMgr *mgr);
+ void onMouseOver(const Common::Point point, CursorMgr *mgr) override;
+
+ void onClick() override;
private:
bool isActive();
diff --git a/engines/pink/objects/actors/supporting_actor.cpp b/engines/pink/objects/actors/supporting_actor.cpp
index 9e5eaa6786..ea2a49e9a5 100644
--- a/engines/pink/objects/actors/supporting_actor.cpp
+++ b/engines/pink/objects/actors/supporting_actor.cpp
@@ -46,6 +46,14 @@ void SupportingActor::toConsole() {
_handlerMgr.toConsole();
}
+bool SupportingActor::isLeftClickHandlers() {
+ return _handlerMgr.isLeftClickHandler(this);
+}
+
+bool SupportingActor::isUseClickHandlers(InventoryItem *item) {
+ return _handlerMgr.isUseClickHandler(this, item->getName());
+}
+
void SupportingActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
if (isLeftClickHandlers()){
if (!_cursor.empty())
@@ -57,12 +65,11 @@ void SupportingActor::onMouseOver(Common::Point point, CursorMgr *mgr) {
Actor::onMouseOver(point, mgr);
}
-bool SupportingActor::isLeftClickHandlers() {
- return _handlerMgr.isLeftClickHandler(this);
-}
-
-bool SupportingActor::isUseClickHandlers(InventoryItem *item) {
- return _handlerMgr.isUseClickHandler(this, item->getName());
+void SupportingActor::onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
+ Common::String item = itemName;
+ if (_handlerMgr.isUseClickHandler(this, itemName))
+ item += kClickable;
+ Actor::onHover(point, item, cursorMgr);
}
void SupportingActor::onTimerMessage() {
@@ -81,11 +88,4 @@ const Common::String &SupportingActor::getLocation() const {
return _location;
}
-void SupportingActor::onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) {
- Common::String item = itemName;
- if (_handlerMgr.isUseClickHandler(this, itemName))
- item += kClickable;
- Actor::onHover(point, item, cursorMgr);
-}
-
} // End of namespace Pink
diff --git a/engines/pink/objects/actors/supporting_actor.h b/engines/pink/objects/actors/supporting_actor.h
index d9b77f7498..1d200d2945 100644
--- a/engines/pink/objects/actors/supporting_actor.h
+++ b/engines/pink/objects/actors/supporting_actor.h
@@ -33,26 +33,25 @@ class InventoryMgr;
class SupportingActor : public Actor {
public:
- virtual void deserialize(Archive &archive);
- virtual void toConsole();
+ virtual void deserialize(Archive &archive) override;
- virtual void onMouseOver(Common::Point point, CursorMgr *mgr);
+ virtual void toConsole() override;
- virtual bool isClickable() { return 1; }
- bool isLeftClickHandlers();
- bool isUseClickHandlers(InventoryItem *item);
+ bool isLeftClickHandlers() override;
+ bool isUseClickHandlers(InventoryItem *item) override;
- void onTimerMessage();
- bool onLeftClickMessage();
- bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr);
+ void onMouseOver(Common::Point point, CursorMgr *mgr) override;
+ void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr) override;
- virtual void onHover(Common::Point point, const Common::String &itemName, CursorMgr *cursorMgr);
-
- const Common::String &getLocation() const;
+ void onTimerMessage() override;
+ bool onLeftClickMessage() override;
+ bool onUseClickMessage(InventoryItem *item, InventoryMgr *mgr) override;
+ const Common::String &getLocation() const override;
private:
HandlerMgr _handlerMgr;
+
Common::String _location;
Common::String _pdaLink;
Common::String _cursor;
diff --git a/engines/pink/objects/object.cpp b/engines/pink/objects/object.cpp
index 02249a3020..0218cb70c8 100644
--- a/engines/pink/objects/object.cpp
+++ b/engines/pink/objects/object.cpp
@@ -26,17 +26,27 @@
namespace Pink {
-Pink::NamedObject::NamedObject(const Common::String &name)
+Object::~Object() {}
+
+void Object::load(Archive &) {}
+
+void Object::deserialize(Archive &) {}
+
+void Object::init() {}
+
+void Object::toConsole() {}
+
+NamedObject::NamedObject() {}
+
+NamedObject::NamedObject(const Common::String &name)
: _name(name) {}
-void Pink::NamedObject::deserialize(Archive &archive) {
+void NamedObject::deserialize(Archive &archive) {
_name = archive.readString();
}
-const Common::String &Pink::NamedObject::getName() const {
+const Common::String &NamedObject::getName() const {
return _name;
}
-void NamedObject::store(Archive &archive) {}
-
} // End of namespace Pink
diff --git a/engines/pink/objects/object.h b/engines/pink/objects/object.h
index e69fa4b406..3f331f2f4b 100644
--- a/engines/pink/objects/object.h
+++ b/engines/pink/objects/object.h
@@ -31,21 +31,22 @@ class Archive;
class Object {
public:
- virtual ~Object() {};
- virtual void load(Archive &) {};
- virtual void store(Archive &) {};
- virtual void deserialize(Archive &) {};
- virtual void init() {}
- virtual void toConsole() {};
+ virtual ~Object();
+
+ virtual void load(Archive &);
+ virtual void deserialize(Archive &);
+
+ virtual void init();
+
+ virtual void toConsole();
};
class NamedObject : public Object {
public:
- NamedObject() {};
+ NamedObject();
NamedObject(const Common::String &name);
void deserialize(Archive &archive);
- void store(Archive &archive);
const Common::String &getName() const;
diff --git a/engines/pink/objects/sequences/seq_timer.cpp b/engines/pink/objects/sequences/seq_timer.cpp
index 5026051b33..95fe53ba67 100644
--- a/engines/pink/objects/sequences/seq_timer.cpp
+++ b/engines/pink/objects/sequences/seq_timer.cpp
@@ -46,14 +46,15 @@ void SeqTimer::toConsole() {
}
void SeqTimer::update() {
- Common::RandomSource &rnd =_sequencer->_page->getGame()->getRnd();
+ Common::RandomSource &rnd = _sequencer->_page->getGame()->getRnd();
if (_updatesToMessage--)
return;
_updatesToMessage = _range ? _period + rnd.getRandomNumber(_range) : _period;
- SupportingActor *actor = static_cast<SupportingActor*>(_sequencer->_page->findActor(_actor));
- if (actor && !_sequencer->findSequenceActorState(actor->getName())) {
+ Actor *actor = _sequencer->_page->findActor(_actor);
+ assert(actor);
+ if (!_sequencer->findSequenceActorState(actor->getName())) {
actor->onTimerMessage();
}
}