aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-07-20 19:36:38 -0400
committerPaul Gilbert2015-07-20 19:36:38 -0400
commite4975cef852222ac663464829ec2a64a7920fdbb (patch)
tree9172de4e9798a3b101e5d1d15031360d5408df23
parente1dd57e016bfd9b20e389ecc69f089dfe59b2d86 (diff)
downloadscummvm-rg350-e4975cef852222ac663464829ec2a64a7920fdbb.tar.gz
scummvm-rg350-e4975cef852222ac663464829ec2a64a7920fdbb.tar.bz2
scummvm-rg350-e4975cef852222ac663464829ec2a64a7920fdbb.zip
SHERLOCK: RT: Implemented WidgetLab handleEvents
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.h4
-rw-r--r--engines/sherlock/tattoo/widget_lab.cpp122
-rw-r--r--engines/sherlock/tattoo/widget_lab.h8
3 files changed, 132 insertions, 2 deletions
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 7f284531de..1cefec688d 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 47955a0d26..dfa470fbb8 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 344dae7934..df2ff34c63 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: