fix: category types added
This commit is contained in:
+32
-5
@@ -336,8 +336,10 @@ function BagFrame:Update()
|
||||
|
||||
if viewType == "category" then
|
||||
self:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||
if getglobal("Guda_BagFrame_SortButton") then getglobal("Guda_BagFrame_SortButton"):Hide() end
|
||||
else
|
||||
self:DisplayItems(bagData, isOtherChar, charName)
|
||||
if getglobal("Guda_BagFrame_SortButton") then getglobal("Guda_BagFrame_SortButton"):Show() end
|
||||
end
|
||||
|
||||
-- Update money
|
||||
@@ -401,7 +403,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||
-- Group items by category
|
||||
local categories = {}
|
||||
local categoryList = {
|
||||
"Equipment", "Consumable", "Quest", "Trade Goods", "Reagent", "Recipe", "Quiver", "Container", "Miscellaneous", "Soul Bag", "Keyring"
|
||||
"Weapon", "Armor", "Consumable", "Food", "Drink", "Quest", "Trade Goods", "Reagent", "Recipe", "Quiver", "Container", "Soul Bag", "Keyring", "Miscellaneous"
|
||||
}
|
||||
for _, cat in ipairs(categoryList) do categories[cat] = {} end
|
||||
|
||||
@@ -412,11 +414,33 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||
for slotID, itemData in pairs(bag.slots) do
|
||||
if itemData then
|
||||
local cat = itemData.class or "Miscellaneous"
|
||||
-- Special handling for equipment
|
||||
|
||||
-- Split Equipment into Weapon and Armor
|
||||
if itemData.equipSlot and itemData.equipSlot ~= "" then
|
||||
cat = "Equipment"
|
||||
if itemData.class == "Weapon" or itemData.class == "Armor" then
|
||||
cat = itemData.class
|
||||
else
|
||||
cat = "Armor" -- Accessories etc usually fall here if equippable
|
||||
end
|
||||
end
|
||||
if not categories[cat] then categories[cat] = {} end
|
||||
|
||||
-- Detect Food and Drink
|
||||
if itemData.class == "Consumable" then
|
||||
local sub = itemData.subclass or ""
|
||||
if sub == "Food & Drink" or string.find(sub, "Food") or string.find(sub, "Drink") then
|
||||
-- Try to be more specific if possible, but "Food & Drink" is the standard subclass
|
||||
-- For simplicity we can check item name or texture if we wanted to split,
|
||||
-- but user asked for "Food", "Drink".
|
||||
-- If we can't easily distinguish, we'll put them in "Food" or "Drink" based on subclass text
|
||||
if string.find(sub, "Drink") then
|
||||
cat = "Drink"
|
||||
else
|
||||
cat = "Food"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not categories[cat] then cat = "Miscellaneous" end
|
||||
table.insert(categories[cat], {bagID = bagID, slotID = slotID, itemData = itemData})
|
||||
end
|
||||
end
|
||||
@@ -444,8 +468,11 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName)
|
||||
for _, catName in ipairs(categoryList) do
|
||||
local items = categories[catName]
|
||||
if items and table.getn(items) > 0 then
|
||||
-- Sort items in category
|
||||
-- Sort items in category: Subclass > Quality > Name
|
||||
table.sort(items, function(a, b)
|
||||
if a.itemData.subclass ~= b.itemData.subclass then
|
||||
return (a.itemData.subclass or "") < (b.itemData.subclass or "")
|
||||
end
|
||||
if a.itemData.quality ~= b.itemData.quality then
|
||||
return a.itemData.quality > b.itemData.quality
|
||||
end
|
||||
|
||||
+38
-8
@@ -191,8 +191,10 @@ function BankFrame:Update()
|
||||
|
||||
if viewType == "category" then
|
||||
self:DisplayItemsByCategory(bankData, isOtherChar, charName)
|
||||
if getglobal("Guda_BankFrame_SortButton") then getglobal("Guda_BankFrame_SortButton"):Hide() end
|
||||
else
|
||||
self:DisplayItems(bankData, isOtherChar, charName)
|
||||
if getglobal("Guda_BankFrame_SortButton") then getglobal("Guda_BankFrame_SortButton"):Show() end
|
||||
end
|
||||
|
||||
-- Update money
|
||||
@@ -253,18 +255,45 @@ function BankFrame:DisplayItemsByCategory(bankData, isOtherChar, charName)
|
||||
-- Group items by category
|
||||
local categories = {}
|
||||
local categoryList = {
|
||||
"Equipment", "Consumable", "Quest", "Trade Goods", "Reagent", "Recipe", "Quiver", "Container", "Miscellaneous"
|
||||
"Weapon", "Armor", "Consumable", "Food", "Drink", "Quest", "Trade Goods", "Reagent", "Recipe", "Quiver", "Container", "Soul Bag", "Miscellaneous"
|
||||
}
|
||||
for _, cat in ipairs(categoryList) do categories[cat] = {} end
|
||||
|
||||
-- Helper to assign category
|
||||
local function GetItemCategory(itemData)
|
||||
local cat = itemData.class or "Miscellaneous"
|
||||
|
||||
-- Split Equipment into Weapon and Armor
|
||||
if itemData.equipSlot and itemData.equipSlot ~= "" then
|
||||
if itemData.class == "Weapon" or itemData.class == "Armor" then
|
||||
cat = itemData.class
|
||||
else
|
||||
cat = "Armor"
|
||||
end
|
||||
end
|
||||
|
||||
-- Detect Food and Drink
|
||||
if itemData.class == "Consumable" then
|
||||
local sub = itemData.subclass or ""
|
||||
if sub == "Food & Drink" or string.find(sub, "Food") or string.find(sub, "Drink") then
|
||||
if string.find(sub, "Drink") then
|
||||
cat = "Drink"
|
||||
else
|
||||
cat = "Food"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not categories[cat] then cat = "Miscellaneous" end
|
||||
return cat
|
||||
end
|
||||
|
||||
-- Bank main slots (bagID -1)
|
||||
local bankMain = bankData[-1]
|
||||
if bankMain and bankMain.slots then
|
||||
for slotID, itemData in pairs(bankMain.slots) do
|
||||
if itemData then
|
||||
local cat = itemData.class or "Miscellaneous"
|
||||
if itemData.equipSlot and itemData.equipSlot ~= "" then cat = "Equipment" end
|
||||
if not categories[cat] then categories[cat] = {} end
|
||||
local cat = GetItemCategory(itemData)
|
||||
table.insert(categories[cat], {bagID = -1, slotID = slotID, itemData = itemData})
|
||||
end
|
||||
end
|
||||
@@ -277,9 +306,7 @@ function BankFrame:DisplayItemsByCategory(bankData, isOtherChar, charName)
|
||||
if bag and bag.slots then
|
||||
for slotID, itemData in pairs(bag.slots) do
|
||||
if itemData then
|
||||
local cat = itemData.class or "Miscellaneous"
|
||||
if itemData.equipSlot and itemData.equipSlot ~= "" then cat = "Equipment" end
|
||||
if not categories[cat] then categories[cat] = {} end
|
||||
local cat = GetItemCategory(itemData)
|
||||
table.insert(categories[cat], {bagID = bagID, slotID = slotID, itemData = itemData})
|
||||
end
|
||||
end
|
||||
@@ -294,8 +321,11 @@ function BankFrame:DisplayItemsByCategory(bankData, isOtherChar, charName)
|
||||
for _, catName in ipairs(categoryList) do
|
||||
local items = categories[catName]
|
||||
if items and table.getn(items) > 0 then
|
||||
-- Sort items in category
|
||||
-- Sort items in category: Subclass > Quality > Name
|
||||
table.sort(items, function(a, b)
|
||||
if a.itemData.subclass ~= b.itemData.subclass then
|
||||
return (a.itemData.subclass or "") < (b.itemData.subclass or "")
|
||||
end
|
||||
if a.itemData.quality ~= b.itemData.quality then
|
||||
return a.itemData.quality > b.itemData.quality
|
||||
end
|
||||
|
||||
+22
-22
@@ -949,28 +949,28 @@ function Guda_ItemButton_OnEnter(self)
|
||||
|
||||
-- Debug: print hovered item's texture path to chat
|
||||
-- Uses GetItemInfo on the hovered item's ID
|
||||
--if self.hasItem then
|
||||
-- local link = nil
|
||||
-- if self.itemData and self.itemData.link then
|
||||
-- link = self.itemData.link
|
||||
-- else
|
||||
-- -- Fallback to live bag query
|
||||
-- link = GetContainerItemLink(self.bagID, self.slotID)
|
||||
-- end
|
||||
-- if link and addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.ExtractItemID then
|
||||
-- local itemID = addon.Modules.Utils:ExtractItemID(link)
|
||||
-- if itemID and addon.Modules.Utils.GetItemInfoSafe then
|
||||
-- local name, itemLink, itemRarity, itemLevel, itemCategory, itemType, itemStackCount,
|
||||
-- itemSubType, itemTexture, itemEquipLoc, itemSellPrice = addon.Modules.Utils:GetItemInfoSafe(itemID)
|
||||
-- if addon and addon.Print then
|
||||
-- addon:Print("itemTexture: %s", tostring(itemTexture))
|
||||
-- addon:Print("itemCategory: %s", tostring(itemCategory))
|
||||
-- addon:Print("itemType: %s", tostring(itemType))
|
||||
-- addon:Print("itemType: %s", tostring(itemType))
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
--end
|
||||
if self.hasItem then
|
||||
local link = nil
|
||||
if self.itemData and self.itemData.link then
|
||||
link = self.itemData.link
|
||||
else
|
||||
-- Fallback to live bag query
|
||||
link = GetContainerItemLink(self.bagID, self.slotID)
|
||||
end
|
||||
if link and addon and addon.Modules and addon.Modules.Utils and addon.Modules.Utils.ExtractItemID then
|
||||
local itemID = addon.Modules.Utils:ExtractItemID(link)
|
||||
if itemID and addon.Modules.Utils.GetItemInfoSafe then
|
||||
local name, itemLink, itemRarity, itemLevel, itemCategory, itemType, itemStackCount,
|
||||
itemSubType, itemTexture, itemEquipLoc, itemSellPrice = addon.Modules.Utils:GetItemInfoSafe(itemID)
|
||||
if addon and addon.Print then
|
||||
addon:Print("itemTexture: %s", tostring(itemTexture))
|
||||
addon:Print("itemCategory: %s", tostring(itemCategory))
|
||||
addon:Print("itemType: %s", tostring(itemType))
|
||||
addon:Print("itemType: %s", tostring(itemType))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Handle merchant sell cursor (same approach as BagShui)
|
||||
if MerchantFrame:IsShown() and not self.isBank and not self.otherChar and self.hasItem then
|
||||
ShowContainerSellCursor(self.bagID, self.slotID)
|
||||
|
||||
Reference in New Issue
Block a user