-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBroker.lua
More file actions
99 lines (80 loc) · 2.52 KB
/
Broker.lua
File metadata and controls
99 lines (80 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
local LibQTip = LibStub('LibQTip-1.0')
local icon = LibStub("LibDBIcon-1.0")
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local addonName = "Call To Arms"
local dataobj = ldb:NewDataObject(addonName, {
type = "data source",
text = "Broker: Call to Arms",
-- Find the current satchel icon with this search, grab the icon name and put it behind \\Icons\\
-- https://www.wowhead.com/search?q=satchel%20of%20cooperation#items;0-3-2
icon = "Interface\\Icons\\inv_misc_bag_horadricsatchel",
})
local function OnRelease(self)
LibQTip:Release(self.tooltip)
self.tooltip = nil
end
local function anchor_OnEnter(self)
if self.tooltip then
LibQTip:Release(self.tooltip)
self.tooltip = nil
end
-- Acquire a tooltip with 3 columns, respectively aligned to left, center and right
local tooltip = LibQTip:Acquire("BrokerCtaTooltip", 3, "LEFT", "LEFT", "LEFT")
self.tooltip = tooltip
tooltip.OnRelease = OnRelease
tooltip.OnLeave = OnLeave
tooltip:SetAutoHideDelay(.1, self)
broker_cta_display.build_tooltip(tooltip)
-- Use smart anchoring code to anchor the tooltip to our frame
tooltip:SmartAnchorTo(self)
-- Show it, et voilà !
tooltip:Show()
end
-- tooltip/broker object settings
function dataobj:OnEnter()
anchor_OnEnter(self)
end
function dataobj:OnLeave()
-- Nothing to do. Needs to be defined for some display addons apparently
end
function dataobj:OnClick(button)
if button == "LeftButton" then
ToggleLFDParentFrame()
end
if button == "RightButton" then
icbat_cta_minimap_settings["hide"] = not icbat_cta_minimap_settings["hide"]
if icbat_cta_minimap_settings["hide"] then
icon:Hide(addonName)
else
icon:Show(addonName)
end
end
end
function on_load_setup()
if icbat_cta_minimap_settings == nil then
icbat_cta_minimap_settings = {
hide = false,
}
end
if not icon:IsRegistered(addonName) then
icon:Register(addonName, dataobj, icbat_cta_minimap_settings)
end
set_label()
end
function set_label()
dataobj.text = broker_cta_display.build_label()
end
-- invisible frame for updating/hooking events
local f = CreateFrame("frame")
local UPDATEPERIOD = 5
local elapsed = 0
f:SetScript("OnUpdate", function(self, elap)
elapsed = elapsed + elap
if elapsed < UPDATEPERIOD then
return
end
elapsed = 0
set_label()
end)
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", on_load_setup)