diff options
author | Paul Gilbert | 2015-07-19 17:31:40 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-07-19 17:31:40 -0400 |
commit | a9150b5c3c1159e3c8982c8eb5b73bd54532dcf3 (patch) | |
tree | 714ef7bb21db395e1cd46171f7875de75b792d5d /engines | |
parent | b16dced3c97f1a239c9468760584c325593973ae (diff) | |
download | scummvm-rg350-a9150b5c3c1159e3c8982c8eb5b73bd54532dcf3.tar.gz scummvm-rg350-a9150b5c3c1159e3c8982c8eb5b73bd54532dcf3.tar.bz2 scummvm-rg350-a9150b5c3c1159e3c8982c8eb5b73bd54532dcf3.zip |
SHERLOCK: RT: Show tooltip when selecting scene object to use item on
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.h | 2 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_base.cpp | 8 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_inventory.cpp | 60 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_inventory.h | 3 |
4 files changed, 34 insertions, 39 deletions
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h index 88012bb368..436158092e 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.h +++ b/engines/sherlock/tattoo/tattoo_user_interface.h @@ -119,8 +119,6 @@ public: int _maskCounter; ImageFile *_interfaceImages; WidgetText _textWidget; - Common::String _action; - Common::String _verb; public: TattooUserInterface(SherlockEngine *vm); virtual ~TattooUserInterface(); diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp index 5f16e8800d..66ade474c2 100644 --- a/engines/sherlock/tattoo/widget_base.cpp +++ b/engines/sherlock/tattoo/widget_base.cpp @@ -35,6 +35,14 @@ WidgetBase::WidgetBase(SherlockEngine *vm) : _vm(vm) { void WidgetBase::summonWindow() { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + + // Double-check that the same widget isn't added twice + for (Common::List<WidgetBase *>::iterator i = ui._widgets.begin(); i != ui._widgets.end(); ++i) { + if ((*i) == this) + error("Tried to add a widget twice"); + } + + // Add widget to the screen ui._widgets.push_back(this); _outsideMenu = false; diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 1e96b0efbe..52ab5bf23f 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -122,17 +122,6 @@ void WidgetInventoryTooltip::handleEvents() { Common::String strWith = fixedText.getText(kFixedText_With); Common::String strUse = fixedText.getText(kFixedText_Use); - // If there's a floating graphic for a selected inventory item, update it's bounds - if (_owner->_invVerbMode == 2 || _owner->_invVerbMode == 3) { - _oldInvGraphicBounds = _invGraphicBounds; - - // Set the New position of the graphic - int xp = CLIP(mousePos.x - _invGraphicBounds.width() / 2, 0, SHERLOCK_SCENE_WIDTH - _invGraphicBounds.width()); - int yp = CLIP(mousePos.y - _invGraphicBounds.height() / 2, 0, SHERLOCK_SCREEN_HEIGHT - _invGraphicBounds.height()); - - _invGraphicBounds.moveTo(xp, yp); - } - // If we are using an inventory item on an object in the room, display the appropriate text above the mouse cursor if (_owner->_invVerbMode == 3) { select = ui._bgFound; @@ -147,18 +136,18 @@ void WidgetInventoryTooltip::handleEvents() { if (_vm->getLanguage() == Common::GR_GRE) { if (!_owner->_swapItems) - str = Common::String::format("%s %s %s %s", ui._action.c_str(), obj._description.c_str(), - inv[_owner->_invSelect]._name.c_str(), ui._verb.c_str()); + str = Common::String::format("%s %s %s %s", _owner->_action.c_str(), obj._description.c_str(), + inv[_owner->_invSelect]._name.c_str(), _owner->_verb.c_str()); else - str = Common::String::format("%s %s %s %s", ui._action.c_str(), inv[_owner->_invSelect]._name.c_str(), - obj._description.c_str(), ui._verb.c_str()); + str = Common::String::format("%s %s %s %s", _owner->_action.c_str(), inv[_owner->_invSelect]._name.c_str(), + obj._description.c_str(), _owner->_verb.c_str()); } else { if (_owner->_swapItems) - str = Common::String::format("%s %s %s %s", ui._verb.c_str(), obj._description.c_str(), ui._action.c_str(), + str = Common::String::format("%s %s %s %s", _owner->_verb.c_str(), obj._description.c_str(), _owner->_action.c_str(), inv[_owner->_invSelect]._name.c_str()); else - str = Common::String::format("%s %s %s %s", ui._verb.c_str(), inv[_owner->_invSelect]._name.c_str(), - ui._action.c_str(), obj._description.c_str()); + str = Common::String::format("%s %s %s %s", _owner->_verb.c_str(), inv[_owner->_invSelect]._name.c_str(), + _owner->_action.c_str(), obj._description.c_str()); } } } else { @@ -167,19 +156,19 @@ void WidgetInventoryTooltip::handleEvents() { if (!person._description.empty() && !person._description.hasPrefix(" ")) { if (_vm->getLanguage() == Common::GR_GRE) { if (!_owner->_swapItems) - str = Common::String::format("%s %s %s %s", ui._action.c_str(), person._description.c_str(), - inv[_owner->_invSelect]._name.c_str(), ui._verb.c_str()); + str = Common::String::format("%s %s %s %s", _owner->_action.c_str(), person._description.c_str(), + inv[_owner->_invSelect]._name.c_str(), _owner->_verb.c_str()); else - str = Common::String::format("%s %s %s %s", ui._action.c_str(), inv[_owner->_invSelect]._name.c_str(), - person._description.c_str(), ui._verb.c_str()); + str = Common::String::format("%s %s %s %s", _owner->_action.c_str(), inv[_owner->_invSelect]._name.c_str(), + person._description.c_str(), _owner->_verb.c_str()); } else { if (_owner->_swapItems) - str = Common::String::format("%s %s %s %s", ui._verb.c_str(), person._description.c_str(), - ui._action.c_str(), inv[_owner->_invSelect]._name.c_str()); + str = Common::String::format("%s %s %s %s", _owner->_verb.c_str(), person._description.c_str(), + _owner->_action.c_str(), inv[_owner->_invSelect]._name.c_str()); else - str = Common::String::format("%s %s %s %s", ui._verb.c_str(), - inv[_owner->_invSelect]._name.c_str(), ui._action.c_str(), person._description.c_str()); + str = Common::String::format("%s %s %s %s", _owner->_verb.c_str(), + inv[_owner->_invSelect]._name.c_str(), _owner->_action.c_str(), person._description.c_str()); } } } @@ -267,7 +256,7 @@ void WidgetInventoryVerbs::load() { _inventCommands.push_back(FIXED(Look)); // Default the Action word to "with" - ui._action = _vm->getLanguage() == Common::GR_GRE ? "" : FIXED(With); + _owner->_action = _vm->getLanguage() == Common::GR_GRE ? "" : FIXED(With); // Search all the bgshapes for any matching Target Fields for (uint idx = 0; idx < scene._bgShapes.size(); ++idx) { @@ -293,7 +282,7 @@ void WidgetInventoryVerbs::load() { if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*VSWAP", 6)) _owner->_swapItems = true; else - ui._action = Common::String(obj._use[useNum]._names[nameNum].c_str() + 2); + _owner->_action = Common::String(obj._use[useNum]._names[nameNum].c_str() + 2); } } } @@ -428,7 +417,7 @@ void WidgetInventoryVerbs::handleEvents() { events.clearEvents(); ui.checkAction(inv[_owner->_invSelect]._verb, 2000); } else { - ui._verb = _inventCommands[_invVerbSelect]; + _owner->_verb = _inventCommands[_invVerbSelect]; } // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor @@ -437,8 +426,10 @@ void WidgetInventoryVerbs::handleEvents() { ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; events.setCursor(ARROW, imgFrame._frame); - // Close the inventory dialog as well + // Close the inventory dialog as well, then add the tooltip directly to the UI + // so that it will receive events even though the inventory dialog is now closed _owner->close(); + _owner->_tooltipWidget.summonWindow(); } } } @@ -623,7 +614,7 @@ void WidgetInventory::handleEvents() { if (ui._bgFound != -1) { if (ui._personFound) { for (int idx = 0; idx < 2; ++idx) { - if (!people[ui._bgFound - 1000]._use[idx]._verb.compareToIgnoreCase(ui._verb) && + if (!people[ui._bgFound - 1000]._use[idx]._verb.compareToIgnoreCase(_verb) && !people[ui._bgFound - 1000]._use[idx]._target.compareToIgnoreCase(_invTarget)) { ui.checkAction(people[ui._bgFound - 1000]._use[idx], ui._bgFound); found = true; @@ -631,7 +622,7 @@ void WidgetInventory::handleEvents() { } } else { for (int idx = 0; idx < 6; ++idx) { - if (!ui._bgShape->_use[idx]._verb.compareToIgnoreCase(ui._verb) && + if (!ui._bgShape->_use[idx]._verb.compareToIgnoreCase(_verb) && !ui._bgShape->_use[idx]._target.compareToIgnoreCase(_invTarget)) { ui.checkAction(ui._bgShape->_use[idx], ui._bgFound); found = true; @@ -647,6 +638,7 @@ void WidgetInventory::handleEvents() { // Want to close the window (clicked outside of it). So close the window and return to Standard close(); events.setCursor(ARROW); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; } else if (_bounds.contains(mousePos)) { // Mouse button was released inside the inventory window @@ -755,14 +747,10 @@ void WidgetInventory::erase() { void WidgetInventory::close() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; - TattooScene &scene = *(TattooScene *)_vm->_scene; - TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; banishWindow(); inv.freeInv(); - events.clearEvents(); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; } } // End of namespace Tattoo diff --git a/engines/sherlock/tattoo/widget_inventory.h b/engines/sherlock/tattoo/widget_inventory.h index 27f0d4f847..53bc2038e0 100644 --- a/engines/sherlock/tattoo/widget_inventory.h +++ b/engines/sherlock/tattoo/widget_inventory.h @@ -40,7 +40,6 @@ class WidgetInventory; class WidgetInventoryTooltip: public WidgetTooltipBase { private: WidgetInventory *_owner; - Common::Rect _oldInvGraphicBounds, _invGraphicBounds; protected: /** * Overriden from base class, since tooltips have a completely transparent background @@ -111,6 +110,8 @@ private: void highlightControls(); public: int _invMode; + Common::String _action; + Common::String _verb; public: WidgetInventory(SherlockEngine *vm); virtual ~WidgetInventory() {} |