forked from Mapkov2/Midnight-Simple-Auras
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSA_PlayerBuffs.lua
More file actions
96 lines (86 loc) · 3.63 KB
/
MSA_PlayerBuffs.lua
File metadata and controls
96 lines (86 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
-- ########################################################
-- MSA_PlayerBuffs.lua (v3 - minimal event relay)
--
-- Buff tracking is done DIRECTLY in UpdateEngine hot-path
-- via C_UnitAuras.GetAuraDataBySpellID() - like WeakAuras.
--
-- This file only provides:
-- 1) UNIT_AURA event relay -> triggers UpdateEngine redraw
-- 2) Legacy compat: ns.PlayerBuffs.UpdateIcon
-- 3) Stub functions so Options code doesn't error
--
-- Zero pcall. Zero state. Zero registration.
-- ########################################################
local ADDON_NAME, ns = ...
local type = type
-----------------------------------------------------------
-- Event relay: UNIT_AURA on player -> trigger redraw
-----------------------------------------------------------
local relay = CreateFrame("Frame", "MSWA_BuffEventFrame", UIParent)
relay:RegisterEvent("UNIT_AURA")
relay:RegisterEvent("PLAYER_ENTERING_WORLD")
relay:SetScript("OnEvent", function(_, event, arg1)
if event == "UNIT_AURA" then
if arg1 == "player" then
-- Invalidate per-frame cache so next poll gets fresh data
if MSWA_InvalidateBuffCache then MSWA_InvalidateBuffCache() end
if MSWA_RequestUpdateSpells then MSWA_RequestUpdateSpells() end
end
return
end
-- PLAYER_ENTERING_WORLD: trigger initial draw
if MSWA_InvalidateBuffCache then MSWA_InvalidateBuffCache() end
if MSWA_RequestUpdateSpells then
MSWA_RequestUpdateSpells()
end
end)
-----------------------------------------------------------
-- Stub functions (Options code references these)
-----------------------------------------------------------
function MSWA_RegisterBuffWatch() end
function MSWA_UnregisterBuffWatch() end
function MSWA_ClearAllBuffWatches() end
function MSWA_FullBuffRescan() end
function MSWA_BuffBootstrap() end
-----------------------------------------------------------
-- Legacy compat: ns.PlayerBuffs.UpdateIcon
-----------------------------------------------------------
local PB = ns.PlayerBuffs or {}
ns.PlayerBuffs = PB
function PB.UpdateIcon(iconFrame, spellID)
if not iconFrame or not spellID then return end
local auraData = MSWA_GetPlayerAuraDataBySpellID(spellID)
if auraData then
iconFrame.icon:SetDesaturated(false)
iconFrame.icon:SetVertexColor(1, 1, 1)
-- Stacks via wrapper
local sText = MSWA_GetAuraStackText(auraData, 2)
local target = iconFrame.stackText or iconFrame.count
if target then
if sText then target:SetText(sText); target:Show()
else target:SetText(""); target:Hide() end
end
-- Cooldown: EQoL issecretvalue pattern
local cd = iconFrame.cooldown
if cd then
local dur = auraData.duration
local exp = auraData.expirationTime
local isSecret = MSWA_IsSecretValue(dur) or MSWA_IsSecretValue(exp)
if isSecret and cd.SetCooldownFromExpirationTime then
cd:SetCooldownFromExpirationTime(exp, dur, auraData.timeMod)
cd.__mswaSet = true
elseif dur and dur > 0 and exp then
cd:SetCooldown(exp - dur, dur)
cd.__mswaSet = true
else
MSWA_ClearCooldownFrame(cd)
end
end
else
iconFrame.icon:SetDesaturated(true)
iconFrame.icon:SetVertexColor(0.35, 0.35, 0.35)
if iconFrame.count then iconFrame.count:SetText(""); iconFrame.count:Hide() end
if iconFrame.stackText then iconFrame.stackText:SetText(""); iconFrame.stackText:Hide() end
if iconFrame.cooldown then MSWA_ClearCooldownFrame(iconFrame.cooldown) end
end
end