Author SHA1 Message Date
Brues 8ea5c81789 bump CAPI min to 1.12.4 2026-08-24 23:40:01 -05:00
Brues 39a46563a1 tracking: use native ClassicAPI tracking API
Replace the hardcoded knownTrackingSpells class table and the
icon-substring spellbook scan with ClassicAPI's native tracking
functions:

- RefreshSpells now enumerates GetNumTrackingTypes() / GetTrackingInfo(),
  which the DLL derives from the spellbook by tracking-aura effect. This
  drops the per-class spell/icon table and picks up server-custom
  trackers (e.g. Turtle's Find Trees) automatically.
- Selecting a tracker in the menu uses SetTracking(index) instead of
  CastSpell(slot, BOOKTYPE_SPELL).
- Keep the Druid Cat Form gate on Track Humanoids (5225) and the
  existing invalidSpells filter. Falls back to no entries if the tracking
  API is absent.

Active icon (GetTrackingTexture), cancel (CancelTrackingBuff), and the
hover tooltip (GameTooltip:SetTrackingSpell) were already native and are
unchanged.
2026-08-24 23:35:49 -05:00
2 changed files with 24 additions and 91 deletions
+23 -90
View File
@@ -3,56 +3,15 @@ pfUI:RegisterModule("tracking", function ()
MINIMAP_TRACKING_FRAME:UnregisterAllEvents() MINIMAP_TRACKING_FRAME:UnregisterAllEvents()
MINIMAP_TRACKING_FRAME:Hide() MINIMAP_TRACKING_FRAME:Hide()
local function HasEntries(tbl)
for _ in pairs(tbl) do
return true
end
return nil
end
local rawborder, border = GetBorderSize() local rawborder, border = GetBorderSize()
local size = tonumber(C.appearance.minimap.tracking_size) local size = tonumber(C.appearance.minimap.tracking_size)
local pulse = C.appearance.minimap.tracking_pulse == "1" local pulse = C.appearance.minimap.tracking_pulse == "1"
-- Tracking spells identified by SpellID + expected icon path. -- Tracking spells come from ClassicAPI's native GetNumTrackingTypes /
-- SpellID is the primary identifier (stable, locale-independent). -- GetTrackingInfo (see the DLL's docs/API.md "Tracking"). The DLL
-- Icon path is used as secondary confirmation when scanning the spellbook. -- enumerates them straight from the spellbook by tracking-aura effect,
local knownTrackingSpells = { -- so there is no spell table to maintain here and server-custom trackers
any = { -- (e.g. Turtle's Find Trees) are picked up automatically.
{ id = 2481, icon = "Racial_Dwarf_FindTreasure" }, -- Find Treasure
{ id = 2580, icon = "Spell_Nature_Earthquake" }, -- Find Minerals
{ id = 2383, icon = "INV_Misc_Flower_02" }, -- Find Herbs (Rank 1)
{ id = 8387, icon = "INV_Misc_Flower_02" }, -- Find Herbs (Rank 2)
{ id = 52917, icon = "INV_TradeSkillItem_03" }, -- Find Trees (TurtleWow)
},
HUNTER = {
{ id = 1494, icon = "Ability_Tracking" }, -- Track Beasts
{ id = 19883, icon = "Spell_Holy_PrayerOfHealing" }, -- Track Humanoids
{ id = 19884, icon = "Spell_Shadow_DarkSummoning" }, -- Track Undead
{ id = 19885, icon = "Ability_Stealth" }, -- Track Hidden
{ id = 19880, icon = "Spell_Frost_SummonWaterElemental" }, -- Track Elementals
{ id = 19878, icon = "Spell_Shadow_SummonFelHunter" }, -- Track Demons
{ id = 19882, icon = "Ability_Racial_Avatar" }, -- Track Giants
{ id = 19879, icon = "INV_Misc_Head_Dragon_01" }, -- Track Dragonkin
},
PALADIN = {
{ id = 5502, icon = "Spell_Holy_SenseUndead" }, -- Sense Undead
},
WARLOCK = {
{ id = 5500, icon = "Spell_Shadow_Metamorphosis" }, -- Sense Demons
},
DRUID = {
{ id = 5225, icon = "Ability_Tracking" }, -- Track Humanoids (Cat Form only)
},
}
-- Build a flat lookup: spellId -> entry, for fast spellbook matching
local spellIdLookup = {}
for _, entries in pairs(knownTrackingSpells) do
for _, entry in ipairs(entries) do
spellIdLookup[entry.id] = entry
end
end
local state = { local state = {
texture = nil, texture = nil,
@@ -128,50 +87,24 @@ pfUI:RegisterModule("tracking", function ()
end) end)
function pfUI.tracking:RefreshSpells() function pfUI.tracking:RefreshSpells()
local playerClass = UnitClassBase("player") state.spells = {}
local isCatForm = pfUI.tracking:PlayerIsDruidInCatForm(playerClass) if not GetNumTrackingTypes then return end
-- Build set of valid SpellIDs for this class -- Druid Track Humanoids (5225) only casts in Cat Form. Hide it out of
local validIds = {} -- form so the menu never offers a tracker that would fail to cast.
for _, entry in ipairs(knownTrackingSpells.any) do local isCatForm = pfUI.tracking:PlayerIsDruidInCatForm(UnitClassBase("player"))
validIds[entry.id] = true
end
if knownTrackingSpells[playerClass] then
for _, entry in ipairs(knownTrackingSpells[playerClass]) do
validIds[entry.id] = true
end
end
-- Druids only get Track Humanoids in Cat Form for i = 1, GetNumTrackingTypes() do
if playerClass == "DRUID" and not isCatForm then local name, texture, _, _, spellId = GetTrackingInfo(i)
validIds[5225] = nil local castable = not (spellId == 5225 and not isCatForm)
end if name and texture and castable
and not pfUI.tracking.invalidSpells[name] then
-- Scan spellbook: match by icon path, confirm SpellID is valid for this class state.spells[i] = {
for tabIndex = 1, GetNumSpellTabs() do index = i, -- tracking index, passed to SetTracking()
local _, _, offset, numSpells = GetSpellTabInfo(tabIndex) name = name,
for spellIndex = offset + 1, offset + numSpells do texture = texture,
local spellTexture = GetSpellTexture(spellIndex, BOOKTYPE_SPELL) spellId = spellId,
local spellName = GetSpellName(spellIndex, BOOKTYPE_SPELL) }
if pfUI.tracking.invalidSpells[spellName] then
spellTexture = nil
end
if spellTexture then
local lowerTexture = string.lower(spellTexture)
for spellId, entry in pairs(spellIdLookup) do
if validIds[spellId] and not state.spells[spellId]
and strfind(lowerTexture, string.lower(entry.icon)) then
state.spells[spellId] = {
index = spellIndex,
name = spellName,
texture = spellTexture,
spellId = spellId,
}
end
end
end
end end
end end
end end
@@ -187,7 +120,7 @@ pfUI:RegisterModule("tracking", function ()
elseif not texture then elseif not texture then
state.texture = nil state.texture = nil
if pulse and HasEntries(state.spells) then if pulse and next(state.spells) ~= nil then
pfUI.tracking.pulse = true pfUI.tracking.pulse = true
pfUI.tracking.icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark") pfUI.tracking.icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
pfUI.tracking.icon:SetVertexColor(1,1,1,1) pfUI.tracking.icon:SetVertexColor(1,1,1,1)
@@ -217,7 +150,7 @@ pfUI:RegisterModule("tracking", function ()
checked = spell.texture == state.texture, checked = spell.texture == state.texture,
arg1 = spell, arg1 = spell,
func = function (arg1) func = function (arg1)
CastSpell(arg1.index, BOOKTYPE_SPELL) SetTracking(arg1.index)
CloseDropDownMenus() CloseDropDownMenus()
end end
}) })
+1 -1
View File
@@ -23,7 +23,7 @@ do
-- ClassicAPI dependency check. -- ClassicAPI dependency check.
-- pfUI relies pervasively on the modern C_* / SuperWoW / nameplate / focus -- pfUI relies pervasively on the modern C_* / SuperWoW / nameplate / focus
-- API surface that ClassicAPI polyfills, so presence is required. -- API surface that ClassicAPI polyfills, so presence is required.
local PFUI_CLASSIC_API_MIN = 11201 -- (X*10000 + Y*100 + Z) local PFUI_CLASSIC_API_MIN = 11204 -- (X*10000 + Y*100 + Z)
local PFUI_CLASSIC_API_LATEST = PFUI_CLASSIC_API_MIN local PFUI_CLASSIC_API_LATEST = PFUI_CLASSIC_API_MIN
local PFUI_CLASSIC_API_WEBSITE = "https://github.com/brues-code/ClassicAPI" local PFUI_CLASSIC_API_WEBSITE = "https://github.com/brues-code/ClassicAPI"
local PFUI_CLASSIC_API_LATEST_URL = PFUI_CLASSIC_API_WEBSITE .. "/releases/latest" local PFUI_CLASSIC_API_LATEST_URL = PFUI_CLASSIC_API_WEBSITE .. "/releases/latest"