Skip to content

Commit

Permalink
Fix loaded/unloaded if groups or sections weren't expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
InfusOnWoW committed Jan 23, 2024
1 parent 21eb8eb commit 0dcc134
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,15 @@ local methods = {
self.loaded.desc = description;
self.loaded:GetNormalTexture():SetVertexColor(unpack(color))
end,
["IsLoaded"] = function(self)
return OptionsPrivate.Private.loaded[self.data.id] == true
end,
["IsStandby"] = function(self)
return OptionsPrivate.Private.loaded[self.data.id] == false
end,
["IsUnloaded"] = function(self)
return OptionsPrivate.Private.loaded[self.data.id] == nil
end,
["Pick"] = function(self)
self.frame:LockHighlight();
self:PriorityShow(1);
Expand Down
21 changes: 13 additions & 8 deletions WeakAurasOptions/OptionsFrames/OptionsFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -747,22 +747,27 @@ function OptionsPrivate.CreateFrame()
loadedButton:SetCollapseDescription(L["Collapse all loaded displays"])
loadedButton:SetViewClick(function()
local suspended = OptionsPrivate.Private.PauseAllDynamicGroups()

if loadedButton.view.visibility == 2 then
for _, child in pairs(loadedButton.childButtons) do
child:PriorityHide(2)
for _, child in ipairs(loadedButton.childButtons) do
if child:IsLoaded() then
child:PriorityHide(2)
end
end
loadedButton:PriorityHide(2)
else
for _, child in pairs(loadedButton.childButtons) do
child:PriorityShow(2)
for _, child in ipairs(loadedButton.childButtons) do
if child:IsLoaded() then
child:PriorityShow(2)
end
end
loadedButton:PriorityShow(2)
end
OptionsPrivate.Private.ResumeAllDynamicGroups(suspended)
end)
loadedButton.RecheckVisibility = function(self)
local none, all = true, true
for _, child in pairs(loadedButton.childButtons) do
for _, child in ipairs(loadedButton.childButtons) do
if child:GetVisibility() ~= 2 then
all = false
end
Expand Down Expand Up @@ -810,12 +815,12 @@ function OptionsPrivate.CreateFrame()
unloadedButton:SetViewClick(function()
local suspended = OptionsPrivate.Private.PauseAllDynamicGroups()
if unloadedButton.view.visibility == 2 then
for _, child in pairs(unloadedButton.childButtons) do
for _, child in ipairs(unloadedButton.childButtons) do
child:PriorityHide(2)
end
unloadedButton:PriorityHide(2)
else
for _, child in pairs(unloadedButton.childButtons) do
for _, child in ipairs(unloadedButton.childButtons) do
child:PriorityShow(2)
end
unloadedButton:PriorityShow(2)
Expand All @@ -824,7 +829,7 @@ function OptionsPrivate.CreateFrame()
end)
unloadedButton.RecheckVisibility = function(self)
local none, all = true, true
for _, child in pairs(unloadedButton.childButtons) do
for _, child in ipairs(unloadedButton.childButtons) do
if child:GetVisibility() ~= 2 then
all = false
end
Expand Down
23 changes: 17 additions & 6 deletions WeakAurasOptions/WeakAurasOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -971,19 +971,18 @@ function OptionsPrivate.UpdateButtonsScroll()
frame.buttonsScroll:DoLayout()
end

local function addButton(button, aurasMatchingFilter, visible, list)
local function addButton(button, aurasMatchingFilter, visible)
button.frame:Show();
if button.AcquireThumbnail then
button:AcquireThumbnail()
end
tinsert(frame.buttonsScroll.children, button);
tinsert(list, button)
visible[button] = true

if button.data.controlledChildren and button:GetExpanded() then
for _, childId in ipairs(button.data.controlledChildren) do
if aurasMatchingFilter[childId] then
addButton(displayButtons[childId], aurasMatchingFilter, visible, list)
addButton(displayButtons[childId], aurasMatchingFilter, visible)
end
end
end
Expand Down Expand Up @@ -1154,7 +1153,7 @@ function OptionsPrivate.SortDisplayButtons(filter, overrideReset, id)

if not child:GetGroup() then
-- Top Level aura
if OptionsPrivate.Private.loaded[child.data.id] ~= nil then
if OptionsPrivate.Private.loaded[id] ~= nil then
tinsert(topLevelLoadedAuras, id)
else
tinsert(topLevelUnloadedAuras, id)
Expand All @@ -1167,23 +1166,35 @@ function OptionsPrivate.SortDisplayButtons(filter, overrideReset, id)
table.sort(topLevelLoadedAuras, function(a, b) return a:lower() < b:lower() end)
for _, id in ipairs(topLevelLoadedAuras) do
if aurasMatchingFilter[id] then
addButton(displayButtons[id], aurasMatchingFilter, visible, frame.loadedButton.childButtons)
addButton(displayButtons[id], aurasMatchingFilter, visible)
end
end
end

for _, id in ipairs(topLevelLoadedAuras) do
for child in OptionsPrivate.Private.TraverseAllChildren(WeakAuras.GetData(id)) do
tinsert(frame.loadedButton.childButtons, displayButtons[child.id])
end
end

tinsert(frame.buttonsScroll.children, frame.unloadedButton);

wipe(frame.unloadedButton.childButtons)
if frame.unloadedButton:GetExpanded() then
table.sort(topLevelUnloadedAuras, function(a, b) return a:lower() < b:lower() end)
for _, id in ipairs(topLevelUnloadedAuras) do
if aurasMatchingFilter[id] then
addButton(displayButtons[id], aurasMatchingFilter, visible, frame.unloadedButton.childButtons)
addButton(displayButtons[id], aurasMatchingFilter, visible)
end
end
end

for _, id in ipairs(topLevelUnloadedAuras) do
for child in OptionsPrivate.Private.TraverseAllChildren(WeakAuras.GetData(id)) do
tinsert(frame.unloadedButton.childButtons, displayButtons[child.id])
end
end

for _, child in pairs(displayButtons) do
if(not visible[child]) then
child.frame:Hide();
Expand Down

0 comments on commit 0dcc134

Please sign in to comment.