完成焦点等开发
This commit is contained in:
@@ -1700,17 +1700,20 @@ function SFrames.Bags.Bank:Initialize()
|
||||
local sortBtn = CreateHeaderIconButton("SFramesBankSortBtn", SFBankFrame, "Interface\\Icons\\INV_Misc_Note_05")
|
||||
sortBtn:SetPoint("LEFT", searchEB, "RIGHT", 6, 0)
|
||||
SFrames:SetIcon(sortBtn.icon, "gold")
|
||||
sortBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||
sortBtn:SetScript("OnEnter", function()
|
||||
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
|
||||
GameTooltip:SetText(TEXT_SORT, 1, 1, 1)
|
||||
GameTooltip:AddLine("\229\183\166\233\148\174\230\149\180\231\144\134 | \229\143\179\233\148\174\229\143\141\229\186\143\230\149\180\231\144\134", 0.7, 0.7, 0.7)
|
||||
GameTooltip:Show()
|
||||
end)
|
||||
sortBtn:SetScript("OnLeave", function()
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
sortBtn:SetScript("OnClick", function()
|
||||
local reverse = (arg1 == "RightButton")
|
||||
if SFrames.Bags.Sort and SFrames.Bags.Sort.StartBank then
|
||||
SFrames.Bags.Sort:StartBank()
|
||||
SFrames.Bags.Sort:StartBank(reverse)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -920,11 +920,12 @@ function SFrames.Bags.Container:Initialize()
|
||||
insets = { left = 3, right = 3, top = 3, bottom = 3 },
|
||||
})
|
||||
local _A = SFrames.ActiveTheme
|
||||
local _bagBgA = (SFramesDB and SFramesDB.Bags and type(SFramesDB.Bags.bgAlpha) == "number") and SFramesDB.Bags.bgAlpha or 0.95
|
||||
if _A and _A.panelBg then
|
||||
BagFrame:SetBackdropColor(_A.panelBg[1], _A.panelBg[2], _A.panelBg[3], _A.panelBg[4] or 0.95)
|
||||
BagFrame:SetBackdropColor(_A.panelBg[1], _A.panelBg[2], _A.panelBg[3], _bagBgA)
|
||||
BagFrame:SetBackdropBorderColor(_A.panelBorder[1], _A.panelBorder[2], _A.panelBorder[3], _A.panelBorder[4] or 0.9)
|
||||
else
|
||||
BagFrame:SetBackdropColor(0.12, 0.06, 0.10, 0.95)
|
||||
BagFrame:SetBackdropColor(0.12, 0.06, 0.10, _bagBgA)
|
||||
BagFrame:SetBackdropBorderColor(0.55, 0.30, 0.42, 0.9)
|
||||
end
|
||||
local bagShadow = CreateFrame("Frame", nil, BagFrame)
|
||||
@@ -1418,16 +1419,21 @@ function SFrames.Bags.Container:Initialize()
|
||||
local sortBtn = CreateHeaderIconButton("SFramesBagSortBtn", BagFrame, "Interface\\Icons\\INV_Misc_Note_05")
|
||||
sortBtn:SetPoint("LEFT", eb, "RIGHT", 6, 0)
|
||||
SFrames:SetIcon(sortBtn.icon, "backpack")
|
||||
sortBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||
sortBtn:SetScript("OnEnter", function()
|
||||
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
|
||||
GameTooltip:SetText(TEXT_SORT, 1, 1, 1)
|
||||
GameTooltip:AddLine("\229\183\166\233\148\174\230\149\180\231\144\134 | \229\143\179\233\148\174\229\143\141\229\186\143\230\149\180\231\144\134", 0.7, 0.7, 0.7)
|
||||
GameTooltip:Show()
|
||||
end)
|
||||
sortBtn:SetScript("OnLeave", function()
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
sortBtn:SetScript("OnClick", function()
|
||||
if SFrames.Bags.Sort then SFrames.Bags.Sort:Start() end
|
||||
if SFrames.Bags.Sort then
|
||||
local reverse = (arg1 == "RightButton")
|
||||
SFrames.Bags.Sort:Start(reverse)
|
||||
end
|
||||
end)
|
||||
|
||||
local hsBtn = CreateHeaderIconButton("SFramesBagHSBtn", BagFrame, "Interface\\Icons\\INV_Misc_Rune_01")
|
||||
|
||||
118
Bags/Sort.lua
118
Bags/Sort.lua
@@ -108,16 +108,30 @@ local function GetSpecialType(link, isBag)
|
||||
return "Normal"
|
||||
end
|
||||
|
||||
local activeReverse = false
|
||||
|
||||
local function SortItemsByRule(items)
|
||||
table.sort(items, function(a, b)
|
||||
if a.score ~= b.score then
|
||||
return a.score > b.score
|
||||
elseif a.name ~= b.name then
|
||||
return a.name < b.name
|
||||
else
|
||||
return a.count > b.count
|
||||
end
|
||||
end)
|
||||
if activeReverse then
|
||||
table.sort(items, function(a, b)
|
||||
if a.score ~= b.score then
|
||||
return a.score < b.score
|
||||
elseif a.name ~= b.name then
|
||||
return a.name > b.name
|
||||
else
|
||||
return a.count < b.count
|
||||
end
|
||||
end)
|
||||
else
|
||||
table.sort(items, function(a, b)
|
||||
if a.score ~= b.score then
|
||||
return a.score > b.score
|
||||
elseif a.name ~= b.name then
|
||||
return a.name < b.name
|
||||
else
|
||||
return a.count > b.count
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function ResetSortState()
|
||||
@@ -127,6 +141,7 @@ local function ResetSortState()
|
||||
activeCompleteUpdate = nil
|
||||
activeBagOrder = nil
|
||||
activePhase = nil
|
||||
activeReverse = false
|
||||
timeSinceLast = 0
|
||||
sortTimer:Hide()
|
||||
end
|
||||
@@ -178,13 +193,22 @@ function SFrames.Bags.Sort:ExecuteSimpleSort(items, bagOrder)
|
||||
end
|
||||
|
||||
-- Now assign target slot to each item
|
||||
-- When reverse sorting, fill from the last slot (bottom-right) instead of first
|
||||
for _, item in ipairs(items) do
|
||||
local targetSlot = nil
|
||||
|
||||
if item.specialType ~= "Normal" and slotPool[item.specialType] and table.getn(slotPool[item.specialType]) > 0 then
|
||||
targetSlot = table.remove(slotPool[item.specialType], 1)
|
||||
if activeReverse then
|
||||
targetSlot = table.remove(slotPool[item.specialType])
|
||||
else
|
||||
targetSlot = table.remove(slotPool[item.specialType], 1)
|
||||
end
|
||||
elseif table.getn(slotPool.Normal) > 0 then
|
||||
targetSlot = table.remove(slotPool.Normal, 1)
|
||||
if activeReverse then
|
||||
targetSlot = table.remove(slotPool.Normal)
|
||||
else
|
||||
targetSlot = table.remove(slotPool.Normal, 1)
|
||||
end
|
||||
end
|
||||
|
||||
if targetSlot then
|
||||
@@ -356,9 +380,73 @@ function SFrames.Bags.Sort:StartPlacementPhase(ignoreLocked)
|
||||
end
|
||||
|
||||
function SFrames.Bags.Sort:StartForBags(bagOrder, completeMessage, completeUpdate)
|
||||
if isSorting then return end
|
||||
-- If a previous sort is still running, force-cancel it first
|
||||
if isSorting then
|
||||
-- Drop cursor item if held
|
||||
if CursorHasItem() then
|
||||
for _, bag in ipairs(activeBagOrder or bagOrder) do
|
||||
local bagSlots = GetContainerNumSlots(bag) or 0
|
||||
for slot = 1, bagSlots do
|
||||
local _, _, locked = GetContainerItemInfo(bag, slot)
|
||||
if locked then
|
||||
PickupContainerItem(bag, slot)
|
||||
break
|
||||
end
|
||||
end
|
||||
if not CursorHasItem() then break end
|
||||
end
|
||||
end
|
||||
ResetSortState()
|
||||
end
|
||||
|
||||
-- Save reverse flag before any potential defer (ResetSortState clears it)
|
||||
local savedReverse = activeReverse
|
||||
|
||||
-- Wait for any lingering locked items before starting
|
||||
local hasLocked = false
|
||||
for _, bag in ipairs(bagOrder) do
|
||||
local bagSlots = GetContainerNumSlots(bag) or 0
|
||||
for slot = 1, bagSlots do
|
||||
local _, _, locked = GetContainerItemInfo(bag, slot)
|
||||
if locked then
|
||||
hasLocked = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if hasLocked then break end
|
||||
end
|
||||
|
||||
if hasLocked then
|
||||
-- Defer start until locks clear
|
||||
local waitTimer = CreateFrame("Frame")
|
||||
local waitElapsed = 0
|
||||
local selfRef = self
|
||||
waitTimer:SetScript("OnUpdate", function()
|
||||
waitElapsed = waitElapsed + arg1
|
||||
if waitElapsed < 0.05 then return end
|
||||
waitElapsed = 0
|
||||
|
||||
local still = false
|
||||
for _, bag in ipairs(bagOrder) do
|
||||
local bagSlots = GetContainerNumSlots(bag) or 0
|
||||
for slot = 1, bagSlots do
|
||||
local _, _, locked = GetContainerItemInfo(bag, slot)
|
||||
if locked then still = true; break end
|
||||
end
|
||||
if still then break end
|
||||
end
|
||||
|
||||
if not still then
|
||||
this:SetScript("OnUpdate", nil)
|
||||
activeReverse = savedReverse
|
||||
selfRef:StartForBags(bagOrder, completeMessage, completeUpdate)
|
||||
end
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
isSorting = true
|
||||
activeReverse = savedReverse
|
||||
sortQueue = {}
|
||||
timeSinceLast = 0
|
||||
activeCompleteMessage = completeMessage
|
||||
@@ -384,12 +472,13 @@ function SFrames.Bags.Sort:StartForBags(bagOrder, completeMessage, completeUpdat
|
||||
self:StartPlacementPhase(false)
|
||||
end
|
||||
|
||||
function SFrames.Bags.Sort:Start()
|
||||
function SFrames.Bags.Sort:Start(reverse)
|
||||
if SFrames.Bags.Container and SFrames.Bags.Container.isOffline then
|
||||
SFrames:Print(TEXT_OFFLINE_BAGS)
|
||||
return
|
||||
end
|
||||
|
||||
activeReverse = reverse or false
|
||||
self:StartForBags(
|
||||
{0, 1, 2, 3, 4},
|
||||
TEXT_BAG_DONE,
|
||||
@@ -401,12 +490,13 @@ function SFrames.Bags.Sort:Start()
|
||||
)
|
||||
end
|
||||
|
||||
function SFrames.Bags.Sort:StartBank()
|
||||
function SFrames.Bags.Sort:StartBank(reverse)
|
||||
if SFrames.Bags.Bank and SFrames.Bags.Bank.isOffline then
|
||||
SFrames:Print(TEXT_OFFLINE_BANK)
|
||||
return
|
||||
end
|
||||
|
||||
activeReverse = reverse or false
|
||||
self:StartForBags(
|
||||
{-1, 5, 6, 7, 8, 9, 10, 11},
|
||||
TEXT_BANK_DONE,
|
||||
|
||||
Reference in New Issue
Block a user