mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-30 03:06:01 +00:00
libspell uses ClassicAPI GetSpellInfo
GetSpellInfo internals now delegate to ClassicAPI's GetSpellInfo for the DBC metadata read instead of scraping castTime/range out of the tooltip. Drops the libtipscan dependency from libspell and the regex-based parsing of SPELL_CAST_TIME_SEC/MIN/SPELL_RANGE. Same 8-value return shape so all call sites (libtotem, libpredict, libcast, actionbar) continue working.
This commit is contained in:
+12
-40
@@ -4,7 +4,6 @@ setfenv(1, pfUI:GetEnvironment())
|
||||
-- return instantly when another libspell is already active
|
||||
if pfUI.api.libspell then return end
|
||||
|
||||
local scanner = libtipscan:GetScanner("libspell")
|
||||
local libspell = {}
|
||||
|
||||
-- [ GetSpellMaxRank ]
|
||||
@@ -91,55 +90,28 @@ function libspell.GetSpellInfo(index, bookType)
|
||||
local cache = spellinfo[index]
|
||||
if cache then return cache[1], cache[2], cache[3], cache[4], cache[5], cache[6], cache[7], cache[8] end
|
||||
|
||||
local name, rank, id
|
||||
local icon = ""
|
||||
local castingTime = 0
|
||||
local minRange = 0
|
||||
local maxRange = 0
|
||||
|
||||
local slot
|
||||
if type(index) == "string" then
|
||||
local _, _, sname, srank = string.find(index, '(.+)%((.+)%)')
|
||||
name = sname or index
|
||||
rank = srank or libspell.GetSpellMaxRank(name)
|
||||
id, bookType = libspell.GetSpellIndex(name, rank)
|
||||
|
||||
-- correct name in case of wrong upper/lower cases
|
||||
if id and bookType then
|
||||
name = GetSpellName(id, bookType)
|
||||
end
|
||||
local name = sname or index
|
||||
local rank = srank or libspell.GetSpellMaxRank(name)
|
||||
slot, bookType = libspell.GetSpellIndex(name, rank)
|
||||
else
|
||||
if not bookType or (bookType ~= BOOKTYPE_SPELL and bookType ~= BOOKTYPE_PET) then
|
||||
return nil
|
||||
end
|
||||
name, rank = GetSpellName(index, bookType)
|
||||
id, bookType = libspell.GetSpellIndex(name, rank)
|
||||
slot = index
|
||||
end
|
||||
|
||||
if name and id then
|
||||
icon = GetSpellTexture(id, bookType)
|
||||
end
|
||||
if not slot or not bookType then return nil end
|
||||
|
||||
if id then
|
||||
scanner:SetSpell(id, bookType)
|
||||
local _, sec = scanner:Find(gsub(SPELL_CAST_TIME_SEC, "%%.3g", "%(.+%)"), false)
|
||||
local _, min = scanner:Find(gsub(SPELL_CAST_TIME_MIN, "%%.3g", "%(.+%)"), false)
|
||||
local _, range = scanner:Find(gsub(SPELL_RANGE, "%%s", "%(.+%)"), false)
|
||||
-- ClassicAPI's GetSpellInfo returns: name, rank, icon, cost, isFunnel, powerType,
|
||||
-- castTime(ms), minRange, maxRange, spellID. Keep libspell's historical positional
|
||||
-- shape (castingTime at 4, ranges at 5/6, slot+bookType at 7/8).
|
||||
local name, rank, icon, _, _, _, castingTime, minRange, maxRange = GetSpellInfo(slot, bookType)
|
||||
|
||||
castingTime = (tonumber(sec) or tonumber(min) or 0) * 1000
|
||||
if range then
|
||||
local _, _, min, max = string.find(range, "(.+)-(.+)")
|
||||
if min and max then
|
||||
minRange = tonumber(min)
|
||||
maxRange = tonumber(max)
|
||||
else
|
||||
minRange = 0
|
||||
maxRange = tonumber(range)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
spellinfo[index] = { name, rank, icon, castingTime, minRange, maxRange, id, bookType }
|
||||
return name, rank, icon, castingTime, minRange, maxRange, id, bookType
|
||||
spellinfo[index] = { name, rank, icon, castingTime, minRange, maxRange, slot, bookType }
|
||||
return name, rank, icon, castingTime, minRange, maxRange, slot, bookType
|
||||
end
|
||||
|
||||
-- Reset all spell caches whenever new spells are learned/unlearned
|
||||
|
||||
Reference in New Issue
Block a user