Add ClassicAPI item charges fast path
This commit is contained in:
@@ -12,6 +12,8 @@ local hasContainerInfo = type(C_Container) == "table"
|
|||||||
and type(C_Container.GetContainerItemInfo) == "function"
|
and type(C_Container.GetContainerItemInfo) == "function"
|
||||||
local hasContainerItemID = type(C_Container) == "table"
|
local hasContainerItemID = type(C_Container) == "table"
|
||||||
and type(C_Container.GetContainerItemID) == "function"
|
and type(C_Container.GetContainerItemID) == "function"
|
||||||
|
local hasContainerCharges = type(C_Container) == "table"
|
||||||
|
and type(C_Container.GetContainerItemCharges) == "function"
|
||||||
|
|
||||||
local function ExtractItemID(link)
|
local function ExtractItemID(link)
|
||||||
if not link then return nil end
|
if not link then return nil end
|
||||||
@@ -31,6 +33,10 @@ function ClassicAPI:HasContainerItemID()
|
|||||||
return hasContainerItemID
|
return hasContainerItemID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ClassicAPI:HasContainerItemCharges()
|
||||||
|
return hasContainerCharges
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns a modern-style ContainerItemInfo table.
|
-- Returns a modern-style ContainerItemInfo table.
|
||||||
-- ClassicAPI supplies this directly. The fallback normalizes Vanilla's flat
|
-- ClassicAPI supplies this directly. The fallback normalizes Vanilla's flat
|
||||||
-- GetContainerItemInfo tuple into the same shape so callers stay branch-free.
|
-- GetContainerItemInfo tuple into the same shape so callers stay branch-free.
|
||||||
@@ -81,10 +87,21 @@ function ClassicAPI:GetContainerItemLink(bagID, slotID, info)
|
|||||||
return GetContainerItemLink(bagID, slotID)
|
return GetContainerItemLink(bagID, slotID)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ClassicAPI reads the live per-instance charge count directly from the item.
|
||||||
|
-- This avoids a hidden-tooltip scan just to parse strings such as "5 Charges".
|
||||||
|
-- Returns nil when ClassicAPI does not expose the function, the slot is empty,
|
||||||
|
-- or the item does not have a charge concept.
|
||||||
|
function ClassicAPI:GetContainerItemCharges(bagID, slotID)
|
||||||
|
if bagID == nil or slotID == nil or slotID < 1 then return nil end
|
||||||
|
if not hasContainerCharges then return nil end
|
||||||
|
return C_Container.GetContainerItemCharges(bagID, slotID)
|
||||||
|
end
|
||||||
|
|
||||||
function ClassicAPI:GetStatus()
|
function ClassicAPI:GetStatus()
|
||||||
return {
|
return {
|
||||||
available = self:IsAvailable(),
|
available = self:IsAvailable(),
|
||||||
containerInfo = hasContainerInfo,
|
containerInfo = hasContainerInfo,
|
||||||
containerItemID = hasContainerItemID,
|
containerItemID = hasContainerItemID,
|
||||||
|
containerCharges = hasContainerCharges,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user