forked from Stanzilla/ClassTimer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.lua
More file actions
549 lines (535 loc) · 14.2 KB
/
options.lua
File metadata and controls
549 lines (535 loc) · 14.2 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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
local sm = LibStub("LibSharedMedia-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("ClassTimer", true)
-- GLOBALS: ClassTimer CONFIGMODE_CALLBACKS
local bars = ClassTimer.bars
local unlocked = ClassTimer.unlocked
local function dragstart(self)
self:StartMoving()
end
local function dragstop(self)
ClassTimer.db.profile.Units[self.unit].x = self:GetLeft()
ClassTimer.db.profile.Units[self.unit].y = self:GetBottom()
self:StopMovingOrSizing()
end
local function getColor(info)
return unpack(ClassTimer.db.profile.Units[info.arg[1]][info.arg[2]])
end
local function setColor(info, ...)
if info.arg[1] == "general" then
for k in pairs(bars) do
ClassTimer.db.profile.Units[k][info.arg[2]] = { ... }
end
end
ClassTimer.db.profile.Units[info.arg[1]][info.arg[2]] = { ... }
ClassTimer.ApplySettings()
end
ClassTimer.options = {
type = 'group',
icon = '',
name = 'ClassTimer',
childGroups = 'tree',
args = {
enable = {
type = 'toggle',
name = L['Enable'],
desc = L['Enable ClassTimer'],
order = 1,
get = function() return ClassTimer:IsEnabled() end,
set = function(_, v) if v then ClassTimer:Enable() else ClassTimer:Disable() end end
},
lock = {
type = 'toggle',
name = L['Lock'],
desc = L['Toggle Cast Bar lock'],
order = 2,
get = function()
return not unlocked['general']
end,
set = function(info, v)
unlocked.general = not v
for k in pairs(bars) do
local unit = k
unlocked[unit] = not v
if v or not ClassTimer.db.profile.Units[unit].enable or (ClassTimer.db.profile.Group[unit] and unit ~= ClassTimer.db.profile.AllInOneOwner) then
bars[unit][1]:SetScript('OnDragStart', nil)
bars[unit][1]:SetScript('OnDragStop', nil)
if not ClassTimer.db.profile.Units[unit].click then
bars[unit][1]:EnableMouse(false)
end
else
local bar = bars[unit][1]
bar.icon:SetTexture("Interface\\Icons\\Ability_Druid_Enrage")
bar.text:SetText(L['%s, Drag to move']:format(L[unit]))
bar:EnableMouse(true)
bar:SetMovable(true)
bar.startTime = GetTime()
bar.endTime = GetTime() + 120
bar:SetMinMaxValues(GetTime(), GetTime() + 120)
bar:RegisterForDrag('LeftButton')
bar.unit = unit
bar:SetScript('OnDragStart', dragstart)
bar:SetScript('OnDragStop', dragstop)
bar:SetAlpha(1)
bar:Show()
end
ClassTimer:UpdateUnitBars(unit)
end
end,
},
BarSettings = {
type = 'group',
name = L['Bar Settings'],
order = 3,
args = {
Spacer = {
type = "header",
order = 1,
name = L["Bar Settings"]
},
EnabledUnits = {
order = 1,
name = L["Enabled Units"],
type = "multiselect",
get = function(info, key)
return ClassTimer.db.profile.Units[key].enable
end,
set = function(info, key, value)
ClassTimer.db.profile.Units[key].enable = value
end,
},
AllInOne = {
type = 'group',
name = L['AllInOne'],
inline = true,
args = {
Units = {
type = 'multiselect',
name = L['Units'],
desc = L['Display all the buffs and debuffs on the AllInOne owner bar'],
get = function(_, key) return ClassTimer.db.profile.Group[key] end,
set = function(_, key, value)
if not ClassTimer.db.profile.AllInOneOwner then
ClassTimer.db.profile.AllInOneOwner = key
elseif not ClassTimer.db.profile.Group[ClassTimer.db.profile.AllInOneOwner] then
ClassTimer.db.profile.AllInOneOwner = key
end
ClassTimer.db.profile.Group[key] = value
end,
order = 2,
},
Owner = {
type = 'select',
name = L['Owner'],
desc = L['Display the AllInOne Bars this bar'],
get = function() return ClassTimer.db.profile.AllInOneOwner end,
set = function(_, value) ClassTimer.db.profile.AllInOneOwner = value ClassTimer.db.profile.Group[value] = true end,
order = 3,
}
}
}
}
},
}
}
CONFIGMODE_CALLBACKS = CONFIGMODE_CALLBACKS or {}
CONFIGMODE_CALLBACKS["ClassTimer"] = function(action, mode)
if action == "ON" then
ClassTimer.options.args.lock.set(nil, false)
elseif action == "OFF" then
ClassTimer.options.args.lock.set(nil, true)
end
end
function ClassTimer:AddUnitOptions(type)
local path = ClassTimer.options.args.BarSettings
path.args[type] = {
name = L[type],
type = "group",
desc = "Settings for "..L[type],
order = type == 'general' and 1 or 20,
childGroups = "tab",
hidden = function() return not(ClassTimer.db.profile.Units[type].enable) end,
get = function(info)
return ClassTimer.db.profile.Units[info.arg[1]][info.arg[2]]
end,
set = function(info, value)
if info.arg[1] == "general" then
for k in pairs(bars) do
ClassTimer.db.profile.Units[k][info.arg[2]] = value
end
end
ClassTimer.db.profile.Units[info.arg[1]][info.arg[2]] = value
ClassTimer.ApplySettings()
end,
args = {
Header = {
type = 'header',
order = 1,
name = L[type],
},
General = {
name = L["General"],
type = "group",
order = 1,
args = {
buffs = {
type = 'toggle',
name = L['Enable Buffs'],
desc = L['Show buffs'],
order = 1,
arg = {type, 'buffs'},
},
debuffs = {
type = 'toggle',
name = L['Enable Debuffs'],
desc = L['Show debuffs'],
order = 2,
arg = {type, 'debuffs'},
},
click = {
type = 'toggle',
name = L['Use Clicks'],
desc = L['Print timeleft and ability on right click'],
arg = {type, 'click'},
order = 4,
},
growUp = {
type = 'toggle',
name = L['Grow Up'],
desc = L['Set bars to grow up'],
order = 5,
arg = {type, 'growup'},
},
reversed = {
type = 'toggle',
name = L['Reversed'],
desc = L['Reverse the bars (fill vs deplete)'],
order = 6,
arg = {type, 'reversed'},
},
reverseSort = {
type = 'toggle',
name = L['Reverse sort'],
desc = L['Reverse up/down sorting'],
order = 7,
arg = {type, 'reverseSort'},
},
showiconsOnly = {
type = 'toggle',
name = L['Show Only Icons'],
desc = L['Show only icons and timeleft'],
arg = {type, 'showIcons'},
order = 8,
},
iconSide = {
type = 'select',
name = L['Icon Position'],
desc = L['Set the side of the bar that the icon appears on'],
values = {['LEFT']=L['Left'], ['RIGHT']=L['Right']},
arg = {type, 'iconSide'},
order = 9,
},
},
},
FrameAttributes = {
name = L["Frame Attributes"],
type = "group",
order = 2,
args = {
width = {
type = 'range',
name = L['Bar Width'],
desc = L['Set the width of the bars'],
min = 50,
max = 300,
step = 1,
--bigStep = 5,
arg = {type, 'width'},
order = 1,
},
height = {
type = 'range',
name = L['Bar Height'],
desc = L['Set the height of the bars'],
min = 4,
max = 25,
step = 1,
--bigStep = 5,
arg = {type, 'height'},
order = 2,
},
scale = {
type = 'range',
name = L['Scale'],
desc = L['Set the scale of the bars'],
min = .1,
max = 2,
step = .01,
--bigStep = .1,
order = 3,
arg = {type, 'scale'},
},
spacing = {
type = 'range',
name = L['Spacing'],
desc = L['Tweak the space between bars'],
min = -5,
max = 5,
step = .1,
--bigStep = 1,
arg = {type, 'spacing'},
order = 4,
},
alpha = {
type = 'range',
name = L['Alpha'],
desc = L['Set the alpha of the bars'],
order = 5,
min = 0,
max = 1,
step = .05,
arg = {type, 'alpha'},
},
sizes = {
type = 'group',
name = L['Change size'],
desc = L['Change bar size depending on duration if its less that the max time setting'],
order = 6,
inline = true,
args = {
enable = {
type = 'toggle',
name = L['Enable'],
desc = L['Enable changing of bar size depending on duration if its less that the max time setting'],
order = 1,
arg = {type, 'sizeEnable'}
},
maxTime = {
type = 'range',
name = L['Max time'],
desc = L['Max time to change bar sizes for'],
order = 2,
max = 60,
min = 5,
step = .5,
--bigStep = 1,
hidden = function() return not ClassTimer.db.profile.Units[type].sizeEnable end,
arg = {type, 'sizeMax'},
}
}
},
},
},
Texts = {
name = L["Texts"],
type = "group",
order = 3,
args = {
text = {
type = 'input',
name = L['Bar Text'],
desc = L['Set the bar text'],
order = 1,
usage = L['<%s for spell, %a for applications, %n for name, %u for unit>'],
arg = {type, 'bartext'},
},
timetext = {
type = 'toggle',
name = L['Time Text'],
desc = L['Display the time remaining on buffs/debuffs on their bars'],
arg = {type, 'timetext'},
order = 2,
},
textcolor = {
type = 'color',
name = L['Text Color'],
desc = L['Set the color of the text for the bars'],
arg = {type, 'textcolor'},
get = getColor,
set = setColor,
order = 3,
},
font = {
type = 'select',
name = L['Font'],
desc = L['Set the font used in the bars'],
values = function() return ClassTimer:List(sm:List('font')) end,
arg = {type, 'font'},
order = 4,
},
fontsize = {
type = 'range',
name = L['Font Size'],
desc = L['Set the font size for the bars'],
min = 3,
max = 15,
step = .5,
--bigStep = 2,
arg = {type, 'fontsize'},
order = 5,
},
},
},
Textures = {
name = L["Textures"],
type = "group",
order = 4,
args = {
texture = {
type = 'select',
name = L['Texture'],
desc = L['Set the bar Texture'],
values = function() return ClassTimer:List(sm:List('statusbar')) end,
order = 1,
arg = {type, 'texture'},
},
showicons = {
type = 'toggle',
name = L['Show Icons'],
desc = L['Show icons on buffs and debuffs'],
arg = {type, 'icons'},
order = 2,
},
iconside = {
type = 'select',
name = L['Icon Position'],
desc = L['Set the side of the bar that the icon appears on'],
values = {LEFT = L['Left'], RIGHT = L['Right']},
arg = {type, 'iconSide'},
order = 3,
},
buffcolor = {
type = 'color',
name = L['Buff Color'],
desc = L['Set the color of the bars for buffs'],
get = getColor,
set = setColor,
hasAlpha = true,
arg = {type, 'buffcolor'},
order = 4,
},
alwaysshownbuffcolor = {
type = 'color',
name = L['AlwaysShown buff Color'],
desc = L['Set the color of the bars for always shown buffs'],
get = getColor,
set = setColor,
hasAlpha = true,
arg = {type, 'alwaysshownbuffcolor'},
order = 5,
},
backgroundcolor = {
type = 'color',
name = L['Background Color'],
desc = L['Set the color of the bars background'],
get = getColor,
set = setColor,
hasAlpha = true,
arg = {type, 'backgroundcolor'},
order = 6,
},
Debuffs = {
type = 'group',
name = L['Debuff Colors'],
desc = L['Set the color of the bars for debuffs'],
inline = true,
order = 7,
args = {
Normal = {
type = 'color',
name = L['Normal'],
desc = L['Set color for normal'],
get = getColor,
set = setColor,
order = 1,
hasAlpha = true,
arg = {type, 'debuffcolor'},
},
alwaysshown = {
type = 'color',
name = L['AlwaysShown'],
desc = L['Set the color for always shown debuffs'],
get = getColor,
set = setColor,
order = 1,
hasAlpha = true,
arg = {type, 'alwaysshowndebuffcolor'},
},
differentColors = {
type = 'toggle',
name = L['Different colors'],
desc = L['Different colors for different debuffs types'],
order = 2,
arg = {type, 'differentColors'},
},
Curse = {
type = 'color',
name = L['Curse'],
desc = L['Set color for curses'],
get = getColor,
set = setColor,
order = 5,
hasAlpha = true,
arg = {type, 'Cursecolor'},
hidden = function() return not ClassTimer.db.profile.Units[type].differentColors end,
},
Poison = {
type = 'color',
name = L['Poison'],
desc = L['Set color for poisons'],
get = getColor,
set = setColor,
order = 6,
hasAlpha = true,
arg = {type, 'Poisoncolor'},
hidden = function() return not ClassTimer.db.profile.Units[type].differentColors end,
},
Magic = {
type = 'color',
name = L['Magic'],
desc = L['Set color for magics'],
get = getColor,
set = setColor,
order = 7,
hasAlpha = true,
arg = {type, 'Magiccolor'},
hidden = function() return not ClassTimer.db.profile.Units[type].differentColors end,
},
Disease = {
type = 'color',
name = L['Disease'],
desc = L['Set color for diseases'],
get = getColor,
set = setColor,
order = 8,
hasAlpha = true,
arg = {type, 'Diseasecolor'},
hidden = function() return not ClassTimer.db.profile.Units[type].differentColors end,
},
},
},
},
},
Sticky = type == "sticky" and {
type = 'group',
name = L['Add Sticky'],
desc = L['Add a move to be sticky'],
order = 7,
args = {},
} or nil
},
}
end
local values = {}
local values2 = {}
for k in pairs(bars) do
values[k] = L[k]
values2[k] = L[k]
ClassTimer:AddUnitOptions(k)
end
ClassTimer:AddUnitOptions('general')
ClassTimer.options.args.BarSettings.args.EnabledUnits.values = values
values2['sticky'] = nil
ClassTimer.options.args.BarSettings.args.AllInOne.args.Units.values = values2
ClassTimer.options.args.BarSettings.args.AllInOne.args.Owner.values = values2
local values = nil
local values2 = nil