from retail

This commit is contained in:
NoM0Re
2025-01-16 21:57:41 +01:00
parent ec42e803b4
commit 869ac5c1b4
+110 -62
View File
@@ -443,31 +443,7 @@ StaticPopupDialogs["WEAKAURAS_CONFIRM_DELETE"] = {
button2 = L["Cancel"],
OnAccept = function(self)
if self.data then
local suspended = OptionsPrivate.Private.PauseAllDynamicGroups()
OptionsPrivate.massDelete = true
for _, auraData in pairs(self.data.toDelete) do
WeakAuras.Delete(auraData)
end
OptionsPrivate.massDelete = false
if self.data.parents then
for id in pairs(self.data.parents) do
local parentData = WeakAuras.GetData(id)
local parentButton = OptionsPrivate.GetDisplayButton(id)
WeakAuras.UpdateGroupOrders(parentData)
if(#parentData.controlledChildren == 0) then
parentButton:DisableExpand()
else
parentButton:EnableExpand()
end
parentButton:SetNormalTooltip()
WeakAuras.Add(parentData)
WeakAuras.ClearAndUpdateOptions(parentData.id)
parentButton:UpdateParentWarning()
end
end
OptionsPrivate.Private.ResumeAllDynamicGroups(suspended)
OptionsPrivate.SortDisplayButtons(nil, true)
OptionsPrivate.DeleteAuras(self.data.toDelete, self.data.parents)
end
end,
OnCancel = function(self)
@@ -784,6 +760,54 @@ local function LayoutDisplayButtons(msg)
OptionsPrivate.Private.dynFrame:AddAction("LayoutDisplayButtons1", co1);
end
function OptionsPrivate.DeleteAuras(auras, parents)
local func1 = function()
frame:SetLoadProgressVisible(true)
local num = 0
local total = 0
for _, auraData in pairs(auras) do
total = total +1
end
frame.loadProgress:SetText(L["Deleting auras: "]..num.."/"..total)
local suspended = OptionsPrivate.Private.PauseAllDynamicGroups()
OptionsPrivate.massDelete = true
for _, auraData in pairs(auras) do
WeakAuras.Delete(auraData)
num = num +1
frame.loadProgress:SetText(L["Deleting auras: "]..num.."/"..total)
coroutine.yield()
end
OptionsPrivate.massDelete = false
if parents then
for id in pairs(parents) do
local parentData = WeakAuras.GetData(id)
local parentButton = OptionsPrivate.GetDisplayButton(id)
WeakAuras.UpdateGroupOrders(parentData)
if(#parentData.controlledChildren == 0) then
parentButton:DisableExpand()
else
parentButton:EnableExpand()
end
parentButton:SetNormalTooltip()
WeakAuras.Add(parentData)
WeakAuras.ClearAndUpdateOptions(parentData.id)
frame.loadProgress:SetText(L["Finishing..."])
coroutine.yield()
end
end
OptionsPrivate.Private.ResumeAllDynamicGroups(suspended)
OptionsPrivate.SortDisplayButtons(nil, true)
frame:SetLoadProgressVisible(false)
end
local co1 = coroutine.create(func1)
OptionsPrivate.Private.dynFrame:AddAction("Deleting Auras", co1)
end
function WeakAuras.ShowOptions(msg)
local firstLoad = not(frame);
OptionsPrivate.Private.Pause();
@@ -1466,51 +1490,75 @@ end
function OptionsPrivate.Drop(mainAura, target, action, area)
WeakAuras_DropDownMenu:Hide()
local mode = ""
if (frame.pickedDisplay == tempGroup and #tempGroup.controlledChildren > 0) then
mode = "MULTI"
elseif mainAura.controlledChildren then
mode = "GROUP"
else
mode = "SINGLE"
end
local func1 = function()
frame:SetLoadProgressVisible(true)
local buttonsToSort = {}
local total = 0
local num = 0
for id, button in pairs(displayButtons) do
if button:IsDragging() then
total = total + 1
end
end
frame.loadProgress:SetText(L["Moving auras: "]..num.."/"..total)
for id, button in pairs(displayButtons) do
if button:IsDragging() then
tinsert(buttonsToSort, button)
local mode = ""
if (frame.pickedDisplay == tempGroup and #tempGroup.controlledChildren > 0) then
mode = "MULTI"
elseif mainAura.controlledChildren then
mode = "GROUP"
else
button:Drop(mode, mainAura, target, action);
mode = "SINGLE"
end
end
if mode == "MULTI" then
-- If we are dragging and dropping multiple auras at once, the order in which we drop is important
-- We want to preserve the top-down order
-- Depending on how exactly we find the insert position, we need to use the right order of insertions
if area == "GROUP" then
table.sort(buttonsToSort, CompareButtonOrderReverse)
elseif area == "BEFORE" then
table.sort(buttonsToSort, CompareButtonOrder)
else -- After
table.sort(buttonsToSort, CompareButtonOrderReverse)
local buttonsToSort = {}
for id, button in pairs(displayButtons) do
if button:IsDragging() then
tinsert(buttonsToSort, button)
num = num + 1
frame.loadProgress:SetText(L["Preparing auras: "]..num.."/"..total)
else
button:Drop(mode, mainAura, target, action);
end
coroutine.yield()
end
num = 0
frame.loadProgress:SetText(L["Moving auras: "]..num.."/"..total)
if mode == "MULTI" then
-- If we are dragging and dropping multiple auras at once, the order in which we drop is important
-- We want to preserve the top-down order
-- Depending on how exactly we find the insert position, we need to use the right order of insertions
if area == "GROUP" then
table.sort(buttonsToSort, CompareButtonOrderReverse)
elseif area == "BEFORE" then
table.sort(buttonsToSort, CompareButtonOrder)
else -- After
table.sort(buttonsToSort, CompareButtonOrderReverse)
end
end
for _, button in ipairs(buttonsToSort) do
button:Drop(mode, mainAura, target, action)
num = num + 1
frame.loadProgress:SetText(L["Moving auras: "]..num.."/"..total)
coroutine.yield()
end
-- Update offset, this is a bit wasteful to do for every aura
-- But we also need to update the offset if a parent was dragged
for _, button in pairs(displayButtons) do
button:UpdateOffset();
end
coroutine.yield()
frame:SetLoadProgressVisible(false)
OptionsPrivate.SortDisplayButtons()
OptionsPrivate.UpdateButtonsScroll()
end
for _, button in ipairs(buttonsToSort) do
button:Drop(mode, mainAura, target, action)
end
-- Update offset, this is a bit wasteful to do for every aura
-- But we also need to update the offset if a parent was dragged
for _, button in pairs(displayButtons) do
button:UpdateOffset();
end
OptionsPrivate.SortDisplayButtons()
OptionsPrivate.UpdateButtonsScroll()
WeakAuras.FillOptions()
local co1 = coroutine.create(func1)
OptionsPrivate.Private.dynFrame:AddAction("Dropping Auras", co1)
end
function OptionsPrivate.StartDrag(mainAura)