From 56fb41845a07f9beeb3f2ecb7c85ae70897eb796 Mon Sep 17 00:00:00 2001 From: "Fillip H." <9424286+filliph@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:36:24 +0300 Subject: [PATCH] feat: TomTom shim update & new globals - Add new functions to TomTom shim - Add new global functions to make waypoint management easier - Add new function for fetching the nearest pin --- modules/pins/pinManager.lua | 8 +++++++- modules/providers/global.lua | 19 +++++++++++++++++++ modules/providers/tomtom.lua | 13 +++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/pins/pinManager.lua b/modules/pins/pinManager.lua index eabb3295..0589e3ce 100644 --- a/modules/pins/pinManager.lua +++ b/modules/pins/pinManager.lua @@ -28,7 +28,7 @@ function PinManager:GetPositionStringForPin(pinData) return string.format("%s:%.4f:%.4f", pinData.mapID, pinData.x, pinData.y) end -function PinManager:TrackNearestPin() +function PinManager:GetNearestPin() local nearestPin = nil local playerX, playerY, playerMap = Blizz:GetPlayerMapPosition() if not playerMap or not playerX or not playerY then return end @@ -42,6 +42,12 @@ function PinManager:TrackNearestPin() } end end + + return nearestPin +end + +function PinManager:TrackNearestPin() + local nearestPin = self:GetNearestPin() if nearestPin then nearestPin.pin:Track() end diff --git a/modules/providers/global.lua b/modules/providers/global.lua index e2fc79cc..8263ac61 100644 --- a/modules/providers/global.lua +++ b/modules/providers/global.lua @@ -12,5 +12,24 @@ end globalMapPinEnhanced.AddWaypoint = function(_, pinData) PinManager:AddPin(pinData) end +globalMapPinEnhanced.TrackNearestPin = function() + PinManager:TrackNearestPin() +end +globalMapPinEnhanced.SetClosestWaypoint = function() + PinManager:TrackNearestPin() +end +globalMapPinEnhanced.GetNearestPin = function() + return PinManager:GetNearestPin() +end +globalMapPinEnhanced.GetClosestWaypoint = function() + return PinManager:GetNearestPin() +end +globalMapPinEnhanced.ClearAllPins = function() + PinManager:ClearPins() +end +globalMapPinEnhanced.ClearAllWaypoints = function() + PinManager:ClearPins() +end + ---@type table _G[MapPinEnhanced.addonName] = globalMapPinEnhanced diff --git a/modules/providers/tomtom.lua b/modules/providers/tomtom.lua index 4acb1354..a359f8da 100644 --- a/modules/providers/tomtom.lua +++ b/modules/providers/tomtom.lua @@ -54,6 +54,19 @@ local function AddTomTomShim() setTracked = true, }) end + + TomTom.SetClosestWaypoint = function(_, ...) + PinManager:TrackNearestPin() + end + + TomTom.GetClosestWaypoint = function(_, ...) + return PinManager:GetNearestPin() + end + + TomTom.ClearAllWaypoints = function(_, ...) + PinManager:ClearPins() + end + _G.TomTom = TomTom end