mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-26 14:00:48 +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
|
-- return instantly when another libspell is already active
|
||||||
if pfUI.api.libspell then return end
|
if pfUI.api.libspell then return end
|
||||||
|
|
||||||
local scanner = libtipscan:GetScanner("libspell")
|
|
||||||
local libspell = {}
|
local libspell = {}
|
||||||
|
|
||||||
-- [ GetSpellMaxRank ]
|
-- [ GetSpellMaxRank ]
|
||||||
@@ -91,55 +90,28 @@ function libspell.GetSpellInfo(index, bookType)
|
|||||||
local cache = spellinfo[index]
|
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
|
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 slot
|
||||||
local icon = ""
|
|
||||||
local castingTime = 0
|
|
||||||
local minRange = 0
|
|
||||||
local maxRange = 0
|
|
||||||
|
|
||||||
if type(index) == "string" then
|
if type(index) == "string" then
|
||||||
local _, _, sname, srank = string.find(index, '(.+)%((.+)%)')
|
local _, _, sname, srank = string.find(index, '(.+)%((.+)%)')
|
||||||
name = sname or index
|
local name = sname or index
|
||||||
rank = srank or libspell.GetSpellMaxRank(name)
|
local rank = srank or libspell.GetSpellMaxRank(name)
|
||||||
id, bookType = libspell.GetSpellIndex(name, rank)
|
slot, bookType = libspell.GetSpellIndex(name, rank)
|
||||||
|
|
||||||
-- correct name in case of wrong upper/lower cases
|
|
||||||
if id and bookType then
|
|
||||||
name = GetSpellName(id, bookType)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if not bookType or (bookType ~= BOOKTYPE_SPELL and bookType ~= BOOKTYPE_PET) then
|
if not bookType or (bookType ~= BOOKTYPE_SPELL and bookType ~= BOOKTYPE_PET) then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
name, rank = GetSpellName(index, bookType)
|
slot = index
|
||||||
id, bookType = libspell.GetSpellIndex(name, rank)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if name and id then
|
if not slot or not bookType then return nil end
|
||||||
icon = GetSpellTexture(id, bookType)
|
|
||||||
end
|
|
||||||
|
|
||||||
if id then
|
-- ClassicAPI's GetSpellInfo returns: name, rank, icon, cost, isFunnel, powerType,
|
||||||
scanner:SetSpell(id, bookType)
|
-- castTime(ms), minRange, maxRange, spellID. Keep libspell's historical positional
|
||||||
local _, sec = scanner:Find(gsub(SPELL_CAST_TIME_SEC, "%%.3g", "%(.+%)"), false)
|
-- shape (castingTime at 4, ranges at 5/6, slot+bookType at 7/8).
|
||||||
local _, min = scanner:Find(gsub(SPELL_CAST_TIME_MIN, "%%.3g", "%(.+%)"), false)
|
local name, rank, icon, _, _, _, castingTime, minRange, maxRange = GetSpellInfo(slot, bookType)
|
||||||
local _, range = scanner:Find(gsub(SPELL_RANGE, "%%s", "%(.+%)"), false)
|
|
||||||
|
|
||||||
castingTime = (tonumber(sec) or tonumber(min) or 0) * 1000
|
spellinfo[index] = { name, rank, icon, castingTime, minRange, maxRange, slot, bookType }
|
||||||
if range then
|
return name, rank, icon, castingTime, minRange, maxRange, slot, bookType
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Reset all spell caches whenever new spells are learned/unlearned
|
-- Reset all spell caches whenever new spells are learned/unlearned
|
||||||
|
|||||||
Reference in New Issue
Block a user