Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Mouse scrolls automap #1729

Open
MrAlaux opened this issue Jun 7, 2024 · 2 comments · May be fixed by #1809
Open

[Feature] Mouse scrolls automap #1729

MrAlaux opened this issue Jun 7, 2024 · 2 comments · May be fixed by #1809

Comments

@MrAlaux
Copy link
Collaborator

MrAlaux commented Jun 7, 2024

It's a simple concept: if a certain button is held down while the automap is up, mouse movement will scroll the map instead of moving the player; a Scroll On button, similar to the existing Strafe On.

@fabiangreffrath
Copy link
Owner

Proof of concept, currently bound to the "strafe" key and limited to mouse movement:

diff --git a/src/am_map.c b/src/am_map.c
index eb08d3b3..33c0b894 100644
--- a/src/am_map.c
+++ b/src/am_map.c
@@ -28,6 +28,7 @@
 #include "doomdef.h"
 #include "doomstat.h"
 #include "doomtype.h"
+#include "g_input.h"
 #include "hu_stuff.h"
 #include "i_video.h"
 #include "m_config.h"
@@ -128,6 +129,8 @@ static int m_zoomin_mouse = M2_ZOOMIN;
 static int m_zoomout_mouse = M2_ZOOMOUT;
 static boolean mousewheelzoom;
 
+static boolean scrollmode;
+
 // translates between frame-buffer and map distances
 // [FG] fix int overflow that causes map and grid lines to disappear
 #define FTOM(x) ((((int64_t)(x)<<16)*scale_ftom)>>16)
@@ -485,6 +488,12 @@ static void AM_changeWindowLoc(void)
     incy = m_paninc.y;
   }
 
+  if (scrollmode)
+  {
+    m_paninc.x = 0;
+    m_paninc.y = 0;
+  }
+
   if (automaprotate)
   {
     AM_rotate(&incx, &incy, ANGLE_MAX - mapangle);
@@ -916,6 +925,10 @@ boolean AM_Responder
       automaprotate = !automaprotate;
       togglemsg("%s", automaprotate ? s_AMSTR_ROTATEON : s_AMSTR_ROTATEOFF);
     }
+    else if (M_InputActivated(input_strafe))
+    {
+      scrollmode = true;
+    }
     else
     {
       rc = false;
@@ -955,11 +968,25 @@ boolean AM_Responder
     {
       buttons_state[ZOOM_IN] = 0;
     }
+    else if (M_InputDeactivated(input_strafe))
+    {
+      scrollmode = false;
+    }
   }
 
   m_paninc.x = 0;
   m_paninc.y = 0;
 
+  if (scrollmode)
+  {
+    if (ev->type == ev_mouse)
+    {
+      m_paninc.x -= (int)G_CalcMouseSide(ev->data1) * MAPUNIT;
+      m_paninc.y += (int)G_CalcMouseVert(ev->data2) * MAPUNIT;
+      rc = true;
+    }
+  }
+
   if (!followplayer)
   {
     int scaled_f_paninc = (f_paninc * video.xscale) >> FRACBITS;

@fabiangreffrath
Copy link
Owner

Proof of concept, currently bound to the "strafe" key and limited to mouse movement:

I'm still unsure of the scroll direction. Should moving the mouse move the map itself or move the "window" through which we see the map? Similar to two-finger touchpad scrolling on Mac vs. Windows. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants