-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOptions.lua
878 lines (827 loc) · 31.4 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
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
local ADDON_NAME = ...
local L = LibStub("AceLocale-3.0"):GetLocale(ADDON_NAME)
local AceConfigRegistry = LibStub("AceConfigRegistry-3.0")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
MessageClassifierConfig = {}
--[[
-- Fields and values of classificationRules:
{
id = <integer> -- Only for default rules. Don't change it once assigned.
logic = "and"
"or"
Default: "or"
conditions = { -- Matches any message if conditions is an empty array
{
field: "author",
"channel"
"content"
operator: "equal"
"not equal"
"contain"
"not contain"
"match"
"not match"
value: <string>
<regular expression>
Example: "molten"
" AA "
"15g"
"%bAA%b"
"%d+g%b"
caseSensitive: true
false
Default: false
}, ...
}
class: <string>,
Available variables: {author}
{channel},
Example: "RAID"
"Sell"
"Quest"
"The Molten Core"
"By Author/{author}"
"By Channel/{channel}"
hideFromChatWindow: true
false
Default: false
enabled: true
false
Default: true
}, ...
]]
MessageClassifierDefaultRules = MessageClassifierDefaultRules or {}
local defaultConfig = {
["enabled"] = true,
["minDupInterval"] = 0,
["classificationRules"] = {},
["enabledDefaultRules"] = {},
["defRulHideFromChatWindow"] = {},
}
local classPathLocales = {
["{author}"] = string.format("{%s}", L["author"]),
["{channel}"] = string.format("{%s}", L["channel"]),
}
local function localizeClassPath(class)
for k,v in pairs(classPathLocales) do
class = class:gsub(k, v)
end
return class
end
local function localizeClassPathWithColor(class)
class = class:gsub('/', '|cffdb800a/|r')
for k,v in pairs(classPathLocales) do
class = class:gsub(k, string.format("|cffc586c0%s|r", v))
end
return class
end
local function delocalizeClassPath(class)
for k,v in pairs(classPathLocales) do
class = class:gsub(v, k)
end
return class
end
local function ruleToText(ruleSet)
local text = ""
if #ruleSet.conditions == 0 then
text = text..string.format("%s:\n %s", L["OPTION_CLASS_NO_CONDITIONS"], localizeClassPathWithColor(ruleSet.class))
else
if #ruleSet.conditions == 1 then
text = text..string.format("%s", L["OPTION_CONDITIONS"])
local rule = ruleSet.conditions[1]
text = text..string.format(" |cffdcdcaa%s|r |cff569cd6%s|r |cffce9178%s|r", L[rule.field], L[rule.operator], rule.value)
if rule.caseSensitive then
text = text..string.format(" (%s)", L["OPTION_COND_CASESENSITIVE"])
end
else
local logicOr = ruleSet.logic ~= "and"
text = text..string.format("%s |cffc586c0%s|r:", L["OPTION_CONDITIONS"], logicOr and L["OPTION_RULE_LOGIC_OR"] or L["OPTION_RULE_LOGIC_AND"])
for _, rule in ipairs(ruleSet.conditions) do
text = text..string.format("\n |cffdcdcaa%s|r |cff569cd6%s|r |cffce9178%s|r", L[rule.field], L[rule.operator], rule.value)
if rule.caseSensitive then
text = text..string.format(" (%s)", L["OPTION_COND_CASESENSITIVE"])
end
end
end
text = text..string.format("\n\n%s:\n %s", L["OPTION_CLASS"], localizeClassPathWithColor(ruleSet.class))
end
return text
end
local function deepCopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[deepCopy(orig_key)] = deepCopy(orig_value)
end
setmetatable(copy, deepCopy(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
MessageClassifierConfigFrame = CreateFrame("Frame", "MessageClassifierConfigFrame", UIParent)
MessageClassifierConfigFrame.ruleEditCache = {}
MessageClassifierConfigFrame.ruleSetsFilter = ""
MessageClassifierConfigFrame.lastRuleSetsFilterValues = {}
MessageClassifierConfigFrame.lastUpdatedClass = ""
function MessageClassifierConfigFrame:loadConfig()
if not MessageClassifierConfig then MessageClassifierConfig = {} end
for key, val in pairs(defaultConfig) do
if MessageClassifierConfig[key] == nil then
MessageClassifierConfig[key] = val
end
end
self.configTable = {
type = "group",
name = L["CONFIG_PAGE_TITLE"],
args = {
enabled = {
order = 1,
type = "toggle",
width = "full",
name = L["OPTION_ENABLED"],
desc = L["OPTION_ENABLED_TOOLTIP"],
get = function(info)
return MessageClassifierConfig.enabled
end,
set = function(info, val)
MessageClassifier.Toggle(val)
end
},
minDupInterval = {
order = 2,
type = "range",
width = 3,
name = L["OPTION_MIN_DUP_INTERVAL"],
min = 0,
max = 86400,
softMin = 0,
softMax = 3600,
bigStep = 10,
get = function(info)
return MessageClassifierConfig.minDupInterval
end,
set = function(info, val)
MessageClassifierConfig.minDupInterval = val
end
},
reset = {
order = 3,
type = "execute",
name = L["OPTION_RESET"],
desc = L["OPTION_RESET_TOOLTIP"],
func = function(info)
MessageClassifier.Reset()
end
},
openBrowser = {
order = 4,
type = "execute",
name = L["OPTION_OPEN_MESSAGE_BROWSER"],
func = function(info)
MessageClassifierBrowser:Show()
end
},
ruleSetsTitle = {
order = 5,
type = "header",
name = L["OPTION_RULE_SETS_TITLE"],
},
ruleSetsFilter = {
order = 9,
type = "select",
width = "full",
name = L["OPTION_RULE_SETS_FILTER"],
values = function()
local classFilter = {
[""] = string.format("|cff569cd6%s|r", L["OPTION_RULE_SETS_FILTER_ALL"]),
}
for _,v in pairs(MessageClassifierConfig.classificationRules) do
classFilter[v.class] = localizeClassPathWithColor(v.class)
end
for _,v in pairs(MessageClassifierDefaultRules) do
classFilter[v.class] = localizeClassPathWithColor(v.class)
end
self.lastRuleSetsFilterValues = classFilter
return classFilter
end,
get = function(info)
-- Automatically go to the edited class after editing it
if self.ruleSetsFilter ~= ""
and not self.lastRuleSetsFilterValues[self.ruleSetsFilter]
and self.lastUpdatedClass ~= ""
and self.lastRuleSetsFilterValues[self.lastUpdatedClass]
then
self.ruleSetsFilter = self.lastUpdatedClass
end
return self.ruleSetsFilter
end,
set = function(info, val)
self.ruleSetsFilter = val
end
},
ruleSets = {
order = 10,
type = "group",
inline = true,
name = L["OPTION_RULE_SETS"],
args = {
actionBar = {
order = 0, -- at the top
type = "group",
inline = true,
name = "",
args = {
enabledAll = {
order = 1,
type = "toggle",
name = L["OPTION_SELECT_ALL"],
width = 0.5,
get = function(info)
local ruleSets = MessageClassifierConfig.classificationRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) and rule.enabled == false then
return false
end
end
return true
end,
set = function(info, val)
local ruleSets = MessageClassifierConfig.classificationRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) then
rule.enabled = val
end
end
MessageClassifierBrowser:updateAllMessages()
end,
},
hideFromChatWindowAll = {
order = 2,
type = "toggle",
name = L["OPTION_SELECT_ALL"],
width = 1.5,
get = function(info)
local ruleSets = MessageClassifierConfig.classificationRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) and rule.hideFromChatWindow ~= true then
return false
end
end
return true
end,
set = function(info, val)
local ruleSets = MessageClassifierConfig.classificationRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) then
rule.hideFromChatWindow = val
end
end
MessageClassifierBrowser:updateAllMessages()
end,
},
bottomLine = {
order = 99,
type = "header",
name = "",
},
}
},
addRuleSet = {
order = 999999, -- at the end
type = "execute",
name = L["OPTION_ADD"],
func = function(info)
MessageClassifierConfigFrame:addRuleSet()
end
},
},
},
defaultRuleSets = {
order = 20,
type = "group",
inline = true,
name = L["OPTION_DEFAULT_RULE_SETS"],
args = {
actionBar = {
order = 0, -- at the top
type = "group",
inline = true,
name = "",
args = {
enabledAll = {
order = 1,
type = "toggle",
name = L["OPTION_SELECT_ALL"],
width = 0.5,
get = function(info)
local ruleSets = MessageClassifierDefaultRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) and
MessageClassifierConfig.enabledDefaultRules[rule.id] == false
then
return false
end
end
return true
end,
set = function(info, val)
local ruleSets = MessageClassifierDefaultRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) then
MessageClassifierConfig.enabledDefaultRules[rule.id] = val
end
end
MessageClassifierBrowser:updateAllMessages()
end,
},
hideFromChatWindowAll = {
order = 2,
type = "toggle",
name = L["OPTION_SELECT_ALL"],
width = 1.5,
get = function(info)
local ruleSets = MessageClassifierDefaultRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) and
MessageClassifierConfig.defRulHideFromChatWindow[rule.id] ~= true
then
return false
end
end
return true
end,
set = function(info, val)
local ruleSets = MessageClassifierDefaultRules
for _, rule in ipairs(ruleSets) do
if not self:isHiddenRule(rule) then
MessageClassifierConfig.defRulHideFromChatWindow[rule.id] = val
end
end
MessageClassifierBrowser:updateAllMessages()
end,
},
bottomLine = {
order = 99,
type = "header",
name = "",
},
}
},
},
}
}
}
for k,v in pairs(MessageClassifierConfig.classificationRules) do
self:addRuleSetToView(k, v)
end
for k,v in pairs(MessageClassifierDefaultRules) do
self:addDefaultRuleSetToView(k, v)
end
self.registeredOptionsTable = AceConfigRegistry:RegisterOptionsTable(ADDON_NAME, self.configTable)
self.blizOptions = AceConfigDialog:AddToBlizOptions(ADDON_NAME, L["CONFIG_PAGE_TITLE"])
end
function MessageClassifierConfigFrame:updateRuleSetView()
self.configTable.args.ruleSets.args = {
actionBar = self.configTable.args.ruleSets.args.actionBar,
addRuleSet = self.configTable.args.ruleSets.args.addRuleSet,
}
for k,v in pairs(MessageClassifierConfig.classificationRules) do
self:addRuleSetToView(k, v)
end
MessageClassifierBrowser:updateAllMessages()
end
function MessageClassifierConfigFrame:updateDefaultRuleSetView()
self.configTable.args.defaultRuleSets.args = {}
for k,v in pairs(MessageClassifierDefaultRules) do
self:addDefaultRuleSetToView(k, v)
end
end
function MessageClassifierConfigFrame:addRuleSet()
local index = #MessageClassifierConfig.classificationRules + 1
local defaultClass = "xxx/{author}"
if self.ruleSetsFilter ~= "" then
defaultClass = self.ruleSetsFilter
elseif self.lastUpdatedClass ~= "" then
defaultClass = self.lastUpdatedClass
end
MessageClassifierConfig.classificationRules[index] = {
conditions = {
{
operator = "contain",
field = "content",
value = "xxx",
},
},
class = defaultClass,
tmp = true,
enabled = false,
}
self:editRuleSet(index)
--AceConfigRegistry:NotifyChange(ADDON_NAME)
end
function MessageClassifierConfigFrame:removeRuleSet(index)
table.remove(MessageClassifierConfig.classificationRules, index)
self.configTable.args.ruleSets.args = {
actionBar = self.configTable.args.ruleSets.args.actionBar,
addRuleSet = self.configTable.args.ruleSets.args.addRuleSet,
}
for k,v in pairs(MessageClassifierConfig.classificationRules) do
self:addRuleSetToView(k, v)
end
MessageClassifierBrowser:updateAllMessages()
--AceConfigRegistry:NotifyChange(ADDON_NAME)
end
function MessageClassifierConfigFrame:isHiddenRule(rule)
return self.ruleSetsFilter ~= "" and self.ruleSetsFilter ~= rule.class
end
function MessageClassifierConfigFrame:addRuleSetToView(index, ruleSet)
local group = self.configTable.args.ruleSets
local option = {
type = "group",
inline = true,
order = index,
name = "",
hidden = function()
return self:isHiddenRule(ruleSet)
end,
args = {
enabled = {
order = 1,
type = "toggle",
name = L["OPTION_ENABLE"],
width = 0.5,
get = function(info)
return ruleSet.enabled ~= false
end,
set = function(info, val)
ruleSet.enabled = val
MessageClassifierBrowser:updateAllMessages()
end,
},
hideFromChatWindow = {
order = 2,
type = "toggle",
name = L["OPTION_HIDE_FROM_CHAT_WINDOW"],
width = 1.5,
get = function(info)
return ruleSet.hideFromChatWindow == true
end,
set = function(info, val)
ruleSet.hideFromChatWindow = val
MessageClassifierBrowser:updateAllMessages()
end,
},
editRuleSet = {
order = 3,
type = "execute",
name = L["OPTION_EDIT"],
width = 0.5,
func = function(info)
MessageClassifierConfigFrame:editRuleSet(index)
end
},
removeRuleSet = {
order = 4,
type = "execute",
name = L["OPTION_REMOVE"],
width = 0.5,
func = function(info)
MessageClassifierConfigFrame:removeRuleSet(index)
end
},
conditions = {
order = 11,
type = "description",
name = ruleToText(ruleSet),
width = "full",
},
bottomLine = {
order = 99,
type = "header",
name = "",
},
}
}
group.args[tostring(index)] = option
end
function MessageClassifierConfigFrame:editRuleSet(index)
local group = self.configTable.args.ruleSets
local ruleSet = MessageClassifierConfig.classificationRules[index]
if self.ruleEditCache[index] == nil then
self.ruleEditCache[index] = deepCopy(ruleSet)
end
local cache = self.ruleEditCache[index]
if cache.tmp then
cache.enabled = nil
end
local option = {
type = "group",
inline = true,
order = index,
name = "",
args = {
enabled = {
order = 1,
type = "toggle",
name = L["OPTION_ENABLE"],
width = 0.5,
get = function(info)
return cache.enabled ~= false
end,
set = function(info, val)
cache.enabled = val
MessageClassifierBrowser:updateAllMessages()
end,
},
hideFromChatWindow = {
order = 2,
type = "toggle",
name = L["OPTION_HIDE_FROM_CHAT_WINDOW"],
width = 1.5,
get = function(info)
return cache.hideFromChatWindow == true
end,
set = function(info, val)
cache.hideFromChatWindow = val
MessageClassifierBrowser:updateAllMessages()
end,
},
saveRuleSet = {
order = 3,
type = "execute",
name = L["OPTION_SAVE"],
width = 0.5,
func = function(info)
MessageClassifierConfigFrame:saveRuleSet(index)
end
},
cancelEditRuleSet = {
order = 3,
type = "execute",
name = L["OPTION_CANCEL"],
width = 0.5,
func = function(info)
MessageClassifierConfigFrame:cancelEditRuleSet(index)
end
},
logic = {
order = 10,
type = "select",
width = 2,
name = L["OPTION_CONDITIONS"],
values = {
["or"] = L["OPTION_RULE_LOGIC_OR"],
["and"] = L["OPTION_RULE_LOGIC_AND"],
},
get = function(info)
return cache.logic == "and" and "and" or "or"
end,
set = function(info, val)
cache.logic = val
end
},
conditions = {
order = 11,
type = "group",
inline = true,
name = "",
args = {
actionBar = {
order = 999999, -- at the end
type = "group",
inline = true,
name = "",
args = {
addCondition = {
order = 1,
type = "execute",
name = L["OPTION_ADD"],
width = 0.5,
func = function(info)
MessageClassifierConfigFrame:addCondition(index)
end
},
}
}
}
},
class = {
order = 21,
type = "input",
name = L["OPTION_CLASS_EDIT_TITLE"],
width = "full",
get = function(info)
return localizeClassPath(cache.class)
end,
set = function(info, val)
cache.class = delocalizeClassPath(val)
self.lastUpdatedClass = cache.class
end,
},
bottomLine = {
order = 99,
type = "header",
name = "",
},
}
}
for conditionIndex, condition in ipairs(cache.conditions) do
self:addConditionToView(index, conditionIndex, condition, option.args.conditions)
end
group.args[tostring(index)] = option
end
function MessageClassifierConfigFrame:addCondition(ruleSetIndex)
local group = self.configTable.args.ruleSets.args[tostring(ruleSetIndex)].args.conditions
local conditions = self.ruleEditCache[ruleSetIndex].conditions
local index = #conditions + 1
conditions[index] = {
operator = "contain",
field = "content",
value = "xxx",
}
self:addConditionToView(ruleSetIndex, index, conditions[index], group)
end
function MessageClassifierConfigFrame:removeCondition(ruleSetIndex, index)
local group = self.configTable.args.ruleSets.args[tostring(ruleSetIndex)].args.conditions
local conditions = self.ruleEditCache[ruleSetIndex].conditions
table.remove(conditions, index)
local actionBar = group.args.actionBar
group.args = {
actionBar = actionBar
}
for i, v in ipairs(conditions) do
self:addConditionToView(ruleSetIndex, i, v, group)
end
end
function MessageClassifierConfigFrame:addConditionToView(ruleSetIndex, index, condition, group)
local option = {
type = "group",
inline = true,
order = index,
name = "",
args = {
field = {
order = 11,
type = "select",
width = 0.7,
name = "",
values = {
["author"] = L["author"],
["channel"] = L["channel"],
["content"] = L["content"],
},
get = function(info)
return condition.field
end,
set = function(info, val)
condition.field = val
end
},
operator = {
order = 12,
type = "select",
width = 0.8,
name = "",
values = {
["equal"] = L["equal"],
["not equal"] = L["not equal"],
["contain"] = L["contain"],
["not contain"] = L["not contain"],
["match"] = L["match"],
["not match"] = L["not match"],
},
get = function(info)
return condition.operator
end,
set = function(info, val)
condition.operator = val
end
},
value = {
order = 13,
type = "input",
width = 1.67,
name = "",
get = function(info)
return condition.value
end,
set = function(info, val)
condition.value = val
end
},
actionBar = {
order = 30,
type = "group",
inline = true,
name = "",
args = {
caseSensitive = {
order = 1,
type = "toggle",
name = L["OPTION_COND_CASESENSITIVE"],
get = function(info)
return condition.caseSensitive == true
end,
set = function(info, val)
condition.caseSensitive = val
end,
},
removeCondition = {
order = 2,
type = "execute",
name = L["OPTION_REMOVE"],
width = 0.5,
func = function(info)
MessageClassifierConfigFrame:removeCondition(ruleSetIndex, index)
end
},
}
},
bottomLine = {
order = 99,
type = "header",
name = "",
},
}
}
group.args[tostring(index)] = option
end
function MessageClassifierConfigFrame:cancelEditRuleSet(index)
local tmp = self.ruleEditCache[index].tmp
self.ruleEditCache[index] = nil
if tmp then
self:removeRuleSet(index)
else
self:addRuleSetToView(index, MessageClassifierConfig.classificationRules[index])
end
end
function MessageClassifierConfigFrame:saveRuleSet(index)
if self.ruleEditCache[index].tmp then
self.ruleEditCache[index].tmp = nil
end
MessageClassifierConfig.classificationRules[index] = self.ruleEditCache[index]
self.ruleEditCache[index] = nil
self:addRuleSetToView(index, MessageClassifierConfig.classificationRules[index])
MessageClassifierBrowser:updateAllMessages()
end
function MessageClassifierConfigFrame:addDefaultRuleSetToView(index, ruleSet)
local group = self.configTable.args.defaultRuleSets
local option = {
type = "group",
inline = true,
order = index,
name = "",
hidden = function()
return self:isHiddenRule(ruleSet)
end,
args = {
enabled = {
order = 1,
type = "toggle",
name = L["OPTION_ENABLE"],
width = 0.5,
get = function(info)
return MessageClassifierConfig.enabledDefaultRules[ruleSet.id] ~= false
end,
set = function(info, val)
MessageClassifierConfig.enabledDefaultRules[ruleSet.id] = val
MessageClassifierBrowser:updateAllMessages()
end,
},
hideFromChatWindow = {
order = 2,
type = "toggle",
name = L["OPTION_HIDE_FROM_CHAT_WINDOW"],
width = 1.5,
get = function(info)
return MessageClassifierConfig.defRulHideFromChatWindow[ruleSet.id] == true
end,
set = function(info, val)
MessageClassifierConfig.defRulHideFromChatWindow[ruleSet.id] = val
MessageClassifierBrowser:updateAllMessages()
end,
},
conditions = {
order = 11,
type = "description",
name = ruleToText(ruleSet),
},
bottomLine = {
order = 99,
type = "header",
name = "",
},
}
}
group.args[tostring(index)] = option
end
MessageClassifierConfigFrame:RegisterEvent("ADDON_LOADED")
MessageClassifierConfigFrame:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == ADDON_NAME then
self:loadConfig()
end
self:UnregisterEvent("ADDON_LOADED")
end)