Quantcast

-Updated RestoreLayout and SaveLayout to be more uniform with the rest of my addons.

Xruptor [04-18-12 - 15:15]
-Updated RestoreLayout and SaveLayout to be more uniform with the rest of my addons.
Filename
XanReputation.lua
XanReputation.toc
diff --git a/XanReputation.lua b/XanReputation.lua
index ac97c45..9240931 100644
--- a/XanReputation.lua
+++ b/XanReputation.lua
@@ -171,62 +171,49 @@ function f:UpdateREP_Frame()
 end

 function f:SaveLayout(frame)
-
+	if type(frame) ~= "string" then return end
+	if not _G[frame] then return end
 	if not XanREP_DB then XanREP_DB = {} end
+
+	local opt = XanREP_DB[frame] or nil

-	local opt = XanREP_DB[frame] or nil;
-
-	if opt == nil then
+	if not opt then
 		XanREP_DB[frame] = {
 			["point"] = "CENTER",
 			["relativePoint"] = "CENTER",
-			["PosX"] = 0,
-			["PosY"] = 0,
+			["xOfs"] = 0,
+			["yOfs"] = 0,
 		}
-		opt = XanREP_DB[frame];
+		opt = XanREP_DB[frame]
+		return
 	end

-	local f = getglobal(frame);
-	local scale = f:GetEffectiveScale();
-	opt.PosX = f:GetLeft() * scale;
-	opt.PosY = f:GetTop() * scale;
-
+	local point, relativeTo, relativePoint, xOfs, yOfs = _G[frame]:GetPoint()
+	opt.point = point
+	opt.relativePoint = relativePoint
+	opt.xOfs = xOfs
+	opt.yOfs = yOfs
 end

 function f:RestoreLayout(frame)
+	if type(frame) ~= "string" then return end
+	if not _G[frame] then return end
+	if not XanREP_DB then XanREP_DB = {} end

-	if not XanREP_DB then XanREP_DB = {} end
-
-	local f = getglobal(frame);
-	local opt = XanREP_DB[frame] or nil;
+	local opt = XanREP_DB[frame] or nil

-	if opt == nil then
+	if not opt then
 		XanREP_DB[frame] = {
 			["point"] = "CENTER",
 			["relativePoint"] = "CENTER",
-			["PosX"] = 0,
-			["PosY"] = 0,
+			["xOfs"] = 0,
+			["yOfs"] = 0,
 		}
-		opt = XanREP_DB[frame];
+		opt = XanREP_DB[frame]
 	end

-	local x = opt.PosX;
-	local y = opt.PosY;
-	local s = f:GetEffectiveScale();
-
-	if (not x or not y) or (x==0 and y==0) then
-		f:ClearAllPoints();
-		f:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
-		return
-	end
-
-	--calculate the scale
-	x,y = x/s,y/s;
-
-	--set the location
-	f:ClearAllPoints();
-	f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x, y);
-
+	_G[frame]:ClearAllPoints()
+	_G[frame]:SetPoint(opt.point, UIParent, opt.relativePoint, opt.xOfs, opt.yOfs)
 end

 function f:BackgroundToggle(switch)
diff --git a/XanReputation.toc b/XanReputation.toc
index 8d7c4eb..6db0261 100644
--- a/XanReputation.toc
+++ b/XanReputation.toc
@@ -2,7 +2,7 @@
 ## Title: xanReputation
 ## Notes: A small window display current reputation xp
 ## Author: Xruptor
-## Version: 1.9.1
+## Version: 1.9.2
 ## SavedVariablesPerCharacter: XanREP_DB

 libs\LibStub.lua