Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Use GetItemCount API for determining item counts if available #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions features/tooltipCounts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,37 @@ local function AddOwners(tooltip, link)
text = ItemText[owner][itemID]
else
if not info.isguild then
local equip = FindItemCount(owner, 'equip', itemID)
local vault = FindItemCount(owner, 'vault', itemID)
local equip
local vault
local bags, bank = 0,0

if info.cached then
for i = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
bags = bags + FindItemCount(owner, i, itemID)
end

for i = FIRST_BANK_SLOT, LAST_BANK_SLOT do
bank = bank + FindItemCount(owner, i, itemID)
end
if (Addon.GetItemCount) then
equip = Addon:GetItemCount(owner, 'equip', itemID)
vault = Addon:GetItemCount(owner, 'vault', itemID)
else
equip = FindItemCount(owner, 'equip', itemID)
vault = FindItemCount(owner, 'vault', itemID)
end

if REAGENTBANK_CONTAINER then
bank = bank + FindItemCount(owner, REAGENTBANK_CONTAINER, itemID)
if info.cached then
if (Addon.GetItemCount) then
bags = Addon:GetItemCount(owner, 'bags', itemID)
bank = Addon:GetItemCount(owner, 'bank', itemID)
else
for i = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
bags = bags + FindItemCount(owner, i, itemID)
end

for i = FIRST_BANK_SLOT, LAST_BANK_SLOT do
bank = bank + FindItemCount(owner, i, itemID)
end

if REAGENTBANK_CONTAINER then
bank = bank + FindItemCount(owner, REAGENTBANK_CONTAINER, itemID)
end

bank = bank + FindItemCount(owner, BANK_CONTAINER, itemID)
end

bank = bank + FindItemCount(owner, BANK_CONTAINER, itemID)
else
local owned = GetItemCount(itemID, true)
local carrying = GetItemCount(itemID)
Expand Down Expand Up @@ -179,7 +192,7 @@ function TooltipCounts:OnEnable()
if Addon.sets.tipCount then
if not ItemText then
ItemText, ItemCount = {}, {}

HookTip(GameTooltip)
HookTip(ItemRefTooltip)
end
Expand Down