aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/tattoo/widget_inventory.cpp
blob: ee8faa3759d3ab2a4802402241a02a32b97ad235 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/* 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_scene.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			// 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"
#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) {
	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_SIZE + 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(_surface);
	drawInventory();
}

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;
	}
}

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

} // End of namespace Sherlock