[Scummvm-cvs-logs] scummvm master -> 8fd588072d545b147f0bfacd68921aea109df786

dreammaster dreammaster at scummvm.org
Sat Aug 1 03:22:51 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:
8fd588072d SHERLOCK: RT: Implement inventory window scrolling


Commit: 8fd588072d545b147f0bfacd68921aea109df786
    https://github.com/scummvm/scummvm/commit/8fd588072d545b147f0bfacd68921aea109df786
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-31T21:21:52-04:00

Commit Message:
SHERLOCK: RT: Implement inventory window scrolling

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



diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index 405fc87..8ec3bd7 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
diff --git a/engines/sherlock/tattoo/widget_inventory.h b/engines/sherlock/tattoo/widget_inventory.h
index 53bc203..a051c32 100644
--- a/engines/sherlock/tattoo/widget_inventory.h
+++ b/engines/sherlock/tattoo/widget_inventory.h
@@ -87,7 +87,6 @@ private:
 	int _invVerbMode;
 	int _selector, _oldSelector;
 	int _invSelect, _oldInvSelect;
-	int _dialogTimer;
 	WidgetInventoryTooltip _tooltipWidget;
 	WidgetInventoryVerbs _verbList;
 	bool _swapItems;






More information about the Scummvm-git-logs mailing list