-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHideButtonGlow.lua
143 lines (128 loc) · 4.37 KB
/
HideButtonGlow.lua
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
local addonName, addon = ...
-- globals
local CreateFrame, GetActionInfo, DEFAULT_CHAT_FRAME, Settings = CreateFrame, GetActionInfo, DEFAULT_CHAT_FRAME, Settings
local GetSpellName = C_Spell.GetSpellName
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)
if not HideButtonGlowDB then
HideButtonGlowDB = {}
HideButtonGlowDB.hideAll = false
HideButtonGlowDB.debugMode = false
HideButtonGlowDB.spells = {}
HideButtonGlowDB.allowedSpells = {}
elseif not HideButtonGlowDB.allowedSpells then
-- upgrade db for v3
HideButtonGlowDB.allowedSpells = {}
end
self:UnregisterEvent(event)
end
function eventFrame:ADDON_LOADED(event, loadedAddon)
if loadedAddon ~= addonName then
return
end
self:UnregisterEvent(event)
SlashCmdList.HideButtonGlow = function()
Settings.OpenToCategory(addonName)
end
SLASH_HideButtonGlow1 = "/hbg"
SLASH_HideButtonGlow2 = "/hidebuttonglow"
end
function addon:AddMessage(message)
DEFAULT_CHAT_FRAME:AddMessage(message)
end
function addon:ShouldHideGlow(spellId)
-- check if the "hide all" option is set
if HideButtonGlowDB.hideAll then
for i = 1, #HideButtonGlowDB.allowedSpells do
if spellId == HideButtonGlowDB.allowedSpells[i] then
if HideButtonGlowDB.debugMode then
self:AddMessage(("Found in allow list, allowing spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
return false
end
end
if HideButtonGlowDB.debugMode then
self:AddMessage(("Hide All is checked, hiding spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
return true
end
-- else iterate through filter list
for i = 1, #HideButtonGlowDB.spells do
if spellId == HideButtonGlowDB.spells[i] then
if HideButtonGlowDB.debugMode then
self:AddMessage(("Filter matched, hiding spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
return true
end
end
-- else show the glow
if HideButtonGlowDB.debugMode then
self:AddMessage(("No filters matched, allowing spell glow for %s (ID %d)."):format(GetSpellName(spellId), spellId))
end
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 addon: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 addon:ShouldHideGlow(spellId) then
return OriginalShowOverlayGlow(self)
end
end
end
end
-- Dominos
if Dominos then
-- since version 10.2.5-beta1, Dominos defines their own ActionButton instead of reusing the buttons
-- from the default Blizzard bars.
local ActionButton = Dominos.ActionButton
if ActionButton and ActionButton.ShowOverlayGlow then
local OriginalShowOverlayGlow = ActionButton.ShowOverlayGlow
function ActionButton.ShowOverlayGlow(self)
local spellType, id = GetActionInfo(self.action)
-- only check spell and macro glows
if not id or not (spellType == "spell" or spellType == "macro") or not addon:ShouldHideGlow(id) then
return OriginalShowOverlayGlow(self)
end
end
end
end
-- Blizzard Bars
hooksecurefunc("ActionButton_ShowOverlayGlow", function(actionButton)
if actionButton and actionButton.action then
local spellType, id = GetActionInfo(actionButton.action)
-- only check spell and macro glows
if id and (spellType == "spell" or spellType == "macro") and addon:ShouldHideGlow(id) then
if actionButton.SpellActivationAlert then
-- Retail, post 10.0.2
actionButton.SpellActivationAlert:Hide()
elseif actionButton.overlay then
-- Cata Classic, pre 10.0.2
actionButton.overlay:Hide()
end
end
end
end)