[Scummvm-cvs-logs] scummvm master -> d325d5375587c582e1aaf09cffc23cac1bcfdd9c

dreammaster dreammaster at scummvm.org
Sat Jul 25 22:00:58 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d325d53755 SHERLOCK: RT: Fix movement and tooltip display when dragging lab objects


Commit: d325d5375587c582e1aaf09cffc23cac1bcfdd9c
    https://github.com/scummvm/scummvm/commit/d325d5375587c582e1aaf09cffc23cac1bcfdd9c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-25T15:59:53-04:00

Commit Message:
SHERLOCK: RT: Fix movement and tooltip display when dragging lab objects

Changed paths:
    engines/sherlock/tattoo/widget_lab.cpp
    engines/sherlock/tattoo/widget_tooltip.cpp
    engines/sherlock/tattoo/widget_tooltip.h



diff --git a/engines/sherlock/tattoo/widget_lab.cpp b/engines/sherlock/tattoo/widget_lab.cpp
index 2572b7a..2873b12 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 b1c13c7..9dfa1ea 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 a7758d4..87f5d54 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() {}
 






More information about the Scummvm-git-logs mailing list