aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/myst.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2017-07-09 11:40:09 +0200
committerBastien Bouclet2017-07-22 20:38:56 +0200
commit3c04ad0227ea1ef48ca16afbe5545306d8cb4312 (patch)
tree75171070be3b61410a7d3ed3f0d5ed48a1ab23ac /engines/mohawk/myst.cpp
parent49f48a5b8d7ae0d2d9625baab24f8b72f7a64f66 (diff)
downloadscummvm-rg350-3c04ad0227ea1ef48ca16afbe5545306d8cb4312.tar.gz
scummvm-rg350-3c04ad0227ea1ef48ca16afbe5545306d8cb4312.tar.bz2
scummvm-rg350-3c04ad0227ea1ef48ca16afbe5545306d8cb4312.zip
MOHAWK: Myst: Keep track of the resource being clicked
Diffstat (limited to 'engines/mohawk/myst.cpp')
-rw-r--r--engines/mohawk/myst.cpp29
1 files changed, 14 insertions, 15 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;
}