Quantcast

Allow user to set POI arrival distance

James Whitehead II [01-25-11 - 09:50]
Allow user to set POI arrival distance

This works for both the ping and the crazy arrow, and will apply to
auto-set waypoints as well as those set by clicking on the POI icon.
Filename
TomTom.lua
TomTom_Config.lua
TomTom_POIIntegration.lua
diff --git a/TomTom.lua b/TomTom.lua
index a28983d..ae9ab47 100755
--- a/TomTom.lua
+++ b/TomTom.lua
@@ -124,9 +124,10 @@ function TomTom:ADDON_LOADED(event, addon)
 					arrow_throttle = 0.1,
 				},
                 poi = {
-                    enable = false,
+                    enable = true,
                     modifier = "C",
-                    setClosest = false,
+                    setClosest = true,
+                    arrival = 0,
                 },
 			},
 		}
@@ -829,6 +830,14 @@ function TomTom:AddMFWaypoint(m, f, x, y, opts)
 	local cleardistance = self.profile.persistence.cleardistance
     local arrivaldistance = self.profile.arrow.arrival

+    -- Allow both of these to be overridde by options
+    if opts.cleardistance then
+        cleardistance = opts.cleardistance
+    end
+    if opts.arrivaldistance then
+        arrivaldistance = opts.arrivaldistance
+    end
+
     if cleardistance == arrivaldistance then
         callbacks.distance[cleardistance] = function(...)
             _both_clear_distance(...);
@@ -880,7 +889,7 @@ function TomTom:AddMFWaypoint(m, f, x, y, opts)
     -- No need to convert x and y because they're already 0-1 instead of 0-100
 	self:SetWaypoint(uid, callbacks, opts.minimap, opts.world)
 	if opts.crazy then
-		self:SetCrazyArrow(uid, self.profile.arrow.arrival, opts.title)
+		self:SetCrazyArrow(uid, arrivaldistance, opts.title)
 	end

     waypoints[m] = waypoints[m] or {}
diff --git a/TomTom_Config.lua b/TomTom_Config.lua
index 08eb0be..892005e 100644
--- a/TomTom_Config.lua
+++ b/TomTom_Config.lua
@@ -675,6 +675,14 @@ local function createconfig()
 				width = "double",
 				arg = "poi.setClosest",
 			},
+			arrival = {
+				order = 5,
+				type = "range",
+				name = L["\"Arrival Distance\""],
+				desc = L["This setting will control the distance at which the waypoint arrow switches to a downwards arrow, indicating you have arrived at your destination"],
+				min = 0, max = 150, step = 5,
+				arg = "poi.arrival",
+			},
 		},
 	} -- End POI Integration settings

diff --git a/TomTom_POIIntegration.lua b/TomTom_POIIntegration.lua
index f4b7e2f..d23d856 100644
--- a/TomTom_POIIntegration.lua
+++ b/TomTom_POIIntegration.lua
@@ -102,11 +102,12 @@ local function ObjectivesChanged()
             lastWaypoint = TomTom:AddMFWaypoint(map, floor, x, y, {
                 title = title,
                 persistent = false,
+                arrivaldistance = TomTom.profile.poi.arrival,
             })

             -- Check and see if the Crazy arrow is empty, and use it if so
             if TomTom:IsCrazyArrowEmpty() then
-                TomTom:SetCrazyArrow(lastWaypoint, TomTom.profile.arrow.arrival, title)
+                TomTom:SetCrazyArrow(lastWaypoint, TomTom.profile.poi.arrival, title)
             end
         end
     else
@@ -187,6 +188,7 @@ local function poi_OnClick(self, button)
     if not alreadySet then
         local uid = TomTom:AddMFWaypoint(m, f, x, y, {
             title = title,
+            arrivaldistance = TomTom.profile.poi.arrival,
         })
         poiclickwaypoints[key] = uid
     end