Add ClassicAPI tooltip item bridges
This commit is contained in:
@@ -72,6 +72,9 @@ API.mapexploration = type(_G.C_MapExplorationInfo) == "table"
|
|||||||
API.eventutils = type(_G.C_EventUtils) == "table"
|
API.eventutils = type(_G.C_EventUtils) == "table"
|
||||||
and type(_G.C_EventUtils.IsEventValid) == "function"
|
and type(_G.C_EventUtils.IsEventValid) == "function"
|
||||||
|
|
||||||
|
API.timer = type(_G.C_Timer) == "table"
|
||||||
|
and type(_G.C_Timer.After) == "function"
|
||||||
|
|
||||||
-- ClassicAPI v1.12.5 made nameplate lifecycle events reload-safe by clearing
|
-- ClassicAPI v1.12.5 made nameplate lifecycle events reload-safe by clearing
|
||||||
-- and rebuilding their token/wrapper state around /reload. Older builds can
|
-- and rebuilding their token/wrapper state around /reload. Older builds can
|
||||||
-- expose the same event names without those guarantees, so keep them on the
|
-- expose the same event names without those guarantees, so keep them on the
|
||||||
@@ -112,11 +115,14 @@ API.unitguid = type(_G.UnitGUID) == "function"
|
|||||||
API.unittoken = type(_G.UnitTokenFromGUID) == "function"
|
API.unittoken = type(_G.UnitTokenFromGUID) == "function"
|
||||||
API.tooltipunit = _G.GameTooltip
|
API.tooltipunit = _G.GameTooltip
|
||||||
and type(_G.GameTooltip.GetUnitGUID) == "function"
|
and type(_G.GameTooltip.GetUnitGUID) == "function"
|
||||||
-- OnTooltipSetUnit shipped in ClassicAPI v1.8.2, but its per-tooltip
|
API.tooltipitem = API.classicapi_version >= 11202
|
||||||
-- handler cells became reload-safe in v1.12.2. Require the fixed generation
|
and _G.GameTooltip and type(_G.GameTooltip.GetItem) == "function"
|
||||||
-- instead of falling back to Vanilla OnShow/mouseover polling.
|
-- OnTooltipSet* shipped before v1.12.2, but their per-tooltip handler cells
|
||||||
|
-- became reload-safe in v1.12.2. Require that fixed generation whenever a
|
||||||
|
-- module hooks the native tooltip-builder scripts.
|
||||||
API.tooltipsetunit = API.classicapi_version >= 11202
|
API.tooltipsetunit = API.classicapi_version >= 11202
|
||||||
and API.tooltipunit and API.unittoken
|
and API.tooltipunit and API.unittoken
|
||||||
|
API.tooltipsetitem = API.tooltipitem
|
||||||
API.unitrange = type(_G.UnitInRange) == "function"
|
API.unitrange = type(_G.UnitInRange) == "function"
|
||||||
|
|
||||||
API.macrospell = type(_G.GetMacroSpell) == "function"
|
API.macrospell = type(_G.GetMacroSpell) == "function"
|
||||||
@@ -319,6 +325,12 @@ API.GetSpellReagents = function(spellID)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
API.Defer = function(callback)
|
||||||
|
if API.timer and callback then
|
||||||
|
return _G.C_Timer.After(0, callback)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
API.GetContainerNumFreeSlots = function(bag)
|
API.GetContainerNumFreeSlots = function(bag)
|
||||||
if API.inventory then
|
if API.inventory then
|
||||||
return _G.C_Container.GetContainerNumFreeSlots(bag)
|
return _G.C_Container.GetContainerNumFreeSlots(bag)
|
||||||
@@ -681,6 +693,13 @@ API.GetTooltipUnitGUID = function(tooltip)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
API.GetTooltipItemID = function(tooltip)
|
||||||
|
if API.tooltipitem and tooltip then
|
||||||
|
local _, _, itemID = tooltip:GetItem()
|
||||||
|
return itemID
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Prefer ClassicAPI's reach-aware 40-yard UnitInRange. The wrapper handles
|
-- Prefer ClassicAPI's reach-aware 40-yard UnitInRange. The wrapper handles
|
||||||
-- the player's own frame explicitly and preserves a Vanilla interaction check
|
-- the player's own frame explicitly and preserves a Vanilla interaction check
|
||||||
-- only as a centralized compatibility fallback.
|
-- only as a centralized compatibility fallback.
|
||||||
|
|||||||
Reference in New Issue
Block a user