-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHideButtonGlow.lua
More file actions
184 lines (171 loc) · 6.16 KB
/
Copy pathHideButtonGlow.lua
File metadata and controls
184 lines (171 loc) · 6.16 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
local addonName, HideButtonGlow = ...
local CreateFrame, GetActionInfo, DEFAULT_CHAT_FRAME, Settings, GetSpellName, InCombatLockdown = CreateFrame, GetActionInfo, DEFAULT_CHAT_FRAME, Settings, C_Spell.GetSpellName, InCombatLockdown
local L = LibStub("AceLocale-3.0"):GetLocale("HideButtonGlow")
local EventFrame = CreateFrame("Frame")
EventFrame:SetScript("OnEvent", function(self, event, ...)
if self[event] then return self[event](self, event, ...) end
end)
EventFrame:RegisterEvent("PLAYER_LOGIN")
EventFrame:RegisterEvent("ADDON_LOADED")
function EventFrame:PLAYER_LOGIN(event)
self:UnregisterEvent(event)
-- set up and validate db
if not HideButtonGlowDB then
HideButtonGlowDB = {}
end
if type(HideButtonGlowDB.hideAll) ~= "boolean" then
HideButtonGlowDB.hideAll = false
end
if type(HideButtonGlowDB.hideOutOfCombat) ~= "boolean" then
HideButtonGlowDB.hideOutOfCombat = false
end
if type(HideButtonGlowDB.debugMode) ~= "boolean" then
HideButtonGlowDB.debugMode = false
end
if type(HideButtonGlowDB.filtered) ~= "table" then
HideButtonGlowDB.filtered = {}
-- migrate old db if present
if type(HideButtonGlowDB.spells) == "table" then
for i = 1, #HideButtonGlowDB.spells do
HideButtonGlowDB.filtered[HideButtonGlowDB.spells[i]] = GetSpellName(HideButtonGlowDB.spells[i])
end
HideButtonGlowDB.spells = nil
end
end
if type(HideButtonGlowDB.allowed) ~= "table" then
HideButtonGlowDB.allowed = {}
-- migrate old db if present
if type(HideButtonGlowDB.allowedSpells) == "table" then
for i = 1, #HideButtonGlowDB.allowedSpells do
HideButtonGlowDB.allowed[HideButtonGlowDB.allowedSpells[i]] = GetSpellName(HideButtonGlowDB.allowedSpells[i])
end
HideButtonGlowDB.allowedSpells = nil
end
end
end
function EventFrame:ADDON_LOADED(event, loadedAddon)
if loadedAddon ~= addonName then
return
end
self:UnregisterEvent(event)
SlashCmdList.HideButtonGlow = function()
if not InCombatLockdown() then
Settings.OpenToCategory(HideButtonGlow.categoryId)
else
HideButtonGlow:AddMessage(L.combat_options)
end
end
SLASH_HideButtonGlow1 = "/hbg"
SLASH_HideButtonGlow2 = "/hidebuttonglow"
end
function HideButtonGlow:AddMessage(message)
DEFAULT_CHAT_FRAME:AddMessage(("|cFF00FF98HideButtonGlow:|r %s"):format(message))
end
do
local lastPrintBySpell = {}
function HideButtonGlow:AddDebugMessageWithSpell(message, spellId)
if HideButtonGlowDB.debugMode then
local t = GetTime()
if t - (lastPrintBySpell[spellId] or 0) > 5 then
lastPrintBySpell[spellId] = t
self:AddMessage(message:format(GetSpellName(spellId) or "", spellId))
end
end
end
end
function HideButtonGlow:ShouldHideGlow(spellId)
if HideButtonGlowDB.hideOutOfCombat and not InCombatLockdown() then
self:AddDebugMessageWithSpell(L.debug_combat:format(L.debug_filtered), spellId)
return true
end
-- check if the "hide all" option is set
if HideButtonGlowDB.hideAll then
if HideButtonGlowDB.allowed[spellId] then
self:AddDebugMessageWithSpell(L.debug_allowed, spellId)
return false
end
self:AddDebugMessageWithSpell(L.debug_filtered, spellId)
return true
end
-- else check filter list
if HideButtonGlowDB.filtered[spellId] then
self:AddDebugMessageWithSpell(L.debug_filtered, spellId)
return true
end
-- else show the glow
self:AddDebugMessageWithSpell(L.debug_allowed, spellId)
return false
end
-- LibButtonGlow
do
local LibButtonGlow = LibStub("LibButtonGlow-1.0", true)
if LibButtonGlow and LibButtonGlow.ShowOverlayGlow then
local OriginalShowOverlayGlow = LibButtonGlow.ShowOverlayGlow
function LibButtonGlow.ShowOverlayGlow(self)
local spellId = self:GetSpellId()
if not spellId or not HideButtonGlow:ShouldHideGlow(spellId) then
return OriginalShowOverlayGlow(self)
end
end
end
end
-- ElvUI
if ElvUI then
local E = unpack(ElvUI)
local LibCustomGlow = E and E.Libs and E.Libs.CustomGlow
-- ElvUI adds a ShowOverlayGlow function to LibCustomGlow where there was not one before
if LibCustomGlow and LibCustomGlow.ShowOverlayGlow then
local OriginalShowOverlayGlow = LibCustomGlow.ShowOverlayGlow
function LibCustomGlow.ShowOverlayGlow(self)
local spellId = self.GetSpellId and self:GetSpellId()
if not spellId or not HideButtonGlow:ShouldHideGlow(spellId) then
return OriginalShowOverlayGlow(self)
end
end
end
end
-- Blizzard Bars
if ActionButtonSpellAlertManager and C_ActionBar.IsAssistedCombatAction then -- Retail (11.1.7+)
local IsAssistedCombatAction = C_ActionBar.IsAssistedCombatAction
hooksecurefunc(ActionButtonSpellAlertManager, "ShowAlert", function(_, actionButton)
local action = actionButton.action
if not action then
-- don't hide glows from buttons that don't have actions (PTR issue reporter)
return
end
local spellType, id = GetActionInfo(action)
-- only check spell and macro glows
if id and (spellType == "spell" or spellType == "macro") and HideButtonGlow:ShouldHideGlow(id) then
if IsAssistedCombatAction(action) then
-- hide matched glows on the Single-Button Assistant button
if actionButton.AssistedCombatRotationFrame and actionButton.AssistedCombatRotationFrame.SpellActivationAlert then
actionButton.AssistedCombatRotationFrame.SpellActivationAlert:Hide()
end
elseif actionButton.SpellActivationAlert then
-- hide matched glows on regular action bars
actionButton.SpellActivationAlert:Hide()
end
end
end)
else -- Classic, Retail (pre 11.1.7)
hooksecurefunc("ActionButton_ShowOverlayGlow", function(actionButton)
if actionButton and actionButton.action then
local spellType, id = GetActionInfo(actionButton.action)
if spellType == "macro" then
-- needed on MoP Classic to convert the macro id to a spell id, not needed in 10.2+ as GetActionInfo will change
-- to just return the spell id in the first place.
id = GetMacroSpell(id)
end
-- only check spell and macro glows
if id and (spellType == "spell" or spellType == "macro") and HideButtonGlow:ShouldHideGlow(id) then
if actionButton.overlay then
-- Cata Classic, Mists Classic, Retail (pre 10.0.2)
actionButton.overlay:Hide()
elseif actionButton.SpellActivationAlert then
-- Retail (10.0.2+)
actionButton.SpellActivationAlert:Hide()
end
end
end
end)
end