Quantcast

Rename xvar and yvar to width and height, remove dontMoveFrame

Tek Hudson [01-10-20 - 15:21]
Rename xvar and yvar to width and height, remove dontMoveFrame
Filename
DruidBar.lua
DruidBar.xml
Options.lua
diff --git a/DruidBar.lua b/DruidBar.lua
index 951aa76..75b473e 100644
--- a/DruidBar.lua
+++ b/DruidBar.lua
@@ -150,8 +150,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
@@ -244,29 +258,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()
@@ -309,12 +323,12 @@ function DruidBar_MainGraphics()

 		-- Set the position lock and dragability
 		if DruidBarKey.Lock then
-			dbarShow(DruidBarDontMove);
+			-- dbarShow(DruidBarDontMove);
 			DruidBarFrame:EnableMouse(0);
 			DruidBarFrame:SetMovable(false)
 			DruidBarFrame:RegisterForDrag()
 		else
-			dbarHide(DruidBarDontMove);
+			-- dbarHide(DruidBarDontMove);
 			DruidBarFrame:EnableMouse(1);
 			DruidBarFrame:SetMovable(true)
 			DruidBarFrame:RegisterForDrag("LeftButton")
@@ -323,7 +337,7 @@ function DruidBar_MainGraphics()
 		end
 	else
 		dbarHide(DruidBarFrame);
-		dbarHide(DruidBarDontMove);
+		-- dbarHide(DruidBarDontMove);
 	end
 end

@@ -331,9 +345,9 @@ function DruidBar_TextRenderer()
 	dbarHide(DruidBarTextLeft);
 	dbarHide(DruidBarTextCenter);
 	dbarHide(DruidBarTextRight);
-
+ -- and MouseIsOver(DruidBarDontMove)
 	-- Text options --
-	if DruidBarKey.Text or (not DruidBarKey.Text and MouseIsOver(DruidBarDontMove)) then
+	if DruidBarKey.Text or (not DruidBarKey.Text) then
 		if DruidBarKey.Percent then
 			if DruidBarKey.Percent == 0 then -- Numbers
 				dbarShow(DruidBarTextCenter);
@@ -385,7 +399,7 @@ function DruidBar_ReplaceGraphics()
 	if UnitPowerType("player") ~= 0 then
 		dbarShow(DruidBarFrame);
 		dbarHide(DruidBarManaBackground);
-		dbarHide(DruidBarDontMove);
+		-- dbarHide(DruidBarDontMove);
 		dbarHide(DruidBarBorder);
 		dbarHide(DruidBarTextLeft);
 		dbarHide(DruidBarTextCenter);
@@ -578,11 +592,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
@@ -602,7 +616,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/DruidBar.xml b/DruidBar.xml
index a65c630..0296659 100644
--- a/DruidBar.xml
+++ b/DruidBar.xml
@@ -115,7 +115,7 @@
 		</Scripts>
 	</Frame>

-	<Button name="DruidBarDontMove" frameStrata="TOOLTIP" toplevel="true" parent="DruidBarFrame" enableMouse="false" movable="false" hidden="true">
+	<!-- <Button name="DruidBarDontMove" frameStrata="TOOLTIP" toplevel="true" parent="DruidBarFrame" enableMouse="false" movable="false" hidden="true">
 		<Size>
 			<AbsDimension x="170" y="18"/>
 		</Size>
@@ -127,7 +127,7 @@
 				</Offset>
 			</Anchor>
 		</Anchors>
-	</Button>
+	</Button> -->

 	<Frame name="DruidBarReplaceText" frameStrata="LOW" enableMouse="true" movable="false" parent="UIParent" hidden="true">
 		<Size>
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