diff options
Diffstat (limited to 'engines/sherlock/tattoo/widget_lab.cpp')
-rw-r--r-- | engines/sherlock/tattoo/widget_lab.cpp | 122 |
1 files changed, 122 insertions, 0 deletions
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() { } |