-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions.lua
More file actions
487 lines (475 loc) · 18.7 KB
/
options.lua
File metadata and controls
487 lines (475 loc) · 18.7 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
476
477
478
479
480
481
482
483
484
485
486
487
---@class RCLootCouncil
local addon = LibStub("AceAddon-3.0"):GetAddon("RCLootCouncil")
---@class RCExtraUtilities
local EU = addon:GetModule("RCExtraUtilities")
local LE = LibStub("AceLocale-3.0"):GetLocale("RCExtraUtilities")
------ Options ------
function EU:OptionsTable()
local addon_db = addon:Getdb()
local Classic = addon.isClassic and addon:GetModule("RCClassic", true)
local options = {
name = "Extra Utilities",
order = 1,
type = "group",
childGroups = "tab",
args = {
desc = {
name = format(LE["extra_util_desc"], self.version),
order = 1,
type = "description",
},
general = {
name = _G.GENERAL,
order = 1,
type = "group",
args = {
columns = {
name = LE["Extra Utilities Columns"],
order = 2,
type = "group",
inline = true,
handler = EU,
set = "ColSet",
get = "ColGet",
args = (function()
local ret = {
pawn = {
name = "Pawn",
order = 1,
type = "toggle",
desc = LE["opt_pawn_desc"],
tristate = true,
},
sockets = {
name = LE["Sockets"],
order = 4,
type = "toggle",
desc = LE["opt_sockets_desc"],
},
-- upgrades = {
-- name = LE["Upgrades"],
-- order = 3,
-- type = "toggle",
-- desc = LE["opt_upgrades_desc"],
-- },
-- ilvlUpgrade = {
-- name = LE["ilvl Upgrades"],
-- order = 8,
-- type = "toggle",
-- desc = LE["opt_ilvlupgrades_desc"],
-- },
setPieces = {
name = LE["Set Pieces"],
order = 5,
type = "toggle",
desc = LE["opt_setpieces_desc"],
},
legendaries = {
name = LE["Legendaries"],
order = 7,
type = "toggle",
desc = LE["opt_legendaries_desc"],
},
spec = {
name = LE["Spec Icon"],
order = 9,
type = "toggle",
desc = LE["opt_specIcon_desc"],
},
guildNotes = {
name = LE["Guild Notes"],
order = 11,
type = "toggle",
desc = LE["opt_guildNotes_desc"],
},
-- covenant = {
-- name = "Covenant",
-- order = 12,
-- type = "toggle",
-- desc = "Enables a column showing which covenant the candidate has chosen.",
-- hidden = addon.isClassic,
-- },
-- rcscore = {
-- name = "RC Score",
-- order = 12,
-- type = "toggle",
-- desc = "A performance metric based on hps/dps and item levels.",
-- tristate = true,
-- },
header = {
order = -1,
name = "",
type = "header",
},
reset = {
name = _G.RESET_TO_DEFAULT,
order = -1,
--width = "full",
type = "execute",
confirm = true,
func = function()
if self.votingFrame.frame and self.votingFrame.frame:IsVisible() then return addon:Print(
LE["You can't change these settings while the voting frame is showing."]) end
for k in pairs(self.db.columns) do
self.db.columns[k] = self.defaults.profile.columns[k]
-- Now apply the changes
self:UpdateColumn(k, self.db.columns[k].enabled)
end
end,
},
}
-- Classic changes
if addon.isClassic then
if Classic:IsClassicEra() then
ret.sockets = nil
end
if Classic:IsPreMists() then
ret.spec = nil
end
if not Classic:IsPreMists() then
ret.bonus = {
name = LE["Bonus Rolls"],
order = 10,
type = "toggle",
desc = LE["opt_bonusRoll_desc"],
}
end
end
return ret
end)()
},
normalColumns = {
name = LE["RCLootCouncil Columns"],
order = 3,
type = "group",
inline = true,
args = {
-- Created further down
header = {
name = "",
order = -1,
type = "header",
},
reset = {
name = _G.RESET_TO_DEFAULT,
order = -1,
--width = "full",
type = "execute",
confirm = true,
func = function()
if self.votingFrame.frame and self.votingFrame.frame:IsVisible() then return addon:Print(LE
["You can't change these settings while the voting frame is showing."]) end
for k in pairs(self.db.normalColumns) do
self.db.normalColumns[k] = self.defaults.profile.normalColumns[k]
-- Now apply the changes
self:UpdateColumn(k, self.db.normalColumns[k].enabled)
end
end,
},
},
},
otherOptions = {
name = LE["Other"],
order = 5,
type = "group",
inline = true,
args = {
decimals = {
name = LE["ilvl Decimals"],
order = 1,
type = "toggle",
desc = LE["opt_ilvldecimals_desc"],
get = function() return addon_db.iLvlDecimal end,
set = function(_, val) addon_db.iLvlDecimal = val end,
},
},
}
},
},
pawnOptions = {
order = 2,
type = "group",
name = "Pawn",
desc = LE["Pawn specific options"],
disabled = function() return not _G.PawnVersion end,
childGroups = "tab",
args = {
acceptPawn = {
order = 1,
name = LE["Accept Pawn"],
desc = LE["opt_acceptPawn_desc"],
type = "toggle",
set = function() self.db.acceptPawn = not self.db.acceptPawn end,
get = function() return self.db.acceptPawn end,
},
pawnNormalMode = {
order = 2,
name = LE["Score Mode"],
desc = LE["opt_pawnMode_desc"],
type = "toggle",
set = function() self.db.pawnNormalMode = not self.db.pawnNormalMode end,
get = function() return self.db.pawnNormalMode end,
},
scalesGroup = {
order = 3,
type = "group",
--inline = true,
name = LE["Scales"],
childGroups = "tree",
args = {
desc = {
name = LE["opt_scalesGroup_desc"],
type = "description",
order = 0,
},
},
},
},
},
widthOptions = {
order = 3,
type = "group",
name = LE["Advanced"],
childGroups = "tab",
args = {
subGroup = {
order = 1,
type = "group",
name = " ",
inline = true,
args = {
open = {
order = 1,
name = LE["Open Voting Frame"],
type = "execute",
func = function() addon:Test(2) end,
},
reset = {
order = 2,
type = "execute",
name = _G.RESET_TO_DEFAULT,
desc = LE["opt_advReset_desc"],
confirm = true,
func = function()
for name in pairs(self.db.columns) do
self.db.columns[name].pos = self.defaults.profile.columns[name].pos
self.db.columns[name].width = self.defaults.profile.columns[name].width
end
for name in pairs(self.db.normalColumns) do
self.db.normalColumns[name].width = self.defaults.profile.normalColumns[name].width
self.db.normalColumns[name].pos = nil
end
self:SetupColumns()
if self.votingFrame.frame then
self.votingFrame.frame.UpdateSt()
end
end,
},
},
},
columns = {
order = -1,
name = LE["Extra Utilities Columns"],
type = "group",
args = {
-- Made further down
desc = {
order = 0,
name = LE["opt_advanced_desc"],
type = "description",
width = "full",
},
},
},
normalColumns = {
order = -1,
name = LE["RCLootCouncil Columns"],
type = "group",
args = {
-- Made further down
},
},
},
},
},
}
-- Create the normalColumns
local i = 0
for _, name in ipairs(self.optionsNormalColOrder) do
local entry = self.db.normalColumns[name]
i = i + 1
-- Enabledness
if type(entry.enabled) == "boolean" then -- Don't allow certain things to be turned off
options.args.general.args.normalColumns.args[name] = {
order = i,
name = entry.name,
type = "toggle",
desc = format(LE["opt_normalcolumn_desc"], entry.name),
set = function()
if self.votingFrame.frame and self.votingFrame.frame:IsVisible() then return addon:Print(LE
["You can't change these settings while the voting frame is showing."]) end
entry.enabled = not entry.enabled
self:UpdateColumn(name, entry.enabled)
end,
get = function() return entry.enabled end
}
end
-- Position
options.args.widthOptions.args.normalColumns.args[name .. "Pos"] = {
order = i,
name = entry.name,
desc = format(LE["opt_position_desc"], entry.name),
type = "input",
pattern = "%d",
usage = LE["opt_position_usage"],
disabled = function() return not self:GetScrollColIndexFromName(name) end,
get = function() return tostring(entry.pos or self:GetScrollColIndexFromName(name)) end,
set = function(info, txt)
entry.pos = tonumber(txt)
self:UpdateColumnPosition(name, tonumber(txt))
self:StripTextures()
end,
}
-- Width
options.args.widthOptions.args.normalColumns.args[name .. "Width"] = {
order = i + 0.1,
name = entry.name,
desc = format(LE["column_width_desc"], entry.name),
type = "range",
width = "double",
min = 10,
max = 300,
step = 1,
disabled = function() return not self:GetScrollColIndexFromName(name) end,
get = function() return entry.width or self.originalCols[name].width end,
set = function(_, val)
entry.width = val
self:UpdateColumnWidth(name, val)
self:StripTextures()
end,
}
end
-- Create width slider for the EU cols
i = 0
for _, name in ipairs(self.optionsColOrder) do
local entry = self.db.columns[name]
self.Log:D("Doing col ", name, entry)
i = i + 1 * 2
options.args.widthOptions.args.columns.args[name .. "Pos"] = {
order = i,
name = name == "spec" and "Spec" or entry.name, -- Special case with spec
desc = format(LE["opt_position_desc"], entry.name),
type = "input",
pattern = "%d",
usage = LE["opt_position_usage"],
disabled = function() return not self:GetScrollColIndexFromName(name) end,
get = function() return tostring(entry.pos) end,
set = function(info, txt)
entry.pos = tonumber(txt)
self:UpdateColumnPosition(name, tonumber(txt))
self:StripTextures()
end,
}
options.args.widthOptions.args.columns.args[name .. "Width"] = {
order = i + 1,
name = name == "spec" and "Spec" or entry.name, -- Special case with spec
desc = format(LE["column_width_desc"], entry.name),
type = "range",
width = "double",
min = 10,
max = 300,
step = 1,
disabled = function() return not self:GetScrollColIndexFromName(name) end,
get = function() return entry.width end,
set = function(_, val)
entry.width = val
self:UpdateColumnWidth(name, val)
self:StripTextures()
end,
}
end
options = self:CreatePawnScaleOptions(options)
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("RCLootCouncil - Extra Utilities", options)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("RCLootCouncil - Extra Utilities",
"Extra Utilities", "RCLootCouncil")
end
function EU:ColSet(info, val)
if self.votingFrame.frame and self.votingFrame.frame:IsVisible() then return addon:Print(LE
["You can't change these settings while the voting frame is showing."]) end
if info.option.tristate then
if info[#info] == "pawn" then
if not _G.PawnVersion then return addon:Print(info.option.name, LE["opt_addon_requirement"]) end
elseif info[#info] == "rcscore" then
if not (_G.Details or _G.Recount or _G.Skada) then return addon:Print("A damage meter",
LE["opt_addon_requirement"]) end
end
end
-- v0.5.0: we can't use val anymore as we have tristates, so just invert stuff
self.db.columns[info[#info]].enabled = not self.db.columns[info[#info]].enabled
self:UpdateColumn(info[#info], val)
end
function EU:ColGet(info)
if info.option.tristate then
if info[#info] == "pawn" then
if not _G.PawnVersion then return nil end
elseif info[#info] == "rcscore" then
if not (_G.Details or _G.Recount or _G.Skada) then return nil end
end
end
if not self.db.columns[info[#info]] then
self.Log:E(self.db.columns[info[#info]], "doesn't exist!"); return false
end
return self.db.columns[info[#info]].enabled
end
-- Seperate Pawn scales for sanity
function EU:CreatePawnScaleOptions(options)
if not _G.PawnVersion then return options end -- Just in case
local scales = {}
for k in pairs(_G.PawnCommon.Scales) do
scales[k] = k
end
local i = 1
for class, opt in pairs(self.db.pawn) do
local c = addon:GetClassColor(class)
local hex = "|cFF" .. addon.Utils:RGBToHex(c.r, c.g, c.b)
options.args.pawnOptions.args.scalesGroup.args[class] = {
order = i,
type = "group",
name = hex .. LOCALIZED_CLASS_NAMES_MALE[class],
args = {},
}
local j = 0
for specID in pairs(opt) do
local _, name, icon
if addon.isClassic then
-- Hooks may not have fired, so extra check for druids
_, name, _, icon = _G.PawnGetSpecializationInfoForClassID(
addon.classTagNameToID[class] or (class == "DRUID" and 11), specID)
else
_, name, _, icon = GetSpecializationInfoByID(specID)
end
options.args.pawnOptions.args.scalesGroup.args[class].args["" .. specID] = {
order = j * 2 + 1,
name = hex .. name,
type = "description",
fontSize = "large",
image = icon,
imageWidth = 26,
imageHeight = 26,
}
options.args.pawnOptions.args.scalesGroup.args[class].args[specID .. "scale"] = {
order = j * 2 + 2,
type = "select",
name = "",
style = "dropdown",
width = "full",
values = scales,
get = function() return self.db.pawn[class][specID] end,
set = function(info, key) self.db.pawn[class][specID] = key end,
}
j = j + 1
end
i = i + 1
end
return options
end