zz_Itemlevel/broker.lua

31 lines
1.5 KiB
Lua
Executable File

local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local zzLDB = LibStub:GetLibrary("zzLDB")
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
local function OnClick(self, button)
zzLDB:DefaultOnClick(self, button, addon, childName)
end
local function OnTooltipShow(tip)
tip:AddLine(childName)
local avgItemLevel, avgItemLevelEquipped, avgItemLevelPvp = GetAverageItemLevel()
tip:AddDoubleLine(L['Itemlevel'], child:colorize(format(child['frm_digits'],avgItemLevel), 'ffffff'))
tip:AddDoubleLine(L['Equipped Itemlevel'], child:colorize(format(child['frm_digits'],avgItemLevelEquipped), 'ffffff'))
tip:AddDoubleLine(L['PvP'], child:colorize(format(child['frm_digits'],avgItemLevelPvp), 'ffffff'))
end
child['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications
['type'] = 'data source', -- required: 'data source' or 'launcher'
['text'] = childName, -- required/optional for launcher
['icon'] = 'Interface\\Icons\\Sha_spell_warlock_demonsoul_nightmare', -- 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)