-
Notifications
You must be signed in to change notification settings - Fork 13
/
AddonMenu.lua
1271 lines (1169 loc) · 45.5 KB
/
AddonMenu.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
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 _
local LAM = LibStub:GetLibrary("LibAddonMenu-2.0")
local LMP = LibStub:GetLibrary("LibMediaProvider-1.0")
local L = AutoCategory.localizefunc
local needReloadUI = false
--cache data for dropdown:
local cacheTags = {}
cacheTags = {}
local cacheBags = {}
cacheBags.showNames = { [AC_BAG_TYPE_BACKPACK] = L(SI_AC_BAGTYPE_SHOWNAME_BACKPACK),
[AC_BAG_TYPE_BANK] = L(SI_AC_BAGTYPE_SHOWNAME_BANK),
[AC_BAG_TYPE_GUILDBANK] = L(SI_AC_BAGTYPE_SHOWNAME_GUILDBANK),
[AC_BAG_TYPE_CRAFTBAG] = L(SI_AC_BAGTYPE_SHOWNAME_CRAFTBAG),
[AC_BAG_TYPE_CRAFTSTATION] = L(SI_AC_BAGTYPE_SHOWNAME_CRAFTSTATION),
}
cacheBags.values = { AC_BAG_TYPE_BACKPACK,
AC_BAG_TYPE_BANK,
AC_BAG_TYPE_GUILDBANK,
AC_BAG_TYPE_CRAFTBAG,
AC_BAG_TYPE_CRAFTSTATION,
}
cacheBags.tooltips = { L(SI_AC_BAGTYPE_TOOLTIP_BACKPACK),
L(SI_AC_BAGTYPE_TOOLTIP_BANK),
L(SI_AC_BAGTYPE_TOOLTIP_GUILDBANK),
L(SI_AC_BAGTYPE_TOOLTIP_CRAFTBAG),
L(SI_AC_BAGTYPE_TOOLTIP_CRAFTSTATION),
}
local cacheRulesByTag = {}
local cacheRulesByBag = {}
--cache for quick index
local cacheRulesByName = {}
local cacheBagEntriesByName = {}
--dropdown data for index
local dropdownData = {
["AC_DROPDOWN_EDITBAG_BAG"] = {indexValue = AC_BAG_TYPE_BACKPACK, choices = {}, choicesValues = {}, choicesTooltips = {}},
["AC_DROPDOWN_EDITBAG_RULE"] = {indexValue = "", choices = {}, choicesValues = {}, choicesTooltips = {}},
["AC_DROPDOWN_ADDCATEGORY_TAG"] = {indexValue = "", choices = {}, choicesValues = {}, choicesTooltips = {}},
["AC_DROPDOWN_ADDCATEGORY_RULE"] = {indexValue = "", choices = {}, choicesValues = {}, choicesTooltips = {}},
["AC_DROPDOWN_EDITRULE_TAG"] = {indexValue = "", choices = {}, choicesValues = {}, choicesTooltips = {}},
["AC_DROPDOWN_EDITRULE_RULE"] = {indexValue = "", choices = {}, choicesValues = {}, choicesTooltips = {}},
["AC_DROPDOWN_IMPORTBAG_BAG"] = {indexValue = AC_BAG_TYPE_BACKPACK, choices = {}, choicesValues = {}, choicesTooltips = {}},
}
local dropdownFontStyle = {'none', 'outline', 'thin-outline', 'thick-outline', 'shadow', 'soft-shadow-thin', 'soft-shadow-thick'}
local dropdownFontAlignment = {}
dropdownFontAlignment.showNames = {L(SI_AC_ALIGNMENT_LEFT), L(SI_AC_ALIGNMENT_CENTER), L(SI_AC_ALIGNMENT_RIGHT)}
dropdownFontAlignment.values = {0, 1, 2}
--warning message
local warningDuplicatedName = {
warningMessage = nil,
}
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
local function UpdateDuplicateNameWarning()
local control = WINDOW_MANAGER:GetControlByName("AC_EDITBOX_EDITRULE_NAME", "")
if control then
control:UpdateWarning()
end
end
local function RefreshPanel()
UpdateDuplicateNameWarning()
--restore warning
warningDuplicatedName.warningMessage = nil
end
local function RuleDataSortingFunction(a, b)
local result = false
if a.tag ~= b.tag then
result = a.tag <b.tag
else
--alphabetical sort, cannot have same name rules
result = a.name <b.name
end
return result
end
local function BagDataSortingFunction(a, b)
local result = false
if a.priority ~= b.priority then
result = a.priority > b.priority
else
result = a.name < b.name
end
return result
end
local function SelectDropDownItem(typeString, item)
dropdownData[typeString].indexValue = item
end
local function GetDropDownSelection(typeString)
return dropdownData[typeString].indexValue
end
local function ToggleSubmenu(typeString, open)
local control = WINDOW_MANAGER:GetControlByName(typeString, "")
if control then
control.open = open
if control.open then
control.animation:PlayFromStart()
else
control.animation:PlayFromEnd()
end
end
end
local function RefreshCache()
--d("|cFF4444RefreshCache|r")
cacheRulesByName = {}
cacheBagEntriesByName = {}
cacheTags = {}
cacheRulesByTag = {}
cacheRulesByBag = {}
table.sort(AutoCategory.curSavedVars.rules, function(a, b) return RuleDataSortingFunction(a, b) end )
for i = 1, #AutoCategory.curSavedVars.rules do
local rule = AutoCategory.curSavedVars.rules[i]
local tag = rule.tag
if tag == "" then
tag = AC_EMPTY_TAG_NAME
end
--update cache for tag grouping
local name = rule.name
cacheRulesByName[name] = rule
--update data for showing in the dropdown menu
if not cacheRulesByTag[tag] then
--d("add tag rule: ".. tag)
cacheRulesByTag[tag] = {showNames = {}, values = {}, tooltips = {}}
table.insert(cacheTags, tag)
end
local tooltip = rule.description
if rule.description == "" then
tooltip = rule.name
end
--d("added rule: ".. name)
table.insert(cacheRulesByTag[tag].showNames, name)
table.insert(cacheRulesByTag[tag].values, name)
table.insert(cacheRulesByTag[tag].tooltips, tooltip)
end
for i = 1, #AutoCategory.curSavedVars.bags do
local bag = AutoCategory.curSavedVars.bags[i]
table.sort(bag.rules, function(a, b) return BagDataSortingFunction(a, b) end )
--update data for showing in the dropdown menu
local bagId = i
if not cacheRulesByBag[bagId] then
cacheRulesByBag[bagId] = {showNames = {}, values = {}, tooltips = {}}
end
if not cacheBagEntriesByName[bagId] then
cacheBagEntriesByName[bagId] = {}
end
for j = 1, #bag.rules do
local data = bag.rules[j]
local ruleName = data.name
cacheBagEntriesByName[bagId][ruleName] = data
local priority = data.priority
local rule = cacheRulesByName[ruleName]
local missing = false
if not rule then
missing = true
end
if not missing then
local tooltip = rule.description
if tooltip == "" then
tooltip = rule.name
end
if data.isHidden then
table.insert(cacheRulesByBag[bagId].showNames, string.format("|c626250%s (%d)|r", ruleName, priority))
table.insert(cacheRulesByBag[bagId].values, ruleName)
table.insert(cacheRulesByBag[bagId].tooltips, tooltip)
else
table.insert(cacheRulesByBag[bagId].showNames, string.format("%s (%d)", ruleName, priority))
table.insert(cacheRulesByBag[bagId].values, ruleName)
table.insert(cacheRulesByBag[bagId].tooltips, tooltip)
end
else
table.insert(cacheRulesByBag[bagId].showNames, string.format("|cFF4444(!)|r %s (%d)", ruleName, priority))
table.insert(cacheRulesByBag[bagId].values, ruleName)
table.insert(cacheRulesByBag[bagId].tooltips, L(SI_AC_WARNING_CATEGORY_MISSING))
end
end
end
end
local function RefreshDropdownData()
--d("|cFF8888RefreshDropdownData|r")
local dataCurrentRules_AddCategory = {}
dataCurrentRules_AddCategory.showNames = {}
dataCurrentRules_AddCategory.values = {}
dataCurrentRules_AddCategory.tooltips = {}
local dataCurrentRules_EditRule = {}
dataCurrentRules_EditRule.showNames = {}
dataCurrentRules_EditRule.values = {}
dataCurrentRules_EditRule.tooltips = {}
local dataCurrentRules_EditBag = {}
dataCurrentRules_EditBag.showNames = {}
dataCurrentRules_EditBag.values = {}
dataCurrentRules_EditBag.tooltips = {}
--update tag & bag selection first
if GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG") == "" and #cacheTags > 0 then
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_TAG", cacheTags[1])
end
if GetDropDownSelection("AC_DROPDOWN_EDITRULE_TAG") == "" and #cacheTags > 0 then
SelectDropDownItem("AC_DROPDOWN_EDITRULE_TAG", cacheTags[1])
end
if GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG") == "" and #cacheBags.values > 0 then
SelectDropDownItem("AC_DROPDOWN_EDITBAG_BAG", cacheBags.values[1])
end
--refresh current dropdown rules
if cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_EDITRULE_TAG")] then
dataCurrentRules_EditRule.showNames = cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_EDITRULE_TAG")].showNames
dataCurrentRules_EditRule.values = cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_EDITRULE_TAG")].values
dataCurrentRules_EditRule.tooltips = cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_EDITRULE_TAG")].tooltips
end
if cacheRulesByBag[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")] then
dataCurrentRules_EditBag.showNames = cacheRulesByBag[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")].showNames
dataCurrentRules_EditBag.values =cacheRulesByBag[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")].values
dataCurrentRules_EditBag.tooltips = cacheRulesByBag[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")].tooltips
end
if cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG")] then
--remove the rules alreadly in bag
for i = 1, #cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG")].values do
local value = cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG")].values[i]
if cacheBagEntriesByName[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")][value] == nil then
--add the rule if not in bag
table.insert(dataCurrentRules_AddCategory.showNames, cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG")].showNames[i])
table.insert(dataCurrentRules_AddCategory.values, cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG")].values[i])
table.insert(dataCurrentRules_AddCategory.tooltips, cacheRulesByTag[GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG")].tooltips[i])
end
end
end
--update rules selection base on current dropdown data
if GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE") == "" and #dataCurrentRules_EditBag.values > 0 then
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", dataCurrentRules_EditBag.values[1])
end
if GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE") == "" and #dataCurrentRules_EditRule.values > 0 then
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", dataCurrentRules_EditRule.values[1])
end
if GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_RULE") == "" and #dataCurrentRules_AddCategory.values > 0 then
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", dataCurrentRules_AddCategory.values[1])
end
--update data indices
dropdownData["AC_DROPDOWN_EDITBAG_BAG"].choices = cacheBags.showNames
dropdownData["AC_DROPDOWN_EDITBAG_BAG"].choicesValues = cacheBags.values
dropdownData["AC_DROPDOWN_EDITBAG_BAG"].choicesTooltips = cacheBags.tooltips
dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choices = dataCurrentRules_EditBag.showNames
dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues = dataCurrentRules_EditBag.values
dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesTooltips = dataCurrentRules_EditBag.tooltips
dropdownData["AC_DROPDOWN_ADDCATEGORY_TAG"].choices = cacheTags
dropdownData["AC_DROPDOWN_ADDCATEGORY_TAG"].choicesValues = cacheTags
dropdownData["AC_DROPDOWN_ADDCATEGORY_TAG"].choicesTooltips = cacheTags
dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choices = dataCurrentRules_AddCategory.showNames
dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesValues = dataCurrentRules_AddCategory.values
dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesTooltips = dataCurrentRules_AddCategory.tooltips
dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choices = cacheTags
dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesValues = cacheTags
dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesTooltips = cacheTags
dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choices = dataCurrentRules_EditRule.showNames
dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choicesValues = dataCurrentRules_EditRule.values
dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choicesTooltips = dataCurrentRules_EditRule.tooltips
dropdownData["AC_DROPDOWN_IMPORTBAG_BAG"].choices = cacheBags.showNames
dropdownData["AC_DROPDOWN_IMPORTBAG_BAG"].choicesValues = cacheBags.values
dropdownData["AC_DROPDOWN_IMPORTBAG_BAG"].choicesTooltips = cacheBags.tooltips
end
local function UpdateDropDownMenu(name)
--d("|cFFCCCCUpdateDropDownMenu|r")
local dropdownCtrl = WINDOW_MANAGER:GetControlByName(name, "")
local data = dropdownData[name]
dropdownCtrl:UpdateChoices(data.choices, data.choicesValues, data.choicesTooltips)
end
local function RemoveDropDownItem(typeString, dataArray, removeItem, emptyCallback)
local removeIndex = -1
local num = #dataArray
for i = 1, num do
if removeItem == dataArray[i] then
removeIndex = i
table.remove(dataArray, removeIndex)
break
end
end
assert(removeIndex ~= -1, "Cannot remove item " .. removeItem .. " in dropdown: " .. typeString)
if num == 1 then
--select none
SelectDropDownItem(typeString, "")
if emptyCallback then
emptyCallback(typeString)
end
elseif removeIndex == num then
--no next one, select previous one
SelectDropDownItem(typeString, dataArray[removeIndex-1])
else
--select next one
SelectDropDownItem(typeString, dataArray[removeIndex])
end
end
local function IsRuleNameUsed(name)
return cacheRulesByName[name] ~= nil
end
local function GetUsableRuleName(name)
local testName = name
local index = 1
while cacheRulesByName[testName] ~= nil do
testName = name .. index
index = index + 1
end
return testName
end
local function CreateNewRule(name, tag)
local rule = {
name = name,
description = "",
rule = "true",
tag = tag,
}
return rule
end
local function CreateNewBagRuleEntry(name)
local entry = {
name = name,
priority = 100,
}
return entry
end
local function RemoveRuleFromBag(ruleName, bagId)
for i = 1, #AutoCategory.curSavedVars.bags[bagId].rules do
local rule = AutoCategory.curSavedVars.bags[bagId].rules[i]
if rule.name == ruleName then
table.remove(AutoCategory.curSavedVars.bags[bagId].rules, i)
return i
end
end
return -1
end
function AutoCategory.GetRuleByName(name)
if cacheRulesByName then
return cacheRulesByName[name]
end
end
function AutoCategory.AddonMenuInit()
RefreshCache()
RefreshDropdownData()
local panelData = {
type = "panel",
name = AutoCategory.settingName,
displayName = AutoCategory.settingDisplayName,
author = AutoCategory.author,
version = AutoCategory.version,
registerForRefresh = true,
registerForDefaults = true,
resetFunc = function()
AutoCategory.ResetToDefaults()
AutoCategory.UpdateCurrentSavedVars()
RefreshCache()
SelectDropDownItem("AC_DROPDOWN_EDITBAG_BAG", AC_BAG_TYPE_BACKPACK)
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", "")
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_TAG", "")
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", "")
SelectDropDownItem("AC_DROPDOWN_EDITRULE_TAG", "")
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", "")
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_BAG")
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_TAG")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_TAG")
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
end,
}
local optionsTable = {
{
type = "submenu",
name = L(SI_AC_MENU_SUBMENU_BAG_SETTING), -- or string id or function returning a string
reference = "AC_SUBMENU_BAG_SETTING",
controls = {
{
type = "checkbox",
name = L(SI_AC_MENU_BS_CHECKBOX_ACCOUNT_WIDE_SETTING),
tooltip = L(SI_AC_MENU_BS_CHECKBOX_ACCOUNT_WIDE_SETTING_TOOLTIP),
getFunc = function() return AutoCategory.charSavedVariables.accountWideSetting end,
setFunc = function(value) AutoCategory.charSavedVariables.accountWideSetting = value
AutoCategory.UpdateCurrentSavedVars()
RefreshCache()
SelectDropDownItem("AC_DROPDOWN_EDITBAG_BAG", AC_BAG_TYPE_BACKPACK)
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", "")
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_TAG", "")
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", "")
SelectDropDownItem("AC_DROPDOWN_EDITRULE_TAG", "")
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", "")
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_BAG")
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_TAG")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_TAG")
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
end,
},
{
type = "divider",
},
{
type = "dropdown",
name = L(SI_AC_MENU_BS_DROPDOWN_BAG),
scrollable = false,
tooltip = L(SI_AC_MENU_BS_DROPDOWN_BAG_TOOLTIP),
choices = dropdownData["AC_DROPDOWN_EDITBAG_BAG"].choices,
choicesValues = dropdownData["AC_DROPDOWN_EDITBAG_BAG"].choicesValues,
choicesTooltips = dropdownData["AC_DROPDOWN_EDITBAG_BAG"].choicesTooltips,
getFunc = function()
return GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
end,
setFunc = function(value)
SelectDropDownItem("AC_DROPDOWN_EDITBAG_BAG", value)
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", "")
--reset add rule's selection, since all data will be changed.
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", "")
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
width = "half",
reference = "AC_DROPDOWN_EDITBAG_BAG"
},
{
type = "dropdown",
name = L(SI_AC_MENU_BS_DROPDOWN_CATEGORIES),
scrollable = true,
choices = dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choices,
choicesValues = dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues,
choicesTooltips = dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesTooltips,
getFunc = function()
return GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE")
end,
setFunc = function(value)
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", value )
end,
disabled = function() return #dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues == 0 end,
width = "half",
reference = "AC_DROPDOWN_EDITBAG_RULE"
},
{
type = "slider",
name = L(SI_AC_MENU_BS_SLIDER_CATEGORY_PRIORITY),
tooltip = L(SI_AC_MENU_BS_SLIDER_CATEGORY_PRIORITY_TOOLTIP),
min = 0,
max = 100,
getFunc = function()
local bag = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
local rule = GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE")
if cacheBagEntriesByName[bag][rule] then
return cacheBagEntriesByName[bag][rule].priority
end
return 0
end,
setFunc = function(value)
local bag = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
local rule = GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE")
if cacheBagEntriesByName[bag][rule] then
cacheBagEntriesByName[bag][rule].priority = value
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
end
end,
disabled = function()
if GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE") == "" then
return true
end
if #dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues == 0 then
return true
end
return false
end,
width = "full",
},
{
type = "checkbox",
name = L(SI_AC_MENU_BS_CHECKBOX_CATEGORY_HIDDEN),
tooltip = L(SI_AC_MENU_BS_CHECKBOX_CATEGORY_HIDDEN_TOOLTIP),
getFunc = function()
local bag = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
local rule = GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE")
if cacheBagEntriesByName[bag][rule] then
return cacheBagEntriesByName[bag][rule].isHidden
end
return 0
end,
setFunc = function(value)
local bag = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
local rule = GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE")
if cacheBagEntriesByName[bag][rule] then
cacheBagEntriesByName[bag][rule].isHidden = value
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
end
end,
disabled = function()
if GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE") == "" then
return true
end
if #dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues == 0 then
return true
end
return false
end,
},
{
type = "button",
name = L(SI_AC_MENU_BS_BUTTON_EDIT),
tooltip = L(SI_AC_MENU_BS_BUTTON_EDIT_TOOLTIP),
func = function()
local ruleName = GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE")
local rule = cacheRulesByName[ruleName]
if rule then
SelectDropDownItem("AC_DROPDOWN_EDITRULE_TAG", rule.tag)
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", rule.name)
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
ToggleSubmenu("AC_SUBMENU_BAG_SETTING", false)
ToggleSubmenu("AC_SUBMENU_CATEGORY_SETTING", true)
end
end,
disabled = function() return #dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues == 0 end,
width = "full",
},
{
type = "button",
name = L(SI_AC_MENU_BS_BUTTON_REMOVE),
tooltip = L(SI_AC_MENU_BS_BUTTON_REMOVE_TOOLTIP),
func = function()
local bagId = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
local ruleName = GetDropDownSelection("AC_DROPDOWN_EDITBAG_RULE")
for i = 1, #AutoCategory.curSavedVars.bags[bagId].rules do
local bagEntry = AutoCategory.curSavedVars.bags[bagId].rules[i]
if bagEntry.name == ruleName then
table.remove(AutoCategory.curSavedVars.bags[bagId].rules, i)
break
end
end
RemoveDropDownItem("AC_DROPDOWN_EDITBAG_RULE", dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues, ruleName)
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
disabled = function() return #dropdownData["AC_DROPDOWN_EDITBAG_RULE"].choicesValues == 0 end,
width = "full",
},
{
type = "header",
name = L(SI_AC_MENU_HEADER_ADD_CATEGORY),
width = "full",
},
{
type = "dropdown",
name = L(SI_AC_MENU_AC_DROPDOWN_TAG),
scrollable = true,
choices = dropdownData["AC_DROPDOWN_ADDCATEGORY_TAG"].choices,
choicesValues = dropdownData["AC_DROPDOWN_ADDCATEGORY_TAG"].choicesValues,
choicesTooltips = dropdownData["AC_DROPDOWN_ADDCATEGORY_TAG"].choicesTooltips,
getFunc = function()
return GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_TAG")
end,
setFunc = function(value)
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_TAG", value)
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", "")
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
width = "half",
disabled = function() return #dropdownData["AC_DROPDOWN_ADDCATEGORY_TAG"].choicesValues == 0 end,
reference = "AC_DROPDOWN_ADDCATEGORY_TAG"
},
{
type = "dropdown",
name = L(SI_AC_MENU_AC_DROPDOWN_CATEGORY),
scrollable = true,
choices = dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choices,
choicesValues = dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesValues,
choicesTooltips = dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesTooltips,
getFunc = function()
return GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
setFunc = function(value)
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", value)
end,
disabled = function() return #dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesValues == 0 end,
width = "half",
reference = "AC_DROPDOWN_ADDCATEGORY_RULE"
},
{
type = "button",
name = L(SI_AC_MENU_AC_BUTTON_EDIT),
tooltip = L(SI_AC_MENU_AC_BUTTON_EDIT_TOOLTIP),
func = function()
local ruleName = GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_RULE")
local rule = cacheRulesByName[ruleName]
if rule then
SelectDropDownItem("AC_DROPDOWN_EDITRULE_TAG", rule.tag)
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", rule.name)
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
ToggleSubmenu("AC_SUBMENU_BAG_SETTING", false)
ToggleSubmenu("AC_SUBMENU_CATEGORY_SETTING", true)
end
end,
disabled = function() return #dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesValues == 0 end,
width = "full",
},
{
type = "button",
name = L(SI_AC_MENU_AC_BUTTON_ADD),
tooltip = L(SI_AC_MENU_AC_BUTTON_ADD_TOOLTIP),
func = function()
local bagId = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
local ruleName = GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_RULE")
assert(cacheBagEntriesByName[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")][ruleName] == nil, "Bag(" .. bagId .. ") already has the rule: ".. ruleName)
local entry = CreateNewBagRuleEntry(ruleName)
table.insert(AutoCategory.curSavedVars.bags[bagId].rules, entry)
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", ruleName)
RemoveDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesValues, ruleName)
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
disabled = function() return #dropdownData["AC_DROPDOWN_ADDCATEGORY_RULE"].choicesValues == 0 end,
width = "full",
},
{
type = "divider",
},
{
type = "checkbox",
name = L(SI_AC_MENU_BS_CHECKBOX_UNGROUPED_CATEGORY_HIDDEN),
tooltip = L(SI_AC_MENU_BS_CHECKBOX_UNGROUPED_CATEGORY_HIDDEN_TOOLTIP),
getFunc = function()
local bag = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
return AutoCategory.curSavedVars.bags[bag].isUngroupedHidden
end,
setFunc = function(value)
local bag = GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")
AutoCategory.curSavedVars.bags[bag].isUngroupedHidden = value
end,
},
{
type = "submenu",
name = L(SI_AC_MENU_SUBMENU_IMPORT_EXPORT),
reference = "SI_AC_MENU_SUBMENU_IMPORT_EXPORT",
controls = {
{
type = "header",
name = L(SI_AC_MENU_HEADER_UNIFY_BAG_SETTINGS),
width = "full",
},
{
type = "button",
name = L(SI_AC_MENU_UBS_BUTTON_EXPORT_TO_ALL_BAGS),
tooltip = L(SI_AC_MENU_UBS_BUTTON_EXPORT_TO_ALL_BAGS_TOOLTIP),
func = function()
local selectedBag = AutoCategory.curSavedVars.bags[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")]
for i = 1, 5 do
AutoCategory.curSavedVars.bags[i] = deepcopy(selectedBag)
end
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", "")
--reset add rule's selection, since all data will be changed.
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", "")
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
width = "full",
},
{
type = "header",
name = L(SI_AC_MENU_HEADER_IMPORT_BAG_SETTING),
width = "full",
},
{
type = "dropdown",
name = L(SI_AC_MENU_IBS_DROPDOWN_IMPORT_FROM_BAG),
scrollable = false,
tooltip = L(SI_AC_MENU_IBS_DROPDOWN_IMPORT_FROM_BAG_TOOLTIP),
choices = dropdownData["AC_DROPDOWN_IMPORTBAG_BAG"].choices,
choicesValues = dropdownData["AC_DROPDOWN_IMPORTBAG_BAG"].choicesValues,
choicesTooltips = dropdownData["AC_DROPDOWN_IMPORTBAG_BAG"].choicesTooltips,
getFunc = function()
return GetDropDownSelection("AC_DROPDOWN_IMPORTBAG_BAG")
end,
setFunc = function(value)
SelectDropDownItem("AC_DROPDOWN_IMPORTBAG_BAG", value)
end,
width = "full",
reference = "AC_DROPDOWN_IMPORTBAG_BAG"
},
{
type = "button",
name = L(SI_AC_MENU_IBS_BUTTON_IMPORT),
tooltip = L(SI_AC_MENU_IBS_BUTTON_IMPORT_TOOLTIP),
func = function()
AutoCategory.curSavedVars.bags[GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG")] = deepcopy( AutoCategory.curSavedVars.bags[GetDropDownSelection("AC_DROPDOWN_IMPORTBAG_BAG")] )
SelectDropDownItem("AC_DROPDOWN_EDITBAG_RULE", "")
--reset add rule's selection, since all data will be changed.
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", "")
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
disabled = function()
return GetDropDownSelection("AC_DROPDOWN_EDITBAG_BAG") == GetDropDownSelection("AC_DROPDOWN_IMPORTBAG_BAG")
end,
width = "full",
},
},
},
{
type = "divider",
},
{
type = "button",
name = L(SI_AC_MENU_AC_BUTTON_NEED_HELP),
func = function() RequestOpenUnsafeURL("https://github.com/rockingdice/AutoCategory/wiki/Become-veteran!") end,
width = "full",
},
},
},
{
type = "submenu",
name = L(SI_AC_MENU_SUBMENU_CATEGORY_SETTING),
reference = "AC_SUBMENU_CATEGORY_SETTING",
controls = {
{
type = "dropdown",
name = L(SI_AC_MENU_CS_DROPDOWN_TAG),
scrollable = true,
tooltip = L(SI_AC_MENU_CS_DROPDOWN_TAG_TOOLTIP),
choices = dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choices,
choicesValues = dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesValues,
choicesTooltips = dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesTooltips,
getFunc = function()
return GetDropDownSelection("AC_DROPDOWN_EDITRULE_TAG")
end,
setFunc = function(value)
SelectDropDownItem("AC_DROPDOWN_EDITRULE_TAG", value)
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", "")
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
end,
width = "half",
disabled = function() return #dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesValues == 0 end,
reference = "AC_DROPDOWN_EDITRULE_TAG"
},
{
type = "dropdown",
name = L(SI_AC_MENU_CS_DROPDOWN_CATEGORY),
scrollable = true,
choices = dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choices,
choicesValues = dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choicesValues,
choicesTooltips = dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choicesTooltips,
getFunc = function()
return GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")
end,
setFunc = function(value)
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", value)
end,
disabled = function() return #dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choicesValues == 0 end,
width = "half",
reference = "AC_DROPDOWN_EDITRULE_RULE"
},
{
type = "header",
name = L(SI_AC_MENU_HEADER_EDIT_CATEGORY),
width = "full",
},
{
type = "editbox",
name = L(SI_AC_MENU_EC_EDITBOX_NAME),
tooltip = L(SI_AC_MENU_EC_EDITBOX_NAME_TOOLTIP),
getFunc = function()
local ruleName = GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")
if cacheRulesByName[ruleName] then
return cacheRulesByName[ruleName].name
end
return ""
end,
warning = function()
return warningDuplicatedName.warningMessage
end,
setFunc = function(value)
local ruleName = GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")
local oldName = cacheRulesByName[ruleName].name
if oldName == value then
return
end
if value == "" then
warningDuplicatedName.warningMessage = L(SI_AC_WARNING_CATEGORY_NAME_EMPTY)
value = oldName
end
local isDuplicated = IsRuleNameUsed(value)
if isDuplicated then
warningDuplicatedName.warningMessage = string.format(L(SI_AC_WARNING_CATEGORY_NAME_DUPLICATED), value, GetUsableRuleName(value))
value = oldName
end
--change editbox's value
local control = WINDOW_MANAGER:GetControlByName("AC_EDITBOX_EDITRULE_NAME", "")
control.editbox:SetText(value)
cacheRulesByName[ruleName].name = value
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", value )
--Update bags so that every entry has the same name, should be changed to new name.
for i = 1, #AutoCategory.curSavedVars.bags do
local bag = AutoCategory.curSavedVars.bags[i]
local rules = bag.rules
for j = 1, #rules do
local rule = rules[j]
if rule.name == oldName then
rule.name = value
end
end
end
--Update drop downs
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
isMultiline = false,
disabled = function() return #dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesValues == 0 end,
width = "half",
reference = "AC_EDITBOX_EDITRULE_NAME",
},
{
type = "editbox",
name = L(SI_AC_MENU_EC_EDITBOX_TAG),
tooltip = L(SI_AC_MENU_EC_EDITBOX_TAG_TOOLTIP),
getFunc = function()
local ruleName = GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")
if cacheRulesByName[ruleName] then
return cacheRulesByName[ruleName].tag
end
return ""
end,
setFunc = function(value)
if value == "" then
value = AC_EMPTY_TAG_NAME
end
local ruleName = GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")
local control = WINDOW_MANAGER:GetControlByName("AC_EDITBOX_EDITRULE_TAG", "")
control.editbox:SetText(value)
local oldGroup = cacheRulesByName[GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")].tag
cacheRulesByName[GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")].tag = value
RemoveDropDownItem("AC_DROPDOWN_EDITRULE_RULE", dropdownData["AC_DROPDOWN_EDITRULE_RULE"].choicesValues, ruleName, function(typeString)
--try to remove this rule from the tag, if tag needs delete, reselect it in add rule tab
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_TAG", "")
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", "")
end)
if GetDropDownSelection("AC_DROPDOWN_ADDCATEGORY_RULE") == ruleName then
--modify the same rule, reselect add rule tab
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_TAG", value)
SelectDropDownItem("AC_DROPDOWN_ADDCATEGORY_RULE", ruleName)
end
SelectDropDownItem("AC_DROPDOWN_EDITRULE_TAG", value)
SelectDropDownItem("AC_DROPDOWN_EDITRULE_RULE", ruleName)
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_TAG")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_TAG")
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
end,
isMultiline = false,
disabled = function() return #dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesValues == 0 end,
width = "half",
reference = "AC_EDITBOX_EDITRULE_TAG",
},
{
type = "editbox",
name = L(SI_AC_MENU_EC_EDITBOX_DESCRIPTION),
tooltip = L(SI_AC_MENU_EC_EDITBOX_DESCRIPTION_TOOLTIP),
getFunc = function()
local ruleName = GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")
if cacheRulesByName[ruleName] then
return cacheRulesByName[ruleName].description
end
return ""
end,
setFunc = function(value)
cacheRulesByName[GetDropDownSelection("AC_DROPDOWN_EDITRULE_RULE")].description = value
RefreshCache()
RefreshDropdownData()
UpdateDropDownMenu("AC_DROPDOWN_EDITBAG_RULE")
UpdateDropDownMenu("AC_DROPDOWN_EDITRULE_RULE")
UpdateDropDownMenu("AC_DROPDOWN_ADDCATEGORY_RULE")
end,
isMultiline = false,
isExtraWide = true,
disabled = function() return #dropdownData["AC_DROPDOWN_EDITRULE_TAG"].choicesValues == 0 end,
width = "full",
},
{
type = "editbox",
name = L(SI_AC_MENU_EC_EDITBOX_RULE),
tooltip = L(SI_AC_MENU_EC_EDITBOX_RULE_TOOLTIP),
getFunc = function()