aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-07-31 21:21:52 -0400
committerPaul Gilbert2015-07-31 21:21:52 -0400
commit8fd588072d545b147f0bfacd68921aea109df786 (patch)
tree99c5089fdddd5ad09cbe7d87661325822881cc9f
parentf99b42a89da4b1f9e25aedd1ccf798085516ff92 (diff)
downloadscummvm-rg350-8fd588072d545b147f0bfacd68921aea109df786.tar.gz
scummvm-rg350-8fd588072d545b147f0bfacd68921aea109df786.tar.bz2
scummvm-rg350-8fd588072d545b147f0bfacd68921aea109df786.zip
SHERLOCK: RT: Implement inventory window scrolling
-rw-r--r--engines/sherlock/tattoo/widget_inventory.cpp36
-rw-r--r--engines/sherlock/tattoo/widget_inventory.h1
2 files changed, 30 insertions, 7 deletions
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
diff --git a/engines/sherlock/tattoo/widget_inventory.h b/engines/sherlock/tattoo/widget_inventory.h
index 53bc2038e0..a051c328e9 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;