Add pref-button to toggle all minimap buttons of childs

This commit is contained in:
robin 2021-05-02 12:56:28 +02:00
parent 33e8f02cbe
commit 60bfaac28d
3 changed files with 32 additions and 6 deletions

View File

@ -1,3 +0,0 @@
<Bindings>
<Binding name="COORDS_TOGGLE" header="COORDS" category="ADDONS">zzCoords_MinimapToggle()</Binding>
</Bindings>

View File

@ -2,5 +2,6 @@ local addonname, addon = ...
local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(childName, "enUS", true)
if L then
L[childName] = childName
L['Toggle Minimap-Icons'] = true
L['Show or Hide all Icons of childs'] = true
end

View File

@ -1,12 +1,40 @@
local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
local function toggleChilds()
local childs = child['children']
if(#childs > 0) then
print("Found parent", child['specs']['name'],"with childs",#childs)
local sb = addon['db']['global']['ldbicons']
for i = 1, #childs do
local cName = childs[i]['specs']['name']
if(cName) then
sb[cName] = sb[cName] or {
['hide'] = true
}
sb[cName]['hide'] = not sb[cName]['hide']
if(ldbicon) then
if(sb[cName]['hide']) then
ldbicon:Hide(cName)
else
ldbicon:Show(cName)
end
end
end
end
end
end
local init = {
Setup = function()
local config = LibStub:GetLibrary("zzConfig")
local options = child['options']
local main = options['args'][childName]
config:AddConfigEntry(main, "toggleChilds", "execute", L['Toggle Minimap-Icons'], L['Show or Hide all Icons of childs'], 3, toggleChilds)
end
}
--print('reg', format("Init%s", childName))
--addon.RegisterCallback(init, format("Init%s", childName), 'Setup')
addon.RegisterCallback(init, format("Init%s", childName), 'Setup')