[Scummvm-cvs-logs] scummvm master -> f02488fc2058994b36116c7ce7daf756e4c94984

dreammaster dreammaster at scummvm.org
Tue Jun 16 01:58:04 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:
f02488fc20 SHERLOCK: RT: Beginnings of UI widget classes


Commit: f02488fc2058994b36116c7ce7daf756e4c94984
    https://github.com/scummvm/scummvm/commit/f02488fc2058994b36116c7ce7daf756e4c94984
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-06-15T19:53:50-04:00

Commit Message:
SHERLOCK: RT: Beginnings of UI widget classes

Changed paths:
  A engines/sherlock/tattoo/widget_tooltip.cpp
  A engines/sherlock/tattoo/widget_tooltip.h
  A engines/sherlock/tattoo/widget_verbs.cpp
  A engines/sherlock/tattoo/widget_verbs.h
    engines/sherlock/module.mk
    engines/sherlock/surface.h
    engines/sherlock/tattoo/tattoo.h
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h



diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index ab4990b..bbbd2f5 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -21,6 +21,8 @@ MODULE_OBJS = \
 	tattoo/tattoo_scene.o \
 	tattoo/tattoo_talk.o \
 	tattoo/tattoo_user_interface.o \
+	tattoo/widget_tooltip.o \
+	tattoo/widget_verbs.o \
 	animation.o \
 	debugger.o \
 	detection.o \
diff --git a/engines/sherlock/surface.h b/engines/sherlock/surface.h
index 0192b22..150796e 100644
--- a/engines/sherlock/surface.h
+++ b/engines/sherlock/surface.h
@@ -145,7 +145,7 @@ public:
 	void maskArea(const ImageFrame &src, const Common::Point &pt, int scrollX);
 
 	/**
-	 * Clear the screen
+	 * Clear the surface
 	 */
 	void clear();
 
@@ -155,6 +155,11 @@ public:
 	void free();
 
 	/**
+	 * Returns true if the surface is empty
+	 */
+	bool empty() const { return _surface.getPixels() == nullptr; }
+
+	/**
 	 * Set the pixels for the surface to an existing data block
 	 */
 	void setPixels(byte *pixels, int width, int height, Graphics::PixelFormat format);
diff --git a/engines/sherlock/tattoo/tattoo.h b/engines/sherlock/tattoo/tattoo.h
index 2342f56..39f4934 100644
--- a/engines/sherlock/tattoo/tattoo.h
+++ b/engines/sherlock/tattoo/tattoo.h
@@ -29,6 +29,12 @@ namespace Sherlock {
 
 namespace Tattoo {
 
+enum {
+	INFO_TOP			= 185,
+	INFO_MIDDLE			= 186,
+	INFO_BOTTOM			= 188
+};
+
 class TattooEngine : public SherlockEngine {
 private:
 	/**
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 6398be6..f51c57a 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -28,10 +28,10 @@ namespace Sherlock {
 
 namespace Tattoo {
 
-TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm) {
+TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm),
+		_tooltipWidget(vm), _verbsWidget(vm) {
 	_menuBuffer = nullptr;
 	_invMenuBuffer = nullptr;
-	_tagBuffer = nullptr;
 	_invGraphic = nullptr;
 	_scrollSize = _scrollSpeed = 0;
 	_drawMenu = false;
@@ -145,9 +145,8 @@ void TattooUserInterface::drawInterface(int bufferNum) {
 		screen._backBuffer1.transBlitFrom(*_menuBuffer, Common::Point(_invMenuBounds.left, _invMenuBounds.top));
 	}
 
-	// See if we need to draw a Text Tag floating with the cursor
-	if (_tagBuffer != nullptr)
-		screen._backBuffer1.transBlitFrom(*_tagBuffer, Common::Point(_tagBounds.left, _tagBounds.top));
+	// Handle drawing the text tooltip if necessary
+	_tooltipWidget.draw();
 
 	// See if we need to draw an Inventory Item Graphic floating with the cursor
 	if (_invGraphic != nullptr)
@@ -181,18 +180,8 @@ void TattooUserInterface::drawInterface(int bufferNum) {
 		_oldInvMenuBounds.left = _oldInvMenuBounds.top = _oldInvMenuBounds.right = _oldInvMenuBounds.bottom = 0;
 	}
 
-	// See if  need to clear any tags
-	if (_oldTagBounds.right) {
-		screen.slamArea(_oldTagBounds.left - _currentScroll.x, _oldTagBounds.top, _oldTagBounds.width(), _oldTagBounds.height());
-
-		// If there's no tag actually being displayed, then reset bounds so we don't keep restoring the area
-		if (_tagBuffer == nullptr) {
-			_tagBounds.left = _tagBounds.top = _tagBounds.right = _tagBounds.bottom = 0;
-			_oldTagBounds.left = _oldTagBounds.top = _oldTagBounds.right = _oldTagBounds.bottom = 0;
-		}
-	}
-	if (_tagBuffer != nullptr)
-		screen.slamArea(_tagBounds.left - _currentScroll.x, _tagBounds.top, _tagBounds.width(), _tagBounds.height());
+	// Clear the tooltip if necessary
+	_tooltipWidget.erase();
 
 	// See if we need to flush areas assocaited with the inventory graphic
 	if (_oldInvGraphicBounds.right) {
@@ -229,9 +218,7 @@ void TattooUserInterface::doBgAnimRestoreUI() {
 		screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_invMenuBounds.left, _invMenuBounds.top), _invMenuBounds);
 
 	// If there is a Text Tag being display, restore the area underneath it
-	if (_oldTagBounds.width() > 0)
-		screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldTagBounds.left, _oldTagBounds.top), 
-			_oldTagBounds);
+	_tooltipWidget.erasePrevious();
 
 	// If there is an Inventory being shown, restore the graphics underneath it
 	if (_oldInvGraphicBounds.width() > 0)
@@ -344,7 +331,16 @@ void TattooUserInterface::doStandardControl() {
 	default:
 		break;
 	}
-
+static bool flag = false;	//***DEBUG**** - temporarily being used for testing walking */
+if (!flag && events._released) {
+	flag = true;
+	people._allowWalkAbort = true;
+	people[HOLMES]._walkDest = Common::Point(235, 370);
+	people[HOLMES].goAllTheWay();
+
+	events._released = false;
+	return;
+}
 	// See if a mouse button was released
 	if (events._released || events._rightReleased) {
 		// See if the mouse was released in an exit (Arrow) zone. Unless it's also pointing at an object
@@ -418,7 +414,7 @@ void TattooUserInterface::doInventoryControl() {
 }
 
 void TattooUserInterface::doVerbControl() {
-	warning("TODO: ui control (verb)");
+	_verbsWidget.execute();
 }
 
 void TattooUserInterface::doTalkControl() {
@@ -434,7 +430,21 @@ void TattooUserInterface::doLabControl() {
 }
 
 void TattooUserInterface::displayObjectNames() {
-	// TODO
+	Events &events = *_vm->_events;
+	Scene &scene = *_vm->_scene;
+	Common::Point mousePos = events.mousePos() + _currentScroll;
+	_arrowZone = -1;
+
+	if (_bgFound == -1 || scene._currentScene == 90) {
+		for (uint idx = 0; idx < scene._exits.size() && _arrowZone == -1; ++idx) {
+			Exit &exit = scene._exits[idx];
+			if (exit.contains(mousePos))
+				_arrowZone = idx;
+		}
+	}
+
+	_tooltipWidget.execute();
+	_oldArrowZone = _arrowZone;
 }
 
 void TattooUserInterface::initFileMenu() {
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 644b20a..f88deaa 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -26,6 +26,8 @@
 #include "common/scummsys.h"
 #include "sherlock/saveload.h"
 #include "sherlock/user_interface.h"
+#include "sherlock/tattoo/widget_tooltip.h"
+#include "sherlock/tattoo/widget_verbs.h"
 
 namespace Sherlock {
 
@@ -37,16 +39,12 @@ private:
 	Common::Rect _oldMenuBounds;
 	Common::Rect _invMenuBounds;
 	Common::Rect _oldInvMenuBounds;
-	Common::Rect _tagBounds;
-	Common::Rect _oldTagBounds;
 	Common::Rect _invGraphicBounds;
 	Common::Rect _oldInvGraphicBounds;
 	Surface *_menuBuffer;
 	Surface *_invMenuBuffer;
-	Surface *_tagBuffer;
 	Surface *_invGraphic;
 	Common::Array<Common::Rect> _grayAreas;
-	int _bgFound, _oldBgFound;
 	Object *_bgShape;
 	bool _personFound;
 	int _lockoutTimer;
@@ -54,8 +52,9 @@ private:
 	SaveMode _fileMode;
 	int _exitZone;
 	int _scriptZone;
-	int _arrowZone, _oldArrowZone;
 	int _activeObj;
+	WidgetTooltip _tooltipWidget;
+	WidgetVerbs _verbsWidget;
 private:
 	/**
 	 * Draws designated areas of the screen that are meant to be grayed out using grayscale colors
@@ -153,6 +152,8 @@ public:
 	Common::Point _currentScroll, _targetScroll;
 	int _scrollSize, _scrollSpeed;
 	bool _drawMenu;
+	int _bgFound, _oldBgFound;
+	int _arrowZone, _oldArrowZone;
 public:
 	TattooUserInterface(SherlockEngine *vm);
 
diff --git a/engines/sherlock/tattoo/widget_tooltip.cpp b/engines/sherlock/tattoo/widget_tooltip.cpp
new file mode 100644
index 0000000..f089411
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_tooltip.cpp
@@ -0,0 +1,220 @@
+/* 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_tooltip.h"
+#include "sherlock/tattoo/tattoo_user_interface.h"
+#include "sherlock/tattoo/tattoo.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : _vm(vm) {
+}
+
+void WidgetTooltip::execute() {
+	Events &events = *_vm->_events;
+	People &people = *_vm->_people;
+	Scene &scene = *_vm->_scene;
+	Screen &screen = *_vm->_screen;
+	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+	Common::Point mousePos = events.mousePos();
+	bool reset = false;
+
+	// See if thay are pointing at a different object and we need to regenerate the tooltip text
+	if (ui._bgFound != ui._oldBgFound || (ui._bgFound != -1 && _surface.empty()) ||
+			ui._arrowZone != ui._oldArrowZone || (ui._arrowZone != -1 && _surface.empty())) {
+		// Keep track of the last place we drew the text
+		_oldBounds = _bounds;
+
+		// See if there is a new object to be displayed
+		if ((ui._bgFound != -1 && (ui._bgFound != ui._oldBgFound || (ui._bgFound != -1 && _surface.empty()))) ||
+				(ui._arrowZone != -1 && (ui._arrowZone != ui._oldArrowZone || (ui._arrowZone != -1 && _surface.empty())))) {
+			Common::String str;
+			if (ui._bgFound != -1) {
+				// Clear the Arrow Zone fields so it won't think we're displaying an Arrow Zone cursor
+				if (scene._currentScene != 90)  // RRR Take out the cludge for room 90
+					ui._arrowZone = ui._oldArrowZone = -1;
+
+				// Get the description string
+				str = (ui._bgFound < 1000) ? scene._bgShapes[ui._bgFound]._description :
+					people[ui._bgFound - 1000]._description;
+			} else {
+				// Get the exit zone description
+				str = scene._exits[ui._arrowZone]._dest;
+			}
+
+			// Make sure that the description is present
+			if (!str.empty() && !str.hasPrefix(" ")) {
+				int width = screen.stringWidth(str) + 2;
+				int height = screen.stringHeight(str) + 2;
+				Common::String line1 = str, line2 = "";
+
+				// See if we need to split it into two lines
+				if (width > 150) {
+					// Go forward word by word to find out where to split the line
+					const char *s = str.c_str();
+					const char *space = nullptr;
+					int dif = 10000;
+
+					for (;;) {
+						// Find end of next word
+						s = strchr(s + 1, ' ');
+
+						if (s == nullptr) {
+							// Reached end of string
+							if (space != nullptr) {
+								line1 = Common::String(str.c_str(), space);
+								line2 = Common::String(space + 1);
+								height = screen.stringHeight(line1) + screen.stringHeight(line2) + 4;
+							}
+							break;
+						}
+
+						// Found space separating words, so see what width the string up to now is
+						Common::String tempLine1 = Common::String(str.c_str(), s);
+						Common::String tempLine2 = Common::String(s + 1);
+						int width1 = screen.stringWidth(tempLine1);
+						int width2 = screen.stringWidth(tempLine2);
+
+						// See if we've found a split point that results in a less overall width
+						if (ABS(width1 - width2) < dif) {
+							// Found a better split point
+							dif = ABS(width1 - width2);
+							space = s;
+							line1 = tempLine1;
+							line2 = tempLine2;
+						}
+					}
+				} else {
+					// No line split needed
+					height = screen.stringHeight(str) + 2;
+				}
+
+				// Reallocate the text surface with the new size
+				_surface.create(width, height, _vm->getPlatform());
+				_surface.fill(TRANSPARENCY);
+
+				if (line2.empty()) {
+					// Only a single line
+					_surface.writeString(str, Common::Point(0, 0), BLACK);
+					_surface.writeString(str, Common::Point(1, 0), BLACK);
+					_surface.writeString(str, Common::Point(2, 0), BLACK);
+					_surface.writeString(str, Common::Point(0, 1), BLACK);
+					_surface.writeString(str, Common::Point(2, 1), BLACK);
+					_surface.writeString(str, Common::Point(0, 2), BLACK);
+					_surface.writeString(str, Common::Point(1, 2), BLACK);
+					_surface.writeString(str, Common::Point(2, 2), BLACK);
+					_surface.writeString(str, Common::Point(1, 1), INFO_TOP);
+				} else {
+					// Two lines to display
+					int xp, yp;
+					xp = (width - screen.stringWidth(line1) - 2) / 2;
+					_surface.writeString(line1, Common::Point(xp, 0), BLACK);
+					_surface.writeString(line1, Common::Point(xp + 1, 0), BLACK);
+					_surface.writeString(line1, Common::Point(xp + 2, 0), BLACK);
+					_surface.writeString(line1, Common::Point(xp, 1), BLACK);
+					_surface.writeString(line1, Common::Point(xp + 2, 1), BLACK);
+					_surface.writeString(line1, Common::Point(xp, 2), BLACK);
+					_surface.writeString(line1, Common::Point(xp + 1, 2), BLACK);
+					_surface.writeString(line1, Common::Point(xp + 2, 2), BLACK);
+					_surface.writeString(line1, Common::Point(xp + 1, 1), INFO_TOP);
+					
+					xp = (width - screen.stringWidth(line2) - 2) / 2;
+					yp = screen.stringHeight(line1) + 2;
+					_surface.writeString(line2, Common::Point(xp, yp), BLACK);
+					_surface.writeString(line2, Common::Point(xp + 1, yp), BLACK);
+					_surface.writeString(line2, Common::Point(xp + 2, yp), BLACK);
+					_surface.writeString(line2, Common::Point(xp, yp + 1), BLACK);
+					_surface.writeString(line2, Common::Point(xp + 2, yp + 1), BLACK);
+					_surface.writeString(line2, Common::Point(xp, yp + 2), BLACK);
+					_surface.writeString(line2, Common::Point(xp + 1, yp + 2), BLACK);
+					_surface.writeString(line2, Common::Point(xp + 2, yp + 2), BLACK);
+					_surface.writeString(line2, Common::Point(xp + 1, yp + 1), INFO_TOP);
+				}
+
+				// Set the initial display position for the tooltip text
+				int tagX = CLIP(mousePos.x - width / 2, 0, SHERLOCK_SCREEN_WIDTH - width);
+				int tagY = MAX(mousePos.y - height, 0);
+
+				_bounds = Common::Rect(tagX, tagY, tagX + width, tagY + height);
+			} else {
+				reset = true;
+			}
+		} else if ((ui._bgFound == -1 && ui._oldBgFound != -1) || (ui._arrowZone == -1 && ui._oldArrowZone != -1)) {
+			reset = true;
+		}
+
+		if (reset && !_surface.empty()) {
+			_surface.free();
+		}
+
+		ui._oldBgFound = ui._bgFound;
+	} else {
+		// Keep track of the last place we drew the Text
+		_oldBounds = _bounds;
+
+		// Set the New position of the Text Tag
+		int tagX = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _bounds.width());
+		int tagY = MAX(mousePos.y - _bounds.height(), 0);
+
+		_bounds.moveTo(tagX, tagY);
+	}
+
+	ui._oldArrowZone = ui._arrowZone;
+}
+
+void WidgetTooltip::draw() {
+	Screen &screen = *_vm->_screen;
+
+	if (!_surface.empty())
+		screen._backBuffer1.transBlitFrom(_surface, Common::Point(_bounds.left, _bounds.top));
+}
+
+void WidgetTooltip::erase() {
+	Screen &screen = *_vm->_screen;
+	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+
+	if (_bounds.width() > 0) {
+		screen.slamArea(_oldBounds.left - ui._currentScroll.x, _oldBounds.top, _oldBounds.width(), _oldBounds.height());
+
+		// If there's no text actually being displayed, then reset bounds so we don't keep restoring the area
+		if (_surface.empty()) {
+			_bounds.left = _bounds.top = _bounds.right = _bounds.bottom = 0;
+			_oldBounds.left = _oldBounds.top = _oldBounds.right = _oldBounds.bottom = 0;
+		}
+	}
+
+	if (!_surface.empty())
+		screen.slamArea(_bounds.left - ui._currentScroll.x, _bounds.top, _bounds.width(), _bounds.height());
+}
+
+void WidgetTooltip::erasePrevious() {
+	Screen &screen = *_vm->_screen;
+	if (_oldBounds.width() > 0)
+		screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldBounds.left, _oldBounds.top),
+		_oldBounds);
+}
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/widget_tooltip.h b/engines/sherlock/tattoo/widget_tooltip.h
new file mode 100644
index 0000000..b704c1e
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_tooltip.h
@@ -0,0 +1,69 @@
+/* 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.
+ *
+ */
+
+#ifndef SHERLOCK_TATTOO_WIDGET_TOOLTIP_H
+#define SHERLOCK_TATTOO_WIDGET_TOOLTIP_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "sherlock/surface.h"
+
+namespace Sherlock {
+
+class SherlockEngine;
+
+namespace Tattoo {
+
+class WidgetTooltip {
+private:
+	SherlockEngine *_vm;
+	Common::Rect _bounds, _oldBounds;
+	Surface _surface;
+public:
+	WidgetTooltip(SherlockEngine *vm);
+
+	/**
+	 * Handle updating the tooltip state
+	 */
+	void execute();
+
+	/**
+	 * Draw the tooltip if necessary
+	 */
+	void draw();
+
+	/**
+	 * Erase the area covered by the tooltip if it's active
+	 */
+	void erase();
+
+	/**
+	 * Erase any area of the screen drawn by the tooltip in the previous frame
+	 */
+	void erasePrevious();
+};
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/tattoo/widget_verbs.cpp b/engines/sherlock/tattoo/widget_verbs.cpp
new file mode 100644
index 0000000..fead526
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_verbs.cpp
@@ -0,0 +1,74 @@
+/* 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_verbs.h"
+#include "sherlock/tattoo/tattoo.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+WidgetVerbs::WidgetVerbs(SherlockEngine *vm) : _vm(vm) {
+	_selector = _oldSelector = -1;
+}
+
+void WidgetVerbs::execute() {
+	checkTabbingKeys(_verbCommands.size());
+
+	// Highlight verb display as necessary
+	highlightVerbControls();
+
+	// TODO
+}
+
+void WidgetVerbs::checkTabbingKeys(int numOptions) {
+
+}
+
+void WidgetVerbs::highlightVerbControls() {
+	Events &events = *_vm->_events;
+	Screen &screen = *_vm->_screen;
+	Common::Point mousePos = events.mousePos();
+
+	// Get highlighted verb
+	_selector = -1;
+	Common::Rect bounds = _bounds;
+	bounds.grow(-3);
+	if (bounds.contains(mousePos))
+		_selector = (mousePos.y - bounds.top) / (screen.fontHeight() + 7);
+
+	// See if a new verb is being pointed at
+	if (_selector != _oldSelector) {
+		// Redraw the verb list
+		for (int idx = 0; idx < (int)_verbCommands.size(); ++idx) {
+			byte color = (idx == _selector) ? COMMAND_HIGHLIGHTED : INFO_TOP;
+			_surface.writeString(_verbCommands[idx], Common::Point((_bounds.width() - screen.stringWidth(_verbCommands[idx])) / 2,
+				(screen.fontHeight() + 7) * idx + 5), color);
+		}
+
+		_oldSelector = _selector;
+	}
+}
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/widget_verbs.h b/engines/sherlock/tattoo/widget_verbs.h
new file mode 100644
index 0000000..160df85
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_verbs.h
@@ -0,0 +1,62 @@
+/* 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.
+ *
+ */
+
+#ifndef SHERLOCK_TATTOO_WIDGET_VERBS_H
+#define SHERLOCK_TATTOO_WIDGET_VERBS_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "common/str-array.h"
+#include "sherlock/surface.h"
+
+namespace Sherlock {
+
+class SherlockEngine;
+
+namespace Tattoo {
+
+class WidgetVerbs {
+private:
+	SherlockEngine *_vm;
+	Common::Rect _bounds;
+	Surface _surface;
+	int _selector, _oldSelector;
+
+	/**
+	 * Highlights the controls for the verb list
+	 */
+	void highlightVerbControls();
+public:
+	Common::StringArray _verbCommands;
+public:
+	WidgetVerbs(SherlockEngine *vm);
+
+	void execute();
+
+	void checkTabbingKeys(int numOptions);
+};
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
+
+#endif






More information about the Scummvm-git-logs mailing list