-
Notifications
You must be signed in to change notification settings - Fork 1
/
Options.lua
executable file
·399 lines (375 loc) · 16.1 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
-- Options
-- user defined configuration options
-------------------------------------------------------------------------------
-- Module Loading
-------------------------------------------------------------------------------
local ADDON_NAME, BQ = ...
---@class Options -- IntelliJ-EmmyLua annotation
---@field supportCombat boolean placate Bliz security rules of "don't SetAnchor() during combat"
---@field doCloseOnClick boolean close the flyout after the user clicks one of its buttons
---@field usePlaceHolders boolean eliminate the need for "Always Show Buttons" in Bliz UI "Edit Mode" config option for action bars
---@field clickers table germ behavior for various mouse clicks
local Options = { }
BQ.Options = Options
local EMPTY = {}
-------------------------------------------------------------------------------
-- Methods
-------------------------------------------------------------------------------
function Options:init()
local whitelist_kill
local blacklist_kill
local optionsMenu = {
name = ADDON_NAME,
type = "group",
args = {
-------------------------------------------------------------------------------
-- General
-------------------------------------------------------------------------------
description = {
order = 5,
type = 'description',
name = "Hides and/or mutes the giant talking heads from NPCs when entering world quests or instances only leaving their text in the regular chat box. \r\r",
},
mute = {
order = 50,
name = "Mute",
desc = "Silence the voiceover.",
--width = "full",
type = "toggle",
set = function(optionsMenu, isMuted)
msg_user("Voiceovers are " .. (isMuted and "muted." or "allowed."))
VO_ENABLED = convertTo0or1(not isMuted)
end,
get = function()
return not is_true(VO_ENABLED)
end,
},
hide = {
order = 60,
name = "Hide",
desc = "Hide the talking head.",
--width = "full",
type = "toggle",
set = function(optionsMenu, isHidden)
local doShow = not isHidden
msg_user("Talking heads will ".. (doShow and "appear." or "be hidden."))
BQ_SHOW_HEADS = convertTo0or1(doShow)
end,
get = function()
return not is_true(BQ_SHOW_HEADS)
end,
},
warn_if_broke = {
order = 70,
hidden = function()
local warn = is_true(VO_ENABLED) and is_true(BQ_SHOW_HEADS)
local hide = not warn
return hide
end,
type = 'description',
name = BQ_RED.."DISABLED! |r With neither Mute nor Hide, BeQuiet will effectively do nothing.",
},
-------------------------------------------------------------------------------
-- Mode
-------------------------------------------------------------------------------
mode_header = {
order = 149,
name = "Mode",
type = 'header',
},
mode_help = {
order = 150,
type = 'description',
name = "There are two modes of BeQuiet: activate everywhere by default but permit specific zones; Or suppress zone by zone. \r\r",
},
mode = {
order = 170,
name = "Mode",
width = "full",
type = "select",
style = "radio", --"dropdown", "radio"
values = {
[true] = "BeQuiet everywhere by default. Zones in the Whitelist will not be suppressed.",
[false] = "BeQuiet nowhere by default. Only zones in the Blacklist will be suppressed.",
},
sorting = { true,false },
set = function(optionsMenu, val)
ENABLED = convertTo0or1(val)
--msg_user(val and allow_msg or block_msg)
end,
get = function()
return is_mode_not_blacklist()
end,
},
-------------------------------------------------------------------------------
-- Warnings
-------------------------------------------------------------------------------
warnings_linebreak = {
order = 1000,
type = 'description',
name = "",
},
warnings = {
order = 65,
name = "Warnings",
desc = "Display a message in your chat box when "..ADDON_NAME.." hides or mutes a talking head.",
--width = "full",
type = "toggle",
set = function(optionsMenu, val)
VERBOSE = convertTo0or1(val)
msg_user("Warnings are " .. (val and "enabled." or "disabled."))
end,
get = function()
return is_true(VERBOSE)
end,
},
-------------------------------------------------------------------------------
-- Whitelist
-------------------------------------------------------------------------------
whitelist_header = {
order = 200,
hidden = is_mode_not_whitelist,
name = "Whitelist",
type = 'header',
},
whitelist_help = {
order = 205,
hidden = is_mode_not_whitelist,
type = 'description',
name = "Zones in the whitelist will be allowed to play the talking heads.",
},
whitelist_current_zone = {
order = 210,
hidden = is_mode_not_whitelist,
name = function() return make_btn_text_for_toggle_current_zone(WHITELIST, "white") or "No Zone" end, -- "Toggle Current Zone",
desc = "Allow talking heads in your current major zone (e.g. Orgrimmar or Stormwind)",
width = "double",
type = "execute",
func = function() toggle_current_zone(WHITELIST, "white") end,
},
whitelist_current_subzone = {
order = 220,
hidden = is_mode_not_whitelist,
name = function() return make_btn_text_for_toggle_current_subzone(WHITELIST, "white") or "No Subzone" end, -- "Toggle Current Subzone",
disabled = function() return nil == make_btn_text_for_toggle_current_subzone(WHITELIST, "white") end,
desc = "Allow talking heads in your current subzone (e.g. Valley of Strength or Old Town)",
width = "double",
type = "execute",
func = function() toggle_current_subzone(WHITELIST, "white") end,
},
whitelist_display = {
-- NOT USED - replaced by hover text
order = 229,
hidden = true, -- use_mode_whitelist,
disabled = true,
name = "", -- "Current Whitelist",
desc = "List of all zones currently in the whitelist.",
width = "double",
type = "input",
multiline = 5,
get = function()
return table.concat(WHITELIST, "\r")
end,
},
whitelist_picker = {
order = 230,
hidden = is_mode_not_whitelist,
name = "Current Whitelist",
desc = table.concat(WHITELIST, "\r"),
width = "double",
type = "select",
values = WHITELIST,
get = function()
return whitelist_kill
end,
set = function(info, val)
whitelist_kill = val
end
},
whitelist_listing_killer = {
order = 230,
hidden = is_mode_not_whitelist,
name = "Delete Selection from Whitelist",
desc = "Allow talking heads in your current subzone (e.g. Valley of Strength or Old Town)",
width = "double",
type = "execute",
disabled = function()
return not (whitelist_kill and true or false)
end,
func = function()
--msg_user("WHITELIST",table.concat(WHITELIST,", "))
--msg_user("killing",whitelist_kill,val)
local val = WHITELIST[whitelist_kill]
--msg_user("killing",val)
removeFirst(WHITELIST, val)
--msg_user("result =", table.concat(WHITELIST,", "))
whitelist_kill = nil
end,
},
whitelist_linebreak = {
order = 235,
hidden = is_mode_not_whitelist,
type = 'description',
name = "",
},
whitelist_RESET = {
order = 250,
hidden = is_mode_not_whitelist,
name = "Reset Whitelist",
desc = "This will ERASE the current whitelist and set it to the default:".. table.concat(WL_DEFAULT, ", "),
--width = "double",
type = "execute",
confirm = true,
func = function()
replace_array(WL_DEFAULT, WHITELIST)
end,
},
whitelist_ERASE = {
order = 240,
hidden = is_mode_not_whitelist,
name = "Erase Whitelist",
desc = "This will ERASE the current whitelist.",
disabled = function() return WHITELIST[1] == nil end,
--width = "double",
type = "execute",
confirm = true,
func = function()
replace_array(EMPTY, WHITELIST)
end,
},
-------------------------------------------------------------------------------
-- Blacklist
-------------------------------------------------------------------------------
blacklist_header = {
order = 300,
hidden = is_mode_not_blacklist,
name = "Blacklist",
type = 'header',
},
blacklist_help = {
order = 305,
hidden = is_mode_not_blacklist,
type = 'description',
name = "Zones in the blacklist will BeQuiet.",
},
blacklist_current_zone = {
order = 310,
hidden = is_mode_not_blacklist,
name = function() return make_btn_text_for_toggle_current_zone(BLACKLIST, "black") or "No Zone" end, -- "Toggle Current Zone",
desc = "Block talking heads in your current major zone (e.g. Orgrimmar or Stormwind)",
width = "double",
type = "execute",
func = function() toggle_current_zone(BLACKLIST, "black") end,
},
blacklist_current_subzone = {
order = 320,
hidden = is_mode_not_blacklist,
name = function() return make_btn_text_for_toggle_current_subzone(BLACKLIST, "black") or "No Subzone" end, -- "Toggle Current Subzone",
disabled = function() return nil == make_btn_text_for_toggle_current_subzone(BLACKLIST, "black") end,
desc = "Block talking heads in your current subzone (e.g. Valley of Strength or Old Town)",
width = "double",
type = "execute",
func = function() toggle_current_subzone(BLACKLIST, "black") end,
},
blacklist_display = {
-- NOT USED - replaced by hover text
order = 329,
hidden = true, -- use_mode_blacklist,
disabled = true,
name = "", -- "Current Blacklist",
desc = "List of all zones currently in the whitelist.",
width = "double",
type = "input",
multiline = 5,
get = function()
return table.concat(BLACKLIST, "\r")
end,
},
blacklist_picker = {
order = 330,
hidden = is_mode_not_blacklist,
name = "Current Blacklist",
desc = table.concat(BLACKLIST, "\r"),
width = "double",
type = "select",
values = BLACKLIST,
get = function()
return blacklist_kill
end,
set = function(info, val)
blacklist_kill = val
end
},
blacklist_listing_killer = {
order = 330,
hidden = is_mode_not_blacklist,
name = "Delete Selection from Blacklist",
desc = "Allow talking heads in your current subzone (e.g. Valley of Strength or Old Town)",
width = "double",
type = "execute",
disabled = function()
return not (blacklist_kill and true or false)
end,
func = function()
--msg_user("BLACKLIST",table.concat(BLACKLIST,", "))
--msg_user("killing",blacklist_kill,val)
local val = BLACKLIST[blacklist_kill]
--msg_user("killing",val)
removeFirst(BLACKLIST, val)
--msg_user("result =", table.concat(BLACKLIST,", "))
blacklist_kill = nil
end,
},
blacklist_linebreak = {
order = 335,
hidden = is_mode_not_blacklist,
type = 'description',
name = "",
},
blacklist_ERASE = {
order = 340,
hidden = is_mode_not_blacklist,
name = "Erase Blacklist",
desc = "This will ERASE the current blacklist.",
disabled = function() return BLACKLIST[1] == nil end,
--width = "double",
type = "execute",
confirm = true,
func = function()
replace_array(BL_DEFAULT, BLACKLIST)
end,
},
-------------------------------------------------------------------------------
-- Instances Implicitly Blacklisted
-------------------------------------------------------------------------------
instance_linebreak = {
order = 400,
hidden = is_mode_not_blacklist,
type = 'description',
name = "",
},
instance = {
order = 410,
hidden = is_mode_not_blacklist,
name = "Instances",
desc = "Always BeQuiet in instances, dungeons, raids, etc.",
--width = "full",
type = "toggle",
set = function(optionsMenu, val)
BQ_SUPPRESS_INSTANCES = val
msg_user("Instance are " .. (val and "supressed." or "free."))
end,
get = function()
return BQ_SUPPRESS_INSTANCES
end,
},
},
}
-- init the message vars etc.
MyAddonCommands()
LibStub("AceConfig-3.0"):RegisterOptionsTable(ADDON_NAME, optionsMenu)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(ADDON_NAME, ADDON_NAME)
end
function BeQuiet_BlizCompartment_OnClick(addonName, mouseClick)
Settings.OpenToCategory(ADDON_NAME)
end