aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsluicebox2019-03-31 02:53:21 -0700
committerFilippos Karapetis2019-04-01 01:16:53 +0300
commit82ccce948aaafed2f8e847359ab87c1a4878c74b (patch)
tree3f1d2c81462045fb7682e9ebe69b9f0d415015e2
parent423dcd0a0116aa05894cc816fa266173e705ae63 (diff)
downloadscummvm-rg350-82ccce948aaafed2f8e847359ab87c1a4878c74b.tar.gz
scummvm-rg350-82ccce948aaafed2f8e847359ab87c1a4878c74b.tar.bz2
scummvm-rg350-82ccce948aaafed2f8e847359ab87c1a4878c74b.zip
SCI: Fix Mac icon bar event handling
Fix mouse presses falling through the icon bar in KQ6 and FPFP Mac
-rw-r--r--engines/sci/engine/kevent.cpp22
-rw-r--r--engines/sci/graphics/maciconbar.cpp27
-rw-r--r--engines/sci/graphics/maciconbar.h3
3 files changed, 29 insertions, 23 deletions
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 608e2e4ce9..df0e94fb8d 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -49,13 +49,6 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
SegManager *segMan = s->_segMan;
Common::Point mousePos;
- // For Mac games with an icon bar, handle possible icon bar events first
- if (g_sci->hasMacIconBar()) {
- reg_t iconObj = g_sci->_gfxMacIconBar->handleEvents();
- if (!iconObj.isNull())
- invokeSelector(s, iconObj, SELECTOR(select), argc, argv, 0, NULL);
- }
-
// If there's a simkey pending, and the game wants a keyboard event, use the
// simkey instead of a normal event
// TODO: This does not really work as expected for keyup events, since the
@@ -78,6 +71,21 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
curEvent = g_sci->getEventManager()->getSciEvent(mask);
+ // For Mac games with an icon bar, handle possible icon bar events first
+ if (g_sci->hasMacIconBar()) {
+ reg_t iconObj = NULL_REG;
+ if (g_sci->_gfxMacIconBar->handleEvents(curEvent, iconObj)) {
+ if (!iconObj.isNull()) {
+ invokeSelector(s, iconObj, SELECTOR(select), argc, argv, 0, NULL);
+ }
+
+ // The mouse press event was handled by the mac icon bar so change
+ // its type to none so that generic event processing can continue
+ // without the mouse press being handled twice
+ curEvent.type = kSciEventNone;
+ }
+ }
+
if (g_sci->_guestAdditions->kGetEventHook()) {
return NULL_REG;
}
diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp
index 9b645e485f..7b2b2a9754 100644
--- a/engines/sci/graphics/maciconbar.cpp
+++ b/engines/sci/graphics/maciconbar.cpp
@@ -24,7 +24,6 @@
#include "sci/engine/kernel.h"
#include "sci/engine/selector.h"
#include "sci/engine/state.h"
-#include "sci/event.h"
#include "sci/graphics/maciconbar.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/screen.h"
@@ -259,21 +258,17 @@ bool GfxMacIconBar::pointOnIcon(uint32 iconIndex, Common::Point point) {
return _iconBarItems[iconIndex].rect.contains(point);
}
-reg_t GfxMacIconBar::handleEvents() {
- // Peek event queue for a mouse button press
+bool GfxMacIconBar::handleEvents(SciEvent evt, reg_t &iconObj) {
EventManager *evtMgr = g_sci->getEventManager();
- SciEvent evt = evtMgr->getSciEvent(kSciEventMousePress | kSciEventPeek);
+ iconObj = NULL_REG;
- // No mouse press found
- if (evt.type == kSciEventNone)
- return NULL_REG;
+ // Not a mouse press
+ if (evt.type != kSciEventMousePress)
+ return false;
// If the mouse is not over the icon bar, return
if (evt.mousePos.y < g_sci->_gfxScreen->getHeight())
- return NULL_REG;
-
- // Remove event from queue
- evtMgr->getSciEvent(kSciEventMousePress);
+ return false;
// Mouse press on the icon bar, check the icon rectangles
uint iconNr;
@@ -282,9 +277,10 @@ reg_t GfxMacIconBar::handleEvents() {
break;
}
- // Mouse press not on an icon
+ // Mouse press on the icon bar but not on an enabled icon,
+ // return true to indicate that this mouse press was handled
if (iconNr == _iconBarItems.size())
- return NULL_REG;
+ return true;
drawIcon(iconNr, true);
bool isSelected = true;
@@ -305,9 +301,10 @@ reg_t GfxMacIconBar::handleEvents() {
// If user moved away from the icon, we do nothing
if (pointOnIcon(iconNr, evt.mousePos))
- return _iconBarItems[iconNr].object;
+ iconObj = _iconBarItems[iconNr].object;
- return NULL_REG;
+ // The mouse press was handled
+ return true;
}
} // End of namespace Sci
diff --git a/engines/sci/graphics/maciconbar.h b/engines/sci/graphics/maciconbar.h
index 21d28dfc29..754da8bf50 100644
--- a/engines/sci/graphics/maciconbar.h
+++ b/engines/sci/graphics/maciconbar.h
@@ -26,6 +26,7 @@
#include "common/array.h"
#include "sci/engine/vm.h"
+#include "sci/event.h"
namespace Graphics {
struct Surface;
@@ -42,7 +43,7 @@ public:
void drawIcons();
void setIconEnabled(int16 index, bool enabled);
void setInventoryIcon(int16 icon);
- reg_t handleEvents();
+ bool handleEvents(SciEvent evt, reg_t &iconObj);
private:
struct IconBarItem {