Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion TheForceEngine/TFE_DarkForces/GameUI/pda.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <cstring>

#include <SDL.h>
#include "pda.h"
#include "menu.h"
#include "missionBriefing.h"
Expand Down Expand Up @@ -103,6 +103,8 @@ namespace TFE_DarkForces

static s32 s_briefingMaxY;
static s16 s_briefY;
static s32 mouseOldPosX = 0, mouseOldPosZ = 0;
static bool mouseMoveReset = true;

void pda_handleInput();
void pda_drawCommonButtons();
Expand Down Expand Up @@ -350,6 +352,32 @@ namespace TFE_DarkForces
// Ensure that mouse movements are not lost between updates.
pda_handleMouseAccum(&wdx, &wdy);

// Handle Mouse Panning
if (TFE_Input::mouseDown(MBUTTON_LEFT))
{
s32 mouseX, mouseZ;
SDL_GetMouseState(&mouseX, &mouseZ);

// Calculate deltas
fixed16_16 deltaX = (mouseX - mouseOldPosX) << 16;
fixed16_16 deltaZ = (mouseZ - mouseOldPosZ) << 16;

mouseOldPosX = mouseX;
mouseOldPosZ = mouseZ;

// Don't bother if this is the first time
if (!mouseMoveReset)
{
automap_updateDeltaCoords(deltaX, deltaZ);
}
mouseMoveReset = false;
}
else
{
// Mouse Up - reset the offsets.
mouseMoveReset = true;
}

if (TFE_Input::mousePressed(MBUTTON_LEFT) || s_simulatePressed >= 0 || wdy)
{
s_buttonPressed = -1;
Expand Down
7 changes: 7 additions & 0 deletions TheForceEngine/TFE_DarkForces/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace TFE_DarkForces
void automap_drawSector(RSector* sector);
void automap_drawPlayer(s32 layer);
void automap_drawSectors();
void automap_updateDeltaCoords(s32 x, s32 z);

void automap_serialize(Stream* stream)
{
Expand Down Expand Up @@ -153,6 +154,12 @@ namespace TFE_DarkForces
}
}

void automap_updateDeltaCoords(s32 x, s32 z)
{
s_mapX1 -= div16(x, s_screenScale);
s_mapZ1 += div16(z, s_screenScale);
}

void automap_updateMapData(MapUpdateID id)
{
switch (id)
Expand Down
1 change: 1 addition & 0 deletions TheForceEngine/TFE_DarkForces/automap.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace TFE_DarkForces
void automap_resetScale();
void automap_draw(u8* framebuffer);
void automap_setPdaActive(JBool enable);
void automap_updateDeltaCoords(s32 x, s32 z);

s32 automap_getLayer();
void automap_setLayer(s32 layer);
Expand Down