Repository navigation
Expand file tree
/
Copy pathBroker.lua
More file actions
47 lines (43 loc) · 1.76 KB
/
Copy pathBroker.lua
File metadata and controls
47 lines (43 loc) · 1.76 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
-- LibDataBroker launcher (shared with our other addons) for Titan Panel, ChocolateBar, Bazooka and other LDB displays (only if one is installed).
local _, ns = ...
local NF = KennyNeutralFlip
local C = ns.Compat
local obj
function NF.UpdateBroker()
if not obj then return end
local ok, list = pcall(NF.Opportunities)
local n = ok and #list or 0
obj.text = n > 0 and (n .. " flips") or "no flips"
return list
end
local function tooltip(tt)
tt:AddLine("NeutralFlip")
local list = NF.UpdateBroker() or {}
if #list == 0 then tt:AddLine("Nothing worth carrying yet. Record prices at both AHs.", 1, 1, 1, true) end
for i = 1, math.min(5, #list) do
local o = list[i]
tt:AddDoubleLine(("%s %s > %s"):format(o.name, NF.KindLabel(o.from), NF.KindLabel(o.to)), "+" .. C.Money(o.total), 1, 1, 1, 0.2, 1, 0.6)
end
tt:AddLine("Left-click: flip list. Right-click: TomTom arrow to a neutral AH.", 0.6, 0.6, 0.6, true)
end
function NF.InstallBroker()
if obj then return obj end
-- One shared "Kenny's addons" entry with a menu when several of our addons are installed; our own entry when alone.
obj = ns.Hub.Launcher("NeutralFlip", {
leftHint = "Flip list", rightHint = "TomTom arrow to a neutral AH",
type = "data source", text = "NeutralFlip", label = "NeutralFlip",
icon = "Interface\\AddOns\\NeutralFlip\\media\\icon",
OnClick = function(_, button)
if button == "RightButton" then NF.Waypoint("") else SlashCmdList.KENNYNEUTRALFLIP("") end
end,
OnTooltipShow = tooltip,
})
NF.UpdateBroker()
return obj
end
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("AUCTION_HOUSE_CLOSED")
f:SetScript("OnEvent", function(_, event)
if event == "PLAYER_LOGIN" then NF.InstallBroker() else NF.UpdateBroker() end
end)