mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 15:46:56 +00:00
822c873132
Drive the cast bar from cast lifecycle events instead of polling C_Spell every frame. OnUpdate now only animates a stamped start/end and fades out; all state transitions come from events: - player: vanilla SPELLCAST_START / _STOP / _FAILED / _INTERRUPTED / _CHANNEL_START / _CHANNEL_STOP, plus nampower SPELL_START_SELF (the only signal for a chained same-spell recast, which never runs the client cast path) and SPELL_DELAYED_SELF for pushback (applied from its delayMs arg). - non-player (target/focus): nampower SPELL_START_OTHER / SPELL_FAILED_OTHER + PLAYER_TARGET_CHANGED / PLAYER_FOCUS_CHANGED. Data comes from ClassicAPI's C_Spell.UnitCastingInfo / UnitChannelInfo (player exact; other units from the SMSG_SPELL_START cache). SPELL_START_* re-polls are deferred one frame so ClassicAPI's packet co-hook has stamped before the read. SPELLCAST_CHANNEL_STOP only clears when a channel is shown, so a lagged channel-stop doesn't wipe a following cast's bar. Remove the now-unused CASTBAR_EVENT_* constants from compat/vanilla.lua.
80 lines
2.7 KiB
Lua
80 lines
2.7 KiB
Lua
-- load pfUI environment
|
|
setfenv(1, pfUI:GetEnvironment())
|
|
|
|
-- [[ Constants ]]--
|
|
EVENTS_MINIMAP_ZONE_UPDATE = {"PLAYER_ENTERING_WORLD", "MINIMAP_ZONE_CHANGED"}
|
|
|
|
MICRO_BUTTONS = {
|
|
'CharacterMicroButton', 'SpellbookMicroButton', 'TalentMicroButton',
|
|
'QuestLogMicroButton', 'SocialsMicroButton', 'WorldMapMicroButton',
|
|
'MainMenuMicroButton', 'HelpMicroButton',
|
|
}
|
|
|
|
NAMEPLATE_OBJECTORDER = { "border", "glow", "name", "level", "levelicon", "raidicon" }
|
|
|
|
NAMEPLATE_FRAMETYPE = "Button"
|
|
|
|
MINIMAP_TRACKING_FRAME = _G.MiniMapTrackingFrame
|
|
|
|
FRIENDS_NAME_LOCATION = "ButtonTextNameLocation"
|
|
|
|
COOLDOWN_FRAME_TYPE = "Model"
|
|
LOOT_BUTTON_FRAME_TYPE = "LootButton"
|
|
|
|
PLAYER_BUFF_START_ID = -1
|
|
|
|
ACTIONBAR_SECURE_TEMPLATE_BAR = nil
|
|
ACTIONBAR_SECURE_TEMPLATE_BUTTON = nil
|
|
UNITFRAME_SECURE_TEMPLATE = nil
|
|
|
|
--[[ Vanilla API Extensions ]]--
|
|
function hooksecurefunc(tbl, name, func, prepend)
|
|
if type(tbl) == "string" then
|
|
prepend, func, name, tbl = func, name, tbl, _G
|
|
end
|
|
|
|
if not tbl or not tbl[name] then return end
|
|
|
|
pfUI.hooks[tostring(func)] = {}
|
|
pfUI.hooks[tostring(func)]["old"] = tbl[name]
|
|
pfUI.hooks[tostring(func)]["new"] = func
|
|
|
|
if prepend then
|
|
pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
|
pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
|
return pfUI.hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
|
end
|
|
else
|
|
pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
|
local ok, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16 = pcall(pfUI.hooks[tostring(func)]["old"], a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
|
if not ok then return end
|
|
pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
|
|
return r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16
|
|
end
|
|
end
|
|
|
|
tbl[name] = pfUI.hooks[tostring(func)]["function"]
|
|
end
|
|
|
|
do -- GetItemInfo
|
|
local name, link, rarity, minlevel, itype, isubtype, stack
|
|
function GetItemInfo(item)
|
|
if not item then return end
|
|
name, link, rarity, minlevel, itype, isubtype, stack = _G.GetItemInfo(item)
|
|
return name, link, rarity, nil, minlevel, itype, isubtype, stack
|
|
end
|
|
end
|
|
|
|
do -- RunMacroText
|
|
local obj = { ["GetText"] = function(self) return self.text end }
|
|
obj = setmetatable(obj, {__index = function(tab,key)
|
|
local value = function() return end
|
|
rawset(tab,key,value)
|
|
return value
|
|
end})
|
|
|
|
function RunMacroText(text)
|
|
obj.text = text
|
|
ChatEdit_ParseText(obj, 1)
|
|
end
|
|
end |