From 4ce4431c61092ed58e072f3f01f785cad796ab87 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Jun 2015 19:45:06 -0400 Subject: SHERLOCK: RT: Beginnings of inventory menu widget --- engines/sherlock/tattoo/widget_inventory.cpp | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 engines/sherlock/tattoo/widget_inventory.cpp (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp new file mode 100644 index 0000000000..d3caa8002d --- /dev/null +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "sherlock/tattoo/widget_inventory.h" +#include "sherlock/tattoo/tattoo_user_interface.h" +#include "sherlock/tattoo/tattoo.h" + +namespace Sherlock { + +namespace Tattoo { + +#define INVENTORY_XSIZE 70 // Width of the box that surrounds inventory items +#define INVENTORY_YSIZE 70 // Width of the box that surrounds inventory items +#define NUM_INVENTORY_SHOWN 8 // Number of Inventory Items Shown +#define BUTTON_XSIZE 15 // Button width + +WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm) { + _invMode = 0; + _invVerbMode = 0; + _invSelect = _oldInvSelect = 0; + _selector = _oldSelector = 0; + _dialogTimer = -1; +} + +void WidgetInventory::load(int mode) { + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Common::Point mousePos = events.mousePos(); + + if (mode != 0) + _invMode = mode; + _invVerbMode = 0; + _invSelect = _oldInvSelect = -1; + _selector = _oldSelector = -1; + _dialogTimer = -1; + + if (mode == 0) { + banishWindow(); + } else { + _bounds = Common::Rect((INVENTORY_XSIZE + 3) * NUM_INVENTORY_SHOWN / 2 + BUTTON_XSIZE + 6, + (INVENTORY_YSIZE + 3) * 2 + 3); + _bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2); + } + + // Ensure menu will be on-screen + checkMenuPosition(); + + // Load the inventory data + inv.loadInv(); + + // Redraw the inventory menu on the widget surface + _surface.create(_bounds.width(), _bounds.height()); + _surface.fill(TRANSPARENCY); + + // Draw the window background and then the inventory on top of it + makeInfoArea(); + //putInv(0); +} + +void WidgetInventory::loadInv() { + // TODO +} + + +} // End of namespace Tattoo + +} // End of namespace Sherlock -- cgit v1.2.3 From 77f256011a239110d3e57d970c14f6b84b964b01 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Jun 2015 21:25:16 -0400 Subject: SHERLOCK: RT: Added remaining rendering code for inventory widget --- engines/sherlock/tattoo/widget_inventory.cpp | 119 +++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 6 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index d3caa8002d..dfa4736ccc 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -29,9 +29,9 @@ namespace Sherlock { namespace Tattoo { #define INVENTORY_XSIZE 70 // Width of the box that surrounds inventory items -#define INVENTORY_YSIZE 70 // Width of the box that surrounds inventory items +#define INVENTORY_YSIZE 70 // Height of the box that surrounds inventory items #define NUM_INVENTORY_SHOWN 8 // Number of Inventory Items Shown -#define BUTTON_XSIZE 15 // Button width +#define BUTTON_SIZE 15 // Button width/height WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm) { _invMode = 0; @@ -56,7 +56,7 @@ void WidgetInventory::load(int mode) { if (mode == 0) { banishWindow(); } else { - _bounds = Common::Rect((INVENTORY_XSIZE + 3) * NUM_INVENTORY_SHOWN / 2 + BUTTON_XSIZE + 6, + _bounds = Common::Rect((INVENTORY_XSIZE + 3) * NUM_INVENTORY_SHOWN / 2 + BUTTON_SIZE + 6, (INVENTORY_YSIZE + 3) * 2 + 3); _bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2); } @@ -73,11 +73,118 @@ void WidgetInventory::load(int mode) { // Draw the window background and then the inventory on top of it makeInfoArea(); - //putInv(0); + drawInventory(); } -void WidgetInventory::loadInv() { - // TODO +void WidgetInventory::drawInventory() { + Inventory &inv = *_vm->_inventory; + + // TODO: Refactor _invIndexinto this widget class + for (int idx= 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx) { + // Figure out the drawing position + Common::Point pt(3 + (INVENTORY_XSIZE + 3) * (idx % (NUM_INVENTORY_SHOWN / 2)), + 3 + (INVENTORY_YSIZE + 3) * idx / (NUM_INVENTORY_SHOWN / 2)); + + // Draw the box to serve as the background for the item + _surface.hLine(pt.x + 1, pt.y, pt.x + INVENTORY_XSIZE - 2, TRANSPARENCY); + _surface.fillRect(Common::Rect(pt.x, pt.y + 1, pt.x + INVENTORY_XSIZE, pt.y + INVENTORY_YSIZE - 1), TRANSPARENCY); + _surface.hLine(pt.x + 1, pt.y + INVENTORY_YSIZE - 1, pt.x + INVENTORY_XSIZE - 2, TRANSPARENCY); + + // Draw the item + if (itemId < inv._holdings) { + ImageFrame &img = (*inv._invShapes[idx])[0]; + _surface.transBlitFrom(img, Common::Point(pt.x + (INVENTORY_XSIZE - img._width) / 2, + pt.y + (INVENTORY_YSIZE - img._height) / 2)); + } + } + + drawScrollBar(); +} + +void WidgetInventory::drawScrollBar() { + Inventory &inv = *_vm->_inventory; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + bool raised; + + // Fill the area with transparency + Common::Rect r(BUTTON_SIZE, _bounds.height() - 6); + r.moveTo(_bounds.width() - BUTTON_SIZE - 3, 3); + _surface.fillRect(r, TRANSPARENCY); + + raised = ui._scrollHighlight != 1; + _surface.fillRect(Common::Rect(r.left + 2, r.top + 2, r.right - 2, r.top + BUTTON_SIZE - 2), INFO_MIDDLE); + drawDialogRect(Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised); + + raised = ui._scrollHighlight != 5; + _surface.fillRect(Common::Rect(r.left + 2, r.bottom - BUTTON_SIZE + 2, r.right - 2, r.bottom - 2), INFO_MIDDLE); + drawDialogRect(Common::Rect(r.left, r.bottom - BUTTON_SIZE, r.right, r.bottom), raised); + + // Draw the arrows on the scroll buttons + byte color = inv._invIndex? INFO_BOTTOM + 2 : INFO_BOTTOM; + _surface.hLine(r.right / 2, r.top - 2 + BUTTON_SIZE / 2, r.right / 2, color); + _surface.fillRect(Common::Rect(r.right / 2 - 1, r.top - 1 + BUTTON_SIZE / 2, + r.right / 2 + 1, r.top - 1 + BUTTON_SIZE / 2), color); + _surface.fillRect(Common::Rect(r.right / 2 - 2, r.top + BUTTON_SIZE / 2, + r.right / 2 + 2, r.top + BUTTON_SIZE / 2), color); + _surface.fillRect(Common::Rect(r.right / 2 - 3, r.top + 1 + BUTTON_SIZE / 2, + r.right / 2 + 3, r.top + 1 + BUTTON_SIZE / 2), color); + + color = (inv._invIndex + NUM_INVENTORY_SHOWN) < inv._holdings ? INFO_BOTTOM + 2 : INFO_BOTTOM; + _surface.fillRect(Common::Rect(r.right / 2 - 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2, + r.right / 2 + 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2), color); + _surface.fillRect(Common::Rect(r.right / 2 - 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2, + r.right / 2 + 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2), color); + _surface.fillRect(Common::Rect(r.right / 2 - 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2, + r.right / 2 + 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2), color); + _surface.fillRect(Common::Rect(r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2, + r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color); + + // Draw the scroll position bar + int idx= inv._holdings; + if (idx% (NUM_INVENTORY_SHOWN / 2)) + idx= (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2)*(NUM_INVENTORY_SHOWN / 2); + int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx; + barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2); + + int barY = (idx<= NUM_INVENTORY_SHOWN) ? r.top + BUTTON_SIZE : + (r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER / (idx- NUM_INVENTORY_SHOWN) + * inv._invIndex / FIXED_INT_MULTIPLIER + r.top + BUTTON_SIZE; + _surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE); + drawDialogRect(Common::Rect(r.left, barY, r.right, barY + barHeight), true); +} + +void WidgetInventory::drawDialogRect(const Common::Rect &r, bool raised) { + switch (raised) { + case true: + // Draw Left + _surface.vLine(r.left, r.top, r.bottom - 1, INFO_TOP); + _surface.vLine(r.left + 1, r.top, r.bottom - 2, INFO_TOP); + // Draw Top + _surface.hLine(r.left + 2, r.top, r.right - 1, INFO_TOP); + _surface.hLine(r.left + 2, r.top + 1, r.right - 2, INFO_TOP); + // Draw Right + _surface.vLine(r.right - 1, r.top + 1,r.bottom - 1, INFO_BOTTOM); + _surface.vLine(r.right - 2, r.top + 2, r.bottom - 1, INFO_BOTTOM); + // Draw Bottom + _surface.hLine(r.left + 1, r.bottom - 1, r.right - 3, INFO_BOTTOM); + _surface.hLine(r.left + 2, r.bottom - 2, r.right - 3, INFO_BOTTOM); + break; + + case false: + // Draw Left + _surface.vLine(r.left, r.top, r.bottom - 1, INFO_BOTTOM); + _surface.vLine(r.left + 1, r.top, r.bottom - 2, INFO_BOTTOM); + // Draw Top + _surface.hLine(r.left + 2, r.top, r.right - 1, INFO_BOTTOM); + _surface.hLine(r.left + 2, r.top + 1, r.right - 2, INFO_BOTTOM); + // Draw Right + _surface.vLine(r.right - 1, r.top + 1, r.bottom - 1, INFO_TOP); + _surface.vLine(r.right - 2, r.top + 2, r.bottom - 1, INFO_TOP); + // Draw Bottom + _surface.hLine(r.left + 1, r.bottom - 1, r.right - 3, INFO_TOP); + _surface.hLine(r.left + 2, r.bottom - 2, r.right - 3, INFO_TOP); + break; + } } -- cgit v1.2.3 From 3adaf2f999c4af74534beb7d02638aba8cc81a1e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Jun 2015 08:46:38 -0400 Subject: SHERLOCK: RT: Implement inventory handleEvents --- engines/sherlock/tattoo/widget_inventory.cpp | 365 ++++++++++++++++++++++++++- 1 file changed, 363 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index dfa4736ccc..ee8faa3759 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -21,6 +21,7 @@ */ #include "sherlock/tattoo/widget_inventory.h" +#include "sherlock/tattoo/tattoo_scene.h" #include "sherlock/tattoo/tattoo_user_interface.h" #include "sherlock/tattoo/tattoo.h" @@ -31,14 +32,26 @@ namespace Tattoo { #define INVENTORY_XSIZE 70 // Width of the box that surrounds inventory items #define INVENTORY_YSIZE 70 // Height of the box that surrounds inventory items #define NUM_INVENTORY_SHOWN 8 // Number of Inventory Items Shown +#define MAX_INV_COMMANDS 10 // Maximum elements in dialog #define BUTTON_SIZE 15 // Button width/height -WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm) { +// TODO: Refactor into FixedText +#define S_INV6 "Foolscap" +#define S_INV7 "Damp Paper" +#define S_SOLVE "Solve" +#define S_LOOK "Look" +#define S_NO_EFFECT "No effect..." +#define S_WITH "with" + +WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _tooltipWidget(vm) { _invMode = 0; _invVerbMode = 0; _invSelect = _oldInvSelect = 0; _selector = _oldSelector = 0; + _invVerbSelect = _oldInvVerbSelect = -1; _dialogTimer = -1; + _scrollHighlight = 0; + _swapItems = false; } void WidgetInventory::load(int mode) { @@ -72,7 +85,7 @@ void WidgetInventory::load(int mode) { _surface.fill(TRANSPARENCY); // Draw the window background and then the inventory on top of it - makeInfoArea(); + makeInfoArea(_surface); drawInventory(); } @@ -187,6 +200,354 @@ void WidgetInventory::drawDialogRect(const Common::Rect &r, bool raised) { } } +void WidgetInventory::handleEvents() { + TattooEngine &vm = *(TattooEngine *)_vm; + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + People &people = *_vm->_people; + TattooScene &scene = *(TattooScene *)_vm->_scene; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + Common::Point mousePos = events.mousePos(); + + if (_invVerbMode == 1) + checkTabbingKeys(MAX_INV_COMMANDS); + else if (_invVerbMode == 0) + checkInvTabbingKeys(); + + if (_invVerbMode != 1) + updateDescription(); + + // Flag is they started pressing outside of the menu + if (events._firstPress && !_bounds.contains(mousePos)) + _outsideMenu = true; + + if (_invVerbMode != 3) + highlightControls(); + + // See if they released a mouse button button + if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { + _dialogTimer = -1; + _scrollHighlight = 0; + + // See if they have a Verb List open for an Inventry Item + if (_invVerbMode == 1) { + // An inventory item's Verb List is open + + // See if they want to close the menu (by clicking outside the menu) + Common::Rect innerBounds = _bounds; + innerBounds.grow(-3); + + if (_outsideMenu && !innerBounds.contains(mousePos)) { + banishWindow(); + _invVerbMode = 0; + } else if (innerBounds.contains(mousePos)) { + _outsideMenu = false; + + // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle + bool doHangman = !inv[_invSelect]._name.compareToIgnoreCase(S_INV6) && + !_inventCommands[_invVerbSelect].compareToIgnoreCase(S_SOLVE); + doHangman |= (!inv[_invSelect]._name.compareToIgnoreCase(S_INV6) || !inv[_invSelect]._name.compareToIgnoreCase(S_INV7)) + && _inventCommands[_invVerbSelect].compareToIgnoreCase(S_LOOK) && vm.readFlags(299); + + if (doHangman) { + // Close the entire Inventory and return to Standard Mode + banishWindow(); + _invVerbMode = 0; + + _tooltipWidget.banishWindow(); + banishWindow(); + inv.freeInv(); + + events.clearEvents(); + events.setCursor(ARROW); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + + scene.doBgAnim(); + vm.doHangManPuzzle(); + } else if (_invVerbSelect == 0) { + // They have released the mouse on the Look Verb command, so Look at the inventory item + ui._invLookFlag = true; + inv.freeInv(); + ui._windowOpen = false; + ui._lookPos = mousePos; + ui.printObjectDesc(inv[_invSelect]._examine, true); + } else { + // Clear the window + banishWindow(); + _invVerbMode = 3; + ui._oldBgFound = -1; + + // See if the selected Verb with the selected Iventory Item, is to be used by itself + if (!_inventCommands[_invVerbSelect].compareToIgnoreCase(inv[_invSelect]._verb._verb) || + !inv[_invSelect]._verb._target.compareToIgnoreCase("*SELF")) { + inv.freeInv(); + + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + events.clearEvents(); + ui.checkAction(inv[_invSelect]._verb, 2000); + } else { + _invVerb = _inventCommands[_invVerbSelect]; + } + } + + // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor + if (ui._menuMode == INV_MODE) { + ImageFrame &imgFrame = (*inv._invShapes[_invSelect - inv._invIndex])[0]; + _invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); + _invGraphicBounds.moveTo(mousePos.x - _invGraphicBounds.width() / 2, + mousePos.y - _invGraphicBounds.height() / 2); + + // Constrain it to the screen + if (_invGraphicBounds.left < 0) + _invGraphicBounds.moveTo(0, _invGraphicBounds.top); + if (_invGraphicBounds.top < 0) + _invGraphicBounds.moveTo(_invGraphicBounds.left, 0); + if (_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) + _invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _invGraphicBounds.width(), _invGraphicBounds.top); + if (_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) + _invGraphicBounds.moveTo(_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _invGraphicBounds.height()); + + // Make a copy of the inventory image + _invGraphic.create(imgFrame._width, imgFrame._height); + _invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); + } + } + } else if (_invVerbMode == 3) { + // Selecting object after inventory verb has been selected + _tooltipWidget.banishWindow(); + _invGraphic.free(); + inv.freeInv(); + + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + events.clearEvents(); + + if (ui._keyState.keycode != Common::KEYCODE_ESCAPE) { + // If user pointed at an item, use the selected inventory item with this item + bool found = false; + if (ui._bgFound != -1) { + if (ui._personFound) { + for (int idx = 0; idx < 2; ++idx) { + if (!people[ui._bgFound - 1000]._use[idx]._verb.compareToIgnoreCase(_invVerb) && + !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(_invVerb) && + !ui._bgShape->_use[idx]._target.compareToIgnoreCase(_invTarget)) { + ui.checkAction(ui._bgShape->_use[idx], ui._bgFound); + found = true; + } + } + } + } + + if (!found) + ui.putMessage(S_NO_EFFECT); + } + } else if ((_outsideMenu && !_bounds.contains(mousePos)) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { + // Want to close the window (clicked outside of it). So close the window and return to Standard + banishWindow(); + inv.freeInv(); + + events.clearEvents(); + events.setCursor(ARROW); + banishWindow(); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + } else if (_bounds.contains(mousePos)) { + // Mouse button was released inside the inventory window + _outsideMenu = false; + + // See if they are pointing at one of the inventory items + if (_invSelect != -1) { + // See if they are in Use Obj with Inv. Mode (they right clicked on an item + // in the room and selected "Use with Inv.") + if (_invMode == 1) { + _tooltipWidget.banishWindow(); + banishWindow(); + + // See if the item in the room that they started with was a person + bool found = false; + if (ui._activeObj >= 1000) { + // Object was a person, activate anything in his two verb fields + for (int idx = 0; idx < 2; ++idx) { + if (!people[ui._activeObj - 1000]._use[idx]._target.compareToIgnoreCase(inv[_invSelect]._name)) { + ui.checkAction(people[ui._activeObj - 1000]._use[idx], ui._activeObj); + found = true; + } + } + } else { + // Object was a regular object, activate anything in its verb fields + for (int idx = 0; idx < 6; ++idx) { + if (!scene._bgShapes[ui._activeObj]._use[idx]._target.compareToIgnoreCase(inv[_invSelect]._name)) { + ui.checkAction(scene._bgShapes[ui._activeObj]._use[idx], ui._activeObj); + found = true; + } + } + } + if (!found) + ui.putMessage(S_NO_EFFECT); + + } else { + // See if they right clicked on an item + if (events._rightReleased) { + _invVerbMode = 1; + _oldInvVerbSelect = -1; + _tooltipWidget.banishWindow(); + + // Keep track of the name of the inventory object so we can check it against the target fields + // of verbs when we activate it + _invTarget = inv[_invSelect]._name; + + // Make the Verb List for this Inventory Item + _inventCommands.clear(); + _inventCommands.push_back(S_LOOK); + + // Default the Action word to "with" + _action = _vm->getLanguage() == Common::GR_GRE ? "" : S_WITH; + _swapItems = false; + + // Search all the bgshapes for any matching Target Fields + for (uint idx = 0; idx < scene._bgShapes.size(); ++idx) { + Object &obj = scene._bgShapes[idx]; + + if (obj._type != INVALID && obj._type != HIDDEN) { + for (int useNum = 0; useNum < 6; ++useNum) { + if (obj._use[useNum]._verb.hasPrefix("*") && + !obj._use[useNum]._target.compareToIgnoreCase(inv[_invSelect]._name)) { + // Make sure the Verb is not already in the list + bool found1 = false; + for (uint cmdNum = 0; cmdNum < _inventCommands.size() && !found1; ++cmdNum) { + if (!_inventCommands[cmdNum].compareToIgnoreCase(obj._use[useNum]._verb)) + found1 = true; + } + + if (!found1) { + _inventCommands.push_back(obj._use[useNum]._verb); + + // Check for any Special Action commands + for (int nameNum = 0; nameNum < 4; ++nameNum) { + if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*V", 2)) { + if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*VSWAP", 6)) + _swapItems = true; + else + _action = Common::String(obj._use[useNum]._names[nameNum].c_str() + 2); + } + } + } + } + } + } + } + + // Search the NPCs for matches as well + for (int idx = 1; idx < MAX_CHARACTERS; ++idx) { + for (int useNum = 0; useNum < 2; ++useNum) { + if (!people[idx]._use[useNum]._target.compareToIgnoreCase(inv[_invSelect]._name) && + !people[idx]._use[useNum]._verb.empty() && !people[idx]._use[useNum]._verb.hasPrefix(" ")) { + bool found1 = false; + for (uint cmdNum = 0; cmdNum < _inventCommands.size() && !found1; ++cmdNum) { + if (!_inventCommands[cmdNum].compareToIgnoreCase(people[idx]._use[cmdNum]._verb)) + found1 = true; + } + + if (!found1) + _inventCommands.push_back(people[idx]._use[useNum]._verb); + } + } + } + + // Finally see if the item itself has a verb + if (!inv[_invSelect]._verb._verb.empty()) { + // Don't add "Solve" to the Foolscap if it's already been "Solved" + if (inv[_invSelect]._verb._verb.compareToIgnoreCase(S_SOLVE) || !vm.readFlags(299)) + _inventCommands.push_back(inv[_invSelect]._verb._verb); + } + + // Now find the widest command in the _inventCommands array + int width = 0; + for (uint idx = 0; idx < _inventCommands.size(); ++idx) + width = MAX(width, _surface.stringWidth(_inventCommands[idx])); + + // Set up bounds for the menu + _menuBounds = Common::Rect(width + _surface.widestChar() * 2 + 6, + (_surface.fontHeight() + 7) * _inventCommands.size() + 3); + _menuBounds.moveTo(mousePos.x + _menuBounds.width() / 2, mousePos.y + _menuBounds.height() / 2); + + // Create the surface + _menuSurface.create(_menuBounds.width(), _menuBounds.height()); + _surface.fill(TRANSPARENCY); + makeInfoArea(_menuSurface); + + // Draw the Verb commands and the lines separating them + ImageFile &images = *_interfaceImages; + for (int idx = 0; idx < (int)_inventCommands.size(); ++idx) { + _menuSurface.writeString(_inventCommands[idx], Common::Point((_menuBounds.width() - + _menuSurface.stringWidth(_inventCommands[idx])) / 2, (_menuSurface.fontHeight() + 7) * idx + 5), INFO_TOP); + + if (idx < (int)_inventCommands.size()- 1) { + _menuSurface.vLine(3, (_menuSurface.fontHeight() + 7) * (idx + 1), _menuBounds.right - 4, INFO_TOP); + _menuSurface.vLine(3, (_menuSurface.fontHeight() + 7) * (idx + 1) + 1, _menuBounds.right - 4, INFO_MIDDLE); + _menuSurface.vLine(3, (_menuSurface.fontHeight() + 7) * (idx + 1) + 2, _menuBounds.right - 4, INFO_BOTTOM); + + _menuSurface.transBlitFrom(images[4], Common::Point(0, (_menuSurface.fontHeight() + 7) * (idx + 1))); + _menuSurface.transBlitFrom(images[5], Common::Point(_menuBounds.width() - images[5]._width, + (_menuSurface.fontHeight() + 7) * (idx + 1) - 1)); + } + } + } else { + // They left clicked on an inventory item, so Look at it + + // Check if they are looking at the solved Foolscap + if ((!inv[_invSelect]._name.compareToIgnoreCase(S_INV6) || !inv[_invSelect]._name.compareToIgnoreCase(S_INV7)) + && vm.readFlags(299)) { + banishWindow(); + _tooltipWidget.erase(); + + _invVerbMode = 0; + inv.freeInv(); + + events.clearEvents(); + events.setCursor(ARROW); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + + scene.doBgAnim(); + vm.doHangManPuzzle(); + } else { + ui._invLookFlag = true; + inv.freeInv(); + + _tooltipWidget.banishWindow(); + ui._windowOpen = false; + ui._lookPos = mousePos; + ui.printObjectDesc(inv[_invSelect]._examine, true); + } + } + } + } + } + } +} + +void WidgetInventory::updateDescription() { + +} + +void WidgetInventory::checkInvTabbingKeys() { +} + +void WidgetInventory::highlightControls() { + // TODO +} + +void WidgetInventory::banishWindow() { + WidgetBase::banishWindow(); + + _menuSurface.free(); + _menuBounds = _oldMenuBounds = Common::Rect(0, 0, 0, 0); +} } // End of namespace Tattoo -- cgit v1.2.3 From dec2b0857ca54ecf61e95c731d10ebfb85b5b375 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Jun 2015 09:47:59 -0400 Subject: SHERLOCK: Split up Journal class for each game --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index ee8faa3759..60da821a1f 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -532,7 +532,7 @@ void WidgetInventory::handleEvents() { } void WidgetInventory::updateDescription() { - + // TODO } void WidgetInventory::checkInvTabbingKeys() { -- cgit v1.2.3 From 0a8630ab46567e137358807208158d080be556e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Jun 2015 14:44:32 -0400 Subject: SHERLOCK: RT: Implemented drawJournalControls --- engines/sherlock/tattoo/widget_inventory.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 60da821a1f..931c6464d8 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -33,7 +33,6 @@ namespace Tattoo { #define INVENTORY_YSIZE 70 // Height of the box that surrounds inventory items #define NUM_INVENTORY_SHOWN 8 // Number of Inventory Items Shown #define MAX_INV_COMMANDS 10 // Maximum elements in dialog -#define BUTTON_SIZE 15 // Button width/height // TODO: Refactor into FixedText #define S_INV6 "Foolscap" @@ -482,7 +481,7 @@ void WidgetInventory::handleEvents() { makeInfoArea(_menuSurface); // Draw the Verb commands and the lines separating them - ImageFile &images = *_interfaceImages; + ImageFile &images = *ui._interfaceImages; for (int idx = 0; idx < (int)_inventCommands.size(); ++idx) { _menuSurface.writeString(_inventCommands[idx], Common::Point((_menuBounds.width() - _menuSurface.stringWidth(_inventCommands[idx])) / 2, (_menuSurface.fontHeight() + 7) * idx + 5), INFO_TOP); -- cgit v1.2.3 From 5a5a225216111b9507595a2ccfd37c3a518aa3a4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Jun 2015 17:23:26 -0400 Subject: SHERLOCK: RT: Implemented further journal draw methods --- engines/sherlock/tattoo/widget_inventory.cpp | 40 +++------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 931c6464d8..ac30fe3c9c 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -125,11 +125,11 @@ void WidgetInventory::drawScrollBar() { raised = ui._scrollHighlight != 1; _surface.fillRect(Common::Rect(r.left + 2, r.top + 2, r.right - 2, r.top + BUTTON_SIZE - 2), INFO_MIDDLE); - drawDialogRect(Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised); + ui.drawDialogRect(_surface, Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised); raised = ui._scrollHighlight != 5; _surface.fillRect(Common::Rect(r.left + 2, r.bottom - BUTTON_SIZE + 2, r.right - 2, r.bottom - 2), INFO_MIDDLE); - drawDialogRect(Common::Rect(r.left, r.bottom - BUTTON_SIZE, r.right, r.bottom), raised); + ui.drawDialogRect(_surface, Common::Rect(r.left, r.bottom - BUTTON_SIZE, r.right, r.bottom), raised); // Draw the arrows on the scroll buttons byte color = inv._invIndex? INFO_BOTTOM + 2 : INFO_BOTTOM; @@ -162,41 +162,7 @@ void WidgetInventory::drawScrollBar() { (r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER / (idx- NUM_INVENTORY_SHOWN) * inv._invIndex / FIXED_INT_MULTIPLIER + r.top + BUTTON_SIZE; _surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE); - drawDialogRect(Common::Rect(r.left, barY, r.right, barY + barHeight), true); -} - -void WidgetInventory::drawDialogRect(const Common::Rect &r, bool raised) { - switch (raised) { - case true: - // Draw Left - _surface.vLine(r.left, r.top, r.bottom - 1, INFO_TOP); - _surface.vLine(r.left + 1, r.top, r.bottom - 2, INFO_TOP); - // Draw Top - _surface.hLine(r.left + 2, r.top, r.right - 1, INFO_TOP); - _surface.hLine(r.left + 2, r.top + 1, r.right - 2, INFO_TOP); - // Draw Right - _surface.vLine(r.right - 1, r.top + 1,r.bottom - 1, INFO_BOTTOM); - _surface.vLine(r.right - 2, r.top + 2, r.bottom - 1, INFO_BOTTOM); - // Draw Bottom - _surface.hLine(r.left + 1, r.bottom - 1, r.right - 3, INFO_BOTTOM); - _surface.hLine(r.left + 2, r.bottom - 2, r.right - 3, INFO_BOTTOM); - break; - - case false: - // Draw Left - _surface.vLine(r.left, r.top, r.bottom - 1, INFO_BOTTOM); - _surface.vLine(r.left + 1, r.top, r.bottom - 2, INFO_BOTTOM); - // Draw Top - _surface.hLine(r.left + 2, r.top, r.right - 1, INFO_BOTTOM); - _surface.hLine(r.left + 2, r.top + 1, r.right - 2, INFO_BOTTOM); - // Draw Right - _surface.vLine(r.right - 1, r.top + 1, r.bottom - 1, INFO_TOP); - _surface.vLine(r.right - 2, r.top + 2, r.bottom - 1, INFO_TOP); - // Draw Bottom - _surface.hLine(r.left + 1, r.bottom - 1, r.right - 3, INFO_TOP); - _surface.hLine(r.left + 2, r.bottom - 2, r.right - 3, INFO_TOP); - break; - } + ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true); } void WidgetInventory::handleEvents() { -- cgit v1.2.3 From 92ac962718b07e9b82199d39bb5ce970717da57d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 25 Jun 2015 20:42:02 -0400 Subject: SHERLOCK: RT: Further split-off of Scalpel-specific code --- engines/sherlock/tattoo/widget_inventory.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index ac30fe3c9c..fe6fa09bff 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -31,7 +31,6 @@ namespace Tattoo { #define INVENTORY_XSIZE 70 // Width of the box that surrounds inventory items #define INVENTORY_YSIZE 70 // Height of the box that surrounds inventory items -#define NUM_INVENTORY_SHOWN 8 // Number of Inventory Items Shown #define MAX_INV_COMMANDS 10 // Maximum elements in dialog // TODO: Refactor into FixedText -- cgit v1.2.3 From d5c1f8b8d645136cf72981186db6e81b2082b773 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Jun 2015 13:29:32 -0400 Subject: SHERLOCK: RT: Implement initial inventory --- engines/sherlock/tattoo/widget_inventory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index fe6fa09bff..ea07793e10 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -90,7 +90,7 @@ void WidgetInventory::load(int mode) { void WidgetInventory::drawInventory() { Inventory &inv = *_vm->_inventory; - // TODO: Refactor _invIndexinto this widget class + // TODO: Refactor _invIndex into this widget class for (int idx= 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx) { // Figure out the drawing position Common::Point pt(3 + (INVENTORY_XSIZE + 3) * (idx % (NUM_INVENTORY_SHOWN / 2)), @@ -151,9 +151,9 @@ void WidgetInventory::drawScrollBar() { r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color); // Draw the scroll position bar - int idx= inv._holdings; - if (idx% (NUM_INVENTORY_SHOWN / 2)) - idx= (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2)*(NUM_INVENTORY_SHOWN / 2); + int idx = inv._holdings; + if (idx % (NUM_INVENTORY_SHOWN / 2)) + idx = (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2) * (NUM_INVENTORY_SHOWN / 2); int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx; barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2); -- cgit v1.2.3 From a041aec839911793bc34a74f6e88fd37fe8adf3c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Jun 2015 20:10:02 -0400 Subject: SHERLOCK: RT: Inventory window now partially showing --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index ea07793e10..2d5e0c3746 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -91,7 +91,7 @@ void WidgetInventory::drawInventory() { Inventory &inv = *_vm->_inventory; // TODO: Refactor _invIndex into this widget class - for (int idx= 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx) { + for (int idx = 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx, ++itemId) { // Figure out the drawing position Common::Point pt(3 + (INVENTORY_XSIZE + 3) * (idx % (NUM_INVENTORY_SHOWN / 2)), 3 + (INVENTORY_YSIZE + 3) * idx / (NUM_INVENTORY_SHOWN / 2)); -- cgit v1.2.3 From b74bc43a53e50439660edf01c7d40e69fef87a27 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Jun 2015 21:15:54 -0400 Subject: SHERLOCK: RT: Fix display of inventory window --- engines/sherlock/tattoo/widget_inventory.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 2d5e0c3746..c2379a5430 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -57,6 +57,11 @@ void WidgetInventory::load(int mode) { Inventory &inv = *_vm->_inventory; Common::Point mousePos = events.mousePos(); + if (mode == 3) { + mode = 2; + mousePos = Common::Point(SHERLOCK_SCREEN_WIDTH / 2, SHERLOCK_SCREEN_HEIGHT / 2); + } + if (mode != 0) _invMode = mode; _invVerbMode = 0; @@ -94,7 +99,7 @@ void WidgetInventory::drawInventory() { for (int idx = 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx, ++itemId) { // Figure out the drawing position Common::Point pt(3 + (INVENTORY_XSIZE + 3) * (idx % (NUM_INVENTORY_SHOWN / 2)), - 3 + (INVENTORY_YSIZE + 3) * idx / (NUM_INVENTORY_SHOWN / 2)); + 3 + (INVENTORY_YSIZE + 3) * (idx / (NUM_INVENTORY_SHOWN / 2))); // Draw the box to serve as the background for the item _surface.hLine(pt.x + 1, pt.y, pt.x + INVENTORY_XSIZE - 2, TRANSPARENCY); -- cgit v1.2.3 From 753a810070b6b96d1a90cff399a41f21c31de885 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Jun 2015 07:51:25 -0400 Subject: SHERLOCK: RT: Beginnings of inventory window tooltip class --- engines/sherlock/tattoo/widget_inventory.cpp | 171 +++++++++++++++++++++++---- 1 file changed, 146 insertions(+), 25 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index c2379a5430..67e227666b 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -21,6 +21,8 @@ */ #include "sherlock/tattoo/widget_inventory.h" +#include "sherlock/tattoo/tattoo_fixed_text.h" +#include "sherlock/tattoo/tattoo_people.h" #include "sherlock/tattoo/tattoo_scene.h" #include "sherlock/tattoo/tattoo_user_interface.h" #include "sherlock/tattoo/tattoo.h" @@ -33,19 +35,142 @@ namespace Tattoo { #define INVENTORY_YSIZE 70 // Height of the box that surrounds inventory items #define MAX_INV_COMMANDS 10 // Maximum elements in dialog -// TODO: Refactor into FixedText -#define S_INV6 "Foolscap" -#define S_INV7 "Damp Paper" -#define S_SOLVE "Solve" -#define S_LOOK "Look" -#define S_NO_EFFECT "No effect..." -#define S_WITH "with" +WidgetInventoryTooltip::WidgetInventoryTooltip(SherlockEngine *vm, WidgetInventory *owner) : + WidgetBase(vm), _owner(owner) { +} + +void WidgetInventoryTooltip::setText(const Common::String &str) { + +} + +void WidgetInventoryTooltip::handleEvents() { + Events &events = *_vm->_events; + FixedText &fixedText = *_vm->_fixedText; + Inventory &inv = *_vm->_inventory; + TattooPeople &people = *(TattooPeople *)_vm->_people; + Scene &scene = *_vm->_scene; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + Common::Point mousePos = events.mousePos(); + Common::String str; + int select = -1, oldSelect = -1; + 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_SCREEN_WIDTH - _invGraphicBounds.width()); + int yp = CLIP(mousePos.y - _invGraphicBounds.height() / 2, 0, SHERLOCK_SCREEN_HEIGHT - _invGraphicBounds.height()); -WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _tooltipWidget(vm) { + _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; + oldSelect = ui._oldBgFound; + + if (select != -1 && (select != oldSelect || (select != -1 && _surface.empty()))) { + // See if we're pointing at a shape or a sprite + if (select < 1000) { + Object &obj = scene._bgShapes[select]; + + if (!obj._description.empty() && !obj._description.hasPrefix(" ")) { + if (_vm->getLanguage() == Common::GR_GRE) { + + if (!_owner->_swapItems) + str = Common::String::format("%s %s %s %s", ui._action, obj._description, + inv[_owner->_invSelect]._name, _owner->_invVerb); + else + str = Common::String::format("%s %s %s %s", ui._action, inv[_owner->_invSelect]._name, + obj._description, _owner->_invVerb); + } else { + if (_owner->_swapItems) + str = Common::String::format("%s %s %s %s", _owner->_invVerb, obj._description, ui._action, + inv[_owner->_invSelect]._name); + else + str = Common::String::format("%s %s %s %s", _owner->_invVerb, inv[_owner->_invSelect]._name, + ui._action, obj._description); + } + } + } else { + Person &person = people[ui._bgFound - 1000]; + + 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, person._description, inv[_owner->_invSelect]._name, _owner->_invVerb); + else + str = Common::String::format("%s %s %s %s", ui._action, inv[_owner->_invSelect]._name, person._description, _owner->_invVerb); + } else { + + if (_owner->_swapItems) + str = Common::String::format("%s %s %s %s", _owner->_invVerb, person._description, ui._action, inv[_owner->_invSelect]._name); + else + str = Common::String::format("%s %s %s %s", _owner->_invVerb, inv[_owner->_invSelect]._name, ui._action, person._description); + } + } + } + } + } else { + Common::Rect r = _owner->_bounds; + r.grow(-3); + + if (r.contains(mousePos)) { + select = (mousePos.x - r.left) / (INVENTORY_XSIZE + 3) + NUM_INVENTORY_SHOWN / 2 * + ((mousePos.y - r.top) / (INVENTORY_YSIZE + 3)) + inv._invIndex; + + if (select >= inv._holdings) { + select = -1; + } else { + oldSelect = _owner->_invSelect; + + if (select != _owner->_invSelect || _surface.empty()) { + + if (_owner->_invMode == 1) { + // See if we were pointing at a shapre or sprite + if (ui._activeObj < 1000) { + Object &obj = scene._bgShapes[ui._activeObj]; + + if (!obj._description.empty() && !obj._description.hasPrefix(" ")) + str = Common::String::format("%s %s %s %s", strUse.c_str(), inv[select]._name.c_str(), + strWith.c_str(), obj._description.c_str()); + } else { + Person &person = people[ui._activeObj - 1000]; + + if (!person._description.empty() && !person._description.hasPrefix(" ")) + str = Common::String::format("%s %s %s %s", strUse.c_str(), inv[select]._name.c_str(), + strWith.c_str(), person._description.c_str()); + } + } else { + if (_owner->_invVerbMode == 2) + str = Common::String::format("%s %s %s %s", strUse.c_str(), inv[_owner->_invSelect]._name.c_str(), + strWith.c_str(), inv[select]._name.c_str()); + else + str = inv[select]._description; + } + } + } + } + } + + // See if they are pointing at a different inventory object and we need to + // change the graphics of the Text Tag + if (select != oldSelect || (select != -1 && _surface.empty())) { + setText(str); + } +} + +/*----------------------------------------------------------------*/ + + +WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _tooltipWidget(vm, this) { _invMode = 0; _invVerbMode = 0; - _invSelect = _oldInvSelect = 0; - _selector = _oldSelector = 0; + _invSelect = _oldInvSelect = -1; + _selector = _oldSelector = -1; _invVerbSelect = _oldInvVerbSelect = -1; _dialogTimer = -1; _scrollHighlight = 0; @@ -184,7 +309,7 @@ void WidgetInventory::handleEvents() { checkInvTabbingKeys(); if (_invVerbMode != 1) - updateDescription(); + _tooltipWidget.handleEvents(); // Flag is they started pressing outside of the menu if (events._firstPress && !_bounds.contains(mousePos)) @@ -213,10 +338,10 @@ void WidgetInventory::handleEvents() { _outsideMenu = false; // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle - bool doHangman = !inv[_invSelect]._name.compareToIgnoreCase(S_INV6) && - !_inventCommands[_invVerbSelect].compareToIgnoreCase(S_SOLVE); - doHangman |= (!inv[_invSelect]._name.compareToIgnoreCase(S_INV6) || !inv[_invSelect]._name.compareToIgnoreCase(S_INV7)) - && _inventCommands[_invVerbSelect].compareToIgnoreCase(S_LOOK) && vm.readFlags(299); + bool doHangman = !inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && + !_inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Solve)); + doHangman |= (!inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) + && _inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); if (doHangman) { // Close the entire Inventory and return to Standard Mode @@ -314,7 +439,7 @@ void WidgetInventory::handleEvents() { } if (!found) - ui.putMessage(S_NO_EFFECT); + ui.putMessage("%s", FIXED(NoEffect).c_str()); } } else if ((_outsideMenu && !_bounds.contains(mousePos)) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { // Want to close the window (clicked outside of it). So close the window and return to Standard @@ -357,7 +482,7 @@ void WidgetInventory::handleEvents() { } } if (!found) - ui.putMessage(S_NO_EFFECT); + ui.putMessage("%s",FIXED(NoEffect).c_str()); } else { // See if they right clicked on an item @@ -372,10 +497,10 @@ void WidgetInventory::handleEvents() { // Make the Verb List for this Inventory Item _inventCommands.clear(); - _inventCommands.push_back(S_LOOK); + _inventCommands.push_back(FIXED(Look)); // Default the Action word to "with" - _action = _vm->getLanguage() == Common::GR_GRE ? "" : S_WITH; + _action = _vm->getLanguage() == Common::GR_GRE ? "" : FIXED(With); _swapItems = false; // Search all the bgshapes for any matching Target Fields @@ -431,7 +556,7 @@ void WidgetInventory::handleEvents() { // Finally see if the item itself has a verb if (!inv[_invSelect]._verb._verb.empty()) { // Don't add "Solve" to the Foolscap if it's already been "Solved" - if (inv[_invSelect]._verb._verb.compareToIgnoreCase(S_SOLVE) || !vm.readFlags(299)) + if (inv[_invSelect]._verb._verb.compareToIgnoreCase(FIXED(Solve)) || !vm.readFlags(299)) _inventCommands.push_back(inv[_invSelect]._verb._verb); } @@ -470,7 +595,7 @@ void WidgetInventory::handleEvents() { // They left clicked on an inventory item, so Look at it // Check if they are looking at the solved Foolscap - if ((!inv[_invSelect]._name.compareToIgnoreCase(S_INV6) || !inv[_invSelect]._name.compareToIgnoreCase(S_INV7)) + if ((!inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) && vm.readFlags(299)) { banishWindow(); _tooltipWidget.erase(); @@ -500,10 +625,6 @@ void WidgetInventory::handleEvents() { } } -void WidgetInventory::updateDescription() { - // TODO -} - void WidgetInventory::checkInvTabbingKeys() { } -- cgit v1.2.3 From 14a852d1a3b2189db59bbbc9b60b4b0097a82e23 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Jun 2015 08:23:50 -0400 Subject: SHERLOCK: RT: Add in .c_str() calls to fix compilation --- engines/sherlock/tattoo/widget_inventory.cpp | 30 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 67e227666b..bcf0c463ca 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -81,18 +81,18 @@ void WidgetInventoryTooltip::handleEvents() { if (_vm->getLanguage() == Common::GR_GRE) { if (!_owner->_swapItems) - str = Common::String::format("%s %s %s %s", ui._action, obj._description, - inv[_owner->_invSelect]._name, _owner->_invVerb); + str = Common::String::format("%s %s %s %s", ui._action.c_str(), obj._description.c_str(), + inv[_owner->_invSelect]._name.c_str(), _owner->_invVerb.c_str()); else - str = Common::String::format("%s %s %s %s", ui._action, inv[_owner->_invSelect]._name, - obj._description, _owner->_invVerb); + str = Common::String::format("%s %s %s %s", ui._action.c_str(), inv[_owner->_invSelect]._name.c_str(), + obj._description.c_str(), _owner->_invVerb.c_str()); } else { if (_owner->_swapItems) - str = Common::String::format("%s %s %s %s", _owner->_invVerb, obj._description, ui._action, - inv[_owner->_invSelect]._name); + str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), obj._description.c_str(), ui._action.c_str(), + inv[_owner->_invSelect]._name.c_str()); else - str = Common::String::format("%s %s %s %s", _owner->_invVerb, inv[_owner->_invSelect]._name, - ui._action, obj._description); + str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), inv[_owner->_invSelect]._name.c_str(), + ui._action.c_str(), obj._description.c_str()); } } } else { @@ -101,15 +101,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, person._description, inv[_owner->_invSelect]._name, _owner->_invVerb); + str = Common::String::format("%s %s %s %s", ui._action.c_str(), person._description.c_str(), + inv[_owner->_invSelect]._name.c_str(), _owner->_invVerb.c_str()); else - str = Common::String::format("%s %s %s %s", ui._action, inv[_owner->_invSelect]._name, person._description, _owner->_invVerb); + str = Common::String::format("%s %s %s %s", ui._action.c_str(), inv[_owner->_invSelect]._name.c_str(), + person._description.c_str(), _owner->_invVerb.c_str()); } else { if (_owner->_swapItems) - str = Common::String::format("%s %s %s %s", _owner->_invVerb, person._description, ui._action, inv[_owner->_invSelect]._name); + str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), person._description.c_str(), + ui._action.c_str(), inv[_owner->_invSelect]._name.c_str()); else - str = Common::String::format("%s %s %s %s", _owner->_invVerb, inv[_owner->_invSelect]._name, ui._action, person._description); + str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), + inv[_owner->_invSelect]._name.c_str(), ui._action.c_str(), person._description.c_str()); } } } @@ -149,7 +153,7 @@ void WidgetInventoryTooltip::handleEvents() { str = Common::String::format("%s %s %s %s", strUse.c_str(), inv[_owner->_invSelect]._name.c_str(), strWith.c_str(), inv[select]._name.c_str()); else - str = inv[select]._description; + str = inv[select]._description.c_str(); } } } -- cgit v1.2.3 From 03adfa2b968b519a560e762df4a5e23e0f302873 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Jun 2015 20:50:48 -0400 Subject: SHERLOCK: RT: Implement further inventory tooltip code --- engines/sherlock/tattoo/widget_inventory.cpp | 84 ++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index bcf0c463ca..84a26049e2 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -40,7 +40,72 @@ WidgetInventoryTooltip::WidgetInventoryTooltip(SherlockEngine *vm, WidgetInvento } void WidgetInventoryTooltip::setText(const Common::String &str) { + // If no text specified, erase any previously displayed tooltip and free it's surface + if (str.empty()) { + erase(); + _surface.free(); + return; + } + + int width = _surface.stringWidth(str) + 2; + int height; + Common::String line1 = str, line2; + + // See if we need to split it into two lines + if (width > 150) { + // Yes, we do + const char *s = str.c_str(); + const char *space = nullptr; + int dif = 10000; + + while (*s) { + s = strchr(s, ' '); + if (!s) { + if (!space) { + height = _surface.stringHeight(str) + 2; + } else { + line1 = Common::String(str.c_str(), space); + line2 = Common::String(space + 1); + int height = _surface.stringHeight(line1) + _surface.stringHeight(line2) + 4; + } + break; + } else { + line1 = Common::String(str.c_str(), s); + line2 = Common::String(s + 1); + int width1 = _surface.stringWidth(line1); + int width2 = _surface.stringWidth(line2); + + if (ABS(width1 - width2) < dif) { + // Found a split point that results in less overall width + space = s; + dif = ABS(width1 - width2); + width = MAX(width1, width2); + } + + s++; + } + } + } else { + height = _surface.stringHeight(str) + 2; + } + + // Allocate a fresh surface for the new string + _surface.create(width, height); + _surface.fill(TRANSPARENCY); + + if (line2.empty()) { + _surface.writeFancyString(str, Common::Point(0, 0), BLACK, INFO_TOP); + } else { + int xp, yp; + + xp = (_bounds.width() - _surface.stringWidth(line1) - 2) / 2; + _surface.writeFancyString(line1, Common::Point(xp, 0), BLACK, INFO_TOP); + + xp = (_bounds.width() - _surface.stringWidth(line2) - 2) / 2; + yp = _surface.stringHeight(line2) + 2; + _surface.writeFancyString(line2, Common::Point(xp, yp), BLACK, INFO_TOP); + } } void WidgetInventoryTooltip::handleEvents() { @@ -163,8 +228,17 @@ void WidgetInventoryTooltip::handleEvents() { // See if they are pointing at a different inventory object and we need to // change the graphics of the Text Tag if (select != oldSelect || (select != -1 && _surface.empty())) { + // Set the text setText(str); + } else if (select == -1 && oldSelect != -1) { + setText(Common::String()); + return; } + + // Update the position of the tooltip + int xs = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _bounds.width()); + int ys = CLIP(mousePos.y - _bounds.height(), 0, SHERLOCK_SCREEN_HEIGHT - _bounds.height()); + _bounds.moveTo(xs, ys); } /*----------------------------------------------------------------*/ @@ -643,6 +717,16 @@ void WidgetInventory::banishWindow() { _menuBounds = _oldMenuBounds = Common::Rect(0, 0, 0, 0); } +void WidgetInventory::draw() { + WidgetBase::draw(); + _tooltipWidget.draw(); +} + +void WidgetInventory::erase() { + WidgetBase::erase(); + _tooltipWidget.erase(); +} + } // End of namespace Tattoo } // End of namespace Sherlock -- cgit v1.2.3 From 93072407bc1f0389a4e5195f96715e4b5acdcc65 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Jun 2015 21:53:40 -0400 Subject: SHERLOCK: RT: Fix display of lines in inventory dialog --- engines/sherlock/tattoo/widget_inventory.cpp | 29 +++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 84a26049e2..ed7ca8fc61 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -67,7 +67,7 @@ void WidgetInventoryTooltip::setText(const Common::String &str) { } else { line1 = Common::String(str.c_str(), space); line2 = Common::String(space + 1); - int height = _surface.stringHeight(line1) + _surface.stringHeight(line2) + 4; + height = _surface.stringHeight(line1) + _surface.stringHeight(line2) + 4; } break; } else { @@ -292,9 +292,36 @@ void WidgetInventory::load(int mode) { // Draw the window background and then the inventory on top of it makeInfoArea(_surface); + drawBars(); drawInventory(); } +void WidgetInventory::drawBars() { + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + ImageFile &images = *ui._interfaceImages; + int x; + + _surface.hLine(3, INVENTORY_YSIZE + 3, _bounds.width() - 4, INFO_TOP); + _surface.hLine(3, INVENTORY_YSIZE + 4, _bounds.width() - 4, INFO_MIDDLE); + _surface.hLine(3, INVENTORY_YSIZE + 5, _bounds.width() - 4, INFO_BOTTOM); + _surface.transBlitFrom(images[4], Common::Point(0, INVENTORY_YSIZE + 2)); + + for (int idx = 1; idx <= NUM_INVENTORY_SHOWN / 2; ++idx) { + x = idx * (INVENTORY_XSIZE + 3); + + _surface.vLine(x, 3, _bounds.height() - 4, INFO_TOP); + _surface.vLine(x + 1, 3, _bounds.height() - 4, INFO_MIDDLE); + _surface.vLine(x + 2, 3, _bounds.height() - 4, INFO_BOTTOM); + + _surface.transBlitFrom(images[6], Common::Point(x - 1, 1)); + _surface.transBlitFrom(images[7], Common::Point(x - 1, _bounds.height() - 4)); + _surface.transBlitFrom(images[6], Common::Point(x - 1, INVENTORY_YSIZE + 5)); + _surface.transBlitFrom(images[7], Common::Point(x - 1, INVENTORY_YSIZE + 2)); + } + + _surface.hLine(x + 2, INVENTORY_YSIZE + 2, INVENTORY_YSIZE + 8, INFO_BOTTOM); +} + void WidgetInventory::drawInventory() { Inventory &inv = *_vm->_inventory; -- cgit v1.2.3 From 9ef857bc6fdad24420872aa9dab91505cb6acfbf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 30 Jun 2015 07:34:46 -0400 Subject: SHERLOCK: RT: Inventory tooltip now partially showing --- engines/sherlock/tattoo/widget_inventory.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index ed7ca8fc61..30a8c3cf10 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -91,6 +91,7 @@ void WidgetInventoryTooltip::setText(const Common::String &str) { } // Allocate a fresh surface for the new string + _bounds = Common::Rect(width, height); _surface.create(width, height); _surface.fill(TRANSPARENCY); @@ -230,6 +231,11 @@ void WidgetInventoryTooltip::handleEvents() { if (select != oldSelect || (select != -1 && _surface.empty())) { // Set the text setText(str); + + if (_owner->_invVerbMode != 3) + _owner->_invSelect = select; + else + ui._oldBgFound = select; } else if (select == -1 && oldSelect != -1) { setText(Common::String()); return; -- cgit v1.2.3 From 2664ee63141a18283984e2e1c9325a1362c2133c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 30 Jun 2015 08:29:09 -0400 Subject: SHERLOCK: RT: Create a tooltip base clsas --- engines/sherlock/tattoo/widget_inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 30a8c3cf10..b4a6daabc2 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -36,7 +36,7 @@ namespace Tattoo { #define MAX_INV_COMMANDS 10 // Maximum elements in dialog WidgetInventoryTooltip::WidgetInventoryTooltip(SherlockEngine *vm, WidgetInventory *owner) : - WidgetBase(vm), _owner(owner) { + WidgetTooltipBase(vm), _owner(owner) { } void WidgetInventoryTooltip::setText(const Common::String &str) { @@ -48,7 +48,7 @@ void WidgetInventoryTooltip::setText(const Common::String &str) { } int width = _surface.stringWidth(str) + 2; - int height; + int height = 0; Common::String line1 = str, line2; // See if we need to split it into two lines -- cgit v1.2.3 From 8e4fca0e75639caa5d425682d8e8d09a5dbf1c27 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 30 Jun 2015 20:01:53 -0400 Subject: SHERLOCK: RT: Fix inventory tooltip when hovering on empty slots --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index b4a6daabc2..1b4fa69a76 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -118,7 +118,7 @@ void WidgetInventoryTooltip::handleEvents() { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; Common::Point mousePos = events.mousePos(); Common::String str; - int select = -1, oldSelect = -1; + int select = -1, oldSelect = 999; Common::String strWith = fixedText.getText(kFixedText_With); Common::String strUse = fixedText.getText(kFixedText_Use); -- cgit v1.2.3 From 169f4b94f2e0999b5825e3328fafa7960df18659 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 2 Jul 2015 20:13:21 -0400 Subject: SHERLOCK: RT: Fix looking at characters --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 1b4fa69a76..1df0e995c5 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -287,7 +287,7 @@ void WidgetInventory::load(int mode) { } // Ensure menu will be on-screen - checkMenuPosition(); + restrictToScreen(); // Load the inventory data inv.loadInv(); -- cgit v1.2.3 From 8d7528c4ce1d938e3bf43b69f88a6a90f0e6d017 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 2 Jul 2015 23:10:24 -0400 Subject: SHERLOCK: RT: Implemented render method for talk dialog --- engines/sherlock/tattoo/widget_inventory.cpp | 57 +--------------------------- 1 file changed, 2 insertions(+), 55 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 1df0e995c5..bc2ae66ea0 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -257,7 +257,6 @@ WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _tooltipW _selector = _oldSelector = -1; _invVerbSelect = _oldInvVerbSelect = -1; _dialogTimer = -1; - _scrollHighlight = 0; _swapItems = false; } @@ -350,59 +349,7 @@ void WidgetInventory::drawInventory() { } } - drawScrollBar(); -} - -void WidgetInventory::drawScrollBar() { - Inventory &inv = *_vm->_inventory; - TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; - bool raised; - - // Fill the area with transparency - Common::Rect r(BUTTON_SIZE, _bounds.height() - 6); - r.moveTo(_bounds.width() - BUTTON_SIZE - 3, 3); - _surface.fillRect(r, TRANSPARENCY); - - raised = ui._scrollHighlight != 1; - _surface.fillRect(Common::Rect(r.left + 2, r.top + 2, r.right - 2, r.top + BUTTON_SIZE - 2), INFO_MIDDLE); - ui.drawDialogRect(_surface, Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised); - - raised = ui._scrollHighlight != 5; - _surface.fillRect(Common::Rect(r.left + 2, r.bottom - BUTTON_SIZE + 2, r.right - 2, r.bottom - 2), INFO_MIDDLE); - ui.drawDialogRect(_surface, Common::Rect(r.left, r.bottom - BUTTON_SIZE, r.right, r.bottom), raised); - - // Draw the arrows on the scroll buttons - byte color = inv._invIndex? INFO_BOTTOM + 2 : INFO_BOTTOM; - _surface.hLine(r.right / 2, r.top - 2 + BUTTON_SIZE / 2, r.right / 2, color); - _surface.fillRect(Common::Rect(r.right / 2 - 1, r.top - 1 + BUTTON_SIZE / 2, - r.right / 2 + 1, r.top - 1 + BUTTON_SIZE / 2), color); - _surface.fillRect(Common::Rect(r.right / 2 - 2, r.top + BUTTON_SIZE / 2, - r.right / 2 + 2, r.top + BUTTON_SIZE / 2), color); - _surface.fillRect(Common::Rect(r.right / 2 - 3, r.top + 1 + BUTTON_SIZE / 2, - r.right / 2 + 3, r.top + 1 + BUTTON_SIZE / 2), color); - - color = (inv._invIndex + NUM_INVENTORY_SHOWN) < inv._holdings ? INFO_BOTTOM + 2 : INFO_BOTTOM; - _surface.fillRect(Common::Rect(r.right / 2 - 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2, - r.right / 2 + 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2), color); - _surface.fillRect(Common::Rect(r.right / 2 - 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2, - r.right / 2 + 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2), color); - _surface.fillRect(Common::Rect(r.right / 2 - 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2, - r.right / 2 + 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2), color); - _surface.fillRect(Common::Rect(r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2, - r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color); - - // Draw the scroll position bar - int idx = inv._holdings; - if (idx % (NUM_INVENTORY_SHOWN / 2)) - idx = (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2) * (NUM_INVENTORY_SHOWN / 2); - int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx; - barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2); - - int barY = (idx<= NUM_INVENTORY_SHOWN) ? r.top + BUTTON_SIZE : - (r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER / (idx- NUM_INVENTORY_SHOWN) - * inv._invIndex / FIXED_INT_MULTIPLIER + r.top + BUTTON_SIZE; - _surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE); - ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true); + drawScrollBar(inv._invIndex, NUM_INVENTORY_SHOWN, inv._holdings); } void WidgetInventory::handleEvents() { @@ -432,7 +379,7 @@ void WidgetInventory::handleEvents() { // See if they released a mouse button button if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { _dialogTimer = -1; - _scrollHighlight = 0; + ui._scrollHighlight = 0; // See if they have a Verb List open for an Inventry Item if (_invVerbMode == 1) { -- cgit v1.2.3 From 323a16e51c5925a07e9316ed69cc23a25401db16 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 3 Jul 2015 11:24:48 -0400 Subject: SHERLOCK: RT: Implement scrollbar event handling --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index bc2ae66ea0..3d43dbe90f 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -379,7 +379,7 @@ void WidgetInventory::handleEvents() { // See if they released a mouse button button if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { _dialogTimer = -1; - ui._scrollHighlight = 0; + ui._scrollHighlight = SH_NONE; // See if they have a Verb List open for an Inventry Item if (_invVerbMode == 1) { -- cgit v1.2.3 From 1e37f0b2efd2acd343bc199fa051c2f8a5da34df Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 3 Jul 2015 16:01:20 -0400 Subject: SHERLOCK: Change FixedText::getText to return const char * --- engines/sherlock/tattoo/widget_inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 3d43dbe90f..3274552f5e 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -497,7 +497,7 @@ void WidgetInventory::handleEvents() { } if (!found) - ui.putMessage("%s", FIXED(NoEffect).c_str()); + ui.putMessage("%s", FIXED(NoEffect)); } } else if ((_outsideMenu && !_bounds.contains(mousePos)) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { // Want to close the window (clicked outside of it). So close the window and return to Standard @@ -540,7 +540,7 @@ void WidgetInventory::handleEvents() { } } if (!found) - ui.putMessage("%s",FIXED(NoEffect).c_str()); + ui.putMessage("%s", FIXED(NoEffect)); } else { // See if they right clicked on an item -- cgit v1.2.3 From 3d20072fd894dc211cf1a8223b4c8e27b0aff1c2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 8 Jul 2015 08:35:03 -0400 Subject: SHERLOCK: RT: Fix display of inventory in scrolled scenes --- engines/sherlock/tattoo/widget_inventory.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 3274552f5e..3ce733b3d6 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -127,7 +127,7 @@ void WidgetInventoryTooltip::handleEvents() { _oldInvGraphicBounds = _invGraphicBounds; // Set the New position of the graphic - int xp = CLIP(mousePos.x - _invGraphicBounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _invGraphicBounds.width()); + 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); @@ -242,7 +242,7 @@ void WidgetInventoryTooltip::handleEvents() { } // Update the position of the tooltip - int xs = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _bounds.width()); + int xs = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCENE_WIDTH - _bounds.width()); int ys = CLIP(mousePos.y - _bounds.height(), 0, SHERLOCK_SCREEN_HEIGHT - _bounds.height()); _bounds.moveTo(xs, ys); } @@ -263,11 +263,12 @@ WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _tooltipW void WidgetInventory::load(int mode) { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; + Screen &screen = *_vm->_screen; Common::Point mousePos = events.mousePos(); if (mode == 3) { mode = 2; - mousePos = Common::Point(SHERLOCK_SCREEN_WIDTH / 2, SHERLOCK_SCREEN_HEIGHT / 2); + mousePos = Common::Point(screen._currentScroll.x + SHERLOCK_SCREEN_WIDTH / 2, SHERLOCK_SCREEN_HEIGHT / 2); } if (mode != 0) -- cgit v1.2.3 From d0a6af6cb92ec4d12ced8c1af90097ec06679a1d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 17 Jul 2015 21:07:03 -0400 Subject: SHERLOCK: RT: Splitting inventory verb dialog code into it's own class --- engines/sherlock/tattoo/widget_inventory.cpp | 383 ++++++++++++++------------- 1 file changed, 205 insertions(+), 178 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 3ce733b3d6..100eb669f4 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -249,8 +249,209 @@ void WidgetInventoryTooltip::handleEvents() { /*----------------------------------------------------------------*/ +WidgetInventoryVerbs::WidgetInventoryVerbs(SherlockEngine *vm, WidgetInventory *owner) : + WidgetBase(vm), _owner(owner) { +} + +void WidgetInventoryVerbs::load() { + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + People &people = *_vm->_people; + Scene &scene = *_vm->_scene; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + Common::Point mousePos = events.mousePos(); + + // Make the Verb List for this Inventory Item + _inventCommands.clear(); + _inventCommands.push_back(FIXED(Look)); + + // Default the Action word to "with" + _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) { + Object &obj = scene._bgShapes[idx]; + + if (obj._type != INVALID && obj._type != HIDDEN) { + for (int useNum = 0; useNum < 6; ++useNum) { + if (obj._use[useNum]._verb.hasPrefix("*") && + !obj._use[useNum]._target.compareToIgnoreCase(inv[_owner->_invSelect]._name)) { + // Make sure the Verb is not already in the list + bool found1 = false; + for (uint cmdNum = 0; cmdNum < _inventCommands.size() && !found1; ++cmdNum) { + if (!_inventCommands[cmdNum].compareToIgnoreCase(obj._use[useNum]._verb)) + found1 = true; + } + + if (!found1) { + _inventCommands.push_back(obj._use[useNum]._verb); + + // Check for any Special Action commands + for (int nameNum = 0; nameNum < 4; ++nameNum) { + if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*V", 2)) { + if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*VSWAP", 6)) + _owner->_swapItems = true; + else + _action = Common::String(obj._use[useNum]._names[nameNum].c_str() + 2); + } + } + } + } + } + } + } + + // Search the NPCs for matches as well + for (int idx = 1; idx < MAX_CHARACTERS; ++idx) { + for (int useNum = 0; useNum < 2; ++useNum) { + if (!people[idx]._use[useNum]._target.compareToIgnoreCase(inv[_owner->_invSelect]._name) && + !people[idx]._use[useNum]._verb.empty() && !people[idx]._use[useNum]._verb.hasPrefix(" ")) { + bool found1 = false; + for (uint cmdNum = 0; cmdNum < _inventCommands.size() && !found1; ++cmdNum) { + if (!_inventCommands[cmdNum].compareToIgnoreCase(people[idx]._use[cmdNum]._verb)) + found1 = true; + } + + if (!found1) + _inventCommands.push_back(people[idx]._use[useNum]._verb); + } + } + } + + // Finally see if the item itself has a verb + if (!inv[_owner->_invSelect]._verb._verb.empty()) { + // Don't add "Solve" to the Foolscap if it's already been "Solved" + if (inv[_owner->_invSelect]._verb._verb.compareToIgnoreCase(FIXED(Solve)) || !_vm->readFlags(299)) + _inventCommands.push_back(inv[_owner->_invSelect]._verb._verb); + } + + // Now find the widest command in the _inventCommands array + int width = 0; + for (uint idx = 0; idx < _inventCommands.size(); ++idx) + width = MAX(width, _surface.stringWidth(_inventCommands[idx])); + + // Set up bounds for the menu + _bounds = Common::Rect(width + _surface.widestChar() * 2 + 6, + (_surface.fontHeight() + 7) * _inventCommands.size() + 3); + _bounds.moveTo(mousePos.x + _bounds.width() / 2, mousePos.y + _bounds.height() / 2); + + // Create the surface + _surface.create(_bounds.width(), _bounds.height()); + _surface.fill(TRANSPARENCY); + makeInfoArea(); + + // Draw the Verb commands and the lines separating them + ImageFile &images = *ui._interfaceImages; + for (int idx = 0; idx < (int)_inventCommands.size(); ++idx) { + _surface.writeString(_inventCommands[idx], Common::Point((_bounds.width() - + _surface.stringWidth(_inventCommands[idx])) / 2, (_surface.fontHeight() + 7) * idx + 5), INFO_TOP); + + if (idx < (int)_inventCommands.size() - 1) { + _surface.vLine(3, (_surface.fontHeight() + 7) * (idx + 1), _bounds.right - 4, INFO_TOP); + _surface.vLine(3, (_surface.fontHeight() + 7) * (idx + 1) + 1, _bounds.right - 4, INFO_MIDDLE); + _surface.vLine(3, (_surface.fontHeight() + 7) * (idx + 1) + 2, _bounds.right - 4, INFO_BOTTOM); + + _surface.transBlitFrom(images[4], Common::Point(0, (_surface.fontHeight() + 7) * (idx + 1))); + _surface.transBlitFrom(images[5], Common::Point(_bounds.width() - images[5]._width, + (_surface.fontHeight() + 7) * (idx + 1) - 1)); + } + } +} + +void WidgetInventoryVerbs::handleEvents() { + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + TattooScene &scene = *(TattooScene *)_vm->_scene; + Common::Point mousePos = events.mousePos(); + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + TattooEngine &vm = *(TattooEngine *)_vm; + + // See if they want to close the menu (by clicking outside the menu) + Common::Rect innerBounds = _bounds; + innerBounds.grow(-3); + + if (_outsideMenu && !innerBounds.contains(mousePos)) { + banishWindow(); + _owner->_invVerbMode = 0; + } else if (innerBounds.contains(mousePos)) { + _outsideMenu = false; + + // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle + bool doHangman = !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && + !_inventCommands[_owner->_invVerbSelect].compareToIgnoreCase(FIXED(Solve)); + doHangman |= (!inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) + && _inventCommands[_owner->_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); + + if (doHangman) { + // Close the entire Inventory and return to Standard Mode + banishWindow(); + _owner->_invVerbMode = 0; + + _owner->_tooltipWidget.banishWindow(); + banishWindow(); + inv.freeInv(); + + events.clearEvents(); + events.setCursor(ARROW); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + + scene.doBgAnim(); + vm.doHangManPuzzle(); + } else if (_owner->_invVerbSelect == 0) { + // They have released the mouse on the Look Verb command, so Look at the inventory item + ui._invLookFlag = true; + inv.freeInv(); + ui._windowOpen = false; + ui._lookPos = mousePos; + ui.printObjectDesc(inv[_owner->_invSelect]._examine, true); + } else { + // Clear the window + banishWindow(); + _owner->_invVerbMode = 3; + ui._oldBgFound = -1; + + // See if the selected Verb with the selected Iventory Item, is to be used by itself + if (!_inventCommands[_owner->_invVerbSelect].compareToIgnoreCase(inv[_owner->_invSelect]._verb._verb) || + !inv[_owner->_invSelect]._verb._target.compareToIgnoreCase("*SELF")) { + inv.freeInv(); + + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + events.clearEvents(); + ui.checkAction(inv[_owner->_invSelect]._verb, 2000); + } + else { + _owner->_invVerb = _inventCommands[_owner->_invVerbSelect]; + } + } + + // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor + if (ui._menuMode == INV_MODE) { + ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; + _owner->_invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); + _owner->_invGraphicBounds.moveTo(mousePos.x - _owner->_invGraphicBounds.width() / 2, + mousePos.y - _owner->_invGraphicBounds.height() / 2); + + // Constrain it to the screen + if (_owner->_invGraphicBounds.left < 0) + _owner->_invGraphicBounds.moveTo(0, _owner->_invGraphicBounds.top); + if (_owner->_invGraphicBounds.top < 0) + _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, 0); + if (_owner->_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) + _owner->_invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _owner->_invGraphicBounds.width(), _owner->_invGraphicBounds.top); + if (_owner->_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) + _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _owner->_invGraphicBounds.height()); + + // Make a copy of the inventory image + _owner->_invGraphic.create(imgFrame._width, imgFrame._height); + _owner->_invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); + } + } +} + +/*----------------------------------------------------------------*/ -WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _tooltipWidget(vm, this) { +WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), + _tooltipWidget(vm, this), _verbList(vm, this) { _invMode = 0; _invVerbMode = 0; _invSelect = _oldInvSelect = -1; @@ -384,87 +585,8 @@ void WidgetInventory::handleEvents() { // See if they have a Verb List open for an Inventry Item if (_invVerbMode == 1) { - // An inventory item's Verb List is open - - // See if they want to close the menu (by clicking outside the menu) - Common::Rect innerBounds = _bounds; - innerBounds.grow(-3); - - if (_outsideMenu && !innerBounds.contains(mousePos)) { - banishWindow(); - _invVerbMode = 0; - } else if (innerBounds.contains(mousePos)) { - _outsideMenu = false; - - // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle - bool doHangman = !inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && - !_inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Solve)); - doHangman |= (!inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) - && _inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); - - if (doHangman) { - // Close the entire Inventory and return to Standard Mode - banishWindow(); - _invVerbMode = 0; - - _tooltipWidget.banishWindow(); - banishWindow(); - inv.freeInv(); - - events.clearEvents(); - events.setCursor(ARROW); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; - - scene.doBgAnim(); - vm.doHangManPuzzle(); - } else if (_invVerbSelect == 0) { - // They have released the mouse on the Look Verb command, so Look at the inventory item - ui._invLookFlag = true; - inv.freeInv(); - ui._windowOpen = false; - ui._lookPos = mousePos; - ui.printObjectDesc(inv[_invSelect]._examine, true); - } else { - // Clear the window - banishWindow(); - _invVerbMode = 3; - ui._oldBgFound = -1; - - // See if the selected Verb with the selected Iventory Item, is to be used by itself - if (!_inventCommands[_invVerbSelect].compareToIgnoreCase(inv[_invSelect]._verb._verb) || - !inv[_invSelect]._verb._target.compareToIgnoreCase("*SELF")) { - inv.freeInv(); - - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; - events.clearEvents(); - ui.checkAction(inv[_invSelect]._verb, 2000); - } else { - _invVerb = _inventCommands[_invVerbSelect]; - } - } + _verbList.handleEvents(); - // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor - if (ui._menuMode == INV_MODE) { - ImageFrame &imgFrame = (*inv._invShapes[_invSelect - inv._invIndex])[0]; - _invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); - _invGraphicBounds.moveTo(mousePos.x - _invGraphicBounds.width() / 2, - mousePos.y - _invGraphicBounds.height() / 2); - - // Constrain it to the screen - if (_invGraphicBounds.left < 0) - _invGraphicBounds.moveTo(0, _invGraphicBounds.top); - if (_invGraphicBounds.top < 0) - _invGraphicBounds.moveTo(_invGraphicBounds.left, 0); - if (_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) - _invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _invGraphicBounds.width(), _invGraphicBounds.top); - if (_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) - _invGraphicBounds.moveTo(_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _invGraphicBounds.height()); - - // Make a copy of the inventory image - _invGraphic.create(imgFrame._width, imgFrame._height); - _invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); - } - } } else if (_invVerbMode == 3) { // Selecting object after inventory verb has been selected _tooltipWidget.banishWindow(); @@ -553,103 +675,9 @@ void WidgetInventory::handleEvents() { // Keep track of the name of the inventory object so we can check it against the target fields // of verbs when we activate it _invTarget = inv[_invSelect]._name; - - // Make the Verb List for this Inventory Item - _inventCommands.clear(); - _inventCommands.push_back(FIXED(Look)); - - // Default the Action word to "with" - _action = _vm->getLanguage() == Common::GR_GRE ? "" : FIXED(With); _swapItems = false; - // Search all the bgshapes for any matching Target Fields - for (uint idx = 0; idx < scene._bgShapes.size(); ++idx) { - Object &obj = scene._bgShapes[idx]; - - if (obj._type != INVALID && obj._type != HIDDEN) { - for (int useNum = 0; useNum < 6; ++useNum) { - if (obj._use[useNum]._verb.hasPrefix("*") && - !obj._use[useNum]._target.compareToIgnoreCase(inv[_invSelect]._name)) { - // Make sure the Verb is not already in the list - bool found1 = false; - for (uint cmdNum = 0; cmdNum < _inventCommands.size() && !found1; ++cmdNum) { - if (!_inventCommands[cmdNum].compareToIgnoreCase(obj._use[useNum]._verb)) - found1 = true; - } - - if (!found1) { - _inventCommands.push_back(obj._use[useNum]._verb); - - // Check for any Special Action commands - for (int nameNum = 0; nameNum < 4; ++nameNum) { - if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*V", 2)) { - if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*VSWAP", 6)) - _swapItems = true; - else - _action = Common::String(obj._use[useNum]._names[nameNum].c_str() + 2); - } - } - } - } - } - } - } - - // Search the NPCs for matches as well - for (int idx = 1; idx < MAX_CHARACTERS; ++idx) { - for (int useNum = 0; useNum < 2; ++useNum) { - if (!people[idx]._use[useNum]._target.compareToIgnoreCase(inv[_invSelect]._name) && - !people[idx]._use[useNum]._verb.empty() && !people[idx]._use[useNum]._verb.hasPrefix(" ")) { - bool found1 = false; - for (uint cmdNum = 0; cmdNum < _inventCommands.size() && !found1; ++cmdNum) { - if (!_inventCommands[cmdNum].compareToIgnoreCase(people[idx]._use[cmdNum]._verb)) - found1 = true; - } - - if (!found1) - _inventCommands.push_back(people[idx]._use[useNum]._verb); - } - } - } - - // Finally see if the item itself has a verb - if (!inv[_invSelect]._verb._verb.empty()) { - // Don't add "Solve" to the Foolscap if it's already been "Solved" - if (inv[_invSelect]._verb._verb.compareToIgnoreCase(FIXED(Solve)) || !vm.readFlags(299)) - _inventCommands.push_back(inv[_invSelect]._verb._verb); - } - - // Now find the widest command in the _inventCommands array - int width = 0; - for (uint idx = 0; idx < _inventCommands.size(); ++idx) - width = MAX(width, _surface.stringWidth(_inventCommands[idx])); - - // Set up bounds for the menu - _menuBounds = Common::Rect(width + _surface.widestChar() * 2 + 6, - (_surface.fontHeight() + 7) * _inventCommands.size() + 3); - _menuBounds.moveTo(mousePos.x + _menuBounds.width() / 2, mousePos.y + _menuBounds.height() / 2); - - // Create the surface - _menuSurface.create(_menuBounds.width(), _menuBounds.height()); - _surface.fill(TRANSPARENCY); - makeInfoArea(_menuSurface); - - // Draw the Verb commands and the lines separating them - ImageFile &images = *ui._interfaceImages; - for (int idx = 0; idx < (int)_inventCommands.size(); ++idx) { - _menuSurface.writeString(_inventCommands[idx], Common::Point((_menuBounds.width() - - _menuSurface.stringWidth(_inventCommands[idx])) / 2, (_menuSurface.fontHeight() + 7) * idx + 5), INFO_TOP); - - if (idx < (int)_inventCommands.size()- 1) { - _menuSurface.vLine(3, (_menuSurface.fontHeight() + 7) * (idx + 1), _menuBounds.right - 4, INFO_TOP); - _menuSurface.vLine(3, (_menuSurface.fontHeight() + 7) * (idx + 1) + 1, _menuBounds.right - 4, INFO_MIDDLE); - _menuSurface.vLine(3, (_menuSurface.fontHeight() + 7) * (idx + 1) + 2, _menuBounds.right - 4, INFO_BOTTOM); - - _menuSurface.transBlitFrom(images[4], Common::Point(0, (_menuSurface.fontHeight() + 7) * (idx + 1))); - _menuSurface.transBlitFrom(images[5], Common::Point(_menuBounds.width() - images[5]._width, - (_menuSurface.fontHeight() + 7) * (idx + 1) - 1)); - } - } + _verbList.load(); } else { // They left clicked on an inventory item, so Look at it @@ -694,8 +722,7 @@ void WidgetInventory::highlightControls() { void WidgetInventory::banishWindow() { WidgetBase::banishWindow(); - _menuSurface.free(); - _menuBounds = _oldMenuBounds = Common::Rect(0, 0, 0, 0); + _verbList.banishWindow(); } void WidgetInventory::draw() { -- cgit v1.2.3 From 3a4b478d983dd67db92b6d12a6042448f6eafc22 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Jul 2015 16:46:32 -0400 Subject: SHERLOCK: RT: Fix display of inventory verb menu --- engines/sherlock/tattoo/widget_inventory.cpp | 172 ++++++++++++++++----------- 1 file changed, 105 insertions(+), 67 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 100eb669f4..f299cc1126 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -251,6 +251,7 @@ void WidgetInventoryTooltip::handleEvents() { WidgetInventoryVerbs::WidgetInventoryVerbs(SherlockEngine *vm, WidgetInventory *owner) : WidgetBase(vm), _owner(owner) { + _invVerbSelect = _oldInvVerbSelect = -1; } void WidgetInventoryVerbs::load() { @@ -333,7 +334,7 @@ void WidgetInventoryVerbs::load() { // Set up bounds for the menu _bounds = Common::Rect(width + _surface.widestChar() * 2 + 6, (_surface.fontHeight() + 7) * _inventCommands.size() + 3); - _bounds.moveTo(mousePos.x + _bounds.width() / 2, mousePos.y + _bounds.height() / 2); + _bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2); // Create the surface _surface.create(_bounds.width(), _bounds.height()); @@ -356,6 +357,8 @@ void WidgetInventoryVerbs::load() { (_surface.fontHeight() + 7) * (idx + 1) - 1)); } } + + summonWindow(); } void WidgetInventoryVerbs::handleEvents() { @@ -366,85 +369,121 @@ void WidgetInventoryVerbs::handleEvents() { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; TattooEngine &vm = *(TattooEngine *)_vm; + // Handle changing highlighted verb entry + highlightControls(); + // See if they want to close the menu (by clicking outside the menu) Common::Rect innerBounds = _bounds; innerBounds.grow(-3); - if (_outsideMenu && !innerBounds.contains(mousePos)) { - banishWindow(); - _owner->_invVerbMode = 0; - } else if (innerBounds.contains(mousePos)) { - _outsideMenu = false; - - // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle - bool doHangman = !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && - !_inventCommands[_owner->_invVerbSelect].compareToIgnoreCase(FIXED(Solve)); - doHangman |= (!inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) - && _inventCommands[_owner->_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); - - if (doHangman) { - // Close the entire Inventory and return to Standard Mode - banishWindow(); - _owner->_invVerbMode = 0; + if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { + ui._scrollHighlight = SH_NONE; - _owner->_tooltipWidget.banishWindow(); + if (_outsideMenu && !innerBounds.contains(mousePos)) { banishWindow(); - inv.freeInv(); + _owner->_invVerbMode = 0; + } + else if (innerBounds.contains(mousePos)) { + _outsideMenu = false; - events.clearEvents(); - events.setCursor(ARROW); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle + bool doHangman = !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && + !_inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Solve)); + doHangman |= (!inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) + && _inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); - scene.doBgAnim(); - vm.doHangManPuzzle(); - } else if (_owner->_invVerbSelect == 0) { - // They have released the mouse on the Look Verb command, so Look at the inventory item - ui._invLookFlag = true; - inv.freeInv(); - ui._windowOpen = false; - ui._lookPos = mousePos; - ui.printObjectDesc(inv[_owner->_invSelect]._examine, true); - } else { - // Clear the window - banishWindow(); - _owner->_invVerbMode = 3; - ui._oldBgFound = -1; + if (doHangman) { + // Close the entire Inventory and return to Standard Mode + banishWindow(); + _owner->_invVerbMode = 0; - // See if the selected Verb with the selected Iventory Item, is to be used by itself - if (!_inventCommands[_owner->_invVerbSelect].compareToIgnoreCase(inv[_owner->_invSelect]._verb._verb) || - !inv[_owner->_invSelect]._verb._target.compareToIgnoreCase("*SELF")) { + _owner->_tooltipWidget.banishWindow(); + banishWindow(); inv.freeInv(); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; events.clearEvents(); - ui.checkAction(inv[_owner->_invSelect]._verb, 2000); + events.setCursor(ARROW); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + + scene.doBgAnim(); + vm.doHangManPuzzle(); + } + else if (_invVerbSelect == 0) { + // They have released the mouse on the Look Verb command, so Look at the inventory item + ui._invLookFlag = true; + inv.freeInv(); + ui._windowOpen = false; + ui._lookPos = mousePos; + ui.printObjectDesc(inv[_owner->_invSelect]._examine, true); } else { - _owner->_invVerb = _inventCommands[_owner->_invVerbSelect]; + // Clear the window + banishWindow(); + _owner->_invVerbMode = 3; + ui._oldBgFound = -1; + + // See if the selected Verb with the selected Iventory Item, is to be used by itself + if (!_inventCommands[_invVerbSelect].compareToIgnoreCase(inv[_owner->_invSelect]._verb._verb) || + !inv[_owner->_invSelect]._verb._target.compareToIgnoreCase("*SELF")) { + inv.freeInv(); + + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + events.clearEvents(); + ui.checkAction(inv[_owner->_invSelect]._verb, 2000); + } + else { + _owner->_invVerb = _inventCommands[_invVerbSelect]; + } + } + + // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor + if (ui._menuMode == INV_MODE) { + ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; + _owner->_invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); + _owner->_invGraphicBounds.moveTo(mousePos.x - _owner->_invGraphicBounds.width() / 2, + mousePos.y - _owner->_invGraphicBounds.height() / 2); + + // Constrain it to the screen + if (_owner->_invGraphicBounds.left < 0) + _owner->_invGraphicBounds.moveTo(0, _owner->_invGraphicBounds.top); + if (_owner->_invGraphicBounds.top < 0) + _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, 0); + if (_owner->_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) + _owner->_invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _owner->_invGraphicBounds.width(), _owner->_invGraphicBounds.top); + if (_owner->_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) + _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _owner->_invGraphicBounds.height()); + + // Make a copy of the inventory image + _owner->_invGraphic.create(imgFrame._width, imgFrame._height); + _owner->_invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); } } + } +} - // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor - if (ui._menuMode == INV_MODE) { - ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; - _owner->_invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); - _owner->_invGraphicBounds.moveTo(mousePos.x - _owner->_invGraphicBounds.width() / 2, - mousePos.y - _owner->_invGraphicBounds.height() / 2); - - // Constrain it to the screen - if (_owner->_invGraphicBounds.left < 0) - _owner->_invGraphicBounds.moveTo(0, _owner->_invGraphicBounds.top); - if (_owner->_invGraphicBounds.top < 0) - _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, 0); - if (_owner->_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) - _owner->_invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _owner->_invGraphicBounds.width(), _owner->_invGraphicBounds.top); - if (_owner->_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) - _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _owner->_invGraphicBounds.height()); - - // Make a copy of the inventory image - _owner->_invGraphic.create(imgFrame._width, imgFrame._height); - _owner->_invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); +void WidgetInventoryVerbs::highlightControls() { + Events &events = *_vm->_events; + Common::Point mousePos = events.mousePos(); + + Common::Rect innerBounds = _bounds; + innerBounds.grow(-3); + + // Set the highlighted verb + _invVerbSelect = -1; + if (innerBounds.contains(mousePos)) + _invVerbSelect = (mousePos.y - _bounds.top - 3) / (_surface.fontHeight() + 7); + + // See if the highlighted verb has changed + if (_invVerbSelect != _oldInvVerbSelect) { + // Draw the list again, with the new highlighting + for (uint idx = 0; idx < _inventCommands.size(); ++idx) { + byte color = (idx == _invVerbSelect) ? COMMAND_HIGHLIGHTED : INFO_TOP; + _surface.writeString(_inventCommands[idx], Common::Point( + (_bounds.width() - _surface.stringWidth(_inventCommands[idx])) / 2, + (_surface.fontHeight() + 7) * idx + 5), color); } + + _oldInvVerbSelect = _invVerbSelect; } } @@ -456,7 +495,6 @@ WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _invVerbMode = 0; _invSelect = _oldInvSelect = -1; _selector = _oldSelector = -1; - _invVerbSelect = _oldInvVerbSelect = -1; _dialogTimer = -1; _swapItems = false; } @@ -584,10 +622,10 @@ void WidgetInventory::handleEvents() { ui._scrollHighlight = SH_NONE; // See if they have a Verb List open for an Inventry Item - if (_invVerbMode == 1) { - _verbList.handleEvents(); + if (_invVerbMode == 1) + return; - } else if (_invVerbMode == 3) { + if (_invVerbMode == 3) { // Selecting object after inventory verb has been selected _tooltipWidget.banishWindow(); _invGraphic.free(); @@ -669,7 +707,7 @@ void WidgetInventory::handleEvents() { // See if they right clicked on an item if (events._rightReleased) { _invVerbMode = 1; - _oldInvVerbSelect = -1; + _verbList._oldInvVerbSelect = -1; _tooltipWidget.banishWindow(); // Keep track of the name of the inventory object so we can check it against the target fields -- cgit v1.2.3 From 1844f8ca3d6258c8b02402eab877e9ae0a556005 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Jul 2015 17:41:10 -0400 Subject: SHERLOCK: RT: Fix event handling for inventory Verbs menu --- engines/sherlock/tattoo/widget_inventory.cpp | 54 +++++++++++++--------------- 1 file changed, 25 insertions(+), 29 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index f299cc1126..8607e875e9 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -382,8 +382,7 @@ void WidgetInventoryVerbs::handleEvents() { if (_outsideMenu && !innerBounds.contains(mousePos)) { banishWindow(); _owner->_invVerbMode = 0; - } - else if (innerBounds.contains(mousePos)) { + } else if (innerBounds.contains(mousePos)) { _outsideMenu = false; // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle @@ -407,16 +406,14 @@ void WidgetInventoryVerbs::handleEvents() { scene.doBgAnim(); vm.doHangManPuzzle(); - } - else if (_invVerbSelect == 0) { + } else if (_invVerbSelect == 0) { // They have released the mouse on the Look Verb command, so Look at the inventory item ui._invLookFlag = true; inv.freeInv(); ui._windowOpen = false; ui._lookPos = mousePos; ui.printObjectDesc(inv[_owner->_invSelect]._examine, true); - } - else { + } else { // Clear the window banishWindow(); _owner->_invVerbMode = 3; @@ -430,32 +427,31 @@ void WidgetInventoryVerbs::handleEvents() { ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; events.clearEvents(); ui.checkAction(inv[_owner->_invSelect]._verb, 2000); - } - else { + } else { _owner->_invVerb = _inventCommands[_invVerbSelect]; } - } - // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor - if (ui._menuMode == INV_MODE) { - ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; - _owner->_invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); - _owner->_invGraphicBounds.moveTo(mousePos.x - _owner->_invGraphicBounds.width() / 2, - mousePos.y - _owner->_invGraphicBounds.height() / 2); - - // Constrain it to the screen - if (_owner->_invGraphicBounds.left < 0) - _owner->_invGraphicBounds.moveTo(0, _owner->_invGraphicBounds.top); - if (_owner->_invGraphicBounds.top < 0) - _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, 0); - if (_owner->_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) - _owner->_invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _owner->_invGraphicBounds.width(), _owner->_invGraphicBounds.top); - if (_owner->_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) - _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _owner->_invGraphicBounds.height()); - - // Make a copy of the inventory image - _owner->_invGraphic.create(imgFrame._width, imgFrame._height); - _owner->_invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); + // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor + if (ui._menuMode == INV_MODE) { + ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; + _owner->_invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); + _owner->_invGraphicBounds.moveTo(mousePos.x - _owner->_invGraphicBounds.width() / 2, + mousePos.y - _owner->_invGraphicBounds.height() / 2); + + // Constrain it to the screen + if (_owner->_invGraphicBounds.left < 0) + _owner->_invGraphicBounds.moveTo(0, _owner->_invGraphicBounds.top); + if (_owner->_invGraphicBounds.top < 0) + _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, 0); + if (_owner->_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) + _owner->_invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _owner->_invGraphicBounds.width(), _owner->_invGraphicBounds.top); + if (_owner->_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) + _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _owner->_invGraphicBounds.height()); + + // Make a copy of the inventory image + _owner->_invGraphic.create(imgFrame._width, imgFrame._height); + _owner->_invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); + } } } } -- cgit v1.2.3 From 08036cc4891bb212f7abb3c739a935e3dfb6f293 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Jul 2015 21:08:47 -0400 Subject: SHERLOCK: RT: Fix pressing Escape to close inventory windows --- engines/sherlock/tattoo/widget_inventory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 8607e875e9..6386ec5d04 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -376,10 +376,14 @@ void WidgetInventoryVerbs::handleEvents() { Common::Rect innerBounds = _bounds; innerBounds.grow(-3); + // Flag is they started pressing outside of the menu + if (events._firstPress && !_bounds.contains(mousePos)) + _outsideMenu = true; + if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { ui._scrollHighlight = SH_NONE; - if (_outsideMenu && !innerBounds.contains(mousePos)) { + if (_outsideMenu && !innerBounds.contains(mousePos) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { banishWindow(); _owner->_invVerbMode = 0; } else if (innerBounds.contains(mousePos)) { -- cgit v1.2.3 From 46c8a5c335b184b7c908dc323926ccb53dd576ed Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Jul 2015 21:37:07 -0400 Subject: SHERLOCK: RT: Implement Escape key handling in waitForMore --- engines/sherlock/tattoo/widget_inventory.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 6386ec5d04..c6ff39fd55 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -382,9 +382,9 @@ void WidgetInventoryVerbs::handleEvents() { if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { ui._scrollHighlight = SH_NONE; + banishWindow(); if (_outsideMenu && !innerBounds.contains(mousePos) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { - banishWindow(); _owner->_invVerbMode = 0; } else if (innerBounds.contains(mousePos)) { _outsideMenu = false; @@ -397,11 +397,9 @@ void WidgetInventoryVerbs::handleEvents() { if (doHangman) { // Close the entire Inventory and return to Standard Mode - banishWindow(); _owner->_invVerbMode = 0; _owner->_tooltipWidget.banishWindow(); - banishWindow(); inv.freeInv(); events.clearEvents(); @@ -418,8 +416,6 @@ void WidgetInventoryVerbs::handleEvents() { ui._lookPos = mousePos; ui.printObjectDesc(inv[_owner->_invSelect]._examine, true); } else { - // Clear the window - banishWindow(); _owner->_invVerbMode = 3; ui._oldBgFound = -1; -- cgit v1.2.3 From f415fe49a74c3c38834b4a40f4720d11676c9be0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Jul 2015 23:12:43 -0400 Subject: SHERLOCK: RT: Fix warnings --- engines/sherlock/tattoo/widget_inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index c6ff39fd55..241eaca182 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -384,7 +384,7 @@ void WidgetInventoryVerbs::handleEvents() { ui._scrollHighlight = SH_NONE; banishWindow(); - if (_outsideMenu && !innerBounds.contains(mousePos) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { + if ((_outsideMenu && !innerBounds.contains(mousePos)) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { _owner->_invVerbMode = 0; } else if (innerBounds.contains(mousePos)) { _outsideMenu = false; @@ -472,7 +472,7 @@ void WidgetInventoryVerbs::highlightControls() { // See if the highlighted verb has changed if (_invVerbSelect != _oldInvVerbSelect) { // Draw the list again, with the new highlighting - for (uint idx = 0; idx < _inventCommands.size(); ++idx) { + for (int idx = 0; idx < (int)_inventCommands.size(); ++idx) { byte color = (idx == _invVerbSelect) ? COMMAND_HIGHLIGHTED : INFO_TOP; _surface.writeString(_inventCommands[idx], Common::Point( (_bounds.width() - _surface.stringWidth(_inventCommands[idx])) / 2, -- cgit v1.2.3 From bc9da9c14decc93fe5a70189426bd6f8600db2d8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jul 2015 15:01:35 -0400 Subject: SHERLOCK: RT: Fix loading of inventory verb list secondary actions --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 241eaca182..a62efcdbea 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -275,7 +275,7 @@ void WidgetInventoryVerbs::load() { if (obj._type != INVALID && obj._type != HIDDEN) { for (int useNum = 0; useNum < 6; ++useNum) { - if (obj._use[useNum]._verb.hasPrefix("*") && + if (!obj._use[useNum]._verb.hasPrefix("*") && !obj._use[useNum]._target.compareToIgnoreCase(inv[_owner->_invSelect]._name)) { // Make sure the Verb is not already in the list bool found1 = false; -- cgit v1.2.3 From b16dced3c97f1a239c9468760584c325593973ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jul 2015 16:09:40 -0400 Subject: SHERLOCK: RT: Support for showing inventory items as a cursor --- engines/sherlock/tattoo/widget_inventory.cpp | 70 +++++++++++++--------------- 1 file changed, 33 insertions(+), 37 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index a62efcdbea..1e96b0efbe 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -148,16 +148,16 @@ void WidgetInventoryTooltip::handleEvents() { 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(), _owner->_invVerb.c_str()); + inv[_owner->_invSelect]._name.c_str(), ui._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(), _owner->_invVerb.c_str()); + obj._description.c_str(), ui._verb.c_str()); } else { if (_owner->_swapItems) - str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), obj._description.c_str(), ui._action.c_str(), + str = Common::String::format("%s %s %s %s", ui._verb.c_str(), obj._description.c_str(), ui._action.c_str(), inv[_owner->_invSelect]._name.c_str()); else - str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), inv[_owner->_invSelect]._name.c_str(), + 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()); } } @@ -168,17 +168,17 @@ void WidgetInventoryTooltip::handleEvents() { 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(), _owner->_invVerb.c_str()); + inv[_owner->_invSelect]._name.c_str(), ui._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(), _owner->_invVerb.c_str()); + person._description.c_str(), ui._verb.c_str()); } else { if (_owner->_swapItems) - str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), person._description.c_str(), + 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()); else - str = Common::String::format("%s %s %s %s", _owner->_invVerb.c_str(), + 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()); } } @@ -267,7 +267,7 @@ void WidgetInventoryVerbs::load() { _inventCommands.push_back(FIXED(Look)); // Default the Action word to "with" - _action = _vm->getLanguage() == Common::GR_GRE ? "" : FIXED(With); + ui._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 +293,7 @@ void WidgetInventoryVerbs::load() { if (!scumm_strnicmp(obj._use[useNum]._names[nameNum].c_str(), "*VSWAP", 6)) _owner->_swapItems = true; else - _action = Common::String(obj._use[useNum]._names[nameNum].c_str() + 2); + ui._action = Common::String(obj._use[useNum]._names[nameNum].c_str() + 2); } } } @@ -428,29 +428,17 @@ void WidgetInventoryVerbs::handleEvents() { events.clearEvents(); ui.checkAction(inv[_owner->_invSelect]._verb, 2000); } else { - _owner->_invVerb = _inventCommands[_invVerbSelect]; + ui._verb = _inventCommands[_invVerbSelect]; } // If we are still in Inventory Mode, setup the graphic to float in front of the mouse cursor if (ui._menuMode == INV_MODE) { + // Add the inventory item to the cursor ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; - _owner->_invGraphicBounds = Common::Rect(imgFrame._width, imgFrame._height); - _owner->_invGraphicBounds.moveTo(mousePos.x - _owner->_invGraphicBounds.width() / 2, - mousePos.y - _owner->_invGraphicBounds.height() / 2); - - // Constrain it to the screen - if (_owner->_invGraphicBounds.left < 0) - _owner->_invGraphicBounds.moveTo(0, _owner->_invGraphicBounds.top); - if (_owner->_invGraphicBounds.top < 0) - _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, 0); - if (_owner->_invGraphicBounds.right > SHERLOCK_SCREEN_WIDTH) - _owner->_invGraphicBounds.moveTo(SHERLOCK_SCREEN_WIDTH - _owner->_invGraphicBounds.width(), _owner->_invGraphicBounds.top); - if (_owner->_invGraphicBounds.bottom > SHERLOCK_SCREEN_HEIGHT) - _owner->_invGraphicBounds.moveTo(_owner->_invGraphicBounds.left, SHERLOCK_SCREEN_HEIGHT - _owner->_invGraphicBounds.height()); - - // Make a copy of the inventory image - _owner->_invGraphic.create(imgFrame._width, imgFrame._height); - _owner->_invGraphic.blitFrom(imgFrame, Common::Point(0, 0)); + events.setCursor(ARROW, imgFrame._frame); + + // Close the inventory dialog as well + _owner->close(); } } } @@ -624,7 +612,6 @@ void WidgetInventory::handleEvents() { if (_invVerbMode == 3) { // Selecting object after inventory verb has been selected _tooltipWidget.banishWindow(); - _invGraphic.free(); inv.freeInv(); ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; @@ -636,7 +623,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(_invVerb) && + if (!people[ui._bgFound - 1000]._use[idx]._verb.compareToIgnoreCase(ui._verb) && !people[ui._bgFound - 1000]._use[idx]._target.compareToIgnoreCase(_invTarget)) { ui.checkAction(people[ui._bgFound - 1000]._use[idx], ui._bgFound); found = true; @@ -644,7 +631,7 @@ void WidgetInventory::handleEvents() { } } else { for (int idx = 0; idx < 6; ++idx) { - if (!ui._bgShape->_use[idx]._verb.compareToIgnoreCase(_invVerb) && + if (!ui._bgShape->_use[idx]._verb.compareToIgnoreCase(ui._verb) && !ui._bgShape->_use[idx]._target.compareToIgnoreCase(_invTarget)) { ui.checkAction(ui._bgShape->_use[idx], ui._bgFound); found = true; @@ -658,13 +645,9 @@ void WidgetInventory::handleEvents() { } } else if ((_outsideMenu && !_bounds.contains(mousePos)) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { // Want to close the window (clicked outside of it). So close the window and return to Standard - banishWindow(); - inv.freeInv(); - - events.clearEvents(); + close(); events.setCursor(ARROW); - banishWindow(); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + } else if (_bounds.contains(mousePos)) { // Mouse button was released inside the inventory window _outsideMenu = false; @@ -769,6 +752,19 @@ void WidgetInventory::erase() { _tooltipWidget.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 } // End of namespace Sherlock -- cgit v1.2.3 From a9150b5c3c1159e3c8982c8eb5b73bd54532dcf3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jul 2015 17:31:40 -0400 Subject: SHERLOCK: RT: Show tooltip when selecting scene object to use item on --- engines/sherlock/tattoo/widget_inventory.cpp | 60 +++++++++++----------------- 1 file changed, 24 insertions(+), 36 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') 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 -- cgit v1.2.3 From 48f5ef847fed6ef97a92c059f8f93bd453051144 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jul 2015 18:56:08 -0400 Subject: SHERLOCK: RT: Fix tooltip display when using inventory item --- engines/sherlock/tattoo/widget_inventory.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 52ab5bf23f..9afe841fa9 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -230,6 +230,10 @@ void WidgetInventoryTooltip::handleEvents() { return; } + if (_owner->_invVerbMode == 3) + // Adjust tooltip to be above the inventory item being shown above the standard cursor + mousePos.y -= events._hotspotPos.y; + // Update the position of the tooltip int xs = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCENE_WIDTH - _bounds.width()); int ys = CLIP(mousePos.y - _bounds.height(), 0, SHERLOCK_SCREEN_HEIGHT - _bounds.height()); -- cgit v1.2.3 From b0c1e6efaa09b855d18ee81edc2a79243b5b91b2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jul 2015 19:23:16 -0400 Subject: SHERLOCK: RT: Implement using items on scene objects --- engines/sherlock/tattoo/widget_inventory.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 9afe841fa9..170fb02481 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -430,10 +430,10 @@ void WidgetInventoryVerbs::handleEvents() { ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; events.setCursor(ARROW, imgFrame._frame); - // 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(); + // Close the inventory dialog without banishing it, so it can keep getting events + // to handle tooltips and actually making the selection of what object to use them item on + inv.freeInv(); + _owner->_surface.free(); } } } @@ -607,10 +607,7 @@ void WidgetInventory::handleEvents() { if (_invVerbMode == 3) { // Selecting object after inventory verb has been selected _tooltipWidget.banishWindow(); - inv.freeInv(); - - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; - events.clearEvents(); + close(); if (ui._keyState.keycode != Common::KEYCODE_ESCAPE) { // If user pointed at an item, use the selected inventory item with this item @@ -641,8 +638,6 @@ void WidgetInventory::handleEvents() { } else if ((_outsideMenu && !_bounds.contains(mousePos)) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { // 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 @@ -751,10 +746,15 @@ 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(); + + events.setCursor(ARROW); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; } } // End of namespace Tattoo -- cgit v1.2.3 From 9e545df252e92a13bc135e0733d5a3148d6220a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 25 Jul 2015 14:24:05 -0400 Subject: SHERLOCK: RT: Generalise code for joining cursor and images as a cursor --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 170fb02481..c2de61fda8 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -428,7 +428,7 @@ void WidgetInventoryVerbs::handleEvents() { if (ui._menuMode == INV_MODE) { // Add the inventory item to the cursor ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0]; - events.setCursor(ARROW, imgFrame._frame); + events.setCursor(ARROW, Common::Point(-100, imgFrame._height), imgFrame._frame); // Close the inventory dialog without banishing it, so it can keep getting events // to handle tooltips and actually making the selection of what object to use them item on -- cgit v1.2.3 From 4cc2bcabe1e59a2074a5aef466911ae1bbbf351f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 31 Jul 2015 17:32:38 -0400 Subject: SHERLOCK: RT: Fix inventory tooltips when in a scene with a mask ScummVM simplifies tooltip handling by drawing tooltips directly to the screen surface. This works well in most cases, but in mask scenes, the screen is recopied at the end of rendering to apply the mask overlay, so the tooltip needs to be redrawn after again in order to be seen --- engines/sherlock/tattoo/widget_inventory.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index c2de61fda8..88507d8231 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -122,6 +122,12 @@ void WidgetInventoryTooltip::handleEvents() { Common::String strWith = fixedText.getText(kFixedText_With); Common::String strUse = fixedText.getText(kFixedText_Use); + // Register the tooltip for requiring post-rendering drawing, since we draw directly to the screen if a scene + // mask is active, since the initial draw to the screen will be covered by the mask rendering + if (ui._mask) { + ui._postRenderWidgets.push_back(this); + } + // 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; -- cgit v1.2.3 From f99b42a89da4b1f9e25aedd1ccf798085516ff92 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 31 Jul 2015 20:44:38 -0400 Subject: SHERLOCK: RT: Don't show inventory item tooltips on scrollbar --- engines/sherlock/tattoo/widget_inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 88507d8231..405fc87c6b 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -180,8 +180,8 @@ void WidgetInventoryTooltip::handleEvents() { } } } else { - Common::Rect r = _owner->_bounds; - r.grow(-3); + const Common::Rect &b = _owner->_bounds; + Common::Rect r(b.left + 3, b.top + 3, b.right - 3 - BUTTON_SIZE, b.bottom - 3); if (r.contains(mousePos)) { select = (mousePos.x - r.left) / (INVENTORY_XSIZE + 3) + NUM_INVENTORY_SHOWN / 2 * -- cgit v1.2.3 From 8fd588072d545b147f0bfacd68921aea109df786 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 31 Jul 2015 21:21:52 -0400 Subject: SHERLOCK: RT: Implement inventory window scrolling --- engines/sherlock/tattoo/widget_inventory.cpp | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 405fc87c6b..8ec3bd7dd3 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -34,6 +34,7 @@ namespace Tattoo { #define INVENTORY_XSIZE 70 // Width of the box that surrounds inventory items #define INVENTORY_YSIZE 70 // Height of the box that surrounds inventory items #define MAX_INV_COMMANDS 10 // Maximum elements in dialog +#define NUM_INV_PER_LINE 4 // Number of inentory items per line in the dialog WidgetInventoryTooltip::WidgetInventoryTooltip(SherlockEngine *vm, WidgetInventory *owner) : WidgetTooltipBase(vm), _owner(owner) { @@ -480,7 +481,6 @@ WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm), _invVerbMode = 0; _invSelect = _oldInvSelect = -1; _selector = _oldSelector = -1; - _dialogTimer = -1; _swapItems = false; } @@ -500,7 +500,7 @@ void WidgetInventory::load(int mode) { _invVerbMode = 0; _invSelect = _oldInvSelect = -1; _selector = _oldSelector = -1; - _dialogTimer = -1; + _scroll = true; if (mode == 0) { banishWindow(); @@ -574,7 +574,8 @@ void WidgetInventory::drawInventory() { } } - drawScrollBar(inv._invIndex, NUM_INVENTORY_SHOWN, inv._holdings); + drawScrollBar(inv._invIndex / NUM_INV_PER_LINE, NUM_INVENTORY_SHOWN / NUM_INV_PER_LINE, + (inv._holdings + NUM_INV_PER_LINE - 1) / NUM_INV_PER_LINE); } void WidgetInventory::handleEvents() { @@ -586,11 +587,35 @@ void WidgetInventory::handleEvents() { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; Common::Point mousePos = events.mousePos(); - if (_invVerbMode == 1) + if (_invVerbMode == 1) { checkTabbingKeys(MAX_INV_COMMANDS); - else if (_invVerbMode == 0) + } else if (_invVerbMode == 0) { checkInvTabbingKeys(); + // Handle scrollbar events + int oldScrollIndex = inv._invIndex / NUM_INV_PER_LINE; + int invIndex = inv._invIndex / NUM_INV_PER_LINE; + + ScrollHighlight oldHighlight = ui._scrollHighlight; + handleScrollbarEvents(invIndex, NUM_INVENTORY_SHOWN / NUM_INV_PER_LINE, + (inv._holdings + NUM_INV_PER_LINE - 1) / NUM_INV_PER_LINE); + + handleScrolling(invIndex, NUM_INVENTORY_SHOWN / NUM_INV_PER_LINE, + (inv._holdings + NUM_INV_PER_LINE - 1) / NUM_INV_PER_LINE); + + if (oldScrollIndex != invIndex) { + // Starting visible item index has changed, so set the index and reload inventory graphics + inv._invIndex = invIndex * NUM_INV_PER_LINE; + inv.freeGraphics(); + inv.loadGraphics(); + } + + if (ui._scrollHighlight != oldHighlight || oldScrollIndex != invIndex) { + drawInventory(); + return; + } + } + if (_invVerbMode != 1) _tooltipWidget.handleEvents(); @@ -603,7 +628,6 @@ void WidgetInventory::handleEvents() { // See if they released a mouse button button if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) { - _dialogTimer = -1; ui._scrollHighlight = SH_NONE; // See if they have a Verb List open for an Inventry Item -- cgit v1.2.3 From 6a21765c2e252f58795e777308079cf93918a4ef Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Aug 2015 17:47:44 -0400 Subject: SHERLOCK: RT: Rename hangman puzzle to foolscap puzzle --- engines/sherlock/tattoo/widget_inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 8ec3bd7dd3..4653172481 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -407,7 +407,7 @@ void WidgetInventoryVerbs::handleEvents() { ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; scene.doBgAnim(); - vm.doHangManPuzzle(); + vm.doFoolscapPuzzle(); } else if (_invVerbSelect == 0) { // They have released the mouse on the Look Verb command, so Look at the inventory item ui._invLookFlag = true; @@ -733,7 +733,7 @@ void WidgetInventory::handleEvents() { ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; scene.doBgAnim(); - vm.doHangManPuzzle(); + vm.doFoolscapPuzzle(); } else { ui._invLookFlag = true; inv.freeInv(); -- cgit v1.2.3 From 6a346b97a20ed02883bf2a8435799665bdf3fe35 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Aug 2015 18:10:41 -0400 Subject: SHERLOCK: RT: Fixes for Foolscap puzzle --- engines/sherlock/tattoo/widget_inventory.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 4653172481..a72f5eb8ee 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -390,23 +390,20 @@ void WidgetInventoryVerbs::handleEvents() { _outsideMenu = false; // Check if they are trying to solve the Foolscap puzzle, or looking at the completed puzzle - bool doHangman = !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && + bool doFoolscap = !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && !_inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Solve)); - doHangman |= (!inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) + doFoolscap |= (!inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) && _inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); - if (doHangman) { + if (doFoolscap) { // Close the entire Inventory and return to Standard Mode _owner->_invVerbMode = 0; _owner->_tooltipWidget.banishWindow(); + _owner->banishWindow(); inv.freeInv(); events.clearEvents(); - events.setCursor(ARROW); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; - - scene.doBgAnim(); vm.doFoolscapPuzzle(); } else if (_invVerbSelect == 0) { // They have released the mouse on the Look Verb command, so Look at the inventory item -- cgit v1.2.3 From 74147989e549741c7cfdd8a124b3841287b8ba49 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Aug 2015 18:40:01 -0400 Subject: SHERLOCK: RT: Fix analysing solved Foolscap --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index a72f5eb8ee..20881ef012 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -393,7 +393,7 @@ void WidgetInventoryVerbs::handleEvents() { bool doFoolscap = !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) && !_inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Solve)); doFoolscap |= (!inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv6)) || !inv[_owner->_invSelect]._name.compareToIgnoreCase(FIXED(Inv7))) - && _inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); + && !_inventCommands[_invVerbSelect].compareToIgnoreCase(FIXED(Look)) && vm.readFlags(299); if (doFoolscap) { // Close the entire Inventory and return to Standard Mode -- cgit v1.2.3 From 303bbe75d58b74dac6ef38c7bebf59f72fca42b1 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 29 Aug 2015 21:30:55 +0200 Subject: SHERLOCK: Fix comment typos --- engines/sherlock/tattoo/widget_inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 20881ef012..3555ecdffd 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -41,7 +41,7 @@ WidgetInventoryTooltip::WidgetInventoryTooltip(SherlockEngine *vm, WidgetInvento } void WidgetInventoryTooltip::setText(const Common::String &str) { - // If no text specified, erase any previously displayed tooltip and free it's surface + // If no text specified, erase any previously displayed tooltip and free its surface if (str.empty()) { erase(); _surface.free(); -- cgit v1.2.3 From ee1ef54f377fa959e05e365514201c44b7ed0c58 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 16 Oct 2015 19:59:31 -0400 Subject: SHERLOCK: RT: Fix crash showing folder to Watson --- engines/sherlock/tattoo/widget_inventory.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/tattoo/widget_inventory.cpp') diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp index 3555ecdffd..b49e30b30d 100644 --- a/engines/sherlock/tattoo/widget_inventory.cpp +++ b/engines/sherlock/tattoo/widget_inventory.cpp @@ -641,10 +641,12 @@ void WidgetInventory::handleEvents() { bool found = false; if (ui._bgFound != -1) { if (ui._personFound) { + Person &person = people[ui._bgFound - 1000]; + for (int idx = 0; idx < 2; ++idx) { - 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); + if (!person._use[idx]._verb.compareToIgnoreCase(_verb) && + !person._use[idx]._target.compareToIgnoreCase(_invTarget)) { + ui.checkAction(person._use[idx], ui._bgFound); found = true; } } -- cgit v1.2.3