Quantcast

Another in restricted area fix this time for minimap coords Previous commit fixes 369 which is similar issues

Repooc [10-27-16 - 00:15]
Another in restricted area fix this time for minimap coords Previous commit fixes 369  which is similar issues
Filename
ElvUI_SLE/modules/minimap/minimapcoords.lua
diff --git a/ElvUI_SLE/modules/minimap/minimapcoords.lua b/ElvUI_SLE/modules/minimap/minimapcoords.lua
index 3985666..be1e971 100644
--- a/ElvUI_SLE/modules/minimap/minimapcoords.lua
+++ b/ElvUI_SLE/modules/minimap/minimapcoords.lua
@@ -6,6 +6,8 @@ local _G = _G
 local cluster = _G["MinimapCluster"]
 local UIFrameFadeIn = UIFrameFadeIn

+MM.RestrictedArea = false
+
 local function HideMinimap()
 	cluster:Hide()
 end
@@ -18,8 +20,8 @@ end

 local function CreateCoords()
 	local x, y = T.GetPlayerMapPosition("player")
-	x = T.format(E.db.sle.minimap.coords.format, x * 100)
-	y = T.format(E.db.sle.minimap.coords.format, y * 100)
+	if x then x = T.format(E.db.sle.minimap.coords.format, x * 100) else x = "0" end
+	if y then y = T.format(E.db.sle.minimap.coords.format, y * 100) else y = "0" end

 	return x, y
 end
@@ -27,11 +29,14 @@ end
 function MM:UpdateCoords(elapsed)
 	MM.coordspanel.elapsed = (MM.coordspanel.elapsed or 0) + elapsed
 	if MM.coordspanel.elapsed < E.db.sle.minimap.coords.throttle then return end
-
-	local x, y = CreateCoords()
-	if x == "0" or x == "0.0" or x == "0.00" then x = "-" end
-	if y == "0" or y == "0.0" or y == "0.00" then y = "-" end
-	MM.coordspanel.Text:SetText(x.." , "..y)
+	if not MM.RestrictedArea then
+		local x, y = CreateCoords()
+		if x == "0" or x == "0.0" or x == "0.00" then x = "-" end
+		if y == "0" or y == "0.0" or y == "0.00" then y = "-" end
+		MM.coordspanel.Text:SetText(x.." , "..y)
+	else
+		MM.coordspanel.Text:SetText("-")
+	end
 	MM:CoordsSize()
 	MM.coordspanel.elapsed = 0
 end
@@ -87,6 +92,15 @@ function MM:CreateCoordsFrame()
 	MM:UpdateCoordinatesPosition()
 end

+function MM:PLAYER_ENTERING_WORLD()
+	local x = T.GetPlayerMapPosition("player")
+	if not x then
+		MM.RestrictedArea = true
+	else
+		MM.RestrictedArea = false
+	end
+end
+
 function MM:UpdateSettings()
 	if E.db.sle.minimap.alpha then E.db.sle.minimap.alpha = nil end
 	if not MM.coordspanel then
@@ -110,6 +124,7 @@ end
 function MM:Initialize()
 	if not SLE.initialized or not E.private.general.minimap.enable then return end

+	self:RegisterEvent("PLAYER_ENTERING_WORLD")
 	hooksecurefunc(M, 'UpdateSettings', MM.UpdateSettings)

 	MM:UpdateSettings()