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