From 9f8356e52e25b11d0e842728d2134d5c32e22e3b Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Fri, 27 Apr 2018 17:08:48 +0300 Subject: PINK: fixed Inventory onClick method and other bugfixes --- engines/pink/objects/actors/lead_actor.cpp | 10 ++++++++-- engines/pink/objects/actors/lead_actor.h | 1 + engines/pink/objects/handlers/handler_timer.cpp | 2 +- engines/pink/objects/inventory.cpp | 3 +++ engines/pink/objects/walk/walk_mgr.cpp | 5 +---- engines/pink/objects/walk/walk_shortest_path.cpp | 5 +++-- 6 files changed, 17 insertions(+), 9 deletions(-) (limited to 'engines/pink/objects') diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp index 2a0f84dbcd..fd4ed7143e 100644 --- a/engines/pink/objects/actors/lead_actor.cpp +++ b/engines/pink/objects/actors/lead_actor.cpp @@ -146,7 +146,7 @@ void LeadActor::start(bool isHandler) { _state = kInDialog1; _nextState = kReady; } - updateCursor({0,0}); + forceUpdateCursor(); } void LeadActor::onMouseMove(Common::Point point) { @@ -222,7 +222,7 @@ void LeadActor::onLeftButtonClick(Common::Point point) { void LeadActor::onMouseOver(Common::Point point, CursorMgr *mgr) { if (_page->getModule()->getInventoryMgr()->isPinkOwnsAnyItems()) - _cursorMgr->setCursor(kClickableFirstFrameCursor, {0, 0}); + _cursorMgr->setCursor(kClickableFirstFrameCursor, point); else Actor::onMouseOver(point, mgr); } @@ -278,6 +278,12 @@ void LeadActor::onInventoryClosed(bool isItemClicked) { _state = _stateCopy; _stateCopy = kUnk_Loading; _page->unpause(); + forceUpdateCursor(); +} + +void LeadActor::forceUpdateCursor() { + Common::Point point = _page->getGame()->getEventManager()->getMousePos(); + updateCursor(point); } void ParlSqPink::toConsole() { diff --git a/engines/pink/objects/actors/lead_actor.h b/engines/pink/objects/actors/lead_actor.h index 45e27f9233..5988c4cc88 100644 --- a/engines/pink/objects/actors/lead_actor.h +++ b/engines/pink/objects/actors/lead_actor.h @@ -75,6 +75,7 @@ public: private: void updateCursor(Common::Point point); + void forceUpdateCursor(); bool sendUseClickMessage(SupportingActor *actor); bool sendLeftClickMessage(SupportingActor *actor); diff --git a/engines/pink/objects/handlers/handler_timer.cpp b/engines/pink/objects/handlers/handler_timer.cpp index 6fdbce1c5f..3de4ad4a71 100644 --- a/engines/pink/objects/handlers/handler_timer.cpp +++ b/engines/pink/objects/handlers/handler_timer.cpp @@ -73,7 +73,7 @@ void HandlerTimerActions::handle(Actor *actor) { void HandlerTimerSequences::execute(Sequence *sequence) { - debug("HandlerTimerSequences function is not implemented"); + error("HandlerTimerSequences function is not implemented"); } void HandlerTimerSequences::toConsole() { diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp index 8183f9dbe4..8406fe709b 100644 --- a/engines/pink/objects/inventory.cpp +++ b/engines/pink/objects/inventory.cpp @@ -148,6 +148,9 @@ void InventoryMgr::update() { } void InventoryMgr::onClick(Common::Point point) { + if (_state != kReady) + return; + Actor *actor = _lead->getPage()->getGame()->getDirector()->getActorByPoint(point); if (actor == _itemActor || actor == _window) { _isClickedOnItem = true; diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp index 0cacbd07f6..b87429d616 100644 --- a/engines/pink/objects/walk/walk_mgr.cpp +++ b/engines/pink/objects/walk/walk_mgr.cpp @@ -44,10 +44,7 @@ WalkLocation *WalkMgr::findLocation(const Common::String &name) { auto it = Common::find_if(_locations.begin(), _locations.end(), [&name](WalkLocation *location) { return location->getName() == name; }); - if (it == _locations.end()) - return nullptr; - - return *it; + return (it != _locations.end()) ? *it : nullptr; } void WalkMgr::toConsole() { diff --git a/engines/pink/objects/walk/walk_shortest_path.cpp b/engines/pink/objects/walk/walk_shortest_path.cpp index 77562e81cb..4c6f84a154 100644 --- a/engines/pink/objects/walk/walk_shortest_path.cpp +++ b/engines/pink/objects/walk/walk_shortest_path.cpp @@ -142,9 +142,9 @@ double WalkShortestPath::getWeight(WalkLocation *location) { bool WalkShortestPath::isLocationVisited(WalkLocation *location) { for (int i = 0; i < _visited.size(); ++i) { if (_visited[i] == location) - return 1; + return true; } - return 0; + return false; } void WalkShortestPath::remove(WalkLocation *location) { @@ -152,6 +152,7 @@ void WalkShortestPath::remove(WalkLocation *location) { if (_locations[i] == location){ _locations.remove_at(i); _weight.remove_at(i); + break; } } } -- cgit v1.2.3