aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-07-25 15:59:53 -0400
committerPaul Gilbert2015-07-25 15:59:53 -0400
commitd325d5375587c582e1aaf09cffc23cac1bcfdd9c (patch)
treeaeeb84a183d93db61e0468bd3a0d514c6c0dd048 /engines
parent9e545df252e92a13bc135e0733d5a3148d6220a6 (diff)
downloadscummvm-rg350-d325d5375587c582e1aaf09cffc23cac1bcfdd9c.tar.gz
scummvm-rg350-d325d5375587c582e1aaf09cffc23cac1bcfdd9c.tar.bz2
scummvm-rg350-d325d5375587c582e1aaf09cffc23cac1bcfdd9c.zip
SHERLOCK: RT: Fix movement and tooltip display when dragging lab objects
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/tattoo/widget_lab.cpp55
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.cpp10
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.h2
3 files changed, 34 insertions, 33 deletions
diff --git a/engines/sherlock/tattoo/widget_lab.cpp b/engines/sherlock/tattoo/widget_lab.cpp
index 2572b7a693..2873b12f22 100644
--- a/engines/sherlock/tattoo/widget_lab.cpp
+++ b/engines/sherlock/tattoo/widget_lab.cpp
@@ -72,6 +72,8 @@ void WidgetLab::handleEvents() {
noDesc = true;
}
+ events.setCursor(ARROW);
+
if (events._rightReleased) {
// If the player is dragging an object around, restore it to its previous location and reset the cursor
if (_labObject) {
@@ -132,35 +134,34 @@ void WidgetLab::handleEvents() {
scene.toggleObject(_labObject->_use[idx]._names[nameNum]);
}
}
-
- events.setCursor(ARROW);
}
}
- } else if (events._pressed) {
- if (!_labObject) {
- // If the mouse is over an object and the object is not SOLID, then we need to pick this object
- // up so the player can move it around
- if (ui._bgFound != -1) {
- // Check if the object is set as SOLID, you can't pick up Solid items
- if (ui._bgShape->_aType != SOLID && ui._bgShape->_type != NO_SHAPE) {
- // Save a reference to the object about to be dragged
- _labObject = ui._bgShape;
-
- // Set the mouse cursor to the object
- Graphics::Surface &img = _labObject->_imageFrame->_frame;
- Common::Point cursorOffset = mousePos - _labObject->_position;
- events.setCursor(ARROW, cursorOffset, img);
- warning("%d,%d", cursorOffset.x, cursorOffset.y);//**DEBUG****
-
- // Hide this object until they are done with it (releasing it)
- _labObject->toggleHidden();
-
- // Toggle any other objects (like shadows) tied to this object
- for (int idx = 0; idx < 6; ++idx) {
- if (!_labObject->_use[idx]._target.compareToIgnoreCase("Toggle")) {
- for (int nameNum = 0; nameNum < 4; ++nameNum)
- scene.toggleObject(_labObject->_use[idx]._names[nameNum]);
- }
+
+ _labObject = nullptr;
+ ui._tooltipWidget._offsetY = 0;
+ } else if (events._pressed && !_labObject) {
+ // If the mouse is over an object and the object is not SOLID, then we need to pick this object
+ // up so the player can move it around
+ if (ui._bgFound != -1) {
+ // Check if the object is set as SOLID, you can't pick up Solid items
+ if (ui._bgShape->_aType != SOLID && ui._bgShape->_type != NO_SHAPE) {
+ // Save a reference to the object about to be dragged
+ _labObject = ui._bgShape;
+
+ // Set the mouse cursor to the object
+ Graphics::Surface &img = _labObject->_imageFrame->_frame;
+ Common::Point cursorOffset = mousePos - _labObject->_position;
+ events.setCursor(ARROW, cursorOffset, img);
+ ui._tooltipWidget._offsetY = cursorOffset.y;
+
+ // Hide this object until they are done with it (releasing it)
+ _labObject->toggleHidden();
+
+ // Toggle any other objects (like shadows) tied to this object
+ for (int idx = 0; idx < 6; ++idx) {
+ if (!_labObject->_use[idx]._target.compareToIgnoreCase("Toggle")) {
+ for (int nameNum = 0; nameNum < 4; ++nameNum)
+ scene.toggleObject(_labObject->_use[idx]._names[nameNum]);
}
}
}
diff --git a/engines/sherlock/tattoo/widget_tooltip.cpp b/engines/sherlock/tattoo/widget_tooltip.cpp
index b1c13c7a29..9dfa1ea86c 100644
--- a/engines/sherlock/tattoo/widget_tooltip.cpp
+++ b/engines/sherlock/tattoo/widget_tooltip.cpp
@@ -68,7 +68,7 @@ void WidgetTooltipBase::erase() {
/*----------------------------------------------------------------*/
-WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : WidgetTooltipBase (vm) {
+WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : WidgetTooltipBase (vm), _offsetY(0) {
}
void WidgetTooltip::setText(const Common::String &str) {
@@ -143,7 +143,7 @@ void WidgetTooltip::setText(const Common::String &str) {
// Set the initial display position for the tooltip text
int tagX = mousePos.x - width / 2;
- int tagY = mousePos.y - height;
+ int tagY = mousePos.y - height - _offsetY;
_bounds = Common::Rect(tagX, tagY, tagX + width, tagY + height);
} else {
@@ -161,7 +161,7 @@ void WidgetTooltip::handleEvents() {
// Set the new position for the tooltip
int xp = mousePos.x - _bounds.width() / 2;
- int yp = mousePos.y - _bounds.height();
+ int yp = mousePos.y - _bounds.height() - _offsetY;
_bounds.moveTo(xp, yp);
}
@@ -202,11 +202,9 @@ void WidgetSceneTooltip::handleEvents() {
ui._oldBgFound = ui._bgFound;
} else {
-
// Set the new position for the tooltip
int tagX = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _bounds.width());
- int tagY = MAX(mousePos.y - _bounds.height(), 0);
-
+ int tagY = MAX(mousePos.y - _bounds.height() - _offsetY, 0);
_bounds.moveTo(tagX, tagY);
}
diff --git a/engines/sherlock/tattoo/widget_tooltip.h b/engines/sherlock/tattoo/widget_tooltip.h
index a7758d4863..87f5d54f0a 100644
--- a/engines/sherlock/tattoo/widget_tooltip.h
+++ b/engines/sherlock/tattoo/widget_tooltip.h
@@ -51,6 +51,8 @@ public:
class WidgetTooltip: public WidgetTooltipBase {
public:
+ int _offsetY;
+public:
WidgetTooltip(SherlockEngine *vm);
virtual ~WidgetTooltip() {}