zz_UI/broker.lua

27 lines
1.1 KiB
Lua

local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local zzLDB = LibStub:GetLibrary("zzLDB")
local folder = addonName ~= childName and format("Interface\\AddOns\\%s\\%s", addonName, childName) or format("Interface\\AddOns\\%s", childName)
local function OnClick(self, button)
zzLDB:DefaultOnClick(self, button, addon, childName)
end
local function OnTooltipShow(tip)
tip:AddLine(childName)
end
child['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications
['type'] = 'launcher', -- required: 'data source' or 'launcher'
['text'] = childName, -- required/optional for launcher
['icon'] = format("%s\\icon2.tga", folder), -- optional/required for launcher
['OnClick'] = OnClick, -- optional/required for launcher
['OnTooltipShow'] = OnTooltipShow, -- optional
}
local init = {
Setup = function(self, childName, event)
-- print("setup ldb", childName, event)
if(child['ldb']['type'] == 'data source') then
child.OnText = zzLDB.DefaultOnText
end
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName)