Quantcast

Fixed some bugs with frame placement

Steven Mey [12-02-19 - 22:52]
Fixed some bugs with frame placement
Filename
D2Minimap.lua
diff --git a/D2Minimap.lua b/D2Minimap.lua
index eb245af..4e6abd0 100644
--- a/D2Minimap.lua
+++ b/D2Minimap.lua
@@ -1,43 +1,66 @@
 D2Minimap = true

 D2MinimapSettings = {
-    ["Frames"] = {
-        ["Minimap"] = {
-            ["Shown"] = true,
-            ["Zoom"] = 5,
-            ["PlayerArrow"] = false,
-            ["MaskSquare"] = false,
-            ["Alpha"] = .1,
-        },
-        ["MinimapZoneTextButton"] = {
-            ["Alpha"] = .3,
-        },
-        ["MinimapBorderTop"] = {
-            ["Alpha"] = 1,
-        },
-        ["TimeManagerClockButton"] = {
-            ["Alpha"] = .3,
-        },
-        ["MiniMapWorldMapButton"] = {
-            ["Alpha"] = .8,
-        },
-        ["MiniMapTracking"] = {
-            ["Alpha"] = .2,
-        },
-        ["MiniMapMailFrame"] = {
-            ["Alpha"] = .5,
-        },
-        ["GarrisonLandingPageMinimapButton"] = {
-            ["Alpha"] = .2,
-        },
-    },
+	["Frames"] = {
+		["MinimapBorderTop"] = {
+			["Alpha"] = 1,
+			["Point"] = {
+			},
+		},
+		["MinimapZoneTextButton"] = {
+			["Alpha"] = 0.3,
+			["Point"] = {
+			},
+		},
+		["MiniMapWorldMapButton"] = {
+			["Alpha"] = 0.8,
+			["Point"] = {
+			},
+		},
+		["MiniMapTracking"] = {
+			["Alpha"] = 0.2,
+			["Point"] = {
+			},
+		},
+		["GarrisonLandingPageMinimapButton"] = {
+			["Alpha"] = 0.2,
+			["Point"] = {
+				["yOfs"] = 0,
+				["xOfs"] = 0,
+				["point"] = "TOPRIGHT",
+				["relativePoint"] = "TOPRIGHT",
+			},
+		},
+		["MiniMapMailFrame"] = {
+			["Alpha"] = 0.5,
+			["Point"] = {
+			},
+		},
+		["TimeManagerClockButton"] = {
+			["Alpha"] = 0.3,
+			["Point"] = {
+			},
+		},
+		["Minimap"] = {
+			["Zoom"] = 5,
+			["Point"] = {
+			},
+			["Shown"] = true,
+			["PlayerArrow"] = false,
+			["Alpha"] = 0.1,
+			["MaskSquare"] = false,
+		},
+	},
 }

 function D2Minimap_load()
     for frame, ftable in pairs(D2MinimapSettings["Frames"]) do
-        pcall(function()
+        pcall(function()
             _G[frame]:SetAlpha(ftable["Alpha"])
+        end)
+        pcall(function()
             p = ftable["Point"]
+            _G[frame]:ClearAllPoints()
             _G[frame]:SetPoint(p.point, p.relativeTo, p.relativePoint, p.xOfs, p.yOfs)
         end)
     end
@@ -45,14 +68,17 @@ end

 function D2Minimap_save()
     for frame, ftable in pairs(D2MinimapSettings["Frames"]) do
-        if not frame == "" then
+        if frame ~= "" then
+            ftable["Alpha"] = _G[frame]:GetAlpha()
             pcall(function()
-                ftable["Alpha"] = _G[frame]:GetAlpha()
                 p = {}
                 p.point, p.relativeTo, p.relativePoint, p.xOfs, p.yOfs = _G[frame]:GetPoint()
+                pcall(function()
+                    p.relativeFrame = p.relativeTo:GetName()
+                end)
                 ftable["Point"] = p
             end)
-        end
+        end
     end
     D2MinimapSettings["Frames"]["Minimap"]["Shown"] = Minimap:IsShown()
     D2MinimapSettings["Frames"]["Minimap"]["Zoom"] = Minimap:GetZoom()
@@ -147,7 +173,6 @@ local function D2Minimap_init(self, event, addon, ...)
             Minimap:Hide()
         end
     end
-
     if (event == "ADDON_LOADED") then
         D2Minimap_load()
     end