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

dreammaster dreammaster at scummvm.org
Tue Jul 21 01:37:43 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:
e4975cef85 SHERLOCK: RT: Implemented WidgetLab handleEvents


Commit: e4975cef852222ac663464829ec2a64a7920fdbb
    https://github.com/scummvm/scummvm/commit/e4975cef852222ac663464829ec2a64a7920fdbb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-20T19:36:38-04:00

Commit Message:
SHERLOCK: RT: Implemented WidgetLab handleEvents

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



diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 7f28453..1cefec6 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -52,8 +52,6 @@ private:
 	int _scriptZone;
 	int _cAnimFramePause;
 	WidgetInventory _inventoryWidget;
-	WidgetSceneTooltip _tooltipWidget;
-	WidgetVerbs _verbsWidget;
 	WidgetMessage _messageWidget;
 	Common::List<WidgetBase *> _widgets;
 	byte _lookupTable[PALETTE_COUNT];
@@ -110,6 +108,8 @@ public:
 	ImageFile *_interfaceImages;
 	WidgetText _textWidget;
 	WidgetLab _labWidget;
+	WidgetVerbs _verbsWidget;
+	WidgetSceneTooltip _tooltipWidget;
 public:
 	TattooUserInterface(SherlockEngine *vm);
 	virtual ~TattooUserInterface();
diff --git a/engines/sherlock/tattoo/widget_lab.cpp b/engines/sherlock/tattoo/widget_lab.cpp
index 47955a0..dfa470f 100644
--- a/engines/sherlock/tattoo/widget_lab.cpp
+++ b/engines/sherlock/tattoo/widget_lab.cpp
@@ -29,12 +29,134 @@ namespace Sherlock {
 namespace Tattoo {
 
 WidgetLab::WidgetLab(SherlockEngine *vm) : WidgetBase(vm) {
+	_labObject = nullptr;
 }
 
 void WidgetLab::handleEvents() {
 	Events &events = *_vm->_events;
+	Scene &scene = *_vm->_scene;
 	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
 	WidgetBase::handleEvents();
+	bool noDesc = false;
+
+	// Handle drawing tooltips. If the user is dragging a lab item, display a tooltip for using the item
+	// on another. Otherwise, fall back on showing standard tooltips
+	if (events.getCursor() == INVALID_CURSOR)
+		displayLabNames();
+	else
+		ui.displayObjectNames();
+
+	// See if they've released a mouse button to do an action
+	if (events._released || events._rightReleased) {
+		// See if the mouse was released in an exit/arrow zone (ie. the "Exit" button)
+		ui._exitZone = -1;
+		if (ui._arrowZone != -1 && events._released)
+			ui._exitZone = ui._arrowZone;
+
+		// Turn any current tooltip off
+		if (ui._arrowZone == -1 || events._rightReleased)
+			ui._tooltipWidget.setText("");
+
+		if (ui._bgFound != -1) {
+			if (ui._bgShape->_description.hasPrefix(" ") || ui._bgShape->_description.empty())
+				noDesc = true;
+		} else {
+			noDesc = true;
+		}
+
+		if (events._rightReleased) {
+			// If the player is dragging an object around, restore it to its previous location and reset the cursor
+			if (_labObject) {
+				_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]);
+					}
+				}
+
+				events.setCursor(ARROW);
+			}
+
+			// Show the command list for this object
+			ui._verbsWidget.load(!noDesc);
+		} else if (!noDesc) {
+			// The player has released on an object, see if they had an object selected 
+			// that will be used with this new object
+			if (_labObject) {
+				// See if the dragged object can be used with the new object
+				for (int idx = 0; idx < 6; ++idx) {
+					// See if the name of the dragged object is in any of the Target
+					// fields of the verbs for the new object
+					if (!_labObject->_name.compareToIgnoreCase(ui._bgShape->_use[idx]._target.c_str())) {
+						// This object can be used, so use it
+						ui.checkAction(ui._bgShape->_use[idx], ui._bgFound);
+						ui._activeObj = -1;
+					}
+				}
+
+				// Restore the dragged object to its previous location
+				_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]);
+					}
+				}
+			} else if (ui._bgShape->_name.compareToIgnoreCase("Exit")) {
+				ui.lookAtObject();
+			}
+		} else {
+			// The player has released the mouse while NOT over an object. If theu were dragging an object
+			// around with the mouse, restore it to its previous location and reset the cursor
+			if (_labObject) {
+				_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]);
+					}
+				}
+
+				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
+					events.setCursor(_labObject->_imageFrame->_frame, 0, 0);
+
+					// 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]);
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+void WidgetLab::displayLabNames() {
 
 }
 
diff --git a/engines/sherlock/tattoo/widget_lab.h b/engines/sherlock/tattoo/widget_lab.h
index 344dae7..df2ff34 100644
--- a/engines/sherlock/tattoo/widget_lab.h
+++ b/engines/sherlock/tattoo/widget_lab.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "sherlock/tattoo/widget_base.h"
+#include "sherlock/objects.h"
 
 namespace Sherlock {
 
@@ -33,6 +34,13 @@ class SherlockEngine;
 namespace Tattoo {
 
 class WidgetLab: public WidgetBase {
+private:
+	Object *_labObject;
+
+	/**
+	 * Display tooltips of using one lab item on another
+	 */
+	void displayLabNames();
 public:
 	Common::String _remainingText;
 public:






More information about the Scummvm-git-logs mailing list