Clickzz/broker.lua

55 lines
2.0 KiB
Lua
Executable File

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 ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(not InCombatLockdown()) then
if(SettingsPanel) then
if(SettingsPanel:IsVisible()) then
HideUIPanel(SettingsPanel)
HideUIPanel(GameMenuFrame)
else
Settings.OpenToCategory(childName)
end
elseif(InterfaceOptionsFrame) then
if(InterfaceOptionsFrame:IsVisible()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
end
end
local function OnTooltipShow(tip)
tip:AddLine(childName)
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'] = 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)