Skip to content

Commit

Permalink
scroll automap content with the mouse (proof of concept)
Browse files Browse the repository at this point in the history
Fixes #1729
  • Loading branch information
fabiangreffrath committed Jul 31, 2024
1 parent b7f1eba commit bfe0730
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bfe0730

Please sign in to comment.