Skip to content

Commit

Permalink
SHERLOCK: RT: Show tooltip when selecting scene object to use item on
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 19, 2015
1 parent b16dced commit a9150b5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 39 deletions.
2 changes: 0 additions & 2 deletions engines/sherlock/tattoo/tattoo_user_interface.h
Expand Up @@ -119,8 +119,6 @@ class TattooUserInterface : public UserInterface {
int _maskCounter;
ImageFile *_interfaceImages;
WidgetText _textWidget;
Common::String _action;
Common::String _verb;
public:
TattooUserInterface(SherlockEngine *vm);
virtual ~TattooUserInterface();
Expand Down
8 changes: 8 additions & 0 deletions engines/sherlock/tattoo/widget_base.cpp
Expand Up @@ -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;

Expand Down
60 changes: 24 additions & 36 deletions engines/sherlock/tattoo/widget_inventory.cpp
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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());
}
}
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
}
}
Expand Down Expand Up @@ -623,15 +614,15 @@ 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;
}
}
} 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;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion engines/sherlock/tattoo/widget_inventory.h
Expand Up @@ -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
Expand Down Expand Up @@ -111,6 +110,8 @@ class WidgetInventory: public WidgetBase {
void highlightControls();
public:
int _invMode;
Common::String _action;
Common::String _verb;
public:
WidgetInventory(SherlockEngine *vm);
virtual ~WidgetInventory() {}
Expand Down

0 comments on commit a9150b5

Please sign in to comment.