mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-21 11:50:49 +00:00
SuperWoW dependency fully removed
Read the Readme for more informations please.
This commit is contained in:
+38
-37
@@ -53,9 +53,6 @@ local scanner = libtipscan:GetScanner("libcast")
|
||||
local libcast = CreateFrame("Frame", "pfEnemyCast")
|
||||
local player = UnitName("player")
|
||||
|
||||
-- Store original SuperWoW UnitChannelInfo if it exists
|
||||
local SuperWoW_UnitChannelInfo = _G.UnitChannelInfo
|
||||
|
||||
UnitChannelInfo = function(unit)
|
||||
-- convert to name if unitstring was given
|
||||
local unitName = pfValidUnits[unit] and UnitName(unit) or unit
|
||||
@@ -100,11 +97,7 @@ UnitChannelInfo = function(unit)
|
||||
return cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill
|
||||
end
|
||||
|
||||
-- For non-player units: use SuperWoW if available, otherwise use libcast.db
|
||||
if SuperWoW_UnitChannelInfo then
|
||||
return SuperWoW_UnitChannelInfo(unit)
|
||||
end
|
||||
|
||||
-- For non-player units: use libdebuff GUID-based tracking or libcast.db
|
||||
-- Try GUID-based lookup first (from libdebuff's SPELL_START tracking)
|
||||
local db = nil
|
||||
if guid and pfUI.libdebuff_casts and pfUI.libdebuff_casts[guid] then
|
||||
@@ -152,9 +145,6 @@ UnitChannelInfo = function(unit)
|
||||
return cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill
|
||||
end
|
||||
|
||||
-- Store original SuperWoW UnitCastingInfo if it exists
|
||||
local SuperWoW_UnitCastingInfo = _G.UnitCastingInfo
|
||||
|
||||
UnitCastingInfo = function(unit)
|
||||
-- convert to name if unitstring was given
|
||||
local unitName = pfValidUnits[unit] and UnitName(unit) or unit
|
||||
@@ -172,7 +162,6 @@ UnitCastingInfo = function(unit)
|
||||
end
|
||||
|
||||
-- For player: ALWAYS use libcast.db because it handles pushback correctly
|
||||
-- SuperWoW's UnitCastingInfo doesn't track SPELLCAST_DELAYED events
|
||||
local isPlayer = unit == "player" or unitName == player
|
||||
|
||||
if isPlayer then
|
||||
@@ -200,11 +189,7 @@ UnitCastingInfo = function(unit)
|
||||
return cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill
|
||||
end
|
||||
|
||||
-- For non-player units: use SuperWoW if available, otherwise use libcast.db
|
||||
if SuperWoW_UnitCastingInfo then
|
||||
return SuperWoW_UnitCastingInfo(unit)
|
||||
end
|
||||
|
||||
-- For non-player units: use libdebuff GUID-based tracking or libcast.db
|
||||
-- Try GUID-based lookup first (from libdebuff's SPELL_START tracking)
|
||||
local db = nil
|
||||
if guid and pfUI.libdebuff_casts and pfUI.libdebuff_casts[guid] then
|
||||
@@ -321,30 +306,34 @@ libcast:RegisterEvent("SPELLCAST_CHANNEL_STOP")
|
||||
libcast:RegisterEvent("SPELLCAST_CHANNEL_UPDATE")
|
||||
|
||||
local mob, spell, icon, _
|
||||
local lastSpellId = nil -- spellId cached from SPELL_START_SELF (Nampower)
|
||||
|
||||
libcast:SetScript("OnEvent", function()
|
||||
-- Fill database with player casts
|
||||
if event == "SPELLCAST_START" then
|
||||
icon = L["spells"][arg1] and L["spells"][arg1].icon and string.format("%s%s", "Interface\\Icons\\", L["spells"][arg1].icon) or lastcasttex
|
||||
|
||||
-- Check if SuperWoW already set the cast data (with correct haste-adjusted casttime)
|
||||
-- If so, only update icon if needed, don't overwrite casttime
|
||||
local superWowAlreadySet = this.db[player].cast == arg1 and this.db[player].casttime and this.db[player].casttime > 0
|
||||
|
||||
if superWowAlreadySet then
|
||||
-- SuperWoW already set correct casttime, only update icon if better
|
||||
if icon and not this.db[player].icon then
|
||||
this.db[player].icon = icon
|
||||
-- Get icon from Nampower using spellId cached from SPELL_START_SELF
|
||||
icon = nil
|
||||
if lastSpellId and GetSpellRecField and GetSpellIconTexture then
|
||||
local iconId = GetSpellRecField(lastSpellId, "spellIconID")
|
||||
if iconId then
|
||||
icon = GetSpellIconTexture(iconId)
|
||||
if icon and not string.find(icon, "\\") then
|
||||
icon = "Interface\\Icons\\" .. icon
|
||||
end
|
||||
end
|
||||
else
|
||||
-- No SuperWoW data, use SPELLCAST_START data
|
||||
this.db[player].cast = arg1
|
||||
this.db[player].rank = lastrank
|
||||
this.db[player].start = GetTime()
|
||||
this.db[player].casttime = arg2
|
||||
this.db[player].icon = icon
|
||||
this.db[player].channel = nil
|
||||
end
|
||||
-- fallback to L["spells"] / lastcasttex if Nampower didn't provide icon
|
||||
if not icon then
|
||||
icon = L["spells"][arg1] and L["spells"][arg1].icon and string.format("%s%s", "Interface\\Icons\\", L["spells"][arg1].icon) or lastcasttex
|
||||
end
|
||||
lastSpellId = nil
|
||||
|
||||
this.db[player].cast = arg1
|
||||
this.db[player].rank = lastrank
|
||||
this.db[player].start = GetTime()
|
||||
this.db[player].casttime = arg2
|
||||
this.db[player].icon = icon
|
||||
this.db[player].channel = nil
|
||||
|
||||
if not L["spells"][arg1] or not L["spells"][arg1].icon or not L["spells"][arg1].t then
|
||||
L["spells"][arg1] = L["spells"][arg1] or { }
|
||||
@@ -353,6 +342,7 @@ libcast:SetScript("OnEvent", function()
|
||||
end
|
||||
lastcasttex, lastrank = nil, nil
|
||||
elseif event == "SPELLCAST_STOP" or event == "SPELLCAST_FAILED" or event == "SPELLCAST_INTERRUPTED" then
|
||||
lastSpellId = nil
|
||||
if this.db[player] and not this.db[player].channel then
|
||||
-- remove cast action to the database
|
||||
this.db[player].cast = nil
|
||||
@@ -530,7 +520,12 @@ libcast.customcast[strlower(multishot)] = function(begin, duration)
|
||||
end
|
||||
|
||||
local function CastCustom(id, bookType, rawSpellName, rank, texture, castingTime)
|
||||
if not id or not rawSpellName or not castingTime then return end -- ignore if the spell is not found or if it is instant-cast
|
||||
if not id or not rawSpellName then return end -- ignore if the spell is not found
|
||||
if not castingTime or castingTime == 0 then
|
||||
-- instant-cast: clear lastcasttex so next cast doesn't inherit this icon
|
||||
lastcasttex, lastrank = nil, nil
|
||||
return
|
||||
end
|
||||
|
||||
lastrank = rank
|
||||
lastcasttex = texture
|
||||
@@ -571,5 +566,11 @@ hooksecurefunc("UseAction", function(slot, target, button)
|
||||
CastCustom(cachedSpellId, cachedBookType, cachedRawSpellName, cachedRank, cachedTexture, cachedCastingTime)
|
||||
end)
|
||||
|
||||
-- Cache spellId from SPELL_START_SELF so SPELLCAST_START can use it for icon lookup
|
||||
pfUI.libdebuff_spell_start_self_hooks = pfUI.libdebuff_spell_start_self_hooks or {}
|
||||
pfUI.libdebuff_spell_start_self_hooks["libcast_icon"] = function(spellId)
|
||||
lastSpellId = spellId
|
||||
end
|
||||
|
||||
-- add libcast to pfUI API
|
||||
pfUI.api.libcast = libcast
|
||||
pfUI.api.libcast = libcast
|
||||
+8
-21
@@ -384,11 +384,6 @@ function libdebuff:GetSpellIcon(spellId)
|
||||
end
|
||||
end
|
||||
|
||||
if not texture and SpellInfo then
|
||||
local _, _, spellTexture = SpellInfo(spellId)
|
||||
texture = spellTexture
|
||||
end
|
||||
|
||||
if not texture then
|
||||
texture = "Interface\\Icons\\INV_Misc_QuestionMark"
|
||||
end
|
||||
@@ -459,7 +454,7 @@ local function GetDebuffSlotMap(guid)
|
||||
local spellId = auras[auraSlot]
|
||||
if spellId and spellId > 0 then
|
||||
displaySlot = displaySlot + 1
|
||||
local spellName = GetSpellRecField and GetSpellRecField(spellId, "name") or SpellInfo(spellId)
|
||||
local spellName = GetSpellRecField and GetSpellRecField(spellId, "name")
|
||||
local texture = libdebuff:GetSpellIcon(spellId)
|
||||
|
||||
-- Get stacks from auraApplications (0-indexed, so +1 for display)
|
||||
@@ -1215,9 +1210,7 @@ if hasNampower then
|
||||
local rec = GetSpellRec(spellId)
|
||||
spellName = rec and rec.name or nil
|
||||
end
|
||||
if not spellName and SpellInfo then
|
||||
spellName = SpellInfo(spellId)
|
||||
end
|
||||
|
||||
|
||||
local icon = libdebuff:GetSpellIcon(spellId)
|
||||
|
||||
@@ -1282,12 +1275,8 @@ if hasNampower then
|
||||
|
||||
if numMissed > 0 or numHit == 0 then return end
|
||||
|
||||
local spellName, spellRankString
|
||||
if SpellInfo then
|
||||
spellName, spellRankString = SpellInfo(spellId)
|
||||
elseif GetSpellRecField then
|
||||
spellName = GetSpellRecField(spellId, "name")
|
||||
end
|
||||
local spellName = GetSpellRecField and GetSpellRecField(spellId, "name")
|
||||
local spellRankString
|
||||
if not spellName then return end
|
||||
|
||||
local castRank = 0
|
||||
@@ -1377,9 +1366,7 @@ if hasNampower then
|
||||
local rec = GetSpellRec(spellId)
|
||||
spellName = rec and rec.name or nil
|
||||
end
|
||||
if not spellName and SpellInfo then
|
||||
spellName = SpellInfo(spellId)
|
||||
end
|
||||
|
||||
|
||||
-- Store pending cast info for libpredict (heal prediction target tracking)
|
||||
-- This allows libpredict to resolve the correct target for Nampower queued casts,
|
||||
@@ -1424,7 +1411,7 @@ if hasNampower then
|
||||
if not spellId then return end
|
||||
if not targetGuid or targetGuid == "" or targetGuid == "0x0000000000000000" then return end
|
||||
|
||||
local spellName = SpellInfo and SpellInfo(spellId) or (GetSpellRecField and GetSpellRecField(spellId, "name"))
|
||||
local spellName = GetSpellRecField and GetSpellRecField(spellId, "name")
|
||||
if not spellName then return end
|
||||
|
||||
-- Deduplicate: Ignore if we processed this exact cast recently (within 100ms)
|
||||
@@ -1680,7 +1667,7 @@ if hasNampower then
|
||||
-- Invalidate slot map cache for this GUID
|
||||
slotMapCache[guid] = nil
|
||||
|
||||
local spellName = SpellInfo and SpellInfo(spellId)
|
||||
local spellName = GetSpellRecField and GetSpellRecField(spellId, "name")
|
||||
if not spellName then return end
|
||||
|
||||
if debugStats.enabled then
|
||||
@@ -1816,7 +1803,7 @@ if hasNampower then
|
||||
-- Invalidate slot map cache for this GUID
|
||||
slotMapCache[guid] = nil
|
||||
|
||||
local spellName = SpellInfo and SpellInfo(spellId) or "?"
|
||||
local spellName = (GetSpellRecField and GetSpellRecField(spellId, "name")) or "?"
|
||||
|
||||
if debugStats.enabled then
|
||||
debugStats.debuff_removed = debugStats.debuff_removed + 1
|
||||
|
||||
+1
-3
@@ -1,8 +1,6 @@
|
||||
-- load pfUI environment
|
||||
setfenv(1, pfUI:GetEnvironment())
|
||||
|
||||
local superwow_active = HasSuperWoW()
|
||||
|
||||
--[[ librange ]]--
|
||||
-- A pfUI library that detects and caches distance to units.
|
||||
--
|
||||
@@ -197,7 +195,7 @@ librange:SetScript("OnUpdate", function()
|
||||
end
|
||||
|
||||
-- try to read distance via superwow second
|
||||
if superwow_active then
|
||||
if HasSuperWoW() and UnitPosition then
|
||||
local x1, y1, z1 = UnitPosition("player")
|
||||
local x2, y2, z2 = UnitPosition(unit)
|
||||
-- only continue if we got position values
|
||||
|
||||
Reference in New Issue
Block a user