ref: 036df9796a134357506f19e4513f1a1f4c165476
parent: 8237514e5f550a161f8ba243bd1515a4415a1c3a
parent: dc0f1f5ce1cc7930678777681cfe31ea8564ed0f
author: Fabian Greffrath <fabian@greffrath.com>
date: Mon Apr 25 12:08:26 EDT 2022
Merge pull request #1458 from mikeday0/hexenmouseinv Hexen: Add mouse inventory buttons
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -779,6 +779,11 @@
}
}
+// If an InventoryMove*() function is called when the inventory is not active,
+// it will instead activate the inventory without attempting to change the
+// selected item. This action is indicated by a return value of false.
+// Otherwise, it attempts to change items and will return a value of true.
+
static boolean InventoryMoveLeft()
{inventoryTics = 5 * 35;
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -744,6 +744,64 @@
}
}
+// If an InventoryMove*() function is called when the inventory is not active,
+// it will instead activate the inventory without attempting to change the
+// selected item. This action is indicated by a return value of false.
+// Otherwise, it attempts to change items and will return a value of true.
+
+static boolean InventoryMoveLeft()
+{+ inventoryTics = 5 * 35;
+ if (!inventory)
+ {+ inventory = true;
+ return false;
+ }
+ inv_ptr--;
+ if (inv_ptr < 0)
+ {+ inv_ptr = 0;
+ }
+ else
+ {+ curpos--;
+ if (curpos < 0)
+ {+ curpos = 0;
+ }
+ }
+ return true;
+}
+
+static boolean InventoryMoveRight()
+{+ player_t *plr;
+
+ plr = &players[consoleplayer];
+ inventoryTics = 5 * 35;
+ if (!inventory)
+ {+ inventory = true;
+ return false;
+ }
+ inv_ptr++;
+ if (inv_ptr >= plr->inventorySlotNum)
+ {+ inv_ptr--;
+ if (inv_ptr < 0)
+ inv_ptr = 0;
+ }
+ else
+ {+ curpos++;
+ if (curpos > 6)
+ {+ curpos = 6;
+ }
+ }
+ return true;
+}
+
static void SetMouseButtons(unsigned int buttons_mask)
{int i;
@@ -764,6 +822,14 @@
{next_weapon = 1;
}
+ else if (i == mousebinvleft)
+ {+ InventoryMoveLeft();
+ }
+ else if (i == mousebinvright)
+ {+ InventoryMoveRight();
+ }
}
mousebuttons[i] = button_on;
@@ -847,51 +913,19 @@
case ev_keydown:
if (ev->data1 == key_invleft)
{- inventoryTics = 5 * 35;
- if (!inventory)
+ if (InventoryMoveLeft())
{- inventory = true;
- break;
+ return (true);
}
- inv_ptr--;
- if (inv_ptr < 0)
- {- inv_ptr = 0;
- }
- else
- {- curpos--;
- if (curpos < 0)
- {- curpos = 0;
- }
- }
- return (true);
+ break;
}
if (ev->data1 == key_invright)
{- inventoryTics = 5 * 35;
- if (!inventory)
+ if (InventoryMoveRight())
{- inventory = true;
- break;
+ return (true);
}
- inv_ptr++;
- if (inv_ptr >= plr->inventorySlotNum)
- {- inv_ptr--;
- if (inv_ptr < 0)
- inv_ptr = 0;
- }
- else
- {- curpos++;
- if (curpos > 6)
- {- curpos = 6;
- }
- }
- return (true);
+ break;
}
if (ev->data1 == key_pause && !MenuActive)
{--- a/src/setup/mouse.c
+++ b/src/setup/mouse.c
@@ -98,7 +98,7 @@
buttons_table = TXT_NewTable(4),
NULL);
- TXT_SetColumnWidths(buttons_table, 16, 11, 14, 10);
+ TXT_SetColumnWidths(buttons_table, 16, 11, 16, 10);
AddMouseControl(buttons_table, "Move forward", &mousebforward);
AddMouseControl(buttons_table, "Strafe left", &mousebstrafeleft);
@@ -109,7 +109,7 @@
AddMouseControl(buttons_table, "Next weapon", &mousebnextweapon);
AddMouseControl(buttons_table, "Run", &mousebspeed);
- if (gamemission == heretic)
+ if (gamemission == heretic || gamemission == hexen)
{AddMouseControl(buttons_table, "Inventory left", &mousebinvleft);
AddMouseControl(buttons_table, "Inventory right", &mousebinvright);
--
⑨