mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 07:36:56 +00:00
b79132b9f4
ClassicAPI's recent C_Spell additions cover remote-unit casts natively
(SMSG_SPELL_START co-hook caching per caster GUID), so the two parallel
cast trackers pfUI was running — libcast.lua and the libdebuff_casts
table inside libdebuff.lua — can both retire.
Migrations:
- modules/castbar.lua: focus/player cast-info gathering reads
C_Spell.UnitCastingInfo / UnitChannelInfo directly. Fallback ladder
(libdebuff_casts → pfGetCastInfo → pfGetChannelInfo) collapses into a
single call. Pushback handlers stop writing back into a non-existent
cache; the local this.endTime is the source of truth.
- modules/nameplates.lua: GetCastInfo(guid) now resolves to a unit token
via UnitTokenFromGUID and queries C_Spell, returning the same compact
struct shape downstream code expected. UpdateCastbar collapses from a
three-branch hierarchy (dead IterDebuffs / libdebuff_casts / libcast)
to one C_Spell read.
- modules/afkcam.lua: pfGetCastInfo+pfGetChannelInfo round-trip becomes
a single C_Spell.UnitCastingInfo("player") or UnitChannelInfo fallback.
- libs/libpredict.lua: HealComm timing uses C_Spell on the sender's unit
token after a small group-roster walk to resolve the sender's name.
Deletions:
- libs/libcast.lua entirely (-571 lines) plus its init/libs.xml entry.
- libdebuff_casts / libdebuff_item_icons tables and their write sites
in libs/libdebuff.lua (the SPELL_START_*, SPELL_GO_*, SPELL_FAILED_*
event handlers stop maintaining them but keep firing the
libdebuff_*_hooks broadcast surface for actionbar / swingtimer /
libtotem). SPELLCAST_CHANNEL_STOP now reads the active channel from
C_Spell.ChannelInfo.
- modules/superwow.lua's supercast block — UNIT_CASTEVENT writes into
libcast.db are redundant now that C_Spell co-hooks the same packet.
- The cast-bar item-icon override that swapped in a potion/trinket
icon for item-triggered casts. Spell icon stays; the item-icon
metadata path (libdebuff_item_icons) went with libdebuff_casts.
Steady Shot synthetic cast bar — Turtle WoW-specific:
- castbar.lua gains a pfUI.synthetic_casts[unit] fallback that fires
only when C_Spell returns nil, so abilities the engine treats as
instant but which have a meaningful wait window can still render a
cast bar.
- modules/turtle-wow.lua replaces the old libcast.customcast block with
a Nampower SPELL_QUEUE_EVENT subscriber. ON_SWING_QUEUED matching
the localized "Steady Shot" name writes a 1.4s synthetic entry;
ON_SWING_QUEUE_POPPED clears it; castbar's endMs guard self-expires
the entry as a safety net. Note: haste scaling (libcast.ApplyShotHaste)
is gone — bar may finish slightly early under +ranged haste buffs.
Net: 152 insertions, 972 deletions.
177 lines
5.8 KiB
Lua
177 lines
5.8 KiB
Lua
-- Compatibility layer to use castbars provided by SuperWoW:
|
|
-- https://github.com/balakethelock/SuperWoW
|
|
|
|
-- DLL Status Check Command (always available)
|
|
SLASH_PFDLLSTATUS1 = "/pfdll"
|
|
SlashCmdList["PFDLLSTATUS"] = function()
|
|
local chat = DEFAULT_CHAT_FRAME
|
|
chat:AddMessage("|cff33ffccpfUI|r: DLL Status Check")
|
|
|
|
-- SuperWoW
|
|
if SUPERWOW_VERSION then
|
|
chat:AddMessage(" |cff00ff00SuperWoW|r: v" .. tostring(SUPERWOW_VERSION))
|
|
elseif SpellInfo or SetAutoloot then
|
|
chat:AddMessage(" |cffffff00SuperWoW|r: Detected (old version)")
|
|
else
|
|
chat:AddMessage(" |cffff0000SuperWoW|r: Not detected")
|
|
end
|
|
|
|
-- Nampower
|
|
if GetNampowerVersion then
|
|
chat:AddMessage(" |cff00ff00Nampower|r: v" .. tostring(GetNampowerVersion()))
|
|
else
|
|
chat:AddMessage(" |cffff0000Nampower|r: Not detected")
|
|
end
|
|
|
|
-- Check if castbar exists for indicator positioning
|
|
if pfUI.castbar and pfUI.castbar.player then
|
|
chat:AddMessage(" |cff00ff00Castbar|r: Available for indicator anchoring")
|
|
else
|
|
chat:AddMessage(" |cffffff00Castbar|r: Not available (indicators use fallback position)")
|
|
end
|
|
|
|
-- Check indicator frames
|
|
if pfUI.uf and pfUI.uf.target then
|
|
chat:AddMessage(" |cff00ff00Target frame|r: exists")
|
|
else
|
|
chat:AddMessage(" |cffff0000Target frame|r: NOT found")
|
|
end
|
|
end
|
|
|
|
pfUI:RegisterModule("superwow", function ()
|
|
if SetAutoloot and SpellInfo and not SUPERWOW_VERSION then
|
|
-- Turn every enchanting link that we create in the enchanting frame,
|
|
-- from "spell:" back into "enchant:". The enchant-version is what is
|
|
-- used by all unmodified game clients. This is required to generate
|
|
-- usable links for everyone from the enchant frame while having SuperWoW.
|
|
local HookGetCraftItemLink = GetCraftItemLink
|
|
_G.GetCraftItemLink = function(index)
|
|
local link = HookGetCraftItemLink(index)
|
|
return string.gsub(link, "spell:", "enchant:")
|
|
end
|
|
|
|
-- Convert every enchanting link that we receive into a
|
|
-- spell link, as for some reason SuperWoW can't handle
|
|
-- enchanting links at all and requires it to be a spell.
|
|
local HookSetItemRef = SetItemRef
|
|
_G.SetItemRef = function(link, text, button)
|
|
link = string.gsub(link, "enchant:", "spell:")
|
|
HookSetItemRef(link, text, button)
|
|
end
|
|
|
|
local HookGameTooltipSetHyperlink = GameTooltip.SetHyperlink
|
|
_G.GameTooltip.SetHyperlink = function(self, link)
|
|
link = string.gsub(link, "enchant:", "spell:")
|
|
HookGameTooltipSetHyperlink(self, link)
|
|
end
|
|
|
|
DEFAULT_CHAT_FRAME:AddMessage("|cffffffaaAn old version of SuperWoW was detected. Please consider updating:")
|
|
DEFAULT_CHAT_FRAME:AddMessage("-> https://github.com/balakethelock/SuperWoW/releases/")
|
|
end
|
|
|
|
if SUPERWOW_VERSION == "1.5" then
|
|
QueueFunction(function()
|
|
local pfCombatText_AddMessage = _G.CombatText_AddMessage
|
|
_G.CombatText_AddMessage = function(message, a, b, c, d, e, f)
|
|
local match, _, hex = string.find(message, ".+ %[(0x.+)%]")
|
|
if hex and UnitName(hex) then
|
|
message = string.gsub(message, hex, UnitName(hex))
|
|
end
|
|
|
|
pfCombatText_AddMessage(message, a, b, c, d, e, f)
|
|
end
|
|
end)
|
|
end
|
|
|
|
-- TrackUnit API for adding group members to minimap
|
|
-- Tracks friendly units on the minimap for easier group coordination
|
|
if TrackUnit and C.unitframes.track_group == "1" then
|
|
local trackFrame = CreateFrame("Frame")
|
|
trackFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
|
|
trackFrame:RegisterEvent("RAID_ROSTER_UPDATE")
|
|
trackFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
trackFrame:RegisterEvent("PLAYER_LOGOUT")
|
|
|
|
trackFrame:SetScript("OnEvent", function()
|
|
-- Handle shutdown to prevent crash 132
|
|
if event == "PLAYER_LOGOUT" then
|
|
this:UnregisterAllEvents()
|
|
this:SetScript("OnEvent", nil)
|
|
return
|
|
end
|
|
|
|
-- Track party members
|
|
for i = 1, 4 do
|
|
local unit = "party" .. i
|
|
if UnitExists(unit) and UnitIsConnected(unit) then
|
|
pcall(TrackUnit, unit)
|
|
end
|
|
end
|
|
|
|
-- Track raid members
|
|
for i = 1, 40 do
|
|
local unit = "raid" .. i
|
|
if UnitExists(unit) and UnitIsConnected(unit) and not UnitIsUnit(unit, "player") then
|
|
pcall(TrackUnit, unit)
|
|
end
|
|
end
|
|
end)
|
|
end
|
|
|
|
-- Raid Marker Targeting API
|
|
-- Allows targeting units by raid marker ("mark1" to "mark8")
|
|
if SUPERWOW_VERSION then
|
|
pfUI.api.GetMarkedUnit = function(markIndex)
|
|
local markUnit = "mark" .. markIndex
|
|
if UnitExists(markUnit) then
|
|
return markUnit
|
|
end
|
|
return nil
|
|
end
|
|
|
|
pfUI.api.TargetMark = function(markIndex)
|
|
local markUnit = "mark" .. markIndex
|
|
if UnitExists(markUnit) then
|
|
TargetUnit(markUnit)
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- Get owner of pet/totem using "owner" suffix
|
|
pfUI.api.GetUnitOwner = function(unit)
|
|
local ownerUnit = unit .. "owner"
|
|
if UnitExists(ownerUnit) then
|
|
return UnitName(ownerUnit), ownerUnit
|
|
end
|
|
return nil
|
|
end
|
|
end
|
|
|
|
-- Clickthrough Mode API
|
|
-- Allows clicking through corpses to loot underneath
|
|
if Clickthrough then
|
|
pfUI.api.SetClickthrough = function(enabled)
|
|
Clickthrough(enabled and 1 or 0)
|
|
end
|
|
|
|
pfUI.api.GetClickthrough = function()
|
|
return Clickthrough() == 1
|
|
end
|
|
|
|
pfUI.api.ToggleClickthrough = function()
|
|
local current = Clickthrough()
|
|
Clickthrough(current == 1 and 0 or 1)
|
|
return Clickthrough() == 1
|
|
end
|
|
|
|
-- Add slash command for clickthrough toggle
|
|
_G.SLASH_PFCLICKTHROUGH1 = "/clickthrough"
|
|
_G.SLASH_PFCLICKTHROUGH2 = "/ct"
|
|
SlashCmdList["PFCLICKTHROUGH"] = function()
|
|
local enabled = pfUI.api.ToggleClickthrough()
|
|
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpfUI|r: Clickthrough mode " .. (enabled and "|cff00ff00enabled|r" or "|cffff0000disabled|r"))
|
|
end
|
|
end
|
|
|
|
end) |