# HG changeset patch # User Vynn # Date 1478366394 14400 # Node ID 4402edd42a3fe835c1bfab477be28eed8afcf00e # Parent 881a2c218fa56ed3c5e3e097dd3f6800c517eef5 Added tooltip to Flight Masters Whistle, improved update function call. diff -r 881a2c218fa5 -r 4402edd42a3f WhistleMaster.lua --- a/WhistleMaster.lua Sat Nov 05 13:18:43 2016 -0400 +++ b/WhistleMaster.lua Sat Nov 05 13:19:54 2016 -0400 @@ -4,13 +4,16 @@ 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 } +--Doesn't work in 1021 (Broken Shore) +WM_validIDs = { [1014] = true, [1015] = true, [1017] = true, [1018] = true, [1021] = false, [1024] = true, [1033] = true, [1096] = true } local WhistleLoc = CreateFrame("FRAME", "WhistleLOC", WorldMapPOIFrame) WhistleLoc:SetSize(64, 64) WhistleLoc:SetPoint("CENTER", 0, 0) WhistleLoc:Show() +WM_ClosestNode = nil + --[[local Rotate = WhistleLoc:CreateTexture() Rotate:SetTexture("Interface\minimap\UI-Minimap-Ping-Rotate") Rotate:SetPoint("CENTER") @@ -51,20 +54,20 @@ 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) + if GetCurrentMapContinent() == 8 and WM_validIDs[ select(1, GetCurrentMapAreaID() ) ] and not GetNumDungeonMapLevels() then + WM_ClosestNode = GetNode() + WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. WM_ClosestNode.index, 0, 0) WhistleLoc:Show() WhistlePing.Ping:Play() + return true else WhistleLoc:Hide() WhistlePing.Ping:Stop() - print("wrong continent for whistle master") + return false end end @@ -78,11 +81,38 @@ if ( (mapVisible) and not WorldMapFrame:IsVisible() ) then mapVisible = false end + if (event == "VARIABLES_LOADED") then + UpdateWhistleMaster() + end end - - local WhistleMaster = CreateFrame("FRAME", "WhistleMaster", WorldMapPOIFrame) WhistleMaster:RegisterEvent("WORLD_MAP_UPDATE") +WhistleMaster:RegisterEvent("VARIABLES_LOADED") WhistleMaster:SetScript("OnEvent", EventHandler) +local cleared = true +local function OnTooltipCleared(self) + cleared = true +end + +local function OnTooltipSetItem(self) + if cleared then + local name, tooltipLink = self:GetItem() + if tooltipLink then + local item = tooltipLink:match("Hitem:(%d+)") + if item == "141605" then + if UpdateWhistleMaster() then + self:AddLine("\nWhistle Destination:|cFFFFFFFF " .. WM_ClosestNode.name ,0.5,1,0.5, true) + else + self:AddLine("\nWhistle Destination:|cFFFFFFFF N/A",0.5,1,0.5, true) + end + end + cleared = true + end + end +end + +GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared) +GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) +