-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathCombatEvents.lua
More file actions
2377 lines (2238 loc) · 65.1 KB
/
CombatEvents.lua
File metadata and controls
2377 lines (2238 loc) · 65.1 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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local _, ns = ...
local Parrot = ns.addon
if not Parrot then return end
local module = Parrot:NewModule("CombatEvents", "AceEvent-3.0", "AceTimer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot")
local LibSharedMedia = LibStub("LibSharedMedia-3.0")
local tinsert, tremove, tconcat, tsort = table.insert, table.remove, table.concat, table.sort
local newList, del, newDict = Parrot.newList, Parrot.del, Parrot.newDict
local debug = Parrot.debug
-- used as table for data about combatEvents in the registry
local combatEvents = {}
local sthrottles
local playerGUID = UnitGUID("player")
-- lookup-table for damage-types
local LS = {
["Physical"] = _G.STRING_SCHOOL_PHYSICAL,
["Holy"] = _G.STRING_SCHOOL_HOLY,
["Fire"] = _G.STRING_SCHOOL_FIRE,
["Nature"] = _G.STRING_SCHOOL_NATURE,
["Frost"] = _G.STRING_SCHOOL_FROST,
["Frostfire"] = _G.STRING_SCHOOL_FROSTFIRE,
["Froststorm"] = _G.STRING_SCHOOL_FROSTSTORM,
["Shadow"] = _G.STRING_SCHOOL_SHADOW,
["Shadowstorm"] = _G.STRING_SCHOOL_SHADOWSTORM,
["Arcane"] = _G.STRING_SCHOOL_ARCANE,
}
local UNKNOWN = _G.UNKNOWN
local db = nil
local defaults = {
profile = {
['*'] = {
['*'] = {}
},
dbver = 0, --[[this must remain 0 so that users upgrading from verions
with no dbver run through all update-functions --]]
cancelUIDSoon = true,
filters = {},
sfilters = {},
throttles = {},
sthrottles = {},
useShortThrottleText = true,
abbreviateStyle = "abbreviate",
abbreviateLength = 30,
stickyCrit = true,
disable_in_raid = false,
disable_in_battleground = false,
hideFullOverheals = 1,
hideSkillNames = false,
hideUnitNames = false,
shortenAmount = false,
breakUpAmount = false,
classcolor = true,
totemDamage = true,
hideRealm = true,
damageTypes = {
color = true,
["Physical"] = "ffffff",
["Holy"] = "ffff7f",
["Fire"] = "ff7f7f",
["Nature"] = "7fff7f",
["Frost"] = "7f7fff",
["Shadow"] = "7f007f",
["Arcane"] = "ff7fff",
["Frostfire"] = "ff0088",
["Froststorm"] = "7f7f7f",
["Shadowstorm"] = "1f1f1f",
},
modifier = {
color = true,
crit = {
enabled = false,
color = "ffffff",
tag = L["[Text] (crit)"],
},
crushing = {
enabled = true,
color = "7f0000",
tag = L["[Text] (crushing)"],
},
glancing = {
enabled = true,
color = "ff0000",
tag = L["[Text] (glancing)"],
},
absorb = {
enabled = true,
color = "ffff00",
tag = L[" ([Amount] absorbed)"],
},
block = {
enabled = true,
color = "7f00ff",
tag = L[" ([Amount] blocked)"],
},
resist = {
enabled = true,
color = "7f007f",
tag = L[" ([Amount] resisted)"],
},
vulnerable = {
enabled = true,
color = "7f7fff",
tag = L[" ([Amount] vulnerable)"],
},
overheal = {
enabled = true,
color = "00af7f",
tag = L[" ([Amount] overheal)"],
},
overkill = {
enabled = true,
color = "00af7f",
tag = L[" ([Amount] overkill)"],
},
},
},
}
--[[
-- to upgrade the DB from previous.
-- usage: if the format is changed, change the defaults to the new format.
-- Then add functions for converting old settings.
--]]
local updateDBFuncs = {
[1] = function()
local entry = db.Notification["Skill cooldown finish"]
if entry and entry.tag then
entry.tag = entry.tag:gsub("%[Skill%]","[Spell]")
end
end,
[2] = function()
local entry = db.Notification["Skill gains"]
if entry and entry.tag then
entry.tag = entry.tag:gsub("%[Skill%]","[Skillname]")
end
end,
[3] = function()
db.hideRealm = not Parrot.db.profile.showNameRealm
Parrot.db.profile.showNameRealm = nil
db.totemEvents = Parrot.db.profile.totemDamage
Parrot.db.profile.totemDamage = nil
end,
[4] = function()
if db.hideFullOverheals == false then
db.hideFullOverheals = 0
end
end,
[5] = function()
if db.disable_in_10man and db.disable_in_25man then
db.disable_in_raid = true
end
db.disable_in_10man = nil
db.disable_in_25man = nil
end,
}
local function updateDB()
if not db.dbver then
db.dbver = 0
end
for i = db.dbver+1, #updateDBFuncs do
updateDBFuncs[i]()
db.dbver = i
end
end
function module:OnNewProfile(_, database)
database.profile.dbver = #updateDBFuncs
end
function module:OnProfileChanged()
db = self.db.profile
updateDB()
sthrottles = db.sthrottles or {}
if next(Parrot.options.args) then
Parrot.options.args.events = del(Parrot.options.args.events)
self:OnOptionsCreate()
end
end
local function checkZone()
local _, instance_type = IsInInstance()
if instance_type == "raid" and db.disable_in_raid then
module:Disable()
elseif instance_type == "pvp" and db.disable_in_battleground then
module:Disable()
elseif not module:IsEnabled() then
module:Enable()
end
end
function module:OnInitialize()
self.db = Parrot.db:RegisterNamespace("CombatEvents", defaults)
self.db.RegisterCallback(self, "OnNewProfile", "OnNewProfile")
db = self.db.profile
updateDB()
sthrottles = db.sthrottles or {}
-- Register with Addons CombatLogEvent-registry for uid-stuff
Parrot:RegisterCombatLog(self)
self:RegisterEvent("PLAYER_ENTERING_WORLD", checkZone)
self:RegisterEvent("ZONE_CHANGED_NEW_AREA", checkZone)
end
function module:OnEnable()
self:ScheduleRepeatingTimer("RunThrottle", 0.05)
end
--[[
-- helper-function for spell-abbriviation
--]]
local function utf8trunc(text, num)
local len = 0
local i = 1
local text_len = #text
while len < num and i <= text_len do
len = len + 1
local b = text:byte(i)
if b <= 127 then
i = i + 1
elseif b <= 223 then
i = i + 2
elseif b <= 239 then
i = i + 3
else
i = i + 4
end
end
return text:sub(1, i-1)
end
--[[
-- abbriviate a spell according to options.
-- Example: "Shadow Bolt"
-- + None: "Shadow Bolt
-- + Truncate: "Shad..."
-- + Abbriviate: "SB"
--]]
function module:GetAbbreviatedSpell(name)
if not name then return end
local style = db.abbreviateStyle
if style == "none" then
return name
end
local name_len = 0
local i = 1
while i <= #name do
name_len = name_len + 1
local b = name:byte(i)
if b <= 127 then
i = i + 1
elseif b <= 223 then
i = i + 2
elseif b <= 239 then
i = i + 3
else
i = i + 4
end
end
local neededLen = db.abbreviateLength
if name_len < neededLen then
return name
end
if style == "abbreviate" then
if name:find("[%(%)]") then
name = name:gsub("%b()", ""):gsub(" +", " "):gsub("^ +", ""):gsub(" +$", "")
end
local t = newList((" "):split(name))
if #t == 1 then
t = del(t)
return name
end
i = 0
while i < #t do
i = i + 1
if t[i] == "" then
tremove(t, i)
i = i - 1
end
end
if #t == 1 then
t = del(t)
return name
end
for j = 1, #t do
local len
local b = t[i]:byte(1)
if b <= 127 then
len = 1
elseif b <= 223 then
len = 2
elseif b <= 239 then
len = 3
else
len = 4
end
if len then
local alpha, bravo = t[j]:sub(1, len), t[j]:sub(len+1)
if bravo:find(":") then
t[j] = alpha .. ":"
else
t[j] = alpha
end
else
t[j] = ""
end
end
local s = tconcat(t)
t = del(t)
return s
elseif style == "truncate" then
local num = neededLen-3
if num < 3 then
num = 3
end
return utf8trunc(name, neededLen) .. "..."
end
return name
end
Parrot.GetAbbreviatedSpell = module.GetAbbreviatedSpell
local modifierTranslationHelps
local throttleTypes = {}
local throttleDefaultTimes = {}
local throttleWaitStyles = {}
local filterTypes = {}
local filterDefaults = {}
local function createOption() end
local function createThrottleOption() end
local function createFilterOption() end
local function setOption(info, value)
local name = info[#info]
debug("Parrot.db: set option ", name, " = ", value)
db[name] = value
end
local function getOption(info)
local name = info[#info]
return db[name]
end
local function tupleToHexColor(r, g, b)
return ("%02x%02x%02x"):format(r * 255, g * 255, b * 255)
end
local function hexColorToTuple(color)
local num = tonumber(color, 16)
return math.floor(num / 256^2)/255, math.floor((num / 256)%256)/255, (num%256)/255
end
function module:OnOptionsCreate()
local function getSubOption(info)
local name = info[#info]
local category = info[#info - 1]
return db[category][name]
end
local function getSubOptionFromArg(info)
local name = info[#info]
local arg = info[#info - 1]
local category = info[#info - 2]
debug(category, " - ", arg)
return db[category][arg][name]
end
local function setSubOption(info, value)
local name = info[#info]
local category = info[#info - 1]
db[category][name] = value
end
local function setSubOptionFromArg(info, value)
local name = info[#info]
local arg = info[#info - 1]
local category = info[#info - 2]
db[category][arg][name] = value
end
local events_opt
events_opt = {
type = 'group',
name = L["Events"],
desc = L["Change event settings"],
order = 2,
get = getOption,
set = setOption,
args = {
enabled = {
name = L["Enabled"],
type = 'group',
inline = true,
args = {
disable_in_raid = {
type = 'toggle',
name = L["Disable in raids"],
desc = L["Disable this module while in a raid instance"],
set = function(info, value)
setOption(info, value)
checkZone()
end,
order = 1,
},
disable_in_battleground = {
type = 'toggle',
name = L["Disable in pvp"],
desc = L["Disable this module while in a battleground"],
set = function(info, value)
setOption(info, value)
checkZone()
end,
order = 2,
},
},
},
textoptions = {
name = L["Text options"],
type = 'group',
inline = true,
args = {
hideFullOverheals = {
type = 'select',
name = L["Hide full overheals"],
desc = L["Do not show heal events when 100% of the amount is overheal"],
values = {
[0] = L["Off"],
[1] = L["Only HoTs"],
[2] = L["Only direct heals"],
[3] = L["On"],
},
order = 1,
},
sep = {
type = "description",
name = "",
order = 2,
},
hideSkillNames = {
type = 'toggle',
name = L["Hide skill names"],
desc = L["Always hide skill names even when present in the tag"],
order = 3,
},
hideUnitNames = {
type = 'toggle',
name = L["Hide unit names"],
desc = L["Always hide unit names even when present in the tag"],
order = 4,
},
hideRealm = {
type = 'toggle',
name = L["Hide realm"],
desc = L["Hide realm in player names"],
order = 5,
},
classcolor = {
type = 'toggle',
name = L["Color by class"],
desc = L["Color unit names by class"],
order = 6,
},
shortenAmount = {
type = 'toggle',
name = L["Shorten amounts"],
desc = L["Abbreviate number values displayed (26500 -> 26.5k)"],
disabled = function() return db.breakUpAmount end,
order = 7,
},
breakUpAmount = {
type = 'toggle',
name = L["Break up amounts"],
desc = L["Break up number values with '%s' (26500 -> %s)"]:format(LARGE_NUMBER_SEPERATOR, BreakUpLargeNumbers(26500)),
disabled = function() return db.shortenAmount end,
order = 8,
},
includeAdditionalText = {
type = 'toggle',
name = L["Include text details after amounts"],
desc = L["Include additional text details after amounts ('overheal', 'resisted', etc.)"],
order = 9,
get = function()
for _, v in pairs(db.modifier) do
if type(v) == 'table' and v.tag ~= nil then
if v.tag == L[" ([Amount])"] then
return false
end
end
end
return true
end,
set = function(_, val)
for k, v in pairs(db.modifier) do
if type(v) == 'table' and v.tag ~= nil then
if val then
v.tag = L[" ([Amount] " .. string.lower(k) .. ")"]
else
v.tag = L[" ([Amount])"]
end
end
end
end,
}
},
},
totemEvents = {
type = 'toggle',
name = L["Show guardian events"],
desc = L["Whether events involving your guardian(s) (totems, ...) should be displayed"],
},
cancelUIDSoon = {
type = 'toggle',
name = L["Hide events used in triggers"],
desc = L["Hides combat events when they were used in triggers"],
width = "double",
},
Incoming = {
type = 'group',
name = L["Incoming"],
desc = L["Incoming events are events which a mob or another player does to you."],
args = {},
order = 1,
},
Outgoing = {
type = 'group',
name = L["Outgoing"],
desc = L["Outgoing events are events which you do to a mob or another player."],
args = {},
order = 1,
},
Notification = {
type = 'group',
name = L["Notification"],
desc = L["Notification events are available to notify you of certain actions."],
args = {},
order = 1,
},
modifier = {
type = 'group',
name = L["Event modifiers"],
desc = L["Options for event modifiers."],
get = getSubOption,
set = setSubOption,
args = {
color = {
order = 1,
type = 'toggle',
name = L["Color"],
desc = L["Whether to color event modifiers or not."],
}
}
},
damageTypes = {
type = 'group',
name = L["Damage types"],
desc = L["Options for damage types."],
args = {
color = {
order = 1,
type = 'toggle',
name = L["Color"],
desc = L["Whether to color damage types or not."],
get = function()
return db.damageTypes.color
end,
set = function(info, value)
db.damageTypes.color = value
end
}
}
},
stickyCrit = {
type = 'toggle',
name = L["Sticky crits"],
desc = L["Enable to show crits in the sticky style."],
},
throttle = {
type = 'group',
name = L["Throttle events"],
desc = L["Whether to merge mass events into single instances instead of excessive spam."],
args = {
useShortThrottleText = {
type = 'toggle',
name = L["Short texts"],
desc = L["Use short throttle-texts (like \"2++\" instead of \"2 crits\")"],
order = 1,
}
},
hidden = function()
return not next(events_opt.args.throttle.args)
end,
},
filters = {
type = 'group',
name = L["Filters"],
desc = L["Filters to be checked for a minimum amount of damage/healing/etc before showing."],
args = {},
hidden = function()
return not next(events_opt.args.filters.args)
end,
},
sfilters = {
type = 'group',
name = L["Spell filters"],
desc = L["Filters that are applied to a single spell"],
args = {},
},
sthrottles = {
type = 'group',
name = L["Spell throttles"],
desc = L["Throttles that are applied to a single spell"],
args = {},
},
abbreviate = {
type = 'group',
name = L["Shorten spell names"],
desc = L["How or whether to shorten spell names."],
args = {
abbreviateStyle = {
type = 'select',
name = L["Style"],
desc = L["How or whether to shorten spell names."],
values = {
none = L["None"],
abbreviate = L["Abbreviate"],
truncate = L["Truncate"],
},
order = 1,
},
abbreviateLength = {
type = 'range',
name = L["Length"],
desc = L["The length at which to shorten spell names."],
disabled = function()
return db.abbreviateStyle == "none"
end,
min = 1,
max = 30,
step = 1,
order = 2,
},
abbrDesc = {
type = 'description',
name = ("%s: %s\n%s: %s\n%s: %s"):format(
L["None"], L["Do not shorten spell names."],
L["Abbreviate"], L["Gift of the Wild => GotW."],
L["Truncate"], L["Gift of the Wild => Gift of t..."]
),
order = 3,
},
},
},
}
}
Parrot:AddOption('events', events_opt)
local handler__tagTranslations
local function handler(literal)
local inner = literal:sub(2, -2)
if handler__tagTranslations[inner] then
return literal
end
local inner_lower = inner:lower()
for k in pairs(handler__tagTranslations) do
if k:lower() == inner_lower then
return "[" .. k .. "]"
end
end
return "[" .. inner:gsub("(%b[])", handler) .. "]"
end
do
-- Event modifiers
local tmp = newDict(
'crit', L["Critical hits/heals"],
'crushing', L["Crushing blows"],
'glancing', L["Glancing hits"],
'absorb', L["Partial absorbs"],
'block', L["Partial blocks"],
'resist', L["Partial resists"],
'vulnerable', L["Vulnerability bonuses"],
'overheal', L["Overheals"],
'overkill', L["Overkills"]
)
local function setTag(info, value)
handler__tagTranslations = modifierTranslationHelps[info.arg]
db.modifier[info.arg].tag = value:gsub("(%b[])", handler)
handler__tagTranslations = nil
end
local function getModifierColor(info)
return hexColorToTuple(db.modifier[info.arg].color)
end
local function setModifierColor(info, r, g, b)
db.modifier[info.arg].color = tupleToHexColor(r, g, b)
end
for k,v in pairs(tmp) do
local usage = L["<Tag>"]
local translationHelp = modifierTranslationHelps[k]
if translationHelp then
local tags = newList()
for tag in next, translationHelp do
tags[#tags+1] = tag
end
tsort(tags)
for _, tag in ipairs(tags) do
usage = ("%s\n[%s] => %s"):format(usage, tag, translationHelp[tag])
end
tags = del(tags)
end
events_opt.args.modifier.args[k] = {
type = 'group',
name = v,
desc = v,
get = getSubOptionFromArg,
set = setSubOptionFromArg,
args = {
enabled = {
type = 'toggle',
name = L["Enabled"],
desc = L["Whether to enable showing this event modifier."],
order = -1,
arg = k,
},
color = {
type = 'color',
name = L["Color"],
desc = L["What color this event modifier takes on."],
get = getModifierColor,
set = setModifierColor,
arg = k,
},
tag = {
type = 'input',
name = L["Text"],
desc = L["What text this event modifier shows."],
usage = usage,
set = setTag,
arg = k,
},
}
}
end
tmp = del(tmp)
end
do
-- Damage types
local tmp = newDict(
"Physical", LS["Physical"],
"Holy", LS["Holy"],
"Fire", LS["Fire"],
"Nature", LS["Nature"],
"Frost", LS["Frost"],
"Shadow", LS["Shadow"],
"Arcane", LS["Arcane"],
"Frostfire", LS["Frostfire"],
"Froststorm", LS["Froststorm"],
"Shadowstorm", LS["Shadowstorm"]
)
local function getColor(info)
return hexColorToTuple(db.damageTypes[info.arg])
end
local function setColor(info, r, g, b)
db.damageTypes[info.arg] = tupleToHexColor(r, g, b)
end
for k,v in pairs(tmp) do
events_opt.args.damageTypes.args[k] = {
type = 'color',
name = v,
desc = L["What color this damage type takes on."],
get = getColor,
set = setColor,
arg = k,
}
end
tmp = del(tmp)
end
-- CombatEvents
local function getArgs(info)
local category = info[2]
local name = info[4]
-- for i,v in ipairs(info) do
-- debug(i, " = ", v)
-- end
return category, name
end
local function getTag(info)
local category, name = getArgs(info)
return db[category][name].tag or combatEvents[category][name].defaultTag
end
local function setTag(info, value)
local category, name = getArgs(info)
handler__tagTranslations = combatEvents[category][name].tagTranslations
value = value:gsub("(%b[])", handler)
handler__tagTranslations = nil
if value == "" or combatEvents[category][name].defaultTag == value then
value = nil
end
db[category][name].tag = value
end
local function getColor(info)
local category, name = getArgs(info)
return hexColorToTuple(db[category][name].color or combatEvents[category][name].color)
end
local function setColor(info, r, g, b)
local category, name = getArgs(info)
local color = tupleToHexColor(r, g, b)
local combatEvent = combatEvents[category][name]
if combatEvent.color == color then
color = nil
end
db[category][name].color = color
end
local function getSticky(info)
local category, name = getArgs(info)
local sticky = db[category][name].sticky
if sticky ~= nil then
return sticky
else
return combatEvents[category][name].sticky
end
end
local function setSticky(info, value)
local category, name = getArgs(info)
if (not not combatEvents[category][name].sticky) == value then
value = nil
end
db[category][name].sticky = value
end
local function getFontFace(info)
local category, name = getArgs(info)
local font = db[category][name].font
if font == nil then
return -1
end
for i, v in next, Parrot.fontValues do
if v == font then return i end
end
end
local function setFontFace(info, value)
local category, name = getArgs(info)
if value == -1 then
db[category][name].font = nil
else
db[category][name].font = Parrot.fontValues[value]
end
end
local function getFontSize(info)
local category, name = getArgs(info)
return db[category][name].fontSize
end
local function setFontSize(info, value)
local category, name = getArgs(info)
db[category][name].fontSize = value
end
local function getFontSizeInherit(info)
local category, name = getArgs(info)
return db[category][name].fontSize == nil
end
local function setFontSizeInherit(info, value)
local category, name = getArgs(info)
if value then
db[category][name].fontSize = nil
else
db[category][name].fontSize = 18
end
end
local function getFontOutline(info)
local category, name = getArgs(info)
local outline = db[category][name].fontOutline
if outline == nil then
return L["Inherit"]
else
return outline
end
end
local function setFontOutline(info, value)
local category, name = getArgs(info)
if value == L["Inherit"] then
value = nil
end
db[category][name].fontOutline = value
end
local fontOutlineChoices = {
NONE = L["None"],
MONOCHROME = L["Monochrome"],
OUTLINE = L["Thin"],
["OUTLINE,MONOCHROME"] = L["Thin, Monochrome"],
THICKOUTLINE = L["Thick"],
[L["Inherit"]] = L["Inherit"],
}
local function getEnable2(category, name)
local disabled = db[category][name].disabled
if disabled == nil then
disabled = combatEvents[category][name].defaultDisabled
end
return not disabled
end
local function getEnable(info)
return getEnable2(getArgs(info))
end
local function setEnable(info, value)
local category, name = getArgs(info)
local disabled = not value
if (not not combatEvents[category][name].defaultDisabled) == disabled then
disabled = nil
end
db[category][name].disabled = disabled
end
local function getScrollArea2(category, name)
local scrollArea = db[category][name].scrollArea
if scrollArea == nil then
scrollArea = category
end
return scrollArea
end
local function getScrollArea(info)
return getScrollArea2(getArgs(info))
end
local function doSetScrollArea(category, name, value)
if value == category then
value = nil
end
db[category][name].scrollArea = value
end
local function setScrollArea(info, value)
local category, name = getArgs(info)
doSetScrollArea(category, name, value)
end
local function getSound(info)
local category, name = getArgs(info)
local value = db[category][name].sound or "None"
for i, v in next, Parrot.soundValues do
if v == value then
return i
end
end
end
local function setSound(info, value)
local category, name = getArgs(info)
local v = Parrot.soundValues[value]
PlaySoundFile(LibSharedMedia:Fetch("sound", v), "Master")
if v == "None" then
v = nil
end
db[category][name].sound = v
end
local function getCommonEnabled(info)
local category, subcat = info.arg[1], info.arg[2]
local one_enabled, one_disabled = false, false
for k,v in pairs(combatEvents[category]) do
if v.subCategory == subcat then
if getEnable2(category, v.name) then
one_enabled = true
else
one_disabled = true
end
end
end
if one_disabled and one_enabled then
return nil
elseif one_disabled then
return false
else
return true
end
end
local function setCommonEnabled(info, value)
local category, subcat = info.arg[1], info.arg[2]
for k,v in pairs(combatEvents[category]) do
if v.subCategory == subcat then
db[category][v.name].disabled = not value
end
end
end
local function getCommonScrollArea(info)
local category, subcat = info.arg[1], info.arg[2]
local common_choice