Quantcast

Add a Minimap Button

Tek Hudson [08-10-19 - 17:32]
Add a Minimap Button
Filename
DruidBar.lua
DruidBar.xml
Options.lua
diff --git a/DruidBar.lua b/DruidBar.lua
index 475236d..0cdec50 100644
--- a/DruidBar.lua
+++ b/DruidBar.lua
@@ -14,6 +14,7 @@ function DruidBar_OnLoad()
 	DruidBarUpdateFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
 	DruidBarUpdateFrame:RegisterEvent("UNIT_INVENTORY_CHANGED");
 	DruidBarUpdateFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORMS");
+
 	SlashCmdList["DRUIDBARSLASH"] = DruidBar_Enable_ChatCommandHandler;
 	SLASH_DRUIDBARSLASH1 = "/dbar";
 	SLASH_DRUIDBARSLASH2 = "/druidbar";
@@ -1000,3 +1001,7 @@ function DruidBar_ChangeBestForm()
 		UIErrorsFrame.AddMessage = UIErrorsFrame.realEcho;
 	end
 end
+
+function DruidBar_MinimapButton_OnClick()
+	DRUIDBAROptionsFrame_Toggle();
+end
diff --git a/DruidBar.xml b/DruidBar.xml
index 83519a8..81596c6 100644
--- a/DruidBar.xml
+++ b/DruidBar.xml
@@ -84,23 +84,23 @@
 						self:SetFrameLevel("1");
 					</OnLoad>
 					<OnMouseDown>
-					  if button == "LeftButton" and not self.isMoving then
-					   self:GetParent():StartMoving();
-					   self.isMoving = true;
-					  end
-					 </OnMouseDown>
-					 <OnMouseUp>
-					  if button == "LeftButton" and self.isMoving then
-					   self:GetParent():StopMovingOrSizing();
-					   self.isMoving = false;
-					  end
-					 </OnMouseUp>
-					 <OnHide>
-					  if self.isMoving then
-					   self:GetParent():StopMovingOrSizing();
-					   self.isMoving = false;
-					  end
-					 </OnHide>
+						if button == "LeftButton" and not self.isMoving then
+						self:GetParent():StartMoving();
+						self.isMoving = true;
+						end
+					</OnMouseDown>
+					<OnMouseUp>
+						if button == "LeftButton" and self.isMoving then
+						self:GetParent():StopMovingOrSizing();
+						self.isMoving = false;
+						end
+					</OnMouseUp>
+					<OnHide>
+						if self.isMoving then
+						self:GetParent():StopMovingOrSizing();
+						self.isMoving = false;
+						end
+					</OnHide>
 				</Scripts>
 			</StatusBar>
 		</Frames>
@@ -112,7 +112,7 @@
 			<OnDragStart>self:StartMoving();</OnDragStart>
 			<OnDragStop>self:StopMovingOrSizing();</OnDragStop>
 		</Scripts>
-  </Frame>
+	</Frame>

 	<Frame name="DruidBarUpdateFrame">
 		<Scripts>
@@ -122,7 +122,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="160" y="18"/>
 		</Size>
@@ -134,7 +134,62 @@
 				</Offset>
 			</Anchor>
 		</Anchors>
-  </Button>
+	</Button>
+
+	<Button name="DruidBar_MinimapButton" parent="Minimap" enableMouse="true" movable="true" hidden="false">
+		<Size>
+			<AbsDimension x="33" y="33"/>
+		</Size>
+
+		<Anchors>
+			<Anchor point="TOPLEFT"/>
+		</Anchors>
+
+		<Layers>
+			<Layer level="BACKGROUND">
+				<Texture name="DruidBar_MinimapButton_Icon" file="Interface\Icons\ABILITY_DRUID_DEMORALIZINGROAR">
+					<Size>
+						<AbsDimension x="21" y="21"/>
+					</Size>
+					<Anchors>
+						<Anchor point="TOPLEFT">
+							<Offset>
+								<AbsDimension x="7" y="-6"/>
+							</Offset>
+						</Anchor>
+					</Anchors>
+				</Texture>
+			</Layer>
+
+			<Layer level="OVERLAY">
+				<Texture file="Interface\Minimap\MiniMap-TrackingBorder">
+					<Size>
+						<AbsDimension x="56" y="56"/>
+					</Size>
+					<Anchors>
+						<Anchor point="TOPLEFT"/>
+					</Anchors>
+				</Texture>
+			</Layer>
+		</Layers>
+
+		<HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>
+
+		<Scripts>
+			<OnLoad>
+				self:RegisterForDrag("LeftButton");
+			</OnLoad>
+			<OnDragStart>
+				self:StartMoving();
+			</OnDragStart>
+			<OnDragStop>
+				self:StopMovingOrSizing();
+			</OnDragStop>
+			<OnClick>
+				DruidBar_MinimapButton_OnClick()
+			</OnClick>
+		</Scripts>
+	</Button>

 	<Frame name="DruidBarReplaceText" frameStrata="LOW" enableMouse="true" movable="true" parent="UIParent" hidden="true">
 		<Size>
@@ -149,7 +204,7 @@
 			</Anchor>
 		</Anchors>

-    <Layers>
+		<Layers>
 			<Layer level="FOREGROUND">
 				<FontString name="DEnergyText" inherits="GameFontNormalSmall" wraponspaces="true">
 					<Size>
@@ -191,6 +246,6 @@
 					</Anchors>
 				</FontString>
 			</Layer>
-    </Layers>
-  </Frame>
+		</Layers>
+	</Frame>
 </Ui>
diff --git a/Options.lua b/Options.lua
index 50be1ad..dd94806 100644
--- a/Options.lua
+++ b/Options.lua
@@ -1,3 +1,7 @@
+function DRUIDBAROptions_OnLoad()
+	UIPanelWindows['DRUIDBAROptionsFrame'] = {area = 'center', pushable = 0};
+end
+
 function DRUIDBAROptionsFrame_Toggle()
 	if(DRUIDBAROptionsFrame:IsVisible()) then
 		DRUIDBAROptionsFrame:Hide();
@@ -7,10 +11,6 @@ function DRUIDBAROptionsFrame_Toggle()
 	end
 end

-function DRUIDBAROptions_OnLoad()
-	UIPanelWindows['DRUIDBAROptionsFrame'] = {area = 'center', pushable = 0};
-end
-
 function DRUIDBAROptions_CheckWidth(self)
 	if ( DRUIDBAROptionsWidthEditBox:GetText() < "1" ) then
 		DRUIDBAROptionsWidthEditBox:SetText("170");
@@ -368,7 +368,6 @@ function DRUIDBAROptions_MessageTrav_OnClick()
 	end
 end

-
 function DRUIDBAROptions_MessageOOM_Initialize()
 	local info;
 	for i = 0, 3, 1 do