mischivin@0
|
1
|
mischivin@0
|
2 function WM_Debug()
|
mischivin@0
|
3 print("debug text")
|
mischivin@0
|
4 end
|
mischivin@0
|
5
|
mischivin@0
|
6 --indexes corrispond to map IDs that contain valid flight points for the Flight Masters Whistle
|
mischivin@3
|
7 --Doesn't work in 1021 (Broken Shore)
|
mischivin@3
|
8 WM_validIDs = { [1014] = true, [1015] = true, [1017] = true, [1018] = true, [1021] = false, [1024] = true, [1033] = true, [1096] = true }
|
mischivin@0
|
9
|
mischivin@0
|
10 local WhistleLoc = CreateFrame("FRAME", "WhistleLOC", WorldMapPOIFrame)
|
mischivin@0
|
11 WhistleLoc:SetSize(64, 64)
|
mischivin@0
|
12 WhistleLoc:SetPoint("CENTER", 0, 0)
|
mischivin@0
|
13 WhistleLoc:Show()
|
mischivin@0
|
14
|
mischivin@3
|
15 WM_ClosestNode = nil
|
mischivin@3
|
16
|
mischivin@0
|
17 --[[local Rotate = WhistleLoc:CreateTexture()
|
mischivin@0
|
18 Rotate:SetTexture("Interface\minimap\UI-Minimap-Ping-Rotate")
|
mischivin@0
|
19 Rotate:SetPoint("CENTER")
|
mischivin@0
|
20 Rotate:SetSize(48, 48)
|
mischivin@0
|
21 Rotate:SetVertexColor(0.9, 0.1, 0.1)
|
mischivin@0
|
22
|
mischivin@0
|
23 local Ring = WhistleLoc:CreateTexture()
|
mischivin@0
|
24 Ring:SetTexture("Interface\minimap\UI-Minimap-Ping-Center")
|
mischivin@0
|
25 Ring:SetPoint("CENTER")
|
mischivin@0
|
26 Ring:SetSize(32, 32)
|
mischivin@0
|
27 Ring:SetVertexColor(0.9, 0.1, 0.1)]]
|
mischivin@0
|
28
|
mischivin@0
|
29
|
mischivin@0
|
30
|
mischivin@0
|
31
|
mischivin@0
|
32 local function GetDistance(nX, nY)
|
mischivin@0
|
33 local pX, pY = GetPlayerMapPosition("player")
|
mischivin@0
|
34
|
mischivin@0
|
35 local dX = pX - nX
|
mischivin@0
|
36 local dY = pY - nY
|
mischivin@0
|
37
|
mischivin@0
|
38 return math.sqrt( ( dX^2 ) + ( dY^2 ) )
|
mischivin@0
|
39 end
|
mischivin@0
|
40
|
mischivin@0
|
41 local function GetNode()
|
mischivin@0
|
42 local node
|
mischivin@0
|
43 local distance
|
mischivin@0
|
44 local index
|
mischivin@0
|
45 for k = 1, GetNumMapLandmarks() do
|
mischivin@0
|
46 local n = {}
|
mischivin@0
|
47 n.type, n.name, n.description, n.textureIndex, n.x, n.y = GetMapLandmarkInfo(k)
|
mischivin@0
|
48 if n.type == LE_MAP_LANDMARK_TYPE_TAXINODE then --LE_MAP_LANDMARK_TYPE_TAXINODE is a constant defined by Blizzard
|
mischivin@0
|
49 local d = GetDistance(n.x, n.y)
|
mischivin@0
|
50 if distance == nil or d < distance then
|
mischivin@0
|
51 n.index = k
|
mischivin@0
|
52 distance = d
|
mischivin@0
|
53 node = n
|
mischivin@0
|
54 end
|
mischivin@0
|
55 end
|
mischivin@0
|
56 end
|
mischivin@0
|
57 return node
|
mischivin@0
|
58 end
|
mischivin@0
|
59
|
mischivin@0
|
60 local function UpdateWhistleMaster()
|
mischivin@3
|
61 if GetCurrentMapContinent() == 8 and WM_validIDs[ select(1, GetCurrentMapAreaID() ) ] and not GetNumDungeonMapLevels() then
|
mischivin@3
|
62 WM_ClosestNode = GetNode()
|
mischivin@3
|
63 WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. WM_ClosestNode.index, 0, 0)
|
mischivin@0
|
64 WhistleLoc:Show()
|
mischivin@0
|
65 WhistlePing.Ping:Play()
|
mischivin@3
|
66 return true
|
mischivin@0
|
67 else
|
mischivin@0
|
68 WhistleLoc:Hide()
|
mischivin@0
|
69 WhistlePing.Ping:Stop()
|
mischivin@3
|
70 return false
|
mischivin@0
|
71 end
|
mischivin@0
|
72 end
|
mischivin@0
|
73
|
mischivin@0
|
74 local mapVisible = false
|
mischivin@0
|
75
|
mischivin@0
|
76 local function EventHandler(self, event, ...)
|
mischivin@0
|
77 if ( (event == "WORLD_MAP_UPDATE") and WorldMapFrame:IsVisible() ) then
|
mischivin@0
|
78 mapVisible = true
|
mischivin@0
|
79 UpdateWhistleMaster()
|
mischivin@0
|
80 end
|
mischivin@0
|
81 if ( (mapVisible) and not WorldMapFrame:IsVisible() ) then
|
mischivin@0
|
82 mapVisible = false
|
mischivin@0
|
83 end
|
mischivin@3
|
84 if (event == "VARIABLES_LOADED") then
|
mischivin@3
|
85 UpdateWhistleMaster()
|
mischivin@3
|
86 end
|
mischivin@0
|
87 end
|
mischivin@0
|
88
|
mischivin@0
|
89 local WhistleMaster = CreateFrame("FRAME", "WhistleMaster", WorldMapPOIFrame)
|
mischivin@0
|
90 WhistleMaster:RegisterEvent("WORLD_MAP_UPDATE")
|
mischivin@3
|
91 WhistleMaster:RegisterEvent("VARIABLES_LOADED")
|
mischivin@0
|
92 WhistleMaster:SetScript("OnEvent", EventHandler)
|
mischivin@0
|
93
|
mischivin@3
|
94 local cleared = true
|
mischivin@3
|
95 local function OnTooltipCleared(self)
|
mischivin@3
|
96 cleared = true
|
mischivin@3
|
97 end
|
mischivin@3
|
98
|
mischivin@3
|
99 local function OnTooltipSetItem(self)
|
mischivin@3
|
100 if cleared then
|
mischivin@3
|
101 local name, tooltipLink = self:GetItem()
|
mischivin@3
|
102 if tooltipLink then
|
mischivin@3
|
103 local item = tooltipLink:match("Hitem:(%d+)")
|
mischivin@3
|
104 if item == "141605" then
|
mischivin@3
|
105 if UpdateWhistleMaster() then
|
mischivin@3
|
106 self:AddLine("\nWhistle Destination:|cFFFFFFFF " .. WM_ClosestNode.name ,0.5,1,0.5, true)
|
mischivin@3
|
107 else
|
mischivin@3
|
108 self:AddLine("\nWhistle Destination:|cFFFFFFFF N/A",0.5,1,0.5, true)
|
mischivin@3
|
109 end
|
mischivin@3
|
110 end
|
mischivin@3
|
111 cleared = true
|
mischivin@3
|
112 end
|
mischivin@3
|
113 end
|
mischivin@3
|
114 end
|
mischivin@3
|
115
|
mischivin@3
|
116 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@3
|
117 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@3
|
118
|