aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBorja Lorente2016-06-30 16:57:14 +0200
committerBorja Lorente2016-08-14 18:43:51 +0200
commit9403ef720a40ce47688b1957d1a64bc91c87df0a (patch)
tree362eaccbfd38aa5e862e561264cd7c95b21cb260 /engines
parent03a9ad4899f19de262a9eed6c9c50219ba44d466 (diff)
downloadscummvm-rg350-9403ef720a40ce47688b1957d1a64bc91c87df0a.tar.gz
scummvm-rg350-9403ef720a40ce47688b1957d1a64bc91c87df0a.tar.bz2
scummvm-rg350-9403ef720a40ce47688b1957d1a64bc91c87df0a.zip
MACVENTURE: Fix clicks and dragging offset
Diffstat (limited to 'engines')
-rw-r--r--engines/macventure/gui.cpp50
-rw-r--r--engines/macventure/gui.h5
-rw-r--r--engines/macventure/macventure.cpp5
-rw-r--r--engines/macventure/macventure.h2
-rw-r--r--engines/macventure/world.cpp2
5 files changed, 43 insertions, 21 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 3d38be508b..8f8acda6dd 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -639,6 +639,7 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface *
child = data.children[i].obj;
mode = (BlitMode)data.children[i].mode;
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 (!_assets.contains(child)) {
@@ -647,16 +648,20 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface *
_assets[child]->blitInto(
surface,
- border.leftOffset + pos.x,
- border.topOffset + pos.y,
+ pos.x,
+ pos.y,
mode);
if (_engine->isObjSelected(child))
_assets[child]->blitInto(
- surface,
- border.leftOffset + pos.x,
- border.topOffset + pos.y,
- kBlitOR);
+ surface, pos.x, pos.y, kBlitOR);
+
+ // For test
+ surface->frameRect(Common::Rect(
+ pos.x,
+ pos.y,
+ pos.x + _assets[child]->getWidth(),
+ pos.y + _assets[child]->getHeight()), kColorGreen);
}
}
@@ -791,6 +796,12 @@ void Gui::updateExit(ObjID obj) {
}
+Common::Point Gui::getWindowSurfacePos(WindowReference reference) {
+ const WindowData &data = getWindowData(reference);
+ BorderBounds border = borderBounds(data.type);
+ return Common::Point(data.bounds.left + border.leftOffset, data.bounds.top + border.topOffset);
+}
+
WindowData & Gui::findWindowData(WindowReference reference) {
assert(_windowData);
@@ -830,8 +841,9 @@ Graphics::MacWindow * Gui::findWindow(WindowReference reference) {
bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
if (_assets.contains(obj) &&
- _engine->isObjClickable(obj) &&
- _engine->isObjVisible(obj)) {
+ //_engine->isObjClickable(obj) &&
+ _engine->isObjVisible(obj))
+ {
Common::Rect bounds = _engine->getObjBounds(obj);
Common::Rect intersection = bounds.findIntersectingRect(target);
// We translate it to the image's coord system
@@ -849,16 +861,20 @@ bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
return false;
}
-void Gui::selectDraggable(ObjID child, Common::Point pos) {
+void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point startPos) {
if (_engine->isObjClickable(child)) {
_draggedObj.id = child;
- _draggedObj.pos = pos;
+ _draggedObj.mouseOffset = (_engine->getObjPosition(child) + getWindowSurfacePos(origin)) - startPos;
+ _draggedObj.pos = startPos + _draggedObj.mouseOffset;
}
}
void Gui::handleDragRelease(Common::Point pos) {
_draggedObj.id = 0;
_engine->updateDelta(pos);
+ _engine->selectControl(kControlOperate);
+ _engine->activateCommand(kControlOperate);
+ _engine->refreshReady();
_engine->preparedToRun();
}
@@ -1002,7 +1018,7 @@ bool Gui::processEvent(Common::Event &event) {
bool processed = false;
if (event.type == Common::EVENT_MOUSEMOVE) {
if (_draggedObj.id != 0) {
- _draggedObj.pos = event.mouse;
+ _draggedObj.pos = event.mouse + _draggedObj.mouseOffset;
}
processed = true;
@@ -1071,8 +1087,8 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e
for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
child = (*it).obj;
if (isRectInsideObject(clickRect, child)) {
- selectDraggable(child, event.mouse);
- _engine->handleObjectSelect(child, kMainGameWindow, event);
+ selectDraggable(child, kMainGameWindow, event.mouse);
+ _engine->handleObjectSelect(child, kMainGameWindow, event, false);
}
}
}
@@ -1090,7 +1106,7 @@ bool MacVenture::Gui::processSelfEvents(WindowClick click, Common::Event & event
return true;
if (event.type == Common::EVENT_LBUTTONUP) {
- _engine->handleObjectSelect(1, kSelfWindow, event);
+ _engine->handleObjectSelect(1, kSelfWindow, event, false);
}
return true;
}
@@ -1120,7 +1136,7 @@ bool MacVenture::Gui::processExitsEvents(WindowClick click, Common::Event & even
}
}
- _engine->handleObjectSelect(data.getData().refcon, kExitsWindow, event);
+ _engine->handleObjectSelect(data.getData().refcon, kExitsWindow, event, false);
}
return getWindowData(kExitsWindow).visible;
}
@@ -1155,8 +1171,8 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) {
for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
child = (*it).obj;
if (isRectInsideObject(clickRect, child)) {
- selectDraggable(child, event.mouse);
- _engine->handleObjectSelect(child, (WindowReference)ref, event);
+ selectDraggable(child, data.refcon, event.mouse);
+ _engine->handleObjectSelect(child, (WindowReference)ref, event, false);
}
}
}
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index dd08173d3c..d71ee6680b 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -147,6 +147,8 @@ struct BorderBounds {
struct DraggedObj {
ObjID id;
Common::Point pos;
+ Common::Point mouseOffset;
+ bool hasMoved;
};
@@ -255,12 +257,13 @@ private: // Methods
void drawWindowTitle(WindowReference target, Graphics::ManagedSurface *surface);
// Finders
+ Common::Point getWindowSurfacePos(WindowReference reference);
WindowData& findWindowData(WindowReference reference);
Graphics::MacWindow *findWindow(WindowReference reference);
// Utils
bool isRectInsideObject(Common::Rect target, ObjID obj);
- void selectDraggable(ObjID child, Common::Point pos);
+ void selectDraggable(ObjID child, WindowReference origin, Common::Point startPos);
void handleDragRelease(Common::Point pos);
Common::Rect calculateClickRect(Common::Point clickPos, Common::Rect windowBounds);
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 08b5ec90c1..b26250a5bf 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -280,7 +280,7 @@ bool MacVentureEngine::printTexts() {
return false;
}
-void MacVentureEngine::handleObjectSelect(ObjID objID, WindowReference win, Common::Event event) {
+void MacVentureEngine::handleObjectSelect(ObjID objID, WindowReference win, Common::Event event, bool isDoubleClick) {
if (win == kExitsWindow) {
win = kMainGameWindow;
}
@@ -826,7 +826,10 @@ ObjID MacVentureEngine::getParent(ObjID objID) {
}
Common::Rect MacVentureEngine::getObjBounds(ObjID objID) {
+ BorderBounds bounds = _gui->borderBounds(_gui->getWindowData(findParentWindow(objID)).type); // HACK
Common::Point pos = getObjPosition(objID);
+ pos.x += bounds.leftOffset;
+ pos.y += bounds.topOffset;
uint w = _gui->getObjWidth(objID); // This shouldn't go here
uint h = _gui->getObjHeight(objID);
return Common::Rect(pos.x, pos.y, pos.x + w, pos.y + h);
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index 9ecfbc0fd7..cdf9a94a5a 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -179,7 +179,7 @@ public:
void runObjQueue();
bool printTexts();
- void handleObjectSelect(ObjID objID, WindowReference win, Common::Event event);
+ void handleObjectSelect(ObjID objID, WindowReference win, Common::Event event, bool isDoubleClick);
void updateDelta(Common::Point newPos);
void focusObjWin(ObjID objID);
void updateWindow(WindowReference winID);
diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp
index 670f39902c..15e3c2a531 100644
--- a/engines/macventure/world.cpp
+++ b/engines/macventure/world.cpp
@@ -59,7 +59,7 @@ uint32 World::getObjAttr(ObjID objID, uint32 attrID) {
res >>= _engine->getGlobalSettings().attrShifts[attrID];
if (res & 0x8000)
res = -((res ^ 0xffff) + 1);
- debug(3, "Attribute %x from object %x is %x", attrID, objID, res);
+ debug(6, "Attribute %x from object %x is %x", attrID, objID, res);
return res;
}