ref: cfdf4dec83392dfaf04520e81f85820c0c359ba3
parent: 181c56fc2e28ede64e03b47252aaaad72fd2d3af
parent: e9e76ede1b18ad4fa5d5816419d1e334f7752cf9
author: Simon Howard <[email protected]>
date: Wed Mar 18 19:02:56 EDT 2020
Merge pull request #1256 from kraflab/add-heretic-mouse-inv Add heretic mouse inventory buttons
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -771,6 +771,59 @@
}
}
+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;
@@ -791,6 +844,14 @@
{
next_weapon = 1;
}
+ else if (i == mousebinvleft)
+ {
+ InventoryMoveLeft();
+ }
+ else if (i == mousebinvright)
+ {
+ InventoryMoveRight();
+ }
}
mousebuttons[i] = button_on;
@@ -873,51 +934,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/m_config.c
+++ b/src/m_config.c
@@ -1055,6 +1055,22 @@
//
CONFIG_VARIABLE_INT(mouseb_nextweapon),
+
+ //!
+ // @game heretic
+ //
+ // Mouse button to move to the left in the inventory.
+ //
+
+ CONFIG_VARIABLE_INT(mouseb_invleft),
+
+ //!
+ // @game heretic
+ //
+ // Mouse button to move to the right in the inventory.
+ //
+
+ CONFIG_VARIABLE_INT(mouseb_invright),
//!
// If non-zero, double-clicking a mouse button acts like pressing
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -116,8 +116,9 @@
int mousebprevweapon = -1;
int mousebnextweapon = -1;
+int mousebinvleft = -1;
+int mousebinvright = -1;
-
int key_message_refresh = KEY_ENTER;
int key_pause = KEY_PAUSE;
int key_demo_quit = 'q';
@@ -264,6 +265,9 @@
M_BindIntVariable("key_invleft", &key_invleft);
M_BindIntVariable("key_invright", &key_invright);
M_BindIntVariable("key_useartifact", &key_useartifact);
+
+ M_BindIntVariable("mouseb_invleft", &mousebinvleft);
+ M_BindIntVariable("mouseb_invright", &mousebinvright);
M_BindIntVariable("key_arti_quartz", &key_arti_quartz);
M_BindIntVariable("key_arti_urn", &key_arti_urn);
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -145,6 +145,8 @@
extern int mousebprevweapon;
extern int mousebnextweapon;
+extern int mousebinvleft;
+extern int mousebinvright;
extern int joybfire;
extern int joybstrafe;
--- a/src/setup/mouse.c
+++ b/src/setup/mouse.c
@@ -46,7 +46,9 @@
&mousebuse,
&mousebjump,
&mousebprevweapon,
- &mousebnextweapon
+ &mousebnextweapon,
+ &mousebinvleft,
+ &mousebinvright
};
static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable))
@@ -102,6 +104,12 @@
AddMouseControl(buttons_table, "Previous weapon", &mousebprevweapon);
AddMouseControl(buttons_table, "Strafe on", &mousebstrafe);
AddMouseControl(buttons_table, "Next weapon", &mousebnextweapon);
+
+ if (gamemission == heretic)
+ {
+ AddMouseControl(buttons_table, "Inventory left", &mousebinvleft);
+ AddMouseControl(buttons_table, "Inventory right", &mousebinvright);
+ }
if (gamemission == hexen || gamemission == strife)
{