fix: improve meat/egg sort
This commit is contained in:
@@ -567,10 +567,14 @@ local function AddSortKeys(items)
|
||||
|
||||
-- Texture pattern for grouping similar items (especially trade goods)
|
||||
item.texturePattern = GetTexturePattern(itemTexture)
|
||||
-- Group Trade Goods that are meats/eggs together regardless of texture
|
||||
-- Group Trade Goods: meats (names ending with 'meat') before eggs
|
||||
local nameLower = item.itemName and string.lower(item.itemName) or ""
|
||||
if itemType == "Trade Goods" and (string.find(nameLower, "meat") or string.find(nameLower, "egg")) then
|
||||
item.texturePattern = "trade_meat_egg"
|
||||
if itemType == "Trade Goods" then
|
||||
if string.find(nameLower, "meat$") then
|
||||
item.texturePattern = "trade_meat"
|
||||
elseif string.find(nameLower, "egg") then
|
||||
item.texturePattern = "trade_egg"
|
||||
end
|
||||
end
|
||||
|
||||
-- Inverted values for descending sorts
|
||||
|
||||
+11
-9
@@ -553,18 +553,20 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||
if numItems > 0 then
|
||||
-- Sort items in category: Subclass > Quality > Name
|
||||
table.sort(items, function(a, b)
|
||||
-- Group Trade Goods that are meats/eggs together
|
||||
local function isMeatEgg(d)
|
||||
if not d or not d.name then return false end
|
||||
-- Rank Trade Goods: meat (name ends with 'meat') = 2, egg (contains 'egg') = 1, others = 0
|
||||
local function tgRank(d)
|
||||
if not d or not d.name then return 0 end
|
||||
local t = d.type or d.class or ""
|
||||
if t ~= "Trade Goods" then return false end
|
||||
if t ~= "Trade Goods" then return 0 end
|
||||
local n = string.lower(d.name)
|
||||
return string.find(n, "meat") or string.find(n, "egg")
|
||||
if string.find(n, "meat$") then return 2 end
|
||||
if string.find(n, "egg") then return 1 end
|
||||
return 0
|
||||
end
|
||||
local ma = isMeatEgg(a.itemData)
|
||||
local mb = isMeatEgg(b.itemData)
|
||||
if ma ~= mb then
|
||||
return ma and not mb
|
||||
local ra = tgRank(a.itemData)
|
||||
local rb = tgRank(b.itemData)
|
||||
if ra ~= rb then
|
||||
return ra > rb
|
||||
end
|
||||
-- Priority: consumable restore tags (eat > drink > restore > nil)
|
||||
local pa = a.itemData and a.itemData.restoreTag or nil
|
||||
|
||||
Reference in New Issue
Block a user