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 fmt = "|c0000ff00%s|r |c00ffffff%s|r" local L = LibStub("AceLocale-3.0"):GetLocale(childName, true) local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0") local function anymod() return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown() end local function OnClick(self, button) if(IsInGuild() and not anymod() and button == "LeftButton") then ToggleGuildFrame() elseif(not anymod() and (button == "LeftButton" or button == "RightButton")) then ToggleFriendsFrame() elseif(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 end end local function OnTooltipShow(tip) tip:AddLine(childName) tip:AddLine("") tip:AddLine(format(fmt,L["Leftclick"],L["Toggles Guild or Friendframe"])) tip:AddLine(format(fmt,L["Rightclick"],L["Toggles Friendframe"])) tip:AddLine(format(fmt,L["Shift+Leftclick"],L["Toggles minimap icon"])) 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) child.OnText = zzLDB.DefaultOnText end } addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName)