shithub: choc

Download patch

ref: 529ad8fd4d3313a2d60dff0c513b621b7219c94f
parent: 036df9796a134357506f19e4513f1a1f4c165476
parent: 236bb3ae5ea98ca9fa6b6eb2a1b51717516b0647
author: Turo Lamminen <turol@users.noreply.github.com>
date: Wed Apr 27 14:06:11 EDT 2022

Merge pull request #1459 from mikeday0/hhmouseusearti

Heretic/Hexen: Add mouse button for "use artifact'

--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -423,7 +423,7 @@
     }
 
     // Use artifact key
-    if (gamekeydown[key_useartifact])
+    if (gamekeydown[key_useartifact] || mousebuttons[mousebuseartifact])
     {
         if (gamekeydown[key_speed] && !noartiskip)
         {
@@ -430,6 +430,7 @@
             if (players[consoleplayer].inventory[inv_ptr].type != arti_none)
             {
                 gamekeydown[key_useartifact] = false;
+                mousebuttons[mousebuseartifact] = false;
                 cmd->arti = 0xff;       // skip artifact code
             }
         }
@@ -840,7 +841,10 @@
 static void SetMouseButtons(unsigned int buttons_mask)
 {
     int i;
+    player_t *plr;
 
+    plr = &players[consoleplayer];
+
     for (i=0; i<MAX_MOUSE_BUTTONS; ++i)
     {
         unsigned int button_on = (buttons_mask & (1 << i)) != 0;
@@ -864,6 +868,14 @@
             else if (i == mousebinvright)
             {
                 InventoryMoveRight();
+            }
+            else if (i == mousebuseartifact)
+            {
+                if (!inventory)
+                {
+                    plr->readyArtifact = plr->inventory[inv_ptr].type;
+                }
+                usearti = true;
             }
         }
 
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -361,7 +361,7 @@
         look = TOCENTER;
     }
     // Use artifact key
-    if (gamekeydown[key_useartifact])
+    if (gamekeydown[key_useartifact] || mousebuttons[mousebuseartifact])
     {
         if (gamekeydown[key_speed] && artiskip)
         {
@@ -368,6 +368,7 @@
             if (players[consoleplayer].inventory[inv_ptr].type != arti_none)
             {                   // Skip an artifact
                 gamekeydown[key_useartifact] = false;
+                mousebuttons[mousebuseartifact] = false;
                 P_PlayerNextArtifact(&players[consoleplayer]);
             }
         }
@@ -805,7 +806,10 @@
 static void SetMouseButtons(unsigned int buttons_mask)
 {
     int i;
+    player_t *plr;
 
+    plr = &players[consoleplayer];
+
     for (i=0; i<MAX_MOUSE_BUTTONS; ++i)
     {
         unsigned int button_on = (buttons_mask & (1 << i)) != 0;
@@ -829,6 +833,14 @@
             else if (i == mousebinvright)
             {
                 InventoryMoveRight();
+            }
+            else if (i == mousebuseartifact)
+            {
+                if (!inventory)
+                {
+                    plr->readyArtifact = plr->inventory[inv_ptr].type;
+                }
+                usearti = true;
             }
         }
 
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1099,6 +1099,14 @@
     CONFIG_VARIABLE_INT(mouseb_invright),
 
     //!
+    // @game heretic hexen
+    //
+    // Mouse button to use artifact.
+    //
+
+    CONFIG_VARIABLE_INT(mouseb_useartifact),
+
+    //!
     // If non-zero, double-clicking a mouse button acts like pressing
     // the "use" key to use an object in-game, eg. a door or switch.
     //
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -122,6 +122,7 @@
 int mousebnextweapon = -1;
 int mousebinvleft = -1;
 int mousebinvright = -1;
+int mousebuseartifact = -1;
 
 int key_message_refresh = KEY_ENTER;
 int key_pause = KEY_PAUSE;
@@ -275,6 +276,7 @@
 
     M_BindIntVariable("mouseb_invleft", &mousebinvleft);
     M_BindIntVariable("mouseb_invright", &mousebinvright);
+    M_BindIntVariable("mouseb_useartifact", &mousebuseartifact);
 
     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
@@ -151,6 +151,7 @@
 extern int mousebnextweapon;
 extern int mousebinvleft;
 extern int mousebinvright;
+extern int mousebuseartifact;
 
 extern int joybfire;
 extern int joybstrafe;
--- a/src/setup/mouse.c
+++ b/src/setup/mouse.c
@@ -50,6 +50,7 @@
     &mousebspeed,
     &mousebinvleft,
     &mousebinvright,
+    &mousebuseartifact,
     &mousebturnleft,
     &mousebturnright,
 };
@@ -113,6 +114,7 @@
     {
       AddMouseControl(buttons_table, "Inventory left", &mousebinvleft);
       AddMouseControl(buttons_table, "Inventory right", &mousebinvright);
+      AddMouseControl(buttons_table, "Use artifact", &mousebuseartifact);
     }
 
     if (gamemission == hexen || gamemission == strife)