zz_Coords/broker.lua

70 lines
2.4 KiB
Lua
Raw Permalink Normal View History

2021-03-23 08:47:50 +00:00
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)
2021-03-23 09:59:35 +00:00
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
2021-03-23 08:47:50 +00:00
local folder = addonName ~= childName and format("Interface\\AddOns\\%s\\%s", addonName, childName) or format("Interface\\AddOns\\%s", childName)
local function OnClick(self, button)
if(button == 'RightButton') then
if(IsShiftKeyDown()) then
2022-10-25 14:12:21 +00:00
-- zzCoords_MinimapToggle()
2021-03-23 08:47:50 +00:00
else
2022-10-25 14:12:21 +00:00
if(not InCombatLockdown()) then
if(SettingsPanel) then
if(SettingsPanel:IsVisible()) then
2022-11-28 22:10:40 +00:00
HideUIPanel(SettingsPanel)
HideUIPanel(GameMenuFrame)
2022-10-25 14:12:21 +00:00
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
2021-03-23 10:01:21 +00:00
end
2021-03-23 08:47:50 +00:00
end
elseif(button == "LeftButton") then
if(IsShiftKeyDown()) then
local db = addon['db']['global']['ldbicons']
db[childName]['hide'] = not db[childName]['hide']
if(ldbicon) then
if(db[childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
ToggleFrame(WorldMapFrame)
end
end
end
local function OnTooltipShow(tip)
tip:AddLine(childName)
tip:AddLine(GetRealZoneText())
tip:AddLine(GetSubZoneText())
tip:AddLine(format("%s: %s",childName, child['playerCoords']))
tip:AddLine(L['HINT'])
tip:AddLine(L['HINT2'])
2022-10-25 14:12:21 +00:00
-- tip:AddLine(L['HINT3'])
-- tip:AddLine(L['HINT4'])
2021-03-23 08:47:50 +00:00
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
}
child.OnText = zzLDB.DefaultOnText
local init = {
Setup = function(self, childName, event)
child.OnText = zzLDB.DefaultOnText
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName)