From 14ef1061a98685dca1c54d538c4943b213c99192 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:58:17 -0400 Subject: [PATCH 1/3] Adding Mouse panning to the PDA --- TheForceEngine/TFE_DarkForces/GameUI/pda.cpp | 30 +++++++++++++++++++- TheForceEngine/TFE_DarkForces/automap.cpp | 7 +++++ TheForceEngine/TFE_DarkForces/automap.h | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp b/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp index 31be38811..8076e276e 100644 --- a/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp +++ b/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp @@ -1,5 +1,5 @@ #include - +#include #include "pda.h" #include "menu.h" #include "missionBriefing.h" @@ -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(); @@ -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; diff --git a/TheForceEngine/TFE_DarkForces/automap.cpp b/TheForceEngine/TFE_DarkForces/automap.cpp index 1b73fcaa4..62a05b8c8 100644 --- a/TheForceEngine/TFE_DarkForces/automap.cpp +++ b/TheForceEngine/TFE_DarkForces/automap.cpp @@ -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) { @@ -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) diff --git a/TheForceEngine/TFE_DarkForces/automap.h b/TheForceEngine/TFE_DarkForces/automap.h index 8ba6f6146..5af5449b5 100644 --- a/TheForceEngine/TFE_DarkForces/automap.h +++ b/TheForceEngine/TFE_DarkForces/automap.h @@ -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); From 50d880a6b14c593a5ba117ce6165961503b08ac3 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:14:29 -0400 Subject: [PATCH 2/3] Switching to TFE_INPUT mouse position. --- TheForceEngine/TFE_DarkForces/GameUI/pda.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp b/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp index 8076e276e..b1df4caed 100644 --- a/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp +++ b/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp @@ -356,7 +356,7 @@ namespace TFE_DarkForces if (TFE_Input::mouseDown(MBUTTON_LEFT)) { s32 mouseX, mouseZ; - SDL_GetMouseState(&mouseX, &mouseZ); + TFE_Input::getMousePos(&mouseX, &mouseZ); // Calculate deltas fixed16_16 deltaX = (mouseX - mouseOldPosX) << 16; From bda14bc28b486a53c034c4c8f425474dc863a6d1 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:02:14 -0400 Subject: [PATCH 3/3] Removed SDL --- TheForceEngine/TFE_DarkForces/GameUI/pda.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp b/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp index b1df4caed..42a5a00f6 100644 --- a/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp +++ b/TheForceEngine/TFE_DarkForces/GameUI/pda.cpp @@ -1,5 +1,4 @@ #include -#include #include "pda.h" #include "menu.h" #include "missionBriefing.h"