fix: sort is working
This commit is contained in:
+45
-10
@@ -488,24 +488,59 @@ function Guda_BankFrame_OnSearchChanged(self)
|
||||
end
|
||||
end
|
||||
|
||||
-- Sort button handler
|
||||
-- Sort button handler with auto-repeat
|
||||
function Guda_BankFrame_Sort()
|
||||
if isReadOnlyMode or currentViewChar then
|
||||
addon:Print("Cannot sort in read-only mode!")
|
||||
return
|
||||
end
|
||||
|
||||
addon.Modules.SortEngine:SortBank()
|
||||
addon:Print("Sorting bank...")
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
local elapsed = 0
|
||||
frame:SetScript("OnUpdate", function()
|
||||
elapsed = elapsed + arg1
|
||||
if elapsed >= 0.5 then
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
BankFrame:Update()
|
||||
local passCount = 0
|
||||
local maxPasses = 10 -- Safety limit
|
||||
|
||||
local function DoSortPass()
|
||||
passCount = passCount + 1
|
||||
|
||||
-- Perform one sort pass
|
||||
local moveCount = addon.Modules.SortEngine:SortBank()
|
||||
|
||||
-- If items were moved and we haven't hit the limit, do another pass
|
||||
if moveCount > 0 and passCount < maxPasses then
|
||||
-- Wait for items to settle, then sort again
|
||||
local frame = CreateFrame("Frame")
|
||||
local elapsed = 0
|
||||
frame:SetScript("OnUpdate", function()
|
||||
elapsed = elapsed + arg1
|
||||
if elapsed >= 0.3 then
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
DoSortPass() -- Recursive call for next pass
|
||||
end
|
||||
end)
|
||||
else
|
||||
-- Sorting complete
|
||||
if passCount >= maxPasses then
|
||||
addon:Print("Bank sort complete! (reached max passes)")
|
||||
else
|
||||
addon:Print("Bank sort complete! (%d passes)", passCount)
|
||||
end
|
||||
|
||||
-- Final update
|
||||
local frame = CreateFrame("Frame")
|
||||
local elapsed = 0
|
||||
frame:SetScript("OnUpdate", function()
|
||||
elapsed = elapsed + arg1
|
||||
if elapsed >= 0.3 then
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
BankFrame:Update()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Start the first pass
|
||||
DoSortPass()
|
||||
end
|
||||
|
||||
-- Switch to Blizzard bank UI
|
||||
|
||||
Reference in New Issue
Block a user