changeset 0:06d230725448

Initial build of WhistleMaster
author Geoff Brock <mischivin@gmail.com>
date Mon, 24 Oct 2016 15:41:49 -0400
parents
children 7f6ef1723137
files WhistleMaster.lua WhistleMaster.toc WhistleMaster.xml
diffstat 3 files changed, 138 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WhistleMaster.lua	Mon Oct 24 15:41:49 2016 -0400
@@ -0,0 +1,88 @@
+
+function WM_Debug() 
+	print("debug text")
+end
+
+--indexes corrispond to map IDs that contain valid flight points for the Flight Masters Whistle
+local validIDs = { [1014] = true, [1015] = true, [1017] = true, [1018] = true, [1024] = true, [1033] = true, [1096] = true }
+
+local WhistleLoc = CreateFrame("FRAME", "WhistleLOC", WorldMapPOIFrame)
+WhistleLoc:SetSize(64, 64)
+WhistleLoc:SetPoint("CENTER", 0, 0)
+WhistleLoc:Show()
+
+--[[local Rotate = WhistleLoc:CreateTexture()
+Rotate:SetTexture("Interface\minimap\UI-Minimap-Ping-Rotate")
+Rotate:SetPoint("CENTER")
+Rotate:SetSize(48, 48)
+Rotate:SetVertexColor(0.9, 0.1, 0.1)
+
+local Ring = WhistleLoc:CreateTexture()
+Ring:SetTexture("Interface\minimap\UI-Minimap-Ping-Center")
+Ring:SetPoint("CENTER")
+Ring:SetSize(32, 32)
+Ring:SetVertexColor(0.9, 0.1, 0.1)]]
+
+
+
+
+local function GetDistance(nX, nY)
+	local pX, pY = GetPlayerMapPosition("player")
+
+	local dX = pX - nX
+    local dY = pY - nY
+ 
+	return math.sqrt( ( dX^2 ) + ( dY^2 ) )
+end
+
+local function GetNode()
+	local node
+	local distance
+	local index
+	for k = 1, GetNumMapLandmarks() do
+		local n = {}
+		n.type, n.name, n.description, n.textureIndex, n.x, n.y = GetMapLandmarkInfo(k)
+		if n.type == LE_MAP_LANDMARK_TYPE_TAXINODE then --LE_MAP_LANDMARK_TYPE_TAXINODE is a constant defined by Blizzard
+			local d = GetDistance(n.x, n.y)
+			if distance == nil or d < distance then
+				n.index = k
+				distance = d
+				node = n
+			end
+		end
+	end
+	print("The closest node is... " .. node.name)
+	return node
+end
+
+local function UpdateWhistleMaster()
+	if GetCurrentMapContinent() == 8 and validIDs[ select(1, GetCurrentMapAreaID() ) ] then
+		local closest = GetNode()
+		WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. closest.index, 0, 0)
+		WhistleLoc:Show()
+		WhistlePing.Ping:Play()
+	else
+		WhistleLoc:Hide()
+		WhistlePing.Ping:Stop()
+		print("wrong continent for whistle master")
+	end
+end
+
+local mapVisible = false
+
+local function EventHandler(self, event, ...)
+	if ( (event == "WORLD_MAP_UPDATE") and WorldMapFrame:IsVisible() ) then
+		mapVisible = true
+		UpdateWhistleMaster()
+	end
+	if ( (mapVisible) and not WorldMapFrame:IsVisible() ) then
+ 		mapVisible = false
+ 	end
+end
+
+
+
+local WhistleMaster = CreateFrame("FRAME", "WhistleMaster", WorldMapPOIFrame)
+WhistleMaster:RegisterEvent("WORLD_MAP_UPDATE")
+WhistleMaster:SetScript("OnEvent", EventHandler)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WhistleMaster.toc	Mon Oct 24 15:41:49 2016 -0400
@@ -0,0 +1,10 @@
+## Interface: 70000
+## Title: WhistleMaster
+## Notes: Shows you which flightmaster the Flight Master's Whistle will take you to when used.
+## Author: Vynn of Khadgar (US)
+## Version: 0.7.0.1
+## X-Email: mischivin@gmail.com
+## X-Category: 
+
+WhistleMaster.lua
+WhistleMaster.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WhistleMaster.xml	Mon Oct 24 15:41:49 2016 -0400
@@ -0,0 +1,40 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
+..\FrameXML\UI.xsd">
+<Frame name="WhistlePing" parent="WhistleLOC" hidden="false">
+	<Size x="64" y="64"/>
+	<Anchors>
+		<Anchor point="CENTER" relativeTo="WhistleLOC"/>
+	</Anchors>
+	<Layers>
+		<Layer level="OVERLAY">
+			<Texture parentKey="centerRing" file="Interface\minimap\UI-Minimap-Ping-Center">
+				<Size x="32" y="32"/>
+				<Color r="0" g="0.3" b="1" a="0.9"/>
+				<Anchors>
+					<Anchor point="CENTER"/>
+				</Anchors>
+			</Texture>
+			<Texture parentKey="rotatingRing" file="Interface\minimap\UI-Minimap-Ping-Rotate">
+				<Size x="48" y="48"/>
+				<Color r="0" g="0.3" b="1" a="0.9"/>
+				<Anchors>
+					<Anchor point="CENTER"/>
+				</Anchors>
+			</Texture>
+			<Texture parentKey="expandingRing" file="Interface\minimap\UI-Minimap-Ping-Expand">
+				<Size x="32" y="32"/>
+				<Color r="0" g="0.3" b="1" a="0.9"/>
+				<Anchors>
+					<Anchor point="CENTER"/>
+				</Anchors>
+			</Texture>
+		</Layer>
+	</Layers>
+	<Animations>
+		<AnimationGroup parentKey="Ping" looping="REPEAT">
+			<Rotation childKey="rotatingRing" degrees="-180" duration="1" order="1"/>
+			<Scale childKey="expandingRing" scaleX="1.5" scaleY="1.5" duration="1" order="1"/>
+		</AnimationGroup>
+	</Animations>
+</Frame>
+</Ui>
\ No newline at end of file