From a6e1202a0c95c8124536504cf1dee81970ae74bb Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Fri, 1 Jul 2016 10:40:13 +0200 Subject: MACVENTURE: Fix object selection fallthrough --- engines/macventure/gui.cpp | 26 +++++++++++++++----------- engines/macventure/gui.h | 1 + engines/macventure/script.cpp | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'engines/macventure') diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index 8f8acda6dd..f07b914d26 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -641,7 +641,7 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface * pos = _engine->getObjPosition(child); pos += Common::Point(border.leftOffset, border.topOffset); - if (child < 600 && child != _draggedObj.id) { // Small HACK until I figre out where the last garbage child in main game window comes from + if (child < 600) { // Small HACK until I figre out where the last garbage child in main game window comes from if (!_assets.contains(child)) { _assets[child] = new ImageAsset(child, _graphics); } @@ -654,7 +654,7 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface * if (_engine->isObjSelected(child)) _assets[child]->blitInto( - surface, pos.x, pos.y, kBlitOR); + surface, pos.x, pos.y, kBlitXOR); // For test surface->frameRect(Common::Rect( @@ -697,7 +697,7 @@ void Gui::drawDraggedObject() { _screen.copyRectToSurface(_draggedSurface, _draggedObj.pos.x, _draggedObj.pos.y, Common::Rect(asset->getWidth() - 1, asset->getHeight() - 1)); - asset->blitInto(&_draggedSurface, 0, 0, kBlitOR); + asset->blitInto(&_draggedSurface, 0, 0, kBlitBIC); g_system->copyRectToScreen( _draggedSurface.getPixels(), @@ -839,6 +839,16 @@ Graphics::MacWindow * Gui::findWindow(WindowReference reference) { return nullptr; } +void Gui::checkSelect(ObjID obj, const Common::Event &event, const Common::Rect & clickRect, WindowReference ref) { + if (_engine->isObjVisible(obj) && + _engine->isObjClickable(obj) && + isRectInsideObject(clickRect, obj)) + { + selectDraggable(obj, ref, event.mouse); + _engine->handleObjectSelect(obj, (WindowReference)ref, event, false); + } +} + bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) { if (_assets.contains(obj) && //_engine->isObjClickable(obj) && @@ -1086,10 +1096,7 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions()); for (Common::Array::const_iterator it = data.children.begin(); it != data.children.end(); it++) { child = (*it).obj; - if (isRectInsideObject(clickRect, child)) { - selectDraggable(child, kMainGameWindow, event.mouse); - _engine->handleObjectSelect(child, kMainGameWindow, event, false); - } + checkSelect(child, event, clickRect, kMainGameWindow); } } return false; @@ -1170,10 +1177,7 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) { Common::Rect clickRect = calculateClickRect(event.mouse, _inventoryWindows[i]->getDimensions()); for (Common::Array::const_iterator it = data.children.begin(); it != data.children.end(); it++) { child = (*it).obj; - if (isRectInsideObject(clickRect, child)) { - selectDraggable(child, data.refcon, event.mouse); - _engine->handleObjectSelect(child, (WindowReference)ref, event, false); - } + checkSelect(child, event, clickRect, (WindowReference)ref); } } return true; diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h index d71ee6680b..f93e8db42b 100644 --- a/engines/macventure/gui.h +++ b/engines/macventure/gui.h @@ -262,6 +262,7 @@ private: // Methods Graphics::MacWindow *findWindow(WindowReference reference); // Utils + void checkSelect(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref); bool isRectInsideObject(Common::Rect target, ObjID obj); void selectDraggable(ObjID child, WindowReference origin, Common::Point startPos); void handleDragRelease(Common::Point pos); diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp index cc9474e6d4..cbc47a9148 100644 --- a/engines/macventure/script.cpp +++ b/engines/macventure/script.cpp @@ -794,8 +794,8 @@ void ScriptEngine::opabLTS(EngineState * state, EngineFrame * frame) { } void ScriptEngine::opacEQ(EngineState * state, EngineFrame * frame) { - word b = neg16(state->pop()); - word a = neg16(state->pop()); + word b = state->pop(); + word a = state->pop(); state->push((a == b) ? 0xFFFF : 0); } -- cgit v1.2.3