fix: mailbox count
This commit is contained in:
+34
-12
@@ -112,17 +112,28 @@ local function CountCurrentCharacterItems(itemID)
|
||||
for _, mail in ipairs(charData.mailbox) do
|
||||
if mail.items then
|
||||
for _, item in ipairs(mail.items) do
|
||||
if item.link then
|
||||
local slotItemID = GetItemIDFromLink(item.link)
|
||||
if slotItemID == itemID then
|
||||
local slotItemID = item.link and GetItemIDFromLink(item.link)
|
||||
if slotItemID == itemID then
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
elseif not slotItemID and item.name then
|
||||
-- Fallback to name matching if link is missing
|
||||
local targetName = GetItemInfo(itemID)
|
||||
if targetName == item.name then
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif mail.item and mail.item.link then -- Fallback for single item data structure
|
||||
local slotItemID = GetItemIDFromLink(mail.item.link)
|
||||
elseif mail.item then -- Fallback for single item data structure
|
||||
local item = mail.item
|
||||
local slotItemID = item.link and GetItemIDFromLink(item.link)
|
||||
if slotItemID == itemID then
|
||||
mailCount = mailCount + (mail.item.count or 1)
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
elseif not slotItemID and item.name then
|
||||
-- Fallback to name matching if link is missing
|
||||
local targetName = GetItemInfo(itemID)
|
||||
if targetName == item.name then
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -193,17 +204,28 @@ local function CountItemsForCharacter(itemID, characterData, isCurrentChar)
|
||||
for _, mail in ipairs(characterData.mailbox) do
|
||||
if mail.items then
|
||||
for _, item in ipairs(mail.items) do
|
||||
if item.link then
|
||||
local slotItemID = GetItemIDFromLink(item.link)
|
||||
if slotItemID == itemID then
|
||||
local slotItemID = item.link and GetItemIDFromLink(item.link)
|
||||
if slotItemID == itemID then
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
elseif not slotItemID and item.name then
|
||||
-- Fallback to name matching if link is missing
|
||||
local targetName = GetItemInfo(itemID)
|
||||
if targetName == item.name then
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif mail.item and mail.item.link then -- Fallback for single item data structure
|
||||
local slotItemID = GetItemIDFromLink(mail.item.link)
|
||||
elseif mail.item then -- Fallback for single item data structure
|
||||
local item = mail.item
|
||||
local slotItemID = item.link and GetItemIDFromLink(item.link)
|
||||
if slotItemID == itemID then
|
||||
mailCount = mailCount + (mail.item.count or 1)
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
elseif not slotItemID and item.name then
|
||||
-- Fallback to name matching if link is missing
|
||||
local targetName = GetItemInfo(itemID)
|
||||
if targetName == item.name then
|
||||
mailCount = mailCount + (item.count or 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+38
-39
@@ -36,49 +36,48 @@ function MailboxScanner:ScanMailItemRows(index)
|
||||
local rows = {}
|
||||
|
||||
if hasItem then
|
||||
-- Turtle WoW supports up to 12 attachments per mail
|
||||
local itemIndex = 1
|
||||
-- GetInboxItem(index, itemIndex) returns: name, texture, count, quality, canUse
|
||||
local name, texture, count, quality, canUse = GetInboxItem(index, itemIndex)
|
||||
if name then
|
||||
local itemLink = addon.Modules.Utils:GetInboxItemLink(index, itemIndex)
|
||||
|
||||
-- GetInboxItem(index, itemIndex) returns: name, texture, count, quality, canUse
|
||||
local name, texture, count, quality, canUse = GetInboxItem(index, itemIndex)
|
||||
if name then
|
||||
local itemLink = addon.Modules.Utils:GetInboxItemLink(index, itemIndex)
|
||||
local itemData = {
|
||||
link = itemLink,
|
||||
texture = texture or "Interface\\Icons\\INV_Misc_Bag_08",
|
||||
count = count or 1,
|
||||
quality = quality or 0,
|
||||
name = name,
|
||||
}
|
||||
|
||||
local itemData = {
|
||||
link = itemLink,
|
||||
texture = texture or "Interface\\Icons\\INV_Misc_Bag_08",
|
||||
count = count or 1,
|
||||
quality = quality or 0,
|
||||
name = name,
|
||||
}
|
||||
|
||||
-- If we have a link, try to get more detailed info
|
||||
if itemLink then
|
||||
local itemName, link, itemQuality, iLevel, itemCategory, itemType, itemStackCount, itemSubType, itemTexture, itemEquipLoc, itemSellPrice = addon.Modules.Utils:GetItemInfo(itemLink)
|
||||
if itemName then
|
||||
itemData.name = itemName
|
||||
itemData.quality = itemQuality or itemData.quality
|
||||
itemData.iLevel = iLevel
|
||||
itemData.type = itemType
|
||||
itemData.class = itemCategory
|
||||
itemData.subclass = itemSubType
|
||||
itemData.equipSlot = itemEquipLoc
|
||||
if itemTexture then itemData.texture = itemTexture end
|
||||
end
|
||||
-- If we have a link, try to get more detailed info
|
||||
if itemLink then
|
||||
local itemName, link, itemQuality, iLevel, itemCategory, itemType, itemStackCount, itemSubType, itemTexture, itemEquipLoc, itemSellPrice = addon.Modules.Utils:GetItemInfo(itemLink)
|
||||
if itemName then
|
||||
itemData.name = itemName
|
||||
itemData.quality = itemQuality or itemData.quality
|
||||
itemData.iLevel = iLevel
|
||||
itemData.type = itemType
|
||||
itemData.class = itemCategory
|
||||
itemData.subclass = itemSubType
|
||||
itemData.equipSlot = itemEquipLoc
|
||||
if itemTexture then itemData.texture = itemTexture end
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(rows, {
|
||||
sender = sender,
|
||||
subject = subject,
|
||||
money = (itemIndex == 1) and money or 0, -- Attach money only to the first row of this mail
|
||||
CODAmount = (itemIndex == 1) and CODAmount or 0,
|
||||
daysLeft = daysLeft,
|
||||
hasItem = true,
|
||||
item = itemData,
|
||||
mailIndex = index,
|
||||
itemIndex = itemIndex,
|
||||
wasRead = wasRead,
|
||||
packageIcon = packageIcon,
|
||||
})
|
||||
table.insert(rows, {
|
||||
sender = sender,
|
||||
subject = subject,
|
||||
money = (itemIndex == 1) and money or 0, -- Attach money only to the first row of this mail
|
||||
CODAmount = (itemIndex == 1) and CODAmount or 0,
|
||||
daysLeft = daysLeft,
|
||||
hasItem = true,
|
||||
item = itemData,
|
||||
mailIndex = index,
|
||||
itemIndex = itemIndex,
|
||||
wasRead = wasRead,
|
||||
packageIcon = packageIcon,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+2
-2
@@ -150,12 +150,12 @@
|
||||
<Frames>
|
||||
<EditBox name="$parent_SearchBox" autoFocus="false" inherits="InputBoxTemplate">
|
||||
<Size>
|
||||
<AbsDimension x="240" y="20"/>
|
||||
<AbsDimension x="235" y="20"/>
|
||||
</Size>
|
||||
<Anchors>
|
||||
<Anchor point="LEFT">
|
||||
<Offset>
|
||||
<AbsDimension x="5" y="0"/>
|
||||
<AbsDimension x="10" y="0"/>
|
||||
</Offset>
|
||||
</Anchor>
|
||||
</Anchors>
|
||||
|
||||
Reference in New Issue
Block a user