From 3c04ad0227ea1ef48ca16afbe5545306d8cb4312 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 9 Jul 2017 11:40:09 +0200 Subject: MOHAWK: Myst: Keep track of the resource being clicked --- engines/mohawk/myst.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'engines/mohawk/myst.cpp') diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index dae6ecd3f3..9462663fee 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -71,8 +71,10 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription _showResourceRects = false; _curCard = 0; _canSafelySaveLoad = false; - _activeResource = nullptr; + _hoverResource = nullptr; + _activeResource = nullptr; + _clickedResource = nullptr; _sound = nullptr; _video = nullptr; @@ -269,26 +271,21 @@ Common::Error MohawkEngine_Myst::run() { while (pollEvent(event)) { switch (event.type) { case Common::EVENT_MOUSEMOVE: { - bool mouseClicked = _system->getEventManager()->getButtonState() & 1; - - // Keep the same resource when dragging - if (!mouseClicked) { - checkCurrentResource(); - } - if (_activeResource && _activeResource->isEnabled() && mouseClicked) { - _activeResource->handleMouseDrag(); + if (_clickedResource && _clickedResource->isEnabled()) { + _clickedResource->handleMouseDrag(); } break; } case Common::EVENT_LBUTTONUP: - if (_activeResource && _activeResource->isEnabled()) { - _activeResource->handleMouseUp(); + if (_clickedResource && _clickedResource->isEnabled()) { + _clickedResource->handleMouseUp(); + _clickedResource = nullptr; } - checkCurrentResource(); break; case Common::EVENT_LBUTTONDOWN: if (_activeResource && _activeResource->isEnabled()) { - _activeResource->handleMouseDown(); + _clickedResource = _activeResource; + _clickedResource->handleMouseDown(); } break; case Common::EVENT_KEYDOWN: @@ -344,6 +341,8 @@ Common::Error MohawkEngine_Myst::run() { } } + checkCurrentResource(); + _system->updateScreen(); // Cut down on CPU usage @@ -641,6 +640,8 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) { // Make sure we have the right cursor showing _hoverResource = nullptr; _activeResource = nullptr; + _clickedResource = nullptr; + checkCurrentResource(); // Debug: Show resource rects @@ -685,8 +686,6 @@ void MohawkEngine_Myst::checkCurrentResource() { } MystArea *MohawkEngine_Myst::updateCurrentResource() { - checkCurrentResource(); - return _activeResource; } -- cgit v1.2.3