Mercurial > wow > whistle-master
annotate WhistleMaster_LDB.lua @ 6:73d6c2ccdd91
First commit of LDB support.
author | Vynn <mischivin@gmail.com> |
---|---|
date | Sat, 05 Nov 2016 23:45:12 -0400 |
parents | |
children | e7f7baf8475f |
rev | line source |
---|---|
mischivin@6 | 1 local dataobj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("WhistleMaster", { |
mischivin@6 | 2 type = "data source", |
mischivin@6 | 3 label = "Whistle Master", |
mischivin@6 | 4 text = "N/A", |
mischivin@6 | 5 icon = "Interface\\Icons\\Ability_Hunter_Beastcall", |
mischivin@6 | 6 OnClick = function(clickedframe, button) |
mischivin@6 | 7 ToggleFrame(WorldMapFrame) |
mischivin@6 | 8 end, |
mischivin@6 | 9 }) |
mischivin@6 | 10 |
mischivin@6 | 11 local f = CreateFrame("frame") |
mischivin@6 | 12 local UPDATEPERIOD, elapsed = 5, 0 |
mischivin@6 | 13 |
mischivin@6 | 14 f:SetScript("OnUpdate", function(self, elap) |
mischivin@6 | 15 elapsed = elapsed + elap |
mischivin@6 | 16 if elapsed < UPDATEPERIOD then return end |
mischivin@6 | 17 elapsed = 0 |
mischivin@6 | 18 |
mischivin@6 | 19 dataobj.text = WM_ClosestNode.name |
mischivin@6 | 20 |
mischivin@6 | 21 end) |
mischivin@6 | 22 |
mischivin@6 | 23 function dataobj:OnTooltipShow() |
mischivin@6 | 24 self:AddLine("Click to open the World Map") |
mischivin@6 | 25 end |
mischivin@6 | 26 |
mischivin@6 | 27 function dataobj:OnEnter() |
mischivin@6 | 28 GameTooltip:SetOwner(self, "ANCHOR_NONE") |
mischivin@6 | 29 GameTooltip:SetPoint("TOP", self, "BOTTOM") |
mischivin@6 | 30 GameTooltip:ClearLines() |
mischivin@6 | 31 dataobj.OnTooltipShow(GameTooltip) |
mischivin@6 | 32 GameTooltip:Show() |
mischivin@6 | 33 end |
mischivin@6 | 34 |
mischivin@6 | 35 function dataobj:OnLeave() |
mischivin@6 | 36 GameTooltip:Hide() |
mischivin@6 | 37 end |