-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathOptions.lua
More file actions
475 lines (468 loc) · 11.3 KB
/
Copy pathOptions.lua
File metadata and controls
475 lines (468 loc) · 11.3 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
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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
local _, T = ...
local L = T.L
local EDDM = LibStub("ElioteDropDownMenu-1.0")
local dropdownFrame = EDDM.UIDropDownMenu_GetOrCreate("SimpleAddonManager_MenuFrame")
--- @type SimpleAddonManager
local SAM = T.AddonFrame
local module = SAM:RegisterModule("Options")
local function MemoryUpdateMenuList()
local db = SAM:GetDb()
local menu = {}
local periods = { -1, 0, 5, 10, 15, 30 }
local periodDesc = {
[-1] = DISABLE,
[0] = L["Update only when opening the main window"],
}
for _, v in ipairs(periods) do
table.insert(menu, {
text = periodDesc[v] or L("${n} seconds", { n = v }),
checked = function()
return db.config.memoryUpdate == v
end,
func = function()
db.config.memoryUpdate = v
SAM:UpdateMemoryTickerPeriod(v)
end,
})
end
return menu
end
local function CPUUpdateMenuList()
local db = SAM:GetDb()
local menu = {}
local periods = { 0, 0.1, 0.25, 0.5, 1, 5 }
for _, v in ipairs(periods) do
table.insert(menu, {
text = (v == 0) and DISABLE or L("${n} seconds", { n = v }),
checked = function()
return db.config.profiling.cpuUpdate == v
end,
func = function()
db.config.profiling.cpuUpdate = v
SAM:GetModule("AddonProfiler"):OnShow()
SAM:Update()
end,
})
end
return menu
end
local function ConfigDropDownCreate()
local db = SAM:GetDb()
return {
{ text = L["Options"], isTitle = true, notCheckable = true },
{
text = ADDON_FORCE_LOAD,
checked = function()
return not SAM.compat.IsAddonVersionCheckEnabled()
end,
func = function(_, _, _, checked)
SAM.compat.SetAddonVersionCheck(checked)
SAM:Update()
end,
},
{
text = L["Replace original Addon wow menu button"],
checked = function()
return db.config.hookMenuButton
end,
func = function()
db.config.hookMenuButton = not db.config.hookMenuButton
if (db.config.hookMenuButton) then
SAM:HookMenuButton()
end
end,
},
{
text = L["Show minimap button"],
checked = function()
return not db.config.minimap.hide
end,
func = function()
SAM:GetModule("Minimap"):ToggleMinimapButton()
end,
},
{
text = L["Show in Addon compartment"],
checked = function()
return db.config.minimap.showInCompartment
end,
func = function()
SAM:GetModule("Minimap"):ToggleCompartment()
end,
},
{
text = L["Show memory usage in broker/minimap tooltip"],
checked = function()
return db.config.showMemoryInBrokerTtp
end,
func = function()
db.config.showMemoryInBrokerTtp = not db.config.showMemoryInBrokerTtp
end,
},
{
text = L["Show warning dialog when a disabled but locked addon is detected"],
checked = function()
return db.lock.canShowWarning
end,
func = function()
db.lock.canShowWarning = not db.lock.canShowWarning
SAM:Update()
end,
},
{
text = L["Memory Update"],
notCheckable = true,
hasArrow = true,
menuList = MemoryUpdateMenuList(),
},
{
text = L["CPU Update"],
notCheckable = true,
hasArrow = true,
disabled = not C_AddOnProfiler or not C_AddOnProfiler.IsEnabled(),
menuList = CPUUpdateMenuList(),
tooltipOnButton = not C_AddOnProfiler or not C_AddOnProfiler.IsEnabled(),
tooltipTitle = L["CPU data is not available in this version of WoW."],
tooltipText = "",
},
{
text = L["CPU Visibility"],
notCheckable = true,
hasArrow = true,
disabled = not C_AddOnProfiler or not C_AddOnProfiler.IsEnabled(),
menuList = {
{
text = L["Show Current"],
checked = function()
return db.config.profiling.cpuShowCurrent
end,
func = function(_, _, _, value)
db.config.profiling.cpuShowCurrent = not value
SAM:Update()
end,
},
{
text = L["Show Average"],
checked = function()
return db.config.profiling.cpuShowAverage
end,
func = function(_, _, _, value)
db.config.profiling.cpuShowAverage = not value
SAM:Update()
end,
},
{
text = L["Show Encounter"],
checked = function()
return db.config.profiling.cpuShowEncounter
end,
func = function(_, _, _, value)
db.config.profiling.cpuShowEncounter = not value
SAM:Update()
end,
},
{
text = L["Show Peak"],
checked = function()
return db.config.profiling.cpuShowPeak
end,
func = function(_, _, _, value)
db.config.profiling.cpuShowPeak = not value
SAM:Update()
end,
},
},
tooltipOnButton = not C_AddOnProfiler or not C_AddOnProfiler.IsEnabled(),
tooltipTitle = L["CPU data is not available in this version of WoW."],
tooltipText = "",
},
T.separatorInfo,
{ text = L["List Options"], isTitle = true, notCheckable = true },
{
text = L["Show versions in AddOns list"],
checked = function()
return db.config.showVersions
end,
func = function()
db.config.showVersions = not db.config.showVersions
SAM:Update()
end,
},
{
text = L["View AddOn list as dependency tree"],
checked = function()
return db.config.addonListStyle == "tree"
end,
func = function(_, _, _, value)
db.config.addonListStyle = (not value) and "tree" or "list"
SAM:Update()
end,
},
{
text = L["Show Blizzard addons found in dependencies"],
checked = function()
return db.config.showSecureAddons
end,
func = function()
local isEnabling = not db.config.showSecureAddons
if (isEnabling) then
SAM:ShowWarningDialog(
L["Be careful with this option, enabling/disabling Blizzard Addons might have unintended consequences!"],
function()
db.config.showSecureAddons = true
SAM:Update()
end
)
else
db.config.showSecureAddons = false
SAM:Update()
end
end,
},
{
text = L["Hide icons"],
checked = function()
return db.config.hideIcons
end,
func = function()
db.config.hideIcons = not db.config.hideIcons
SAM:Update()
end,
},
{
text = L["Collapse all"],
notCheckable = true,
func = function()
for _, v in pairs(SAM:GetAddonsList()) do
SAM:SetAddonCollapsed(v.key, v.parentKey, true)
end
SAM:Update()
end,
disabled = db.config.addonListStyle ~= "tree",
},
{
text = L["Expand all"],
notCheckable = true,
func = function()
SAM:GetDb().collapsedAddons = {}
SAM:Update()
end,
disabled = db.config.addonListStyle ~= "tree",
},
{
text = L["Sort by"],
notCheckable = true,
hasArrow = true,
menuList = {
{ text = L["A-Z"], isTitle = true, notCheckable = true },
{
text = L["Name (improved)"],
checked = function()
return db.config.sorting == "smart"
end,
func = function()
db.config.sorting = "smart"
SAM:Update()
end,
},
{
text = L["Internal name"],
checked = function()
return db.config.sorting == "name"
end,
func = function()
db.config.sorting = "name"
SAM:Update()
end,
},
{
text = L["Title"],
checked = function()
return db.config.sorting == "title"
end,
func = function()
db.config.sorting = "title"
SAM:Update()
end,
},
{
text = L["None"],
checked = function()
return not db.config.sorting
end,
func = function()
db.config.sorting = false
SAM:Update()
end,
},
T.separatorInfo,
{ text = L["CPU Usage"], isTitle = true, notCheckable = true },
{
text = L["Current"],
checked = function()
return db.config.sortingCpu == "current"
end,
func = function()
db.config.sortingCpu = "current"
SAM:Update()
end,
},
{
text = L["Average"],
checked = function()
return db.config.sortingCpu == "average"
end,
func = function()
db.config.sortingCpu = "average"
SAM:Update()
end,
},
{
text = L["Encounter"],
checked = function()
return db.config.sortingCpu == "encounter"
end,
func = function()
db.config.sortingCpu = "encounter"
SAM:Update()
end,
},
{
text = L["Peak"],
checked = function()
return db.config.sortingCpu == "peak"
end,
func = function()
db.config.sortingCpu = "peak"
SAM:Update()
end,
},
{
text = L["None"],
checked = function()
return not db.config.sortingCpu
end,
func = function()
db.config.sortingCpu = false
SAM:Update()
end,
},
},
},
T.separatorInfo,
{ text = L["Category Options"], isTitle = true, notCheckable = true },
{
text = L["Show autogenerated custom categories (X-Category)"],
checked = function()
return db.config.showTocXCategory
end,
func = function()
db.config.showTocXCategory = not db.config.showTocXCategory
SAM:Update()
end,
},
{
text = L["Show autogenerated categories"],
checked = function()
return db.config.showTocCategory
end,
func = function()
db.config.showTocCategory = not db.config.showTocCategory
SAM:Update()
end,
},
{
text = L["Localize autogenerated categories name"],
checked = function()
return db.config.localizeCategoryName
end,
func = function()
db.config.localizeCategoryName = not db.config.localizeCategoryName
SAM:Update()
end,
},
T.separatorInfo,
{ text = L["Search Options"], isTitle = true, notCheckable = true },
{
text = L["Autofocus searchbar when opening the UI"],
checked = function()
return db.config.autofocusSearch
end,
func = function()
db.config.autofocusSearch = not db.config.autofocusSearch
end,
},
{
text = L["Search By"],
notCheckable = true,
hasArrow = true,
menuList = {
{
text = L["Internal name"],
checked = function()
return db.config.searchBy.name
end,
func = function()
db.config.searchBy.name = not db.config.searchBy.name
SAM:Update()
end,
},
{
text = L["Title"],
checked = function()
return db.config.searchBy.title
end,
func = function()
db.config.searchBy.title = not db.config.searchBy.title
SAM:Update()
end,
},
{
text = L["Author"],
checked = function()
return db.config.searchBy.author
end,
func = function()
db.config.searchBy.author = not db.config.searchBy.author
SAM:Update()
end,
},
},
},
T.separatorInfo,
{ text = L["Utilities"], isTitle = true, notCheckable = true },
{
text = L["AddOn binary search"] .. " (beta)",
notCheckable = true,
func = function()
SAM:GetModule("AddonFinder"):StartSearch()
end,
disabled = db.addonFinder and db.addonFinder.isSearching,
},
T.separatorInfo,
T.closeMenuInfo
}
end
function module:OnLoad()
SAM:CreateDefaultOptions(SAM:GetDb().config, {
showMemoryInBrokerTtp = true,
showTocXCategory = false,
showTocCategory = true,
})
end
function module:PreInitialize()
SAM.ConfigButton = Mixin(
CreateFrame("Button", nil, SAM, "UIPanelSquareButton"),
EDDM.HandlesGlobalMouseEventMixin
)
end
function module:Initialize()
SAM.ConfigButton:SetPoint("RIGHT", SAM.CategoryButton, "LEFT", -4, 0)
SAM.ConfigButton:SetSize(30, 30)
SAM.ConfigButton.icon:SetAtlas("OptionsIcon-Brown")
SAM.ConfigButton.icon:SetTexCoord(0, 1, 0, 1)
SAM.ConfigButton.icon:SetSize(16, 16)
SAM.ConfigButton:SetScript("OnClick", function()
EDDM.ToggleEasyMenu(ConfigDropDownCreate(), dropdownFrame, SAM.ConfigButton, 0, 0, "MENU")
end)
end