From 518d336e5a5e266c2b443a9cacfa88abd541fe28 Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Tue, 26 Jul 2016 11:42:58 +0200 Subject: MACVENTURE: Fix item selection on scroll --- engines/macventure/gui.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'engines/macventure/gui.cpp') diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index ed9bad6720..738ea900af 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -683,7 +683,9 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface * // For test if (MACVENTURE_DEBUG_GUI) { - surface->frameRect(_engine->getObjBounds(child), kColorGreen); + Common::Rect testBounds = _engine->getObjBounds(child); + testBounds.translate(-data.scrollPos.x, -data.scrollPos.y); + surface->frameRect(testBounds, kColorGreen); } } @@ -982,7 +984,7 @@ void Gui::checkSelect(const WindowData &data, const Common::Event &event, const child = (*it).obj; } } - if (child != 0) selectDraggable(child, ref, event.mouse); + if (child != 0) selectDraggable(child, ref, event.mouse, data.scrollPos); } bool Gui::canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) { @@ -1004,12 +1006,12 @@ bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) { return _assets[obj]->isRectInside(intersection); } -void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point click) { +void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point click, Common::Point scroll) { if (_engine->isObjClickable(child) && _draggedObj.id == 0) { _draggedObj.hasMoved = false; _draggedObj.id = child; _draggedObj.startWin = origin; - _draggedObj.mouseOffset = (_engine->getObjPosition(child) + getWindowSurfacePos(origin)) - click; + _draggedObj.mouseOffset = (_engine->getObjPosition(child) + getWindowSurfacePos(origin)) - click - scroll; _draggedObj.pos = click + _draggedObj.mouseOffset; _draggedObj.startPos = _draggedObj.pos; } @@ -1263,7 +1265,7 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e WindowData &data = findWindowData(kMainGameWindow); Common::Point pos; // Click rect to local coordinates. We assume the click is inside the window ^ - Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions()); + Common::Rect clickRect = calculateClickRect(event.mouse + data.scrollPos, _mainGameWindow->getDimensions()); checkSelect(data, event, clickRect, kMainGameWindow); } return false; @@ -1371,7 +1373,7 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) { if (click == kBorderInner) { Common::Point pos; // Click rect to local coordinates. We assume the click is inside the window ^ - Common::Rect clickRect = calculateClickRect(event.mouse, win->getDimensions()); + Common::Rect clickRect = calculateClickRect(event.mouse + data.scrollPos, win->getDimensions()); checkSelect(data, event, clickRect, (WindowReference)ref); } } -- cgit v1.2.3