Skip to content

Commit

Permalink
Simplify included sets
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Nov 27, 2024
1 parent 1e92b7c commit e6d75ab
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 63 deletions.
42 changes: 11 additions & 31 deletions BetterAddonList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -428,23 +428,17 @@ do
end

local function IsSetIncluded(data)
local name, setName = data[1], data[2]
return included[name] and included[name][setName] and true
local setA, setB = data[1], data[2]
return included[setA] and included[setA][setB] and true
end

local function SetSetIncluded(data, _, menu)
local function SetSetIncluded(data)
local value = not IsSetIncluded(data)
local name, setName = data[1], data[2]
if not included[name] then
included[name] = {}
local setA, setB = data[1], data[2]
if not included[setA] then
included[setA] = {}
end
included[name][setName] = value or nil
end

local function RemoveIncludedSet(data)
local name, setName = data[1], data[2]
included[setName][name] = nil
-- return MenuResponse.Refresh
included[setA][setB] = value or nil
end

local function GenerateSetsMenu(owner, root)
Expand Down Expand Up @@ -483,27 +477,13 @@ do

set:CreateDivider()

local includeSet = set:CreateButton(L["Include with another set"])
includeSet:SetEnabled(#list > 2) -- have more than the current set and default
includeSet:CreateTitle(L["Include with another set"])
local includeSets = set:CreateButton(L["Enabled with this set"])
includeSets:SetEnabled(#list > 1) -- have more than the current set
-- includeSets:CreateTitle(L["Additionally enable addons from these sets"])
for _, name in ipairs(list) do
if name ~= currentSet then
local s = includeSet:CreateCheckbox(name, IsSetIncluded, SetSetIncluded, {name, currentSet})
if included[currentSet] and included[currentSet][name] then
s:SetEnabled(false)
end
end
end

local removeIncludedSet = set:CreateButton(L["Remove an included set"])
removeIncludedSet:SetEnabled(included[currentSet] and next(included[currentSet]) and true)
removeIncludedSet:CreateTitle(L["Remove an included set"])
if included[currentSet] and next(included[currentSet]) then
for name in next, included[currentSet] do
removeIncludedSet:CreateButton(name, RemoveIncludedSet, {name, currentSet})
includeSets:CreateCheckbox(name, IsSetIncluded, SetSetIncluded, {currentSet, name})
end
else
removeIncludedSet:CreateButton(NONE):SetEnabled(false)
end

set:CreateDivider()
Expand Down
40 changes: 11 additions & 29 deletions BetterAddonList_Classic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -379,24 +379,17 @@ do
end

local function IsSetIncluded(data)
local name, setName = data[1], data[2]
return included[name] and included[name][setName] and true
local setA, setB = data[1], data[2]
return included[setA] and included[setA][setB] and true
end

local function SetSetIncluded(data, _, menu)
local function SetSetIncluded(data)
local value = not IsSetIncluded(data)
local name, setName = data[1], data[2]
if not included[name] then
included[name] = {}
local setA, setB = data[1], data[2]
if not included[setA] then
included[setA] = {}
end
included[name][setName] = value or nil
end

local function RemoveIncludedSet(data)
local name, setName = data[1], data[2]
included[setName][name] = nil

return MenuResponse.Refresh
included[setA][setB] = value or nil
end

local function GenerateSetsMenu(owner, root)
Expand Down Expand Up @@ -435,26 +428,15 @@ do

set:CreateDivider()

local includeSet = set:CreateButton(L["Include with another set"])
includeSet:SetEnabled(#list > 2) -- have more than the current set and default
includeSet:CreateTitle(L["Include with another set"])
local includeSets = set:CreateButton(L["Enabled with this set"])
includeSets:SetEnabled(#list > 1) -- have more than the current set
-- includeSets:CreateTitle(L["Additionally load these sets"])
for _, name in ipairs(list) do
if name ~= currentSet then
includeSet:CreateCheckbox(name, IsSetIncluded, SetSetIncluded, {name, currentSet})
includeSets:CreateCheckbox(name, IsSetIncluded, SetSetIncluded, { currentSet, name })
end
end

local removeIncludedSet = set:CreateButton(L["Remove an included set"])
removeIncludedSet:SetEnabled(included[currentSet] and next(included[currentSet]) and true)
removeIncludedSet:CreateTitle(L["Remove an included set"])
if included[currentSet] and next(included[currentSet]) then
for name in next, included[currentSet] do
removeIncludedSet:CreateButton(name, RemoveIncludedSet, {name, currentSet})
end
else
removeIncludedSet:CreateButton(NONE):SetEnabled(false)
end

set:CreateDivider()

set:CreateButton(L["Enable addons from this set"], function(data) addon:EnableSet(data) end, currentSet)
Expand Down
5 changes: 2 additions & 3 deletions locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local L = setmetatable({}, {
})
ns.L = L

L["... and %d more"] = true
L["Additionally enable addons from these sets"] = true
L["Addon List"] = true
L["Create new set"] = true
L["Delete"] = true
Expand All @@ -24,13 +24,13 @@ L["Disabled all addons."] = true
L["Enable addons from this set"] = true
L["Enabled addons in set %q."] = true
L["Enabled only addons in set %q."] = true
L["Enabled with this set"] = true
L["Enter the name for the new set"] = true
L["Enter the new name for %s"] = true
L.FILTER_ENABLED = "Enabled"
L.FILTER_DISABLED = "Disabled"
L.FILTER_LOD = "Load On Demand"
L.FILTER_PROTECTED = "Protected"
L["Include with another set"] = true
L["Load"] = true
L["Load out of date"] = true
L["Memory: %.02f MB"] = true
Expand All @@ -39,7 +39,6 @@ L["No set named %q."] = true
L["Out of date addons are being disabled! They will not be able to load until their interface version is updated or \"Load out of date AddOns\" is checked."] = true
L["Problem with protected addon %q (%s)"] = true
L["Reload UI to load these addons."] = true
L["Remove an included set"] = true
L["Rename"] = true
L["Reset"] = true
L["Reset addons to what was enabled at login."] = true
Expand Down

0 comments on commit e6d75ab

Please sign in to comment.