-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScrap_Broker.lua
38 lines (32 loc) · 886 Bytes
/
Scrap_Broker.lua
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
--[[
All Rights Reserved
--]]
local Broker = Scrap:NewModule('Broker', LibStub('LibDataBroker-1.1'):NewDataObject('Scrap', {
type = 'data source', tocname = ...
}))
function Broker:OnEnable()
for k,v in pairs(Scrap.Merchant) do
if type(v) == 'function' then
self[k] = self[k] or v
end
end
self.OnEnter, self.OnLeave = nil
self:RegisterEvent('BAG_UPDATE', 'OnUpdate')
self:RegisterSignal('LIST_CHANGED', 'OnUpdate')
self:OnUpdate()
end
function Broker:OnUpdate()
local value = self:GetReport()
self.icon = 'interface/addons/scrap/art/scrap-small' .. (value > 0 and '' or '-disabled')
self.text = GetMoneyString(value, true)
end
function Broker:OnClick(button)
if Scrap.Merchant:IsVisible() or button == 'RightButton' then
Scrap.Merchant.OnClick(self, button)
else
Scrap:DestroyCheapest()
end
end
function Broker:OnTooltipShow()
Broker:UpdateTip(self)
end