mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
update sort
This commit is contained in:
+28
-26
@@ -22,7 +22,6 @@ local GetContainerNumSlots = GetContainerNumSlots
|
|||||||
local ContainerIDToInventoryID = ContainerIDToInventoryID
|
local ContainerIDToInventoryID = ContainerIDToInventoryID
|
||||||
local GetInventoryItemLink = GetInventoryItemLink
|
local GetInventoryItemLink = GetInventoryItemLink
|
||||||
local CursorHasItem = CursorHasItem
|
local CursorHasItem = CursorHasItem
|
||||||
local ARMOR = ARMOR
|
|
||||||
|
|
||||||
local bankBags = {BANK_CONTAINER}
|
local bankBags = {BANK_CONTAINER}
|
||||||
local MAX_MOVE_TIME = 1.25
|
local MAX_MOVE_TIME = 1.25
|
||||||
@@ -57,7 +56,7 @@ local bagStacks = {}
|
|||||||
local bagMaxStacks = {}
|
local bagMaxStacks = {}
|
||||||
local bagGroups = {}
|
local bagGroups = {}
|
||||||
local initialOrder = {}
|
local initialOrder = {}
|
||||||
local itemTypes, itemSubTypes
|
|
||||||
local bagSorted, bagLocked = {}, {}
|
local bagSorted, bagLocked = {}, {}
|
||||||
local moves = {}
|
local moves = {}
|
||||||
local targetItems = {}
|
local targetItems = {}
|
||||||
@@ -116,9 +115,8 @@ end)
|
|||||||
frame:Hide()
|
frame:Hide()
|
||||||
B.SortUpdateTimer = frame
|
B.SortUpdateTimer = frame
|
||||||
|
|
||||||
|
local itemTypes, itemSubTypes = {}, {}
|
||||||
local function BuildSortOrder()
|
local function BuildSortOrder()
|
||||||
itemTypes = {}
|
|
||||||
itemSubTypes = {}
|
|
||||||
for i, iType in ipairs({GetAuctionItemClasses()}) do
|
for i, iType in ipairs({GetAuctionItemClasses()}) do
|
||||||
itemTypes[iType] = i
|
itemTypes[iType] = i
|
||||||
itemSubTypes[iType] = {}
|
itemSubTypes[iType] = {}
|
||||||
@@ -127,6 +125,7 @@ local function BuildSortOrder()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
BuildSortOrder()
|
||||||
|
|
||||||
local function UpdateLocation(from, to)
|
local function UpdateLocation(from, to)
|
||||||
if (bagIDs[from] == bagIDs[to]) and (bagStacks[to] < bagMaxStacks[to]) then
|
if (bagIDs[from] == bagIDs[to]) and (bagStacks[to] < bagMaxStacks[to]) then
|
||||||
@@ -180,21 +179,23 @@ local function DefaultSort(a, b)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _, _, aRarity, _, aType, aSubType, _, aEquipLoc = GetItemInfo(aID)
|
local _, _, _, _, aType, aSubType, _, aEquipLoc = GetItemInfo(aID)
|
||||||
local _, _, bRarity, _, bType, bSubType, _, bEquipLoc = GetItemInfo(bID)
|
local _, _, _, _, bType, bSubType, _, bEquipLoc = GetItemInfo(bID)
|
||||||
|
|
||||||
aRarity = bagQualities[a]
|
local aRarity, bRarity = bagQualities[a], bagQualities[b]
|
||||||
bRarity = bagQualities[b]
|
|
||||||
|
|
||||||
if aRarity ~= bRarity and aRarity and bRarity then
|
if aRarity ~= bRarity and aRarity and bRarity then
|
||||||
return aRarity > bRarity
|
return aRarity > bRarity
|
||||||
end
|
end
|
||||||
|
|
||||||
if itemTypes[aType] ~= itemTypes[bType] then
|
local aItemClassId, aItemSubClassId = itemTypes[aType] or 99, itemSubTypes[aType] and itemSubTypes[aType][aSubType] or 99
|
||||||
return (itemTypes[aType] or 99) < (itemTypes[bType] or 99)
|
local bItemClassId, bItemSubClassId = itemTypes[bType] or 99, itemSubTypes[bType] and itemSubTypes[bType][bSubType] or 99
|
||||||
|
|
||||||
|
if aItemClassId ~= bItemClassId then
|
||||||
|
return aItemClassId < bItemClassId
|
||||||
end
|
end
|
||||||
|
|
||||||
if aType == ARMOR then
|
if aItemClassId == 1 or aItemClassId == 2 then
|
||||||
local aEquipLoc = inventorySlots[aEquipLoc] or -1
|
local aEquipLoc = inventorySlots[aEquipLoc] or -1
|
||||||
local bEquipLoc = inventorySlots[bEquipLoc] or -1
|
local bEquipLoc = inventorySlots[bEquipLoc] or -1
|
||||||
if aEquipLoc == bEquipLoc then
|
if aEquipLoc == bEquipLoc then
|
||||||
@@ -205,12 +206,11 @@ local function DefaultSort(a, b)
|
|||||||
return aEquipLoc < bEquipLoc
|
return aEquipLoc < bEquipLoc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if (aItemClassId == bItemClassId) and (aItemSubClassId == bItemSubClassId) then
|
||||||
if aSubType == bSubType then
|
|
||||||
return PrimarySort(a, b)
|
return PrimarySort(a, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
return ((itemSubTypes[aType] or {})[aSubType] or 99) < ((itemSubTypes[bType] or {})[bSubType] or 99)
|
return (aItemSubClassId or 99) < (bItemSubClassId or 99)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ReverseSort(a, b)
|
local function ReverseSort(a, b)
|
||||||
@@ -239,7 +239,7 @@ end
|
|||||||
local function IterateForwards(bagList, i)
|
local function IterateForwards(bagList, i)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
local step = 1
|
local step = 1
|
||||||
for _, bag in bagList do
|
for _, bag in ipairs(bagList) do
|
||||||
local slots = B:GetNumSlots(bag)
|
local slots = B:GetNumSlots(bag)
|
||||||
if i > slots + step then
|
if i > slots + step then
|
||||||
step = step + slots
|
step = step + slots
|
||||||
@@ -273,7 +273,7 @@ local function IterateBackwards(bagList, i)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function B.IterateBags(bagList, reverse, role)
|
function B.IterateBags(bagList, reverse)
|
||||||
return (reverse and IterateBackwards or IterateForwards), bagList, 0
|
return (reverse and IterateBackwards or IterateForwards), bagList, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -456,6 +456,7 @@ local function buildBlacklist(arg)
|
|||||||
blackList[itemName] = true
|
blackList[itemName] = true
|
||||||
elseif entry ~= "" then
|
elseif entry ~= "" then
|
||||||
if find(entry, "%[") and find(entry, "%]") then
|
if find(entry, "%[") and find(entry, "%]") then
|
||||||
|
--For some reason the entry was not treated as a valid item. Extract the item name.
|
||||||
entry = match(entry, "%[(.*)%]")
|
entry = match(entry, "%[(.*)%]")
|
||||||
end
|
end
|
||||||
tinsert(blackListQueries, entry)
|
tinsert(blackListQueries, entry)
|
||||||
@@ -465,12 +466,13 @@ end
|
|||||||
|
|
||||||
function B.Sort(bags, sorter, invertDirection)
|
function B.Sort(bags, sorter, invertDirection)
|
||||||
if not sorter then sorter = invertDirection and ReverseSort or DefaultSort end
|
if not sorter then sorter = invertDirection and ReverseSort or DefaultSort end
|
||||||
if not itemTypes then BuildSortOrder() end
|
|
||||||
|
|
||||||
|
--Wipe tables before we begin
|
||||||
twipe(blackList)
|
twipe(blackList)
|
||||||
twipe(blackListQueries)
|
twipe(blackListQueries)
|
||||||
twipe(blackListedSlots)
|
twipe(blackListedSlots)
|
||||||
|
|
||||||
|
--Build blacklist of items based on the profile and global list
|
||||||
buildBlacklist(B.db.ignoredItems)
|
buildBlacklist(B.db.ignoredItems)
|
||||||
buildBlacklist(E.global.bags.ignoredItems)
|
buildBlacklist(E.global.bags.ignoredItems)
|
||||||
|
|
||||||
@@ -551,9 +553,11 @@ end
|
|||||||
function B.Fill(sourceBags, targetBags, reverse, canMove)
|
function B.Fill(sourceBags, targetBags, reverse, canMove)
|
||||||
if not canMove then canMove = DefaultCanMove end
|
if not canMove then canMove = DefaultCanMove end
|
||||||
|
|
||||||
|
--Wipe tables before we begin
|
||||||
twipe(blackList)
|
twipe(blackList)
|
||||||
twipe(blackListedSlots)
|
twipe(blackListedSlots)
|
||||||
|
|
||||||
|
--Build blacklist of items based on the profile and global list
|
||||||
buildBlacklist(B.db.ignoredItems)
|
buildBlacklist(B.db.ignoredItems)
|
||||||
buildBlacklist(E.global.bags.ignoredItems)
|
buildBlacklist(E.global.bags.ignoredItems)
|
||||||
|
|
||||||
@@ -584,13 +588,13 @@ end
|
|||||||
function B.SortBags(...)
|
function B.SortBags(...)
|
||||||
for i = 1, arg.n do
|
for i = 1, arg.n do
|
||||||
local bags = arg[i]
|
local bags = arg[i]
|
||||||
for i, slotNum in ipairs(bags) do
|
for _, slotNum in ipairs(bags) do
|
||||||
local bagType = B:IsSpecialtyBag(slotNum)
|
local bagType = B:IsSpecialtyBag(slotNum)
|
||||||
if bagType == false then bagType = "Normal" end
|
if bagType == false then bagType = "Normal" end
|
||||||
if not bagCache[bagType] then bagCache[bagType] = {} end
|
if not bagCache[bagType] then bagCache[bagType] = {} end
|
||||||
--bagCache[bagType][i] = slotNum
|
|
||||||
tinsert(bagCache[bagType], slotNum)
|
tinsert(bagCache[bagType], slotNum)
|
||||||
end
|
end
|
||||||
|
|
||||||
for bagType, sortedBags in pairs(bagCache) do
|
for bagType, sortedBags in pairs(bagCache) do
|
||||||
if bagType ~= "Normal" then
|
if bagType ~= "Normal" then
|
||||||
B.Stack(sortedBags, sortedBags, B.IsPartial)
|
B.Stack(sortedBags, sortedBags, B.IsPartial)
|
||||||
@@ -631,6 +635,7 @@ function B:StopStacking(message)
|
|||||||
moveRetries, lastItemID, lockStop, lastDestination, lastMove = 0, nil, nil, nil, nil, nil
|
moveRetries, lastItemID, lockStop, lastDestination, lastMove = 0, nil, nil, nil, nil, nil
|
||||||
|
|
||||||
self.SortUpdateTimer:Hide()
|
self.SortUpdateTimer:Hide()
|
||||||
|
|
||||||
if message then
|
if message then
|
||||||
E:Print(message)
|
E:Print(message)
|
||||||
end
|
end
|
||||||
@@ -715,10 +720,9 @@ function B:DoMoves()
|
|||||||
moveTracker[moveSource] = targetID
|
moveTracker[moveSource] = targetID
|
||||||
moveTracker[moveTarget] = moveID
|
moveTracker[moveTarget] = moveID
|
||||||
lastDestination = moveTarget
|
lastDestination = moveTarget
|
||||||
lastMove = moves[i]
|
-- lastMove = moves[i] --Where does "i" come from???
|
||||||
lastItemID = moveID
|
lastItemID = moveID
|
||||||
currentItemID = nil
|
-- tremove(moves, i) --Where does "i" come from???
|
||||||
tremove(moves, i)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -748,7 +752,6 @@ function B:DoMoves()
|
|||||||
lastDestination = moveTarget
|
lastDestination = moveTarget
|
||||||
lastMove = moves[i]
|
lastMove = moves[i]
|
||||||
lastItemID = moveID
|
lastItemID = moveID
|
||||||
currentItemID = nil
|
|
||||||
tremove(moves, i)
|
tremove(moves, i)
|
||||||
|
|
||||||
if moves[i-1] then
|
if moves[i-1] then
|
||||||
@@ -774,8 +777,7 @@ end
|
|||||||
function B:CommandDecorator(func, groupsDefaults)
|
function B:CommandDecorator(func, groupsDefaults)
|
||||||
return function(groups)
|
return function(groups)
|
||||||
if self.SortUpdateTimer:IsShown() then
|
if self.SortUpdateTimer:IsShown() then
|
||||||
E:Print(L["Already Running.. Bailing Out!"])
|
B:StopStacking(L["Already Running.. Bailing Out!"])
|
||||||
B:StopStacking()
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -783,7 +785,7 @@ function B:CommandDecorator(func, groupsDefaults)
|
|||||||
if not groups or getn(groups) == 0 then
|
if not groups or getn(groups) == 0 then
|
||||||
groups = groupsDefaults
|
groups = groupsDefaults
|
||||||
end
|
end
|
||||||
for bags in gmatch(groups or "", "[^%s]+") do
|
for bags in gmatch(groups or "", "%S+") do
|
||||||
bags = B:GetGroup(bags)
|
bags = B:GetGroup(bags)
|
||||||
if bags then
|
if bags then
|
||||||
tinsert(bagGroups, bags)
|
tinsert(bagGroups, bags)
|
||||||
|
|||||||
Reference in New Issue
Block a user