diff options
author | Bastien Bouclet | 2017-07-09 11:40:09 +0200 |
---|---|---|
committer | Bastien Bouclet | 2017-07-22 20:38:56 +0200 |
commit | 3c04ad0227ea1ef48ca16afbe5545306d8cb4312 (patch) | |
tree | 75171070be3b61410a7d3ed3f0d5ed48a1ab23ac | |
parent | 49f48a5b8d7ae0d2d9625baab24f8b72f7a64f66 (diff) | |
download | scummvm-rg350-3c04ad0227ea1ef48ca16afbe5545306d8cb4312.tar.gz scummvm-rg350-3c04ad0227ea1ef48ca16afbe5545306d8cb4312.tar.bz2 scummvm-rg350-3c04ad0227ea1ef48ca16afbe5545306d8cb4312.zip |
MOHAWK: Myst: Keep track of the resource being clicked
-rw-r--r-- | engines/mohawk/myst.cpp | 29 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 9 |
2 files changed, 22 insertions, 16 deletions
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; } diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index 0fcc829ef8..00aaff3c33 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -263,9 +263,16 @@ private: void loadResources(); void drawResourceRects(); void checkCurrentResource(); - MystArea *_activeResource; + + /** Area of type kMystAreaHover being hovered by the mouse, if any */ MystAreaHover *_hoverResource; + /** Active area being hovered by the mouse, if any */ + MystArea *_activeResource; + + /** Active area being clicked on / dragged, if any */ + MystArea *_clickedResource; + Common::Array<MystCursorHint> _cursorHints; void loadCursorHints(); uint16 _currentCursor; |