[Scummvm-cvs-logs] scummvm master -> 753a810070b6b96d1a90cff399a41f21c31de885

dreammaster dreammaster at scummvm.org
Mon Jun 29 13:52:25 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
753a810070 SHERLOCK: RT: Beginnings of inventory window tooltip class


Commit: 753a810070b6b96d1a90cff399a41f21c31de885
    https://github.com/scummvm/scummvm/commit/753a810070b6b96d1a90cff399a41f21c31de885
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-06-29T07:51:25-04:00

Commit Message:
SHERLOCK: RT: Beginnings of inventory window tooltip class

Changed paths:
    engines/sherlock/tattoo/tattoo_fixed_text.cpp
    engines/sherlock/tattoo/tattoo_fixed_text.h
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h
    engines/sherlock/tattoo/widget_inventory.cpp
    engines/sherlock/tattoo/widget_inventory.h



diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.cpp b/engines/sherlock/tattoo/tattoo_fixed_text.cpp
index b444009..06704a5 100644
--- a/engines/sherlock/tattoo/tattoo_fixed_text.cpp
+++ b/engines/sherlock/tattoo/tattoo_fixed_text.cpp
@@ -49,10 +49,13 @@ static const char *const FIXED_TEXT_ENGLISH[] = {
 	"Open",
 	"Look",
 	"Talk",
+	"Use",
 	"Journal",
 	"Inventory",
 	"Options",
-	"Solve"
+	"Solve",
+	"with",
+	"No effect..."
 };
 
 TattooFixedText::TattooFixedText(SherlockEngine *vm) : FixedText(vm) {
diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.h b/engines/sherlock/tattoo/tattoo_fixed_text.h
index 845d798..d48f8496 100644
--- a/engines/sherlock/tattoo/tattoo_fixed_text.h
+++ b/engines/sherlock/tattoo/tattoo_fixed_text.h
@@ -49,10 +49,13 @@ enum FixedTextId {
 	kFixedText_Open,
 	kFixedText_Look,
 	kFixedText_Talk,
+	kFixedText_Use,
 	kFixedText_Journal,
 	kFixedText_Inventory,
 	kFixedText_Options,
-	kFixedText_Solve
+	kFixedText_Solve,
+	kFixedText_With,
+	kFixedText_NoEffect
 };
 
 class TattooFixedText: public FixedText {
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 2ebf238..fd94b2e 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -273,9 +273,6 @@ void TattooUserInterface::handleInput() {
 	case FILES_MODE:
 		doFileControl();
 		break;
-	case INV_MODE:
-		doInventoryControl();
-		break;
 	case VERB_MODE:
 		doVerbControl();
 		break;
@@ -525,10 +522,6 @@ void TattooUserInterface::doFileControl() {
 	warning("TODO: ui control (file)");
 }
 
-void TattooUserInterface::doInventoryControl() {
-	_inventoryWidget.handleEvents();
-}
-
 void TattooUserInterface::doVerbControl() {
 	_verbsWidget.handleEvents();
 }
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 527f326..6d8ce76 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -72,11 +72,6 @@ private:
 	void doFileControl();
 
 	/**
-	 * Handle input if an inventory command (INVENT, LOOK, or USE) has an open window and is active
-	 */
-	void doInventoryControl();
-
-	/**
 	 * Handle input while the verb menu is open
 	 */
 	void doVerbControl();
@@ -128,6 +123,7 @@ public:
 	int _maskCounter;
 	ImageFile *_interfaceImages;
 	WidgetText _textWidget;
+	Common::String _action;
 public:
 	TattooUserInterface(SherlockEngine *vm);
 	virtual ~TattooUserInterface();
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index c2379a5..67e2276 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() {
 }
 
diff --git a/engines/sherlock/tattoo/widget_inventory.h b/engines/sherlock/tattoo/widget_inventory.h
index 4193077..41ba142 100644
--- a/engines/sherlock/tattoo/widget_inventory.h
+++ b/engines/sherlock/tattoo/widget_inventory.h
@@ -35,7 +35,34 @@ namespace Tattoo {
 
 #define NUM_INVENTORY_SHOWN 8		// Number of Inventory Items Shown
 
+class WidgetInventory;
+
+class WidgetInventoryTooltip: public WidgetBase {
+private:
+	WidgetInventory *_owner;
+	Common::Rect _oldInvGraphicBounds, _invGraphicBounds;
+protected:
+	/**
+	* Overriden from base class, since tooltips have a completely transparent background
+	*/
+	virtual void drawBackground() {}
+public:
+	WidgetInventoryTooltip(SherlockEngine *vm, WidgetInventory *owner);
+	virtual ~WidgetInventoryTooltip() {}
+
+	/**
+	 * Set the text for the tooltip
+	 */
+	void setText(const Common::String &str);
+
+	/**
+	 * Handle updating the tooltip state
+	 */
+	virtual void handleEvents();
+};
+
 class WidgetInventory: public WidgetBase {
+	friend class WidgetInventoryTooltip;
 private:
 	int _invVerbMode;
 	int _invSelect, _oldInvSelect;
@@ -44,7 +71,7 @@ private:
 	int _dialogTimer;
 	int _scrollHighlight;
 	Common::StringArray _inventCommands;
-	WidgetTooltip _tooltipWidget;
+	WidgetInventoryTooltip _tooltipWidget;
 	Common::String _invVerb;
 	Common::String _invTarget;
 	Common::String _action;
@@ -60,11 +87,6 @@ private:
 	void drawScrollBar();
 
 	/**
-	 * Displays the description of any inventory item the moues cursor is over
-	 */
-	void updateDescription();
-
-	/**
 	 * Check for keys to mouse the mouse within the inventory dialog
 	 */
 	void checkInvTabbingKeys();






More information about the Scummvm-git-logs mailing list