view WhistleMaster_LDB.lua @ 8:e7f7baf8475f

Fix for LDB plugin displaying wrong info when not in the broken isles
author Vynn <mischivin@gmail.com>
date Sun, 06 Nov 2016 01:12:18 -0400
parents 73d6c2ccdd91
children 237c9958b251
line wrap: on
line source
local dataobj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("WhistleMaster", {
	type = "data source",
	label = "Whistle Master",
	text = "N/A",
	icon = "Interface\\Icons\\Ability_Hunter_Beastcall",
	OnClick = function(clickedframe, button)
		ToggleFrame(WorldMapFrame)
	end,
})

local f = CreateFrame("frame")
local UPDATEPERIOD, elapsed = 5, 0

f:SetScript("OnUpdate", function(self, elap)
	elapsed = elapsed + elap
	if elapsed < UPDATEPERIOD then return end
	elapsed = 0
	if UpdateWhistleMaster() then
		dataobj.text = WM_ClosestNode.name
	else
		dataobj.txt = "N/A"
	end

end)

function dataobj:OnTooltipShow()
	self:AddLine("Click to open the World Map")
end

function dataobj:OnEnter()
	GameTooltip:SetOwner(self, "ANCHOR_NONE")
	GameTooltip:SetPoint("TOP", self, "BOTTOM")
	GameTooltip:ClearLines()
	dataobj.OnTooltipShow(GameTooltip)
	GameTooltip:Show()
end

function dataobj:OnLeave()
	GameTooltip:Hide()
end