Quantcast

Make sure that arrow and block positions are always valid and reset properly.

Ludovicus [08-13-19 - 22:56]
Make sure that arrow and block positions are always valid and reset properly.
Filename
TomTom.lua
TomTom_Config.lua
TomTom_CrazyArrow.lua
diff --git a/TomTom.lua b/TomTom.lua
index b93a145..a1a659c 100755
--- a/TomTom.lua
+++ b/TomTom.lua
@@ -428,12 +428,12 @@ function TomTom:ShowHideCoordBlock()

         -- Set the block position
         TomTomBlock:ClearAllPoints()
-        if self.profile.block.position then
-            local pos = self.profile.block.position
-            TomTomBlock:SetPoint(pos[1], UIParent, pos[3], pos[4], pos[5])
-        else
-            TomTomBlock:SetPoint("TOP", UIParent, "BOTTOM", -20, -10)
+        if not self.profile.block.position then
+            self.profile.block.position = {"CENTER", nil, "CENTER", 0, -100}
         end
+        local pos = self.profile.block.position
+        TomTomBlock:SetPoint(pos[1], UIParent, pos[3], pos[4], pos[5])
+

         -- Update the font size
         local font,height = TomTomBlock.Text:GetFont()
diff --git a/TomTom_Config.lua b/TomTom_Config.lua
index 4845e29..aed9674 100755
--- a/TomTom_Config.lua
+++ b/TomTom_Config.lua
@@ -145,7 +145,9 @@ local function createconfig()
 						func = function()
 							if TomTomBlock then
 								TomTomBlock:ClearAllPoints()
-								TomTomBlock:SetPoint("TOP", Minimap, "BOTTOM", -20, -10)
+								local pos = {"CENTER", nil, "CENTER", 0, -100}
+								set({arg="block.position"}, pos)
+								TomTomBlock:SetPoint(pos[1], UIParent, pos[3], pos[4], pos[5])
 							end
 						end,
 					},
@@ -344,7 +346,9 @@ local function createconfig()
 						desc = L["Resets the position of the waypoint arrow if its been dragged off screen"],
 						func = function()
 							TomTomCrazyArrow:ClearAllPoints()
-							TomTomCrazyArrow:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
+							local pos = {"CENTER", nil , "CENTER", 0, 0}
+							set({arg="arrow.position"}, pos)
+							TomTomCrazyArrow:SetPoint(pos[1], UIParent, pos[3], pos[4], pos[5])
 						end,
 					},
 				}
diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua
index 6525832..769435c 100755
--- a/TomTom_CrazyArrow.lua
+++ b/TomTom_CrazyArrow.lua
@@ -75,12 +75,11 @@ local function OnEvent(self, event, ...)
 	end
 	if (event == "PLAYER_ENTERING_WORLD") then
         wayframe:ClearAllPoints()
-        if TomTom.profile.arrow.position then
-            local pos = TomTom.profile.arrow.position
-            wayframe:SetPoint(pos[1], UIParent, pos[3], pos[4], pos[5])
-        else
-            wayframe:SetPoint("CENTER", 0, 0)
+        if not TomTom.profile.arrow.position then
+            TomTom.profile.arrow.position = {"CENTER", nil , "CENTER", 0, 0}
         end
+        local pos = TomTom.profile.arrow.position
+        wayframe:SetPoint(pos[1], UIParent, pos[3], pos[4], pos[5])
     end
 end