-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.lua
219 lines (216 loc) · 11 KB
/
options.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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
local addonName, addon = ...
-- globals
local tinsert, tremove, tContains, tonumber = tinsert, tremove, tContains, tonumber
local GetSpellName, GetSpellInfo = C_Spell.GetSpellName, C_Spell.GetSpellInfo
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable(addonName, function()
return {
order = 1,
type = "group",
name = "Hide Button Glow",
args = {
general = {
order = 1,
type = "group",
name = "Options",
args = {
spacer = {
order = 1,
type = "description",
name = ""
},
hideAll = {
order = 2,
type = "toggle",
name = "Hide all glows",
desc = "Hide all spell glows, except for those under \"Allowed Spells\".",
get = function()
return HideButtonGlowDB.hideAll
end,
set = function()
HideButtonGlowDB.hideAll = not HideButtonGlowDB.hideAll
end
},
debugMode = {
order = 3,
type = "toggle",
name = "Debug mode",
desc = "Prints all filtered/unfiltered spells to chat. Useful for finding spell IDs, or checking how your settings work.",
get = function()
return HideButtonGlowDB.debugMode
end,
set = function()
HideButtonGlowDB.debugMode = not HideButtonGlowDB.debugMode
end
},
hiddenSpellHeader = {
order = 4,
type = "header",
name = "Filtered Spells",
hidden = function()
return HideButtonGlowDB.hideAll
end
},
hiddenSpellDescription = {
order = 5,
type = "description",
name = "Input spell names or spell IDs to prevent button glow for those abilities.",
hidden = function()
return HideButtonGlowDB.hideAll
end
},
hiddenSpellAdd = {
order = 6,
type = "input",
width = "full",
name = "Add",
desc = "Type a spell name or spell ID to prevent it from glowing.",
get = function() return "" end,
set = function(_, value)
local spellID = tonumber(value)
if spellID ~= nil then
local name = GetSpellName(spellID)
if name then
if tContains(HideButtonGlowDB.spells, spellID) then
addon:AddMessage(("ID %2$d already filtered as spell %1$s."):format(name, spellID))
else
addon:AddMessage(("Filtering button glow for spell %s with ID %d."):format(name, spellID))
tinsert(HideButtonGlowDB.spells, spellID)
end
else
addon:AddMessage(("Invalid spell ID: %s"):format(value))
end
else
local spellInfo = GetSpellInfo(value)
if spellInfo and spellInfo.spellID then
if tContains(HideButtonGlowDB.spells, spellInfo.spellID) then
addon:AddMessage(("\"%3$s\" already filtered as spell %1$s with ID %2$d."):format(spellInfo.name, spellInfo.spellID, value))
else
addon:AddMessage(("Filtering button glow for \"%3$s\" as spell %1$s with ID %2$d."):format(spellInfo.name, spellInfo.spellID, value))
tinsert(HideButtonGlowDB.spells, spellInfo.spellID)
end
else
addon:AddMessage(("Invalid spell name: %s"):format(value))
end
end
end,
hidden = function()
return HideButtonGlowDB.hideAll
end
},
hiddenSpellDelete = {
order = 7,
type = "select",
width = "full",
name = "Delete",
desc = "Delete an existing filtered spell.",
get = false,
set = function(_, index)
local spellID = HideButtonGlowDB.spells[index]
local name = GetSpellName(spellID)
addon:AddMessage(("Removing button glow filter for spell %s with ID %d."):format(name, spellID))
tremove(HideButtonGlowDB.spells, index)
end,
values = function()
local spellNames = {}
for i = 1, #HideButtonGlowDB.spells do
local name = GetSpellName(HideButtonGlowDB.spells[i])
tinsert(spellNames, name)
end
return spellNames
end,
disabled = function()
return #HideButtonGlowDB.spells == 0
end,
hidden = function()
return HideButtonGlowDB.hideAll
end
},
allowedSpellHeader = {
order = 9,
type = "header",
name = "Allowed Spells",
hidden = function()
return not HideButtonGlowDB.hideAll
end
},
allowedSpellDescription = {
order = 10,
type = "description",
name = "Input spell names or spell IDs for buttons which will always be allowed to glow, bypassing the \"Hide all glows\" setting.",
hidden = function()
return not HideButtonGlowDB.hideAll
end
},
allowedSpellAdd = {
order = 11,
type = "input",
width = "full",
name = "Add",
desc = "Type a spell name or spell ID to always allow it to glow.",
get = function() return "" end,
set = function(_, value)
local spellID = tonumber(value)
if spellID ~= nil then
local name = GetSpellName(spellID)
if name then
if tContains(HideButtonGlowDB.allowedSpells, spellID) then
addon:AddMessage(("ID %2$d already allowed as spell %1$s."):format(name, spellID))
else
addon:AddMessage(("Allowing button glow for spell %s with ID %d."):format(name, spellID))
tinsert(HideButtonGlowDB.allowedSpells, spellID)
end
else
addon:AddMessage(("Invalid spell ID: %s"):format(value))
end
else
local spellInfo = GetSpellInfo(value)
if spellInfo and spellInfo.spellID then
if tContains(HideButtonGlowDB.allowedSpells, spellInfo.spellID) then
addon:AddMessage(("\"%3$s\" already allowed as spell %s with ID %d."):format(spellInfo.name, spellInfo.spellID, value))
else
addon:AddMessage(("Allowing button glow for \"%3$s\" as spell %1$s with ID %2$d."):format(spellInfo.name, spellInfo.spellID, value))
tinsert(HideButtonGlowDB.allowedSpells, spellInfo.spellID)
end
else
addon:AddMessage(("Invalid spell name: %s"):format(value))
end
end
end,
hidden = function()
return not HideButtonGlowDB.hideAll
end
},
allowedSpellDelete = {
order = 12,
type = "select",
width = "full",
name = "Delete",
desc = "Delete an existing allowed spell.",
get = false,
set = function(_, index)
local spellID = HideButtonGlowDB.allowedSpells[index]
local name = GetSpellName(spellID)
addon:AddMessage(("Removing allowed button glow for spell %s with ID %d."):format(name, spellID))
tremove(HideButtonGlowDB.allowedSpells, index)
end,
values = function()
local spellNames = {}
for i = 1, #HideButtonGlowDB.allowedSpells do
local name = GetSpellName(HideButtonGlowDB.allowedSpells[i])
tinsert(spellNames, name)
end
return spellNames
end,
disabled = function()
return #HideButtonGlowDB.allowedSpells == 0
end,
hidden = function()
return not HideButtonGlowDB.hideAll
end
}
}
}
}
}
end)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addonName, nil, nil, "general")