aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/dialogs.cpp
diff options
context:
space:
mode:
authorDavid Turner2012-12-03 04:05:14 -0800
committerDavid Turner2012-12-03 04:05:14 -0800
commit2509b6475cb05fd9375a3455a5714d8fd2f4c316 (patch)
tree54698591f82cf19545de80cf6449bce14ff23a8c /engines/tinsel/dialogs.cpp
parent997386d15ca751eaef06533f3edc0aa3d029eede (diff)
parent220fb663648059fb39178b081385a0f44a572690 (diff)
downloadscummvm-rg350-2509b6475cb05fd9375a3455a5714d8fd2f4c316.tar.gz
scummvm-rg350-2509b6475cb05fd9375a3455a5714d8fd2f4c316.tar.bz2
scummvm-rg350-2509b6475cb05fd9375a3455a5714d8fd2f4c316.zip
Merge pull request #294 from eriktorbjorn/tinsel-scrollwheel
TINSEL: Add scrollwheel support to save/load and inventory
Diffstat (limited to 'engines/tinsel/dialogs.cpp')
-rw-r--r--engines/tinsel/dialogs.cpp126
1 files changed, 89 insertions, 37 deletions
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index e1a2923233..562f519e99 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -4861,50 +4861,101 @@ static void InvDragEnd() {
g_Xchange = g_Ychange = 0; // Probably no need, but does no harm!
}
-static void MenuPageDown() {
+static bool MenuDown(int lines) {
if (cd.box == loadBox || cd.box == saveBox) {
- if (cd.extraBase < MAX_SAVED_FILES-NUM_RGROUP_BOXES) {
- FirstFile(cd.extraBase+(NUM_RGROUP_BOXES - 1));
+ if (cd.extraBase < MAX_SAVED_FILES - NUM_RGROUP_BOXES) {
+ FirstFile(cd.extraBase + lines);
AddBoxes(true);
- cd.selBox = NUM_RGROUP_BOXES - 1;
- Select(cd.selBox, true);
+ return true;
}
} else if (cd.box == hopperBox1) {
if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {
- FirstScene(cd.extraBase + (NUM_RGROUP_BOXES - 1));
+ FirstScene(cd.extraBase + lines);
AddBoxes(true);
- if (cd.selBox)
- cd.selBox = NUM_RGROUP_BOXES - 1;
- Select(cd.selBox, true);
+ return true;
}
} else if (cd.box == hopperBox2) {
if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {
- FirstEntry(cd.extraBase+(NUM_RGROUP_BOXES - 1));
+ FirstEntry(cd.extraBase + lines);
AddBoxes(true);
- if (cd.selBox)
- cd.selBox = NUM_RGROUP_BOXES - 1;
- Select(cd.selBox, true);
+ return true;
}
}
+ return false;
}
-static void MenuPageUp() {
+static bool MenuUp(int lines) {
if (cd.extraBase > 0) {
if (cd.box == loadBox || cd.box == saveBox)
- FirstFile(cd.extraBase-(NUM_RGROUP_BOXES - 1));
+ FirstFile(cd.extraBase - lines);
else if (cd.box == hopperBox1)
- FirstScene(cd.extraBase-(NUM_RGROUP_BOXES - 1));
+ FirstScene(cd.extraBase - lines);
else if (cd.box == hopperBox2)
- FirstEntry(cd.extraBase-(NUM_RGROUP_BOXES - 1));
+ FirstEntry(cd.extraBase - lines);
else
- return;
+ return false;
AddBoxes(true);
+ return true;
+ }
+ return false;
+}
+
+static void MenuRollDown() {
+ if (MenuDown(1)) {
+ if (cd.selBox > 0)
+ cd.selBox--;
+ Select(cd.selBox, true);
+ }
+}
+
+static void MenuRollUp() {
+ if (MenuUp(1)) {
+ if (cd.selBox < NUM_RGROUP_BOXES - 1)
+ cd.selBox++;
+ Select(cd.selBox, true);
+ }
+}
+
+static void MenuPageDown() {
+ if (MenuDown(NUM_RGROUP_BOXES - 1)) {
+ cd.selBox = NUM_RGROUP_BOXES - 1;
+ Select(cd.selBox, true);
+ }
+}
+
+static void MenuPageUp() {
+ if (MenuUp(NUM_RGROUP_BOXES - 1)) {
cd.selBox = 0;
Select(cd.selBox, true);
}
}
+static void InventoryDown() {
+ // This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo
+ // TODO: So share this duplicate code
+ if (g_InvD[g_ino].NoofVicons == 1)
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
+ for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
+ }
+ g_ItemsChanged = true;
+}
+
+static void InventoryUp() {
+ // This code is a copy of the I_SLIDE_UP case in InvWalkTo
+ // TODO: So share this duplicate code
+ if (g_InvD[g_ino].NoofVicons == 1)
+ g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
+ for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++)
+ g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
+ if (g_InvD[g_ino].FirstDisp < 0)
+ g_InvD[g_ino].FirstDisp = 0;
+ g_ItemsChanged = true;
+}
+
/**************************************************************************/
/************** Incoming events - further processing **********************/
/**************************************************************************/
@@ -5402,16 +5453,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
// Only act if load or save screen
MenuPageDown();
} else {
- // This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo
- // TODO: So share this duplicate code
- if (g_InvD[g_ino].NoofVicons == 1)
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- }
- g_ItemsChanged = true;
+ InventoryDown();
}
break;
@@ -5420,15 +5462,25 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
// Only act if load or save screen
MenuPageUp();
} else {
- // This code is a copy of the I_SLIDE_UP case in InvWalkTo
- // TODO: So share this duplicate code
- if (g_InvD[g_ino].NoofVicons == 1)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ InventoryUp();
+ }
+ break;
+
+ case PLR_WHEEL_DOWN:
+ if (g_ino == INV_MENU) {
+ // Only act if load or save screen
+ MenuRollDown();
+ } else {
+ InventoryDown();
+ }
+ break;
+
+ case PLR_WHEEL_UP:
+ if (g_ino == INV_MENU) {
+ // Only act if load or save screen
+ MenuRollUp();
+ } else {
+ InventoryUp();
}
break;