Repository navigation
Expand file tree
/
Copy pathOneButtonGlow.lua
More file actions
140 lines (104 loc) · 3.84 KB
/
Copy pathOneButtonGlow.lua
File metadata and controls
140 lines (104 loc) · 3.84 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
local glowFrames = {}
local glowSources = {}
-- Build a proc glow overlay, via SpellAlert template, to replace native button glows
local function buildGlowFrame(button)
local btnW, btnH = button:GetSize()
if btnW <= 0 or btnH <= 0 then return nil end
local glow = CreateFrame("Frame", nil, button, "ActionButtonSpellAlertTemplate")
glow:SetPoint("CENTER")
glow:SetSize(btnW * 1.4, btnH * 1.4)
glow.ProcStartFlipbook:Hide()
glow:Hide()
glow._prevW, glow._prevH = btnW, btnH
glowFrames[button] = glow
return glow
end
-- Sync glow dimensions, via cached size check, to match dynamic button resizing
local function syncGlowSize(button, glow)
local btnW, btnH = button:GetSize()
if btnW <= 0 or btnH <= 0 then return end
if glow._prevW == btnW and glow._prevH == btnH then return end
glow:SetSize(btnW * 1.4, btnH * 1.4)
glow._prevW, glow._prevH = btnW, btnH
end
-- Activate proc glow, via direct loop play, to indicate button highlight
local function activateGlow(button)
local glow = glowFrames[button] or buildGlowFrame(button)
if not glow then return end
syncGlowSize(button, glow)
if not glow:IsShown() then
glow:Show()
glow.ProcLoop:Play()
end
end
-- Deactivate proc glow, via hide, to clear button highlight
local function deactivateGlow(button)
local glow = glowFrames[button]
if not glow then return end
glow:Hide()
end
-- Evaluate active glow sources, via flag check, to toggle visibility
local function refreshGlow(button)
local src = glowSources[button]
if src and (src.spell or src.assist) then
activateGlow(button)
else
deactivateGlow(button)
glowSources[button] = nil
end
end
-- Suppress native spell alert, via alpha override, to prevent duplicate highlights
local function suppressSpellAlert(button)
if button.SpellActivationAlert then
button.SpellActivationAlert:SetAlpha(0)
end
local rotFrame = button.AssistedCombatRotationFrame
if rotFrame and rotFrame.SpellActivationAlert then
rotFrame.SpellActivationAlert:SetAlpha(0)
end
end
-- Suppress native assisted highlight, via alpha override, to prevent duplicate highlights
local function suppressAssistedGlow(button)
if button.AssistedCombatHighlightFrame then
button.AssistedCombatHighlightFrame:SetAlpha(0)
end
end
-- Register spell alert source, via native suppression and flag set, to activate custom glow
local function onAlertShown(_, btn)
if not btn then return end
suppressSpellAlert(btn)
local src = glowSources[btn] or {}
src.spell = true
glowSources[btn] = src
refreshGlow(btn)
end
-- Clear spell alert source, via flag reset, to deactivate custom glow
local function onAlertHidden(_, btn)
if not btn then return end
local src = glowSources[btn]
if src then src.spell = nil end
refreshGlow(btn)
end
-- Sync assisted highlight source, via native suppression and flag toggle, to update custom glow
local function onAssistedChanged(_, btn, shown)
if not btn then return end
suppressAssistedGlow(btn)
local src = glowSources[btn] or {}
src.assist = shown or nil
glowSources[btn] = src
refreshGlow(btn)
end
-- Hook glow managers at login, via hooksecurefunc, to intercept native highlight triggers
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:SetScript("OnEvent", function(self)
if ActionButtonSpellAlertManager then
hooksecurefunc(ActionButtonSpellAlertManager, "ShowAlert", onAlertShown)
hooksecurefunc(ActionButtonSpellAlertManager, "HideAlert", onAlertHidden)
end
if AssistedCombatManager then
hooksecurefunc(AssistedCombatManager, "SetAssistedHighlightFrameShown", onAssistedChanged)
end
self:UnregisterEvent("PLAYER_LOGIN")
self:SetScript("OnEvent", nil)
end)