-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuctionatorConfig.lua
1511 lines (986 loc) · 39.2 KB
/
AuctionatorConfig.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 addonName, addonTable = AuctionatorName, AuctionatorAddon;
local zc = addonTable.zc;
local zz = zc.md;
Atr_LoadOptionsSubPanel_NumCalls = 0;
-----------------------------------------
function Atr_LoadOptionsSubPanel (f, name, title, subtitle)
f.name = name
f.parent = "Auctionator";
f.cancel = Atr_Options_Cancel;
local frameName = f:GetName();
f.okay = _G[frameName.."_Save"];
Atr_LoadOptionsSubPanel_NumCalls = Atr_LoadOptionsSubPanel_NumCalls + 1;
if (title == nil) then title = name; end
if (subtitle == nil) then subtitle = ""; end
_G[frameName.."_ATitle"]:SetText (title);
_G[frameName.."_BTitle"]:SetText (subtitle);
InterfaceOptions_AddCategory (f);
f:SetScript("OnShow", Atr_OptionsSubPanel_OnShow)
end
-----------------------------------------
function Atr_OptionsSubPanel_OnShow (self)
self.atr_hasBeenShown = true;
if (self.atr_onShow) then
self.atr_onShow (self);
end
end
-----------------------------------------
function Atr_Options_Cancel ()
Atr_InitOptionsPanels();
end
-----------------------------------------
function Atr_InitOptionsPanels()
if (AUCTIONATOR_SAVEDVARS == nil) then
Atr_ResetSavedVars();
end
Atr_SetupBasicOptionsFrame();
Atr_SetupTooltipsOptionsFrame();
Atr_SetupUCConfigFrame();
Atr_SetupStackingFrame();
Atr_SetupOptionsFrame();
Atr_SetupScanningConfigFrame();
Atr_SetupShpListsFrame();
end
-----------------------------------------
function Atr_SetupOptionsFrame()
local expText = "<html><body>"
.."<p>"..ZT("The latest information on Auctionator can be found at").." auctionator-addon.com.".."</p>"
.."<p><br/>"
.."|cffaaaaaa"..string.format (ZT("German translation courtesy of %s"), "|rCkaotik").."<br/>"
.."|cffaaaaaa"..string.format (ZT("Russian translation courtesy of %s"), "|rStingerSoft").."<br/>"
.."|cffaaaaaa"..string.format (ZT("Swedish translation courtesy of %s"), "|rHellManiac").."<br/>"
.."|cffaaaaaa"..string.format (ZT("French translation courtesy of %s"), "|rKiskewl").."<br/>"
.."|cffaaaaaa"..string.format (ZT("Spanish translation courtesy of %s"), "|rElfindor").."<br/>"
.."|cffaaaaaa"..string.format (ZT("Chinese/Taiwan translation courtesy of %s"), "|rScars").."<br/>"
.."</p>"
.."</body></html>"
;
AuctionatorDescriptionHTML:SetText (expText);
AuctionatorDescriptionHTML:SetSpacing (3);
AuctionatorVersionText:SetText (ZT("Version")..": "..AuctionatorVersion);
end
-----------------------------------------
function Atr_SetDurationOptionRB(name)
Atr_RB_S:SetChecked (zc.StringEndsWith (name, "S"));
Atr_RB_M:SetChecked (zc.StringEndsWith (name, "M"));
Atr_RB_L:SetChecked (zc.StringEndsWith (name, "L"));
end
-----------------------------------------
function Atr_BasicOptionsFrame_Save (frame)
if (not frame.atr_hasBeenShown) then
return;
end
local origValues = zc.msg_str (AUCTIONATOR_ENABLE_ALT, AUCTIONATOR_OPEN_ALL_BAGS, AUCTIONATOR_SHOW_ST_PRICE, AUCTIONATOR_DEFTAB, AUCTIONATOR_DEF_DURATION);
AUCTIONATOR_ENABLE_ALT = zc.BoolToNum(AuctionatorOption_Enable_Alt_CB:GetChecked ());
AUCTIONATOR_OPEN_ALL_BAGS = zc.BoolToNum(AuctionatorOption_Open_All_Bags_CB:GetChecked ());
AUCTIONATOR_SHOW_ST_PRICE = zc.BoolToNum(AuctionatorOption_Show_StartingPrice_CB:GetChecked ());
AUCTIONATOR_DEFTAB = UIDropDownMenu_GetSelectedValue(AuctionatorOption_Deftab);
AUCTIONATOR_DEF_DURATION = "N";
if (Atr_RB_S:GetChecked()) then AUCTIONATOR_DEF_DURATION = "S"; end;
if (Atr_RB_M:GetChecked()) then AUCTIONATOR_DEF_DURATION = "M"; end;
if (Atr_RB_L:GetChecked()) then AUCTIONATOR_DEF_DURATION = "L"; end;
local newValues = zc.msg_str (AUCTIONATOR_ENABLE_ALT, AUCTIONATOR_OPEN_ALL_BAGS, AUCTIONATOR_SHOW_ST_PRICE, AUCTIONATOR_DEFTAB, AUCTIONATOR_DEF_DURATION);
if (origValues ~= newValues) then
zc.msg_anm (ZT ("basic options saved"));
end
Atr_ShowHide_StartingPrice();
end
-----------------------------------------
function Atr_SetupBasicOptionsFrame()
Atr_BasicOptionsFrame_BTitle:SetText (string.format (ZT("Basic Options for %s"), "|cffffff55"..UnitName("player")));
AuctionatorOption_Enable_Alt_CB:SetChecked (zc.NumToBool(AUCTIONATOR_ENABLE_ALT));
AuctionatorOption_Open_All_Bags_CB:SetChecked (zc.NumToBool(AUCTIONATOR_OPEN_ALL_BAGS));
AuctionatorOption_Show_StartingPrice_CB:SetChecked (zc.NumToBool(AUCTIONATOR_SHOW_ST_PRICE));
Atr_SetDurationOptionRB (AUCTIONATOR_DEF_DURATION);
end
-----------------------------------------
function Atr_SetupTooltipsOptionsFrame ()
ATR_tipsVendorOpt_CB:SetChecked (zc.NumToBool(AUCTIONATOR_V_TIPS));
ATR_tipsAuctionOpt_CB:SetChecked (zc.NumToBool(AUCTIONATOR_A_TIPS));
ATR_tipsDisenchantOpt_CB:SetChecked (zc.NumToBool(AUCTIONATOR_D_TIPS));
end
-----------------------------------------
function Atr_TooltipsOptionsFrame_Save(frame)
if (not frame.atr_hasBeenShown) then
return;
end
local origValues = zc.msg_str (AUCTIONATOR_V_TIPS, AUCTIONATOR_A_TIPS, AUCTIONATOR_D_TIPS, AUCTIONATOR_SHIFT_TIPS, AUCTIONATOR_DE_DETAILS_TIPS);
AUCTIONATOR_V_TIPS = zc.BoolToNum(ATR_tipsVendorOpt_CB:GetChecked ());
AUCTIONATOR_A_TIPS = zc.BoolToNum(ATR_tipsAuctionOpt_CB:GetChecked ());
AUCTIONATOR_D_TIPS = zc.BoolToNum(ATR_tipsDisenchantOpt_CB:GetChecked ());
AUCTIONATOR_SHIFT_TIPS = UIDropDownMenu_GetSelectedValue(Atr_tipsShiftDD);
AUCTIONATOR_DE_DETAILS_TIPS = UIDropDownMenu_GetSelectedValue(Atr_deDetailsDD);
local newValues = zc.msg_str (AUCTIONATOR_V_TIPS, AUCTIONATOR_A_TIPS, AUCTIONATOR_D_TIPS, AUCTIONATOR_SHIFT_TIPS, AUCTIONATOR_DE_DETAILS_TIPS);
if (origValues ~= newValues) then
zc.msg_anm (ZT("tooltip configuration saved"));
end
end
-----------------------------------------
function Atr_Opt_Deftab_OnShow(self)
UIDropDownMenu_Initialize (self, Atr_Opt_Deftab_Initialize);
UIDropDownMenu_SetSelectedValue (self, AUCTIONATOR_DEFTAB);
UIDropDownMenu_JustifyText ("LEFT", self);
end
-----------------------------------------
function Atr_Opt_Deftab_Initialize(self)
Atr_Dropdown_AddPick (self, ZT("None"), 0, function() UIDropDownMenu_SetSelectedValue(AuctionatorOption_Deftab, this.value); end);
Atr_Dropdown_AddPick (self, ZT("Sell"), 1, function() UIDropDownMenu_SetSelectedValue(AuctionatorOption_Deftab, this.value); end);
Atr_Dropdown_AddPick (self, ZT("Buy"), 2, function() UIDropDownMenu_SetSelectedValue(AuctionatorOption_Deftab, this.value); end);
Atr_Dropdown_AddPick (self, ZT("More"), 3, function() UIDropDownMenu_SetSelectedValue(AuctionatorOption_Deftab, this.value); end);
end
-----------------------------------------
function Atr_Opt_TipsShift_OnShow(self)
UIDropDownMenu_Initialize (self, Atr_tipsShiftDD_Initialize);
UIDropDownMenu_SetSelectedValue (self, AUCTIONATOR_SHIFT_TIPS);
UIDropDownMenu_JustifyText ("LEFT", self);
end
-----------------------------------------
function Atr_tipsShiftDD_Initialize(self)
Atr_Dropdown_AddPick (self, ZT("stack price"), 1, function() UIDropDownMenu_SetSelectedValue(Atr_tipsShiftDD, this.value); end);
Atr_Dropdown_AddPick (self, ZT("per item price"), 2, function() UIDropDownMenu_SetSelectedValue(Atr_tipsShiftDD, this.value); end);
end
-----------------------------------------
function Atr_Opt_deDetails_OnShow(self)
UIDropDownMenu_Initialize (self, Atr_deDetailsDD_Initialize);
UIDropDownMenu_SetSelectedValue (self, AUCTIONATOR_DE_DETAILS_TIPS);
UIDropDownMenu_SetWidth (175, self);
UIDropDownMenu_JustifyText ("LEFT", self);
end
-----------------------------------------
function Atr_deDetailsDD_Initialize(self)
Atr_Dropdown_AddPick (self, ZT("when SHIFT is held down"), 1, function() UIDropDownMenu_SetSelectedValue(Atr_deDetailsDD, this.value); end);
Atr_Dropdown_AddPick (self, ZT("when CONTROL is held down"), 2, function() UIDropDownMenu_SetSelectedValue(Atr_deDetailsDD, this.value); end);
Atr_Dropdown_AddPick (self, ZT("when ALT is held down"), 3, function() UIDropDownMenu_SetSelectedValue(Atr_deDetailsDD, this.value); end);
Atr_Dropdown_AddPick (self, ZT("never"), 4, function() UIDropDownMenu_SetSelectedValue(Atr_deDetailsDD, this.value); end);
Atr_Dropdown_AddPick (self, ZT("always"), 5, function() UIDropDownMenu_SetSelectedValue(Atr_deDetailsDD, this.value); end);
end
-----------------------------------------
function Atr_Option_OnClick (self)
if (zc.StringContains (self:GetName(), "Open_BUY") and self:GetChecked()) then
AuctionatorOption_Open_SELL_CB:SetChecked (false);
end
if (zc.StringContains (self:GetName(), "Open_SELL") and self:GetChecked()) then
AuctionatorOption_Open_BUY_CB:SetChecked (false);
end
end
-----------------------------------------
local kThresh = {}
kThresh[1] = { amt=5000000, text=ZT("over %d gold"), v=500 };
kThresh[2] = { amt=1000000, text=ZT("over %d gold"), v=100 };
kThresh[3] = { amt=200000, text=ZT("over %d gold"), v=20 };
kThresh[4] = { amt=50000, text=ZT("over %d gold"), v=5 };
kThresh[5] = { amt=10000, text=ZT("over 1 gold"), v=1 };
kThresh[6] = { amt=2000, text=ZT("over %d silver"), v=20 };
kThresh[7] = { amt=500, text=ZT("over %d silver"), v=5 };
-----------------------------------------
function Atr_SetupUCConfigFrame()
for i = 1, #kThresh do
local amt = kThresh[i].amt;
local linetext = string.format (kThresh[i].text, kThresh[i].v);
_G["UC_"..amt.."_RangeText"]:SetText (linetext);
MoneyInputFrame_SetCopper (_G["UC_"..amt.."_MoneyInput"], AUCTIONATOR_SAVEDVARS["_"..amt]);
end
Atr_Starting_Discount:SetText (AUCTIONATOR_SAVEDVARS.STARTING_DISCOUNT);
end
-----------------------------------------
function Atr_UCConfigFrame_Save(frame)
if (not frame.atr_hasBeenShown) then
return;
end
local origValues = AUCTIONATOR_SAVEDVARS.STARTING_DISCOUNT;
AUCTIONATOR_SAVEDVARS.STARTING_DISCOUNT = Atr_Starting_Discount:GetNumber ();
local newValues = AUCTIONATOR_SAVEDVARS.STARTING_DISCOUNT;
for i = 1, #kThresh do
local amt = kThresh[i].amt;
origValues = origValues + AUCTIONATOR_SAVEDVARS["_"..amt];
AUCTIONATOR_SAVEDVARS["_"..amt] = MoneyInputFrame_GetCopper(_G["UC_"..amt.."_MoneyInput"]);
newValues = newValues + AUCTIONATOR_SAVEDVARS["_"..amt];
end
if (origValues ~= newValues) then
zc.msg_anm (ZT("undercutting configuration saved"));
end
end
-----------------------------------------
local function plistEntry (key, txt, num, size)
return { sortkey=key, text=txt, numstacks=num, stacksize=size }
end
-----------------------------------------
local function plistSort (x, y)
return x.sortkey < y.sortkey;
end
-----------------------------------------
local kStackList_LinesToDisplay = 12;
local gStackList_SelectedIndex = 0;
local gStackList_plist;
kStackList_categories = {};
kStackList_categories[ATR_SK_GLYPHS] = { txt=ZT("Glyphs") }
kStackList_categories[ATR_SK_GEMS_CUT] = { txt=ZT("Gems - Cut") }
kStackList_categories[ATR_SK_GEMS_UNCUT] = { txt=ZT("Gems - Uncut") }
kStackList_categories[ATR_SK_ITEM_ENH] = { txt=ZT("Item Enhancements") }
kStackList_categories[ATR_SK_POT_ELIX] = { txt=ZT("Potions and Elixirs") }
kStackList_categories[ATR_SK_FLASKS] = { txt=ZT("Flasks") }
kStackList_categories[ATR_SK_HERBS] = { txt=ZT("Herbs") }
-----------------------------------------
function Atr_SetupStackingFrame ()
if (_G["Atr_StackList1"] == nil) then
local line, n;
for n = 1, kStackList_LinesToDisplay do
local y = -5 - ((n-1)*16);
line = CreateFrame("BUTTON", "Atr_StackList"..n, Atr_Stacking_List, "Atr_StackingEntryTemplate");
line:SetPoint("TOP", 0, y);
end
end
Atr_StackingList_Display();
end
-----------------------------------------
function Atr_StackingList_Display()
gStackList_plist = {};
local plist = gStackList_plist;
local text, spinfo;
local sortkey, info;
local n = 1;
for sortkey, info in pairs (kStackList_categories) do
info.overrideFound = false;
end
if (AUCTIONATOR_STACKING_PREFS == nil) then
Atr_StackingPrefs_Init();
end
for text, spinfo in pairs (AUCTIONATOR_STACKING_PREFS) do
-- skip over any that were set automatically rather than explicitly by the user
-- and mark the built-in categories
if (spinfo.numstacks ~= 0) then
local sortkey = text;
if (kStackList_categories[text]) then
kStackList_categories[text].overrideFound = true;
text = kStackList_categories[text].txt;
end
plist[n] = plistEntry (sortkey, text, spinfo.numstacks, spinfo.stacksize);
n = n + 1;
end
end
for sortkey, info in pairs (kStackList_categories) do
if (not info.overrideFound) then
plist[n] = plistEntry (sortkey, info.txt, -2, 0);
n = n + 1;
end
end
table.sort (plist, plistSort)
local totalRows = #plist;
local line; -- 1 through NN of our window to scroll
local dataOffset; -- an index into our data calculated from the scroll offset
FauxScrollFrame_Update (Atr_Stacking_ScrollFrame, totalRows, kStackList_LinesToDisplay, 16);
for line = 1,kStackList_LinesToDisplay do
dataOffset = line + FauxScrollFrame_GetOffset (Atr_Stacking_ScrollFrame);
local lineEntry = _G["Atr_StackList"..line];
lineEntry:SetID (dataOffset);
if (dataOffset <= totalRows and plist[dataOffset]) then
local lineEntry_text = _G["Atr_StackList"..line.."_text"];
local lineEntry_info = _G["Atr_StackList"..line.."_info"];
local pdata = plist[dataOffset];
local colorText = ((pdata.text == pdata.sortkey) and "" or "|cffffff88");
lineEntry_text:SetText (colorText..pdata.text);
local numstacks = plist[dataOffset].numstacks;
local stacksize = plist[dataOffset].stacksize;
local info = "???";
if (numstacks == -2) then info = "|cff777777"..ZT("default behavior");
elseif (numstacks == -1) then info = string.format (ZT("max. stacks of %d"), stacksize);
elseif (stacksize == 0) then info = "1 "..ZT("stack");
elseif (numstacks == 0) then info = ZT("stacks of").." "..stacksize;
elseif (numstacks > 0) then info = numstacks.." "..ZT("stacks of").." "..stacksize;
end
lineEntry_info:SetText (info);
if (gStackList_SelectedIndex == dataOffset) then
lineEntry:SetButtonState ("PUSHED", true);
else
lineEntry:SetButtonState ("NORMAL", false);
end
lineEntry:Show();
else
lineEntry:Hide();
end
end
zc.EnableDisable (Atr_StackingOptionsFrame_Edit, gStackList_SelectedIndex > 0);
end
-----------------------------------------
function Atr_StackingEntry_OnClick(self)
gStackList_SelectedIndex = self:GetID();
Atr_StackingList_Display();
end
-----------------------------------------
function Atr_StackingEntry_OnDoubleClick(self)
Atr_StackingEntry_OnClick(self);
Atr_StackingList_Edit_OnClick();
end
-----------------------------------------
function Atr_Memorize_Show (isNew)
local numStacks = -1;
local stackSize = 1;
zc.ShowHide (Atr_Mem_itemName_static, not isNew);
zc.ShowHide (Atr_Mem_EB_itemName, isNew);
zc.ShowHide (Atr_Mem_Forget, not isNew);
Atr_MemorizeFrame["isCategory"] = false;
if (not isNew) then
local x = gStackList_SelectedIndex;
local plist = gStackList_plist;
Atr_Mem_itemName_static:SetText (plist[x].text);
stackSize = plist[x].stacksize
numStacks = plist[x].numstacks
local isCategory = (plist[x].sortkey ~= plist[x].text);
Atr_MemorizeFrame["isCategory"] = isCategory;
if (isCategory and numStacks == -2) then
numStacks = -1;
stackSize = 1;
end
zc.SetTextIf (Atr_Mem_itemName_text, isCategory, ZT("Category"), ZT("Item Name"));
zc.SetTextIf (Atr_Mem_Forget, isCategory, ZT("Reset to Default"), ZT("Forget this Item"));
end
Atr_Mem_EB_stackSize:SetText (stackSize);
UIDropDownMenu_Initialize (Atr_Mem_DD_numStacks, Atr_SONumStacks_Initialize);
UIDropDownMenu_SetSelectedValue (Atr_Mem_DD_numStacks, numStacks);
Atr_Mem_EB_itemName:SetText ("");
ShowInterfaceOptionsMask();
Atr_MemorizeFrame:Show();
end
-----------------------------------------
function Atr_StackingList_Edit_OnClick()
Atr_Memorize_Show(false);
end
-----------------------------------------
function Atr_StackingList_New_OnClick()
Atr_Memorize_Show(true);
end
-----------------------------------------
function Atr_Memorize_Save()
zz ("Saving stacking configuration");
local x = gStackList_SelectedIndex;
local plist = gStackList_plist;
local key = Atr_Mem_EB_itemName:GetText();
if (key == nil or key == "") then
key = plist[x].sortkey;
end
if (key and key ~= "") then
Atr_Set_StackingPrefs_numstacks (key, UIDropDownMenu_GetSelectedValue (Atr_Mem_DD_numStacks));
Atr_Set_StackingPrefs_stacksize (key, Atr_Mem_EB_stackSize:GetNumber());
end
Atr_StackingList_Display();
end
-----------------------------------------
function Atr_Memorize_Forget()
local x = gStackList_SelectedIndex;
local plist = gStackList_plist;
local key = plist[x].sortkey;
if (key) then
Atr_Clear_StackingPrefs (key);
end
if (not Atr_MemorizeFrame["isCategory"]) then
gStackList_SelectedIndex = 0;
end
Atr_StackingList_Display();
end
-----------------------------------------
function Atr_SONumStacks_OnShow(self)
UIDropDownMenu_Initialize (self, Atr_SONumStacks_Initialize);
UIDropDownMenu_JustifyText ("CENTER", self);
UIDropDownMenu_SetWidth (150, self);
end
-----------------------------------------
function Atr_SONumStacks_Initialize(self)
Atr_Dropdown_AddPick (self, ZT("As many as possible"), -1, Atr_SONumStacks_OnClick)
Atr_Dropdown_AddPick (self, "1", 1, Atr_SONumStacks_OnClick)
Atr_Dropdown_AddPick (self, "2", 2, Atr_SONumStacks_OnClick)
Atr_Dropdown_AddPick (self, "3", 3, Atr_SONumStacks_OnClick)
Atr_Dropdown_AddPick (self, "4", 4, Atr_SONumStacks_OnClick)
Atr_Dropdown_AddPick (self, "5", 5, Atr_SONumStacks_OnClick)
Atr_Dropdown_AddPick (self, "10", 10, Atr_SONumStacks_OnClick)
end
-----------------------------------------
function Atr_SONumStacks_OnClick(self)
UIDropDownMenu_SetSelectedValue(Atr_Mem_DD_numStacks, this.value);
Atr_Mem_stacksOf_text:SetText (ZT ((this.value == 1) and "stack of" or "stacks of"));
end
-----------------------------------------
function Atr_ShowOptionTooltip (elem)
local name = elem:GetName();
local text;
if (zc.StringContains (name, "Enable_Alt")) then
text = ZT("If this option is checked, holding the Alt key down while clicking an item in your bags will switch to the Auctionator panel, place the item in the Auction Item area, and start the scan.");
end
if (zc.StringContains (name, "Deftab")) then
text = ZT("Select the Auctionator panel to be displayed first whenever you open the Auction House window.");
end
if (zc.StringContains (name, "Open_BUY")) then
text = ZT("If this option is checked, the Auctionator BUY panel will display first whenever you open the Auction House window.");
end
if (zc.StringContains (name, "Open_All_Bags")) then
text = ZT("If this option is checked, ALL your bags will be opened when you first open the Auctionator panel.");
end
if (zc.StringContains (name, "Def_Duration")) then
text = ZT("If this option is checked, every time you initiate a new auction the auction duration will be reset to the default duration you've selected.");
end
if (text) then
local titleFrame = _G[name.."_CB_Text"] or _G[name.."_Text"];
local titleText = titleFrame and titleFrame:GetText() or "???";
GameTooltip:SetOwner(elem, "ANCHOR_LEFT");
GameTooltip:SetText(titleText, 0.9, 1.0, 1.0);
GameTooltip:AddLine(text, 0.5, 0.5, 1.0, 1);
GameTooltip:Show();
end
end
-----------------------------------------
function Atr_SetupScanningConfigFrame ()
Atr_ScanningOptionsFrame.atr_onShow = Atr_ScanningConfigFrame_Update;
end
-----------------------------------------
function Atr_ScanOpts_ApplyNow()
Atr_ScanningOptionsFrame_Save(Atr_ScanningOptionsFrame);
Atr_PruneScanDB ();
Atr_ScanningConfigFrame_Update();
end
-----------------------------------------
function Atr_ScanningConfigFrame_Update ()
Atr_ScanOpts_ItemCntText:SetText (string.format (ZT("%6d items"), Atr_GetDBsize()));
collectgarbage ("collect");
Atr_ScanOpts_MemUsageText:SetText (Atr_GetAuctionatorMemString());
Atr_MigtrateMaxHistAge();
Atr_ScanOpts_MaxHistAge:SetText (AUCTIONATOR_DB_MAXHIST_DAYS);
end
-----------------------------------------
function Atr_ScanningOptionsFrame_Save(frame)
if (not frame.atr_hasBeenShown) then
return;
end
local origValues = zc.msg_str (AUCTIONATOR_SCAN_MINLEVEL, AUCTIONATOR_DB_MAXITEM_AGE, AUCTIONATOR_DB_MAXHIST_DAYS);
AUCTIONATOR_SCAN_MINLEVEL = UIDropDownMenu_GetSelectedValue(Atr_scanLevelDD);
AUCTIONATOR_DB_MAXHIST_DAYS = Atr_ScanOpts_MaxHistAge:GetNumber();
local newValues = zc.msg_str (AUCTIONATOR_SCAN_MINLEVEL, AUCTIONATOR_DB_MAXITEM_AGE, AUCTIONATOR_DB_MAXHIST_DAYS);
if (origValues ~= newValues) then
zc.msg_anm (ZT("scanning options saved"));
end
end
-----------------------------------------
function Atr_ScanLevel_OnLoad(self)
Atr_ScanLevel_OnShow(self);
end
-----------------------------------------
function Atr_ScanLevel_OnShow(self)
UIDropDownMenu_Initialize (self, Atr_scanLevelDD_Initialize);
UIDropDownMenu_SetSelectedValue (self, AUCTIONATOR_SCAN_MINLEVEL);
UIDropDownMenu_JustifyText ("LEFT", self);
end
-----------------------------------------
function Atr_scanLevelDD_Initialize(self)
Atr_Dropdown_AddPick (self, "|cffa335ee"..ZT("Epic").."|r", 5, function() UIDropDownMenu_SetSelectedValue(Atr_scanLevelDD, this.value); end);
Atr_Dropdown_AddPick (self, "|cff0070dd"..ZT("Rare").."|r", 4, function() UIDropDownMenu_SetSelectedValue(Atr_scanLevelDD, this.value); end);
Atr_Dropdown_AddPick (self, "|cff1eff00"..ZT("Uncommon").."|r", 3, function() UIDropDownMenu_SetSelectedValue(Atr_scanLevelDD, this.value); end);
Atr_Dropdown_AddPick (self, "|cffffffff"..ZT("Common").."|r", 2, function() UIDropDownMenu_SetSelectedValue(Atr_scanLevelDD, this.value); end);
Atr_Dropdown_AddPick (self, "|cff9d9d9d"..ZT("Poor (all)").."|r", 1, function() UIDropDownMenu_SetSelectedValue(Atr_scanLevelDD, this.value); end);
end
-----------------------------------------
function Atr_scanLevelDD_showTip(self)
GameTooltip:SetOwner(self, "ANCHOR_LEFT");
GameTooltip:SetText(ZT("Minimum Quality Level"), 0.9, 1.0, 1.0);
GameTooltip:AddLine(ZT("Only include items in the scanning database that are this level or higher"), 0.5, 0.5, 1.0, 1);
GameTooltip:Show();
end
-----------------------------------------
local gAtr_ConfirmYesAction
-----------------------------------------
function Atr_OnClick_ClearConfirm_Yes()
if (gAtr_ConfirmYesAction) then
collectgarbage ("collect");
UpdateAddOnMemoryUsage()
local before = Atr_GetAuctionatorMemString()
local text = gAtr_ConfirmYesAction()
collectgarbage ("collect");
UpdateAddOnMemoryUsage()
local after = Atr_GetAuctionatorMemString()
zc.msg_anm (text, " Memory went from", before, "to", after);
end
gAtr_ConfirmYesAction = nil
Atr_OnClick_ClearConfirm_Hide()
end
-----------------------------------------
function Atr_OnClick_ClearConfirm_Hide()
Atr_ConfirmClear_Frame:Hide()
HideInterfaceOptionsMask()
end
-----------------------------------------
function Atr_OnClick_ClearHistory(self)
ShowInterfaceOptionsMask();
Atr_ClearConfirm_Text1:SetText (ZT("Are you sure you want to clear the scanned prices database?"))
Atr_ClearConfirm_Text2:SetText (ZT("This will clear the pricing history for all items for all your characters - even characters on different servers."))
gAtr_ConfirmYesAction = function ()
gAtr_ScanDB = nil;
AUCTIONATOR_PRICE_DATABASE = nil;
Atr_InitScanDB();
return "Pricing history cleared."
end
Atr_ConfirmClear_Frame:Show()
end
-----------------------------------------
function Atr_OnClick_ClearPostHistory(self)
ShowInterfaceOptionsMask();
Atr_ClearConfirm_Text1:SetText (ZT("Are you sure you want to clear the posting history?"))
Atr_ClearConfirm_Text2:SetText (ZT("This will clear the information that Auctionator keeps for all items that you've posted - as shown on the \"Other\" tab after you scan for an item that you've sold in the past."))
gAtr_ConfirmYesAction = function ()
AUCTIONATOR_PRICING_HISTORY = {}
return "Posting history cleared."
end
Atr_ConfirmClear_Frame:Show()
end
-----------------------------------------
function Atr_OnClick_ClearStackPrefs(self)
ShowInterfaceOptionsMask();
Atr_ClearConfirm_Text1:SetText (ZT("Are you sure you want to clear your stacking preferences?"))
Atr_ClearConfirm_Text2:SetText (ZT("Go ahead - this isn't a big deal. Auctionator will figure it out again fairly quickly. This is just some info Auctionator keeps to help it set the default stack size a bit more intelligently."))
gAtr_ConfirmYesAction = function ()
Atr_ClearItemStackingPrefs()
return "Stacking preferences cleared."
end
Atr_ConfirmClear_Frame:Show()
end
-----------------------------------------
function Atr_OnClick_ClearShopLists(self)
ShowInterfaceOptionsMask();
Atr_ClearConfirm_Text1:SetText (ZT("Are you sure you want to clear your shopping lists?"))
Atr_ClearConfirm_Text2:SetText (ZT("If you put a lot of time into constructing detailed shopping lists, this will require you to buidl them all over again."))
gAtr_ConfirmYesAction = function ()
AUCTIONATOR_SHOPPING_LISTS = {}
Atr_SList.create (ZT("Recent Searches"), true);
return "Shopping lists cleared."
end
Atr_ConfirmClear_Frame:Show()
end
-------------------------------------------------------------------------------------------------------------------
-- Shopping Lists options panel
-------------------------------------------------------------------------------------------------------------------
local kShpLists_LinesToDisplay = 18
local kShpLists_LineHeight = 16
local kShpLists_SelectedIndices = {}
local kShpLists_NeedUpdate = true
local kShpLists_NumShpLists = 0
-----------------------------------------
function Atr_SetupShpListsFrame()
if (_G["Atr_ShpList1"] == nil) then
local line, n;
for n = 1, kShpLists_LinesToDisplay do
local y = -10 - ((n-1)*kShpLists_LineHeight);
line = CreateFrame("BUTTON", "Atr_ShpList"..n, Atr_ShpList_Frame, "Atr_ShpListsEntryTemplate");
line:SetPoint("TOP", 0, y);
end
end
if (InterfaceOptionsFrame:GetFrameStrata() == "FULLSCREEN_DIALOG") then -- Chatter sets to FULLSCREEN_DIALOG which prevents popup from being on top
InterfaceOptionsFrame:SetFrameStrata ("HIGH")
end
kShpLists_NeedUpdate = true
end
-----------------------------------------
function Atr_ShpList_Options_Update(self, elapsed)
if (Atr_ShpList_Options_Frame:IsShown()) then
if (kShpLists_NeedUpdate or kShpLists_NumShpLists ~= #AUCTIONATOR_SHOPPING_LISTS) then
kShpLists_NeedUpdate = false
Atr_ShpLists_Display()
end
end
end
-----------------------------------------
function Atr_ShpLists_Display()
local sllist = AUCTIONATOR_SHOPPING_LISTS
kShpLists_NumShpLists = #AUCTIONATOR_SHOPPING_LISTS
local totalRows = #sllist - 1; -- minus Recents
local line; -- 1 through NN of our window to scroll
local dataOffset; -- an index into our data calculated from the scroll offset
FauxScrollFrame_Update (Atr_ShpList_ScrollFrame, totalRows, kShpLists_LinesToDisplay, 16);
for line = 1,kShpLists_LinesToDisplay do
dataOffset = line + FauxScrollFrame_GetOffset (Atr_ShpList_ScrollFrame);
local lineEntry = _G["Atr_ShpList"..line];
lineEntry:SetID (dataOffset);
if (dataOffset <= totalRows and sllist[dataOffset]) then
local lineEntry_text = _G["Atr_ShpList"..line.."_text"];
lineEntry_text:SetText (sllist[dataOffset+1].name) -- +1 to skip Recents
if (Atr_ShpLists_IsSelected (dataOffset) > 0) then
lineEntry:SetButtonState ("PUSHED", true);
else
lineEntry:SetButtonState ("NORMAL", false);
end
lineEntry:Show();
else
lineEntry:Hide();
end
end
zc.EnableDisable (Atr_ShpList_DeleteButton, #kShpLists_SelectedIndices == 1);
zc.EnableDisable (Atr_ShpList_EditButton, #kShpLists_SelectedIndices == 1);
zc.EnableDisable (Atr_ShpList_RenameButton, #kShpLists_SelectedIndices == 1);
end
-----------------------------------------
function Atr_ShpLists_IsSelected (index)
local n
for n = 1,#kShpLists_SelectedIndices do
if (kShpLists_SelectedIndices[n] == index) then
return n
end
end
return 0
end
-----------------------------------------
function Atr_ShpListsEntry_OnClick(self)
index = self:GetID()