aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/event.cpp
diff options
context:
space:
mode:
authorColin Snover2016-08-20 21:02:07 -0500
committerColin Snover2016-09-29 19:39:16 -0500
commit44dd029cb17160316b2015321a0a53f8854b6dd3 (patch)
treeb6975dd6bf0f1bc7723345273abdecf034a667a5 /engines/sci/event.cpp
parent2be2629a3b2b43a0c86cfb7ea26cf979b91251bd (diff)
downloadscummvm-rg350-44dd029cb17160316b2015321a0a53f8854b6dd3.tar.gz
scummvm-rg350-44dd029cb17160316b2015321a0a53f8854b6dd3.tar.bz2
scummvm-rg350-44dd029cb17160316b2015321a0a53f8854b6dd3.zip
SCI32: Implement kSetHotRectangles
Used only by chapter 7 of Phant1.
Diffstat (limited to 'engines/sci/event.cpp')
-rw-r--r--engines/sci/event.cpp64
1 files changed, 55 insertions, 9 deletions
diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp
index 43db00c566..345b380a48 100644
--- a/engines/sci/event.cpp
+++ b/engines/sci/event.cpp
@@ -109,8 +109,12 @@ static const MouseEventConversion mouseEventMappings[] = {
{ Common::EVENT_MBUTTONUP, SCI_EVENT_MOUSE_RELEASE }
};
-EventManager::EventManager(bool fontIsExtended) : _fontIsExtended(fontIsExtended) {
-}
+EventManager::EventManager(bool fontIsExtended) :
+ _fontIsExtended(fontIsExtended)
+#ifdef ENABLE_SCI32
+ , _hotRectanglesActive(false)
+#endif
+ {}
EventManager::~EventManager() {
}
@@ -138,8 +142,8 @@ static int altify(int ch) {
SciEvent EventManager::getScummVMEvent() {
#ifdef ENABLE_SCI32
- SciEvent input = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point() };
- SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point() };
+ SciEvent input = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point(), -1 };
+ SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point(), -1 };
#else
SciEvent input = { SCI_EVENT_NONE, 0, 0, Common::Point() };
SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, Common::Point() };
@@ -169,17 +173,20 @@ SciEvent EventManager::getScummVMEvent() {
if (getSciVersion() >= SCI_VERSION_2) {
const Buffer &screen = g_sci->_gfxFrameout->getCurrentBuffer();
+ Common::Point mousePosSci = mousePos;
+ mulru(mousePosSci, Ratio(screen.scriptWidth, screen.screenWidth), Ratio(screen.scriptHeight, screen.screenHeight));
+ noEvent.mousePosSci = input.mousePosSci = mousePosSci;
+
if (ev.type == Common::EVENT_MOUSEMOVE) {
// This will clamp `mousePos` according to the restricted zone,
// so any cursor or screen item associated with the mouse position
// does not bounce when it hits the edge (or ignore the edge)
g_sci->_gfxCursor32->deviceMoved(mousePos);
+ if (_hotRectanglesActive) {
+ checkHotRectangles(mousePosSci);
+ }
}
- Common::Point mousePosSci = mousePos;
- mulru(mousePosSci, Ratio(screen.scriptWidth, screen.screenWidth), Ratio(screen.scriptHeight, screen.screenHeight));
- noEvent.mousePosSci = input.mousePosSci = mousePosSci;
-
} else {
#endif
g_sci->_gfxScreen->adjustBackUpscaledCoordinates(mousePos.y, mousePos.x);
@@ -365,7 +372,7 @@ void EventManager::updateScreen() {
SciEvent EventManager::getSciEvent(uint32 mask) {
#ifdef ENABLE_SCI32
- SciEvent event = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point() };
+ SciEvent event = { SCI_EVENT_NONE, 0, 0, Common::Point(), Common::Point(), -1 };
#else
SciEvent event = { SCI_EVENT_NONE, 0, 0, Common::Point() };
#endif
@@ -402,4 +409,43 @@ SciEvent EventManager::getSciEvent(uint32 mask) {
return event;
}
+
+#ifdef ENABLE_SCI32
+void EventManager::setHotRectanglesActive(const bool active) {
+ _hotRectanglesActive = active;
+}
+
+void EventManager::setHotRectangles(const Common::Array<Common::Rect> &rects) {
+ _hotRects = rects;
+}
+
+void EventManager::checkHotRectangles(const Common::Point &mousePosition) {
+ int lastActiveRectIndex = _activeRectIndex;
+ _activeRectIndex = -1;
+
+ for (int16 i = 0; i < (int16)_hotRects.size(); ++i) {
+ if (_hotRects[i].contains(mousePosition)) {
+ _activeRectIndex = i;
+ if (i != lastActiveRectIndex) {
+ SciEvent hotRectEvent;
+ hotRectEvent.type = SCI_EVENT_HOT_RECTANGLE;
+ hotRectEvent.hotRectangleIndex = i;
+ _events.push_front(hotRectEvent);
+ break;
+ }
+
+ lastActiveRectIndex = _activeRectIndex;
+ }
+ }
+
+ if (lastActiveRectIndex != _activeRectIndex && lastActiveRectIndex != -1) {
+ _activeRectIndex = -1;
+ SciEvent hotRectEvent;
+ hotRectEvent.type = SCI_EVENT_HOT_RECTANGLE;
+ hotRectEvent.hotRectangleIndex = -1;
+ _events.push_front(hotRectEvent);
+ }
+}
+#endif
+
} // End of namespace Sci