Quantcast

Merge pull request #20 from tekHudson/rename-to-width-height

Tek Hudson [01-10-20 - 15:29]
Merge pull request #20 from tekHudson/rename-to-width-height

Rename xvar and yvar to width and height, remove dontMoveFrame
Filename
DruidBar.lua
Options.lua
diff --git a/DruidBar.lua b/DruidBar.lua
index 5fbc1bc..4083d85 100644
--- a/DruidBar.lua
+++ b/DruidBar.lua
@@ -152,8 +152,22 @@ function Load_Variables(className)
 	if not DruidBarKey.color then DruidBarKey.color = {0,0,1,1}; end
 	if not DruidBarKey.bordercolor then DruidBarKey.bordercolor = {1,1,1,1}; end
 	if not DruidBarKey.bgcolor then DruidBarKey.bgcolor = {0,0,0,0.5}; end
-	if(not DruidBarKey.tempW or DruidBarKey.tempW == 0) then DruidBarKey.tempW = DruidBarKey.xvar; end
-	if(not DruidBarKey.tempH or DruidBarKey.tempH == 0) then DruidBarKey.tempH = DruidBarKey.yvar; end
+	if(not DruidBarKey.tempW or DruidBarKey.tempW == 0) then
+		if DruidBarKey.width < 0 then
+			DruidBarKey.tempW = DruidBarKey.width;
+		else
+			DruidBarKey.width = DruidBarKey.xvar;
+			DruidBarKey.tempW = DruidBarKey.xvar;
+		end
+	end
+	if(not DruidBarKey.tempH or DruidBarKey.tempH == 0) then
+		if DruidBarKey.height < 0 then
+			DruidBarKey.tempW = DruidBarKey.height;
+		else
+			DruidBarKey.height = DruidBarKey.yvar;
+			DruidBarKey.tempW = DruidBarKey.yvar;
+		end
+	end
 	if(not DruidBarKey.DontShiftBack) then DruidBarKey.DontShiftBack = false; end
 	if not DruidBarKey.bgstrata then DruidBarKey.bgstrata = "BORDER" end
 	if not DruidBarKey.manatexture then DruidBarKey.manatexture = "Interface\\TargetingFrame\\UI-StatusBar"; end
@@ -246,29 +260,29 @@ function dbarShow(frame)
 end

 function dbarLength()
-	if not DruidBarKey.xvar then DruidBarKey.xvar = 170; end
+	if not DruidBarKey.width then DruidBarKey.width = 170; end

-	if DruidBarFrame:GetWidth() ~= DruidBarKey.xvar then
-		DruidBarFrame:SetWidth(DruidBarKey.xvar);
-		DruidBarKey.xvar = DruidBarFrame:GetWidth();
+	if DruidBarFrame:GetWidth() ~= DruidBarKey.width then
+		DruidBarFrame:SetWidth(DruidBarKey.width);
+		DruidBarKey.width = DruidBarFrame:GetWidth();
 	end

-	DruidBarMana:SetWidth(DruidBarKey.xvar*0.95);
-	DruidBarManaBackground:SetWidth(DruidBarKey.xvar*0.95);
-	DruidBarDontMove:SetWidth(DruidBarKey.xvar*0.95);
+	DruidBarMana:SetWidth(DruidBarKey.width*0.95);
+	DruidBarManaBackground:SetWidth(DruidBarKey.width*0.95);
+	DruidBarDontMove:SetWidth(DruidBarKey.width*0.95);
 end

 function dbarHeight()
-	if not DruidBarKey.yvar then DruidBarKey.yvar = 18; end
+	if not DruidBarKey.height then DruidBarKey.height = 18; end

-	if DruidBarFrame:GetHeight() ~= DruidBarKey.yvar then
-		DruidBarFrame:SetHeight(DruidBarKey.yvar);
-		DruidBarKey.yvar = DruidBarFrame:GetHeight();
+	if DruidBarFrame:GetHeight() ~= DruidBarKey.height then
+		DruidBarFrame:SetHeight(DruidBarKey.height);
+		DruidBarKey.height = DruidBarFrame:GetHeight();
 	end

-	DruidBarMana:SetHeight(DruidBarKey.yvar*(2/3));
-	DruidBarManaBackground:SetHeight(DruidBarKey.yvar*(2/3));
-	DruidBarDontMove:SetHeight(DruidBarKey.yvar*(2/3));
+	DruidBarMana:SetHeight(DruidBarKey.height*(2/3));
+	DruidBarManaBackground:SetHeight(DruidBarKey.height*(2/3));
+	DruidBarDontMove:SetHeight(DruidBarKey.height*(2/3));
 end

 function Minimap_Button_Renderer()
@@ -580,11 +594,11 @@ function DruidBar_Enable_ChatCommandHandler(text)
 		DruidBarKey.Graphics = DruidBar_Toggle(DruidBarKey.Graphics, "DruidBar's visual data is");
 		DRUIDBAR_FrameSet();
 	elseif msg[1] == "width" and msg[2] and tonumber(msg[2]) then
-		DruidBarKey.xvar = tonumber(msg[2]);
+		DruidBarKey.width = tonumber(msg[2]);
 		DruidBar_Print("Width is now set to "..msg[2]);
 		DRUIDBAR_FrameSet();
 	elseif msg[1] == "height" and msg[2] and tonumber(msg[2]) then
-		DruidBarKey.yvar = tonumber(msg[2]);
+		DruidBarKey.height = tonumber(msg[2]);
 		DruidBar_Print("Height is now set to "..msg[2]);
 		DRUIDBAR_FrameSet();
 	elseif msg[1] == "hide" then
@@ -604,7 +618,7 @@ function DruidBar_Enable_ChatCommandHandler(text)
 		DRUIDBAR_FrameSet();
 	elseif msg[1] == "player" then
 		DruidBarKey.Player = DruidBar_Toggle(DruidBarKey.Player, "Showing the bar below the Player Frame is");
-		if DruidBarKey.Player then DruidBarKey.xvar = 150; DruidBarKey.yvar = 18; else DruidBarKey.xvar = 170; DruidBarKey.yvar = 18; end
+		if DruidBarKey.Player then DruidBarKey.width = 150; DruidBarKey.height = 18; else DruidBarKey.width = 170; DruidBarKey.height = 18; end
 		DRUIDBAR_FrameSet();
 	elseif msg[1] == "text" then
 		if not DruidBarKey.Text then DruidBarKey.Text = 0; DruidBar_Print("Original-Style text on!"); elseif DruidBarKey.Text == 0 then DruidBarKey.Text = 1; DruidBar_Print("New-Style text on!"); elseif DruidBarKey.Text == 1 then DruidBarKey.Text = nil; DruidBar_Print("Text removed."); end
diff --git a/Options.lua b/Options.lua
index 2704d92..466c427 100644
--- a/Options.lua
+++ b/Options.lua
@@ -16,15 +16,15 @@ end
 function DRUIDBAROptions_Width(self)
 	if ( DRUIDBAROptionsWidthEditBox:GetText() < "1" ) then
 		DRUIDBAROptionsWidthEditBox:SetText("170");
-		DruidBarKey.xvar = self:GetNumber();
-		DruidBarKey.tempW = DruidBarKey.xvar;
+		DruidBarKey.width = self:GetNumber();
+		DruidBarKey.tempW = DruidBarKey.width;
 	elseif( DRUIDBAROptionsWidthEditBox:GetText() > "9999" ) then
 		DRUIDBAROptionsWidthEditBox:SetText("9999");
-		DruidBarKey.xvar = self:GetNumber();
-		DruidBarKey.tempW = DruidBarKey.xvar;
+		DruidBarKey.width = self:GetNumber();
+		DruidBarKey.tempW = DruidBarKey.width;
 	else
-		DruidBarKey.xvar = self:GetNumber();
-		DruidBarKey.tempW = DruidBarKey.xvar;
+		DruidBarKey.width = self:GetNumber();
+		DruidBarKey.tempW = DruidBarKey.width;
 	end
 end

@@ -32,15 +32,15 @@ end
 function DRUIDBAROptions_Height(self)
 	if ( DRUIDBAROptionsHeightEditBox:GetText() < "1" ) then
 		DRUIDBAROptionsHeightEditBox:SetText("18");
-		DruidBarKey.yvar = self:GetNumber();
-		DruidBarKey.tempH = DruidBarKey.yvar;
+		DruidBarKey.height = self:GetNumber();
+		DruidBarKey.tempH = DruidBarKey.height;
 	elseif( DRUIDBAROptionsHeightEditBox:GetText() > "999" ) then
 		DRUIDBAROptionsHeightEditBox:SetText("999");
-		DruidBarKey.yvar = self:GetNumber();
-		DruidBarKey.tempH = DruidBarKey.yvar;
+		DruidBarKey.height = self:GetNumber();
+		DruidBarKey.tempH = DruidBarKey.height;
 	else
-		DruidBarKey.yvar = self:GetNumber();
-		DruidBarKey.tempH = DruidBarKey.yvar;
+		DruidBarKey.height = self:GetNumber();
+		DruidBarKey.tempH = DruidBarKey.height;
 	end
 end

@@ -112,8 +112,8 @@ function DRUIDBAROptions_Player()
 	DruidBarKey.Player = true;
 	DruidBarKey.Custom = false;
 	--Assign value that default to match player frame
-	DruidBarKey.xvar = 125;
-	DruidBarKey.yvar = 18;
+	DruidBarKey.width = 125;
+	DruidBarKey.height = 18;
 	DruidBarKey.Lock = true;
 	renderOptionsFrame();
 end
@@ -124,8 +124,8 @@ function DRUIDBAROptions_Custom()
 	DruidBarKey.Replace = false;
 	DruidBarKey.Player = false;
 	DruidBarKey.Lock = false;
-	DruidBarKey.xvar = DruidBarKey.tempW;
-	DruidBarKey.yvar = DruidBarKey.tempH;
+	DruidBarKey.width = DruidBarKey.tempW;
+	DruidBarKey.height = DruidBarKey.tempH;
 	renderOptionsFrame();
 end