-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuctionatorShop.lua
1111 lines (747 loc) · 24.4 KB
/
AuctionatorShop.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_SList = {}
Atr_SList.__index = Atr_SList
local SLITEMS_NUM_LINES = 15
local WEAPON = 1
local ARMOR = 2
ATR_MAXNUM_ITEMS_ON_SHOPPING_LIST = 50
local gCurrentSList
local gTempShoppingList = nil
-----------------------------------------
function Atr_ShoppingListsInit ()
if (AUCTIONATOR_SHOPPING_LISTS == nil) then
AUCTIONATOR_SHOPPING_LISTS = {};
Atr_SList.create (ZT("Recent Searches"), true);
if (zc.IsEnglishLocale()) then
local slist = Atr_SList.create ("Sample Shopping List #1");
slist:AddItem ("Greater Cosmic Essence");
slist:AddItem ("Infinite Dust");
slist:AddItem ("Dream Shard");
slist:AddItem ("Abyss Crystal");
end
end
local num = #AUCTIONATOR_SHOPPING_LISTS;
local x;
for x = 1,num do
setmetatable (AUCTIONATOR_SHOPPING_LISTS[x], Atr_SList);
end
for x = 1,num do
local slist = AUCTIONATOR_SHOPPING_LISTS[x]
if (slist.name == nil) then
slist.name = "foo"
zz ("null named shopping list found")
end
end
end
-----------------------------------------
function Atr_SList.create (name, isRecents, isTemporary)
if (name == nil) then
return
end
local slist = {};
setmetatable (slist,Atr_SList);
slist.name = name;
slist.items = {};
if (isRecents) then
slist.isRecents = 1;
end
if (isTemporary) then
gTempShoppingList = slist
else
table.insert (AUCTIONATOR_SHOPPING_LISTS, slist)
end
local x
for x = 1,#AUCTIONATOR_SHOPPING_LISTS do
local slist = AUCTIONATOR_SHOPPING_LISTS[x]
if (slist.name == nil) then
slist.name = "foo"
zz ("null named shopping list found")
end
end
table.sort (AUCTIONATOR_SHOPPING_LISTS, Atr_SortSlists);
CloseDropDownMenus();
return slist;
end
-----------------------------------------
function Atr_SortSlists (x, y)
if (x.isRecents) then return true; end;
if (y.isRecents) then return false; end;
return (string.lower(x.name) < string.lower(y.name));
end
-----------------------------------------
function Atr_SList.FindByName (name, options)
local checkTempList = (options == nil or not options.skipTempList)
if (checkTempList and gTempShoppingList and zc.StringSame (gTempShoppingList.name, name)) then
return gTempShoppingList
end
local num = #AUCTIONATOR_SHOPPING_LISTS;
local x;
for x = 1,num do
if (zc.StringSame (AUCTIONATOR_SHOPPING_LISTS[x].name, name)) then
return AUCTIONATOR_SHOPPING_LISTS[x];
end
end
end
-----------------------------------------
function Atr_SList:AddItem (itemName)
if (itemName == "" or itemName == nil) then
return;
end
if (self.isRecents) then
table.insert (self.items, 1, itemName);
while (#self.items > 50) do -- max 50 items on recents list
table.remove (self.items);
end
else
table.insert (self.items, itemName);
self.isSorted = false;
end
end
-----------------------------------------
function Atr_SList:RemoveItem (itemName)
local num = #self.items;
local n;
for n = 1,num do
if (zc.StringSame (self.items[n], itemName)) then
table.remove (self.items, n);
return;
end
end
end
-----------------------------------------
function Atr_SList:Clear ()
self.items = {}
end
-----------------------------------------
function Atr_DisplaySlist ()
if (gCurrentSList) then
gCurrentSList:DisplayX ();
end
end
-----------------------------------------
function sortSlist (x, y)
return (string.lower(x) < string.lower(y));
end
-----------------------------------------
function Atr_SList:DisplayX ()
gCurrentSList = self;
local currentPane = Atr_GetCurrentPane();
if (not (self.isRecents or self.isSorted)) then
self.isSorted = true;
table.sort (self.items, sortSlist);
end
local numrows = #self.items;
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_Hlist_ScrollFrame, numrows, SLITEMS_NUM_LINES, 16);
for line = 1,SLITEMS_NUM_LINES do
currentPane.hlistScrollOffset = FauxScrollFrame_GetOffset (Atr_Hlist_ScrollFrame);
dataOffset = line + currentPane.hlistScrollOffset;
local lineEntry = _G["AuctionatorHEntry"..line];
lineEntry:SetID(dataOffset);
local slItem = self.items[dataOffset];
if (dataOffset <= numrows and slItem) then
local lineEntry_text = _G["AuctionatorHEntry"..line.."_EntryText"];
lineEntry_text:SetText (Atr_AbbrevItemName (slItem));
if (Atr_IsShoppingListSearch (slItem)) then
lineEntry_text:SetTextColor (.7,.6,.5);
else
lineEntry_text:SetTextColor (.6,.6,.6);
end
if (currentPane.activeSearch.origSearchText ~= "" and zc.StringSame (slItem , currentPane.activeSearch.origSearchText)) then
lineEntry:SetButtonState ("PUSHED", true);
elseif (currentPane.activeSearch.searchText == "" and zc.StringSame (slItem , Atr_Search_Box:GetText())) then
lineEntry:SetButtonState ("PUSHED", true);
else
lineEntry:SetButtonState ("NORMAL", false);
end
lineEntry:Show();
else
lineEntry:Hide();
end
end
end
-----------------------------------------
function Atr_SList:FindItemIndex (itemName)
local num = #self.items;
local n;
for n = 1,num do
if (zc.StringSame (itemName, self.items[n])) then
return n;
end
end
return 0;
end
-----------------------------------------
function Atr_SList:GetNumItems ()
return #self.items
end
-----------------------------------------
function Atr_SList:GetNthItemName (n)
if (n <= #self.items) then
return self.items[n];
end
return nil;
end
-----------------------------------------
function Atr_SList:IsItemOnList (itemName)
return (self:FindItemIndex(itemName) > 0);
end
-----------------------------------------
function Atr_Search_Onclick ()
local currentPane = Atr_GetCurrentPane();
local searchText = Atr_Search_Box:GetText();
Atr_Search_Button:Disable();
Atr_Adv_Search_Button:Disable();
Atr_Buy1_Button:Disable();
Atr_AddToSListButton:Disable();
Atr_RemFromSListButton:Disable();
Atr_ClearAll();
currentPane:DoSearch (searchText);
Atr_ClearHistory();
end
-----------------------------------------
function Atr_AddToRecents (searchText)
local recentsList = AUCTIONATOR_SHOPPING_LISTS[1];
if (recentsList) then
local isRecentsShown = (gCurrentSList == recentsList);
local n = recentsList:FindItemIndex(searchText);
if (n > 14 or (not isRecentsShown and n > 0)) then
table.remove (recentsList.items, n);
end
n = recentsList:FindItemIndex(searchText);
if (n == 0) then
recentsList:AddItem (searchText);
end
if (isRecentsShown) then
FauxScrollFrame_SetOffset (Atr_Hlist_ScrollFrame, 0);
Atr_Hlist_ScrollFrame:SetVerticalScroll(0);
end
end
end
-----------------------------------------
function Atr_SetSearchText (searchText)
Atr_Search_Box:SetText (searchText)
Atr_Search_Box:ClearFocus()
end
-----------------------------------------
function Atr_Shop_OnFinishScan ()
local currentPane = Atr_GetCurrentPane();
local searchText = currentPane.activeSearch.origSearchText;
Atr_SetSearchText (searchText);
local shplist = Atr_GetShoppingListFromSearchText (searchText)
if (shplist and shplist == gTempShoppingList) then
return -- don't add to recents list
end
Atr_AddToRecents(searchText)
if (#currentPane.activeScan.sortedData > 0) then
currentPane.currIndex = 1;
end
currentPane.UINeedsUpdate = true;
Atr_Search_Button:Enable();
Atr_Adv_Search_Button:Enable();
end
-----------------------------------------
function Atr_DropDownSL_OnShow (self)
local curIndex = 1;
if (gCurrentSList) then
local x;
for x = 1,#AUCTIONATOR_SHOPPING_LISTS do
if (gCurrentSList == AUCTIONATOR_SHOPPING_LISTS[x]) then
curIndex = x;
break;
end
end
end
UIDropDownMenu_Initialize (self, Atr_DropDownSL_Initialize);
UIDropDownMenu_SetSelectedValue (self, curIndex);
UIDropDownMenu_SetWidth (150, self);
UIDropDownMenu_JustifyText ("CENTER", self);
end
-----------------------------------------
function Atr_DropDownSL_Initialize(self)
local num = #AUCTIONATOR_SHOPPING_LISTS;
local x;
for x = 1,num do
local slist = AUCTIONATOR_SHOPPING_LISTS[x];
Atr_Dropdown_AddPick (self, slist.name, x, Atr_DropDownSL_OnClick);
end
end
-----------------------------------------
function Atr_DropDownSL_OnClick(info)
UIDropDownMenu_SetSelectedValue (Atr_DropDownSL, this.value);
gCurrentSList = AUCTIONATOR_SHOPPING_LISTS[this.value];
Atr_SetUINeedsUpdate();
end
-----------------------------------------
function Atr_SEntryOnClick (self)
local entryIndex = self:GetID();
local itemName = gCurrentSList.items[entryIndex];
if (itemName) then
Atr_SetSearchText (itemName);
if (IsAltKeyDown()) then
Atr_GetCurrentPane():ClearSearch();
Atr_RemFromSListOnClick();
else
Atr_Search_Onclick ();
end
Atr_Shop_UpdateUI();
end
-- gCurrentSList:DisplayX(); -- for the highlight
end
-----------------------------------------
function Atr_RenameSList(index, newname)
if (newname == nil or newname == "") then
return
end
local oldname = AUCTIONATOR_SHOPPING_LISTS[index].name
AUCTIONATOR_SHOPPING_LISTS[index].name = newname
-- in case it's the currently selected one
local curIndex = UIDropDownMenu_GetSelectedValue(Atr_DropDownSL)
if (curIndex and curIndex > 0) then
UIDropDownMenu_SetText (AUCTIONATOR_SHOPPING_LISTS[curIndex].name, Atr_DropDownSL) -- needed to fix bug in UIDropDownMenu
end
-- run thru all the lists and fix up any lists that contain this list
local n
for n = 1, #AUCTIONATOR_SHOPPING_LISTS do
local slist = AUCTIONATOR_SHOPPING_LISTS[n]
local foundIndex = slist:FindItemIndex("{ "..oldname.." }")
if (foundIndex > 0) then
slist.items[foundIndex] = "{ "..newname.." }"
end
if (n == curIndex) then
slist:DisplayX()
Atr_SetUINeedsUpdate();
end
end
end
-----------------------------------------
local function FinishCreateNewSList(text)
local slist = Atr_SList.create(text);
local num = #AUCTIONATOR_SHOPPING_LISTS;
local n;
for n = 1,num do
if (AUCTIONATOR_SHOPPING_LISTS[n] == slist) then
UIDropDownMenu_SetSelectedValue(Atr_DropDownSL, n);
UIDropDownMenu_SetText (text, Atr_DropDownSL); -- needed to fix bug in UIDropDownMenu
slist:DisplayX();
Atr_SetUINeedsUpdate();
break;
end
end
end
-----------------------------------------
StaticPopupDialogs["ATR_NEW_SHOPPING_LIST"] = {
text = "",
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = 1,
maxLetters = 32,
OnAccept = function()
local editbox = _G[this:GetParent():GetName().."EditBox"]
local text = editbox:GetText();
FinishCreateNewSList (text);
end,
EditBoxOnEnterPressed = function()
local editbox = _G[this:GetParent():GetName().."EditBox"]
local text = editbox:GetText();
FinishCreateNewSList (text);
this:GetParent():Hide();
end,
OnShow = function()
local editbox = _G[this:GetName().."EditBox"]
editbox:SetText("");
editbox:SetFocus();
end,
timeout = 0,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
};
-----------------------------------------
function Atr_NewSlist_OnClick ()
StaticPopupDialogs["ATR_NEW_SHOPPING_LIST"].text = ZT("Name for your new shopping list");
StaticPopup_Show("ATR_NEW_SHOPPING_LIST");
end
-----------------------------------------
function Atr_MngSLists_OnClick ()
InterfaceOptionsFrame_OpenToFrame ("Shopping Lists");
local slist
local currentPane = Atr_GetCurrentPane()
if (gCurrentSList) then
if (not gCurrentSList.isRecents) then
slist = gCurrentSList
elseif (currentPane and currentPane.activeSearch) then
local searchText = strtrim (currentPane.activeSearch.searchText, "{}")
slist = Atr_SList.FindByName (strtrim (searchText))
end
end
if (slist) then
local n
for n=2,#AUCTIONATOR_SHOPPING_LISTS do
if (AUCTIONATOR_SHOPPING_LISTS[n] == slist) then
Atr_ShpListsEntry_Select(n)
Atr_ShpListsEntry_ScrollToShow(n)
return
end
end
end
end
-----------------------------------------
function Atr_AddToSListOnClick ()
local currentPane = Atr_GetCurrentPane();
if (gCurrentSList) then
if (#gCurrentSList.items >= ATR_MAXNUM_ITEMS_ON_SHOPPING_LIST) then
Atr_Error_Text:SetText (string.format (ZT("You may have no more than\n\n%d items on a shopping list."), ATR_MAXNUM_ITEMS_ON_SHOPPING_LIST));
Atr_Error_Frame.withMask = 1;
Atr_Error_Frame:Show ();
else
gCurrentSList:AddItem (Atr_Search_Box:GetText());
Atr_SetUINeedsUpdate();
end
end
end
-----------------------------------------
function Atr_RemFromSListOnClick ()
local currentPane = Atr_GetCurrentPane();
if (gCurrentSList) then
gCurrentSList:RemoveItem (Atr_Search_Box:GetText());
Atr_SetUINeedsUpdate();
end
end
-----------------------------------------
function Atr_SrchSList_OnClick ()
if (gCurrentSList) then
local searchText = "{ "..gCurrentSList.name.." }";
Atr_SetSearchText(searchText)
Atr_Search_Onclick()
end
end
-----------------------------------------
function Atr_ShpList_Validate ()
if (gCurrentSList and getmetatable (gCurrentSList) ~= Atr_SList) then
zc.msg_badErr ("gCurrentSList bad metatable; type gCurrentSList: ", type (gCurrentSList))
end
zz ("num shopping lists: ", #AUCTIONATOR_SHOPPING_LISTS)
local x, slist
for x = 1,#AUCTIONATOR_SHOPPING_LISTS do
slist = AUCTIONATOR_SHOPPING_LISTS[x]
if (slist == nil) then
zz ("slist["..x.."] is nil")
elseif (getmetatable (slist) ~= Atr_SList) then
zc.msg_badErr ("slist["..x.."] bad metatable; type: ", type (slist))
else
zz ("slist["..x.."] is valid")
end
end
end
-----------------------------------------
function Atr_Shop_UpdateUI ()
local currentPane = Atr_GetCurrentPane();
Atr_AddToSListButton:Disable();
Atr_RemFromSListButton:Disable();
Atr_SrchSListButton:Disable();
if (gCurrentSList == nil) then
Atr_ShpList_SetToRecents()
end
if (getmetatable (gCurrentSList) ~= Atr_SList) then
Atr_ShpList_Validate()
end
if (gCurrentSList and getmetatable (gCurrentSList) == Atr_SList) then -- somehow gCurrentSList:DisplayX is sometimes nil - not sure why yet
gCurrentSList:DisplayX ();
local iName = Atr_Search_Box:GetText();
if (gCurrentSList:IsItemOnList (iName)) then
Atr_RemFromSListButton:Enable();
elseif (iName ~= "" and iName ~= nil and gCurrentSList ~= AUCTIONATOR_SHOPPING_LISTS[1]) then
Atr_AddToSListButton:Enable();
end
if (gCurrentSList ~= AUCTIONATOR_SHOPPING_LISTS[1]) then
Atr_SrchSListButton:Enable();
end
end
Atr_SaveThisList_Button:Hide()
Atr_Back_Button:Hide()
if (currentPane.activeSearch:NumScans() > 1 and not currentPane:IsScanNil()) then
Atr_Back_Button:Show()
elseif (gTempShoppingList) then
local listWithSameName = Atr_SList.FindByName (gTempShoppingList.name, { skipTempList=true } )
if (gTempShoppingList == currentPane.activeSearch.shplist and #gTempShoppingList.items > 1 and listWithSameName == nil) then
Atr_SaveThisList_Button:Show()
end
end
end
-----------------------------------------
function Atr_ShpList_SetToRecents()
gCurrentSList = AUCTIONATOR_SHOPPING_LISTS[1]
UIDropDownMenu_SetSelectedValue(Atr_DropDownSL, 1);
UIDropDownMenu_SetText (gCurrentSList.name, Atr_DropDownSL); -- needed to fix bug in UIDropDownMenu
end
-----------------------------------------
function Atr_Onclick_SaveTempList()
if (gTempShoppingList) then
table.insert (AUCTIONATOR_SHOPPING_LISTS, gTempShoppingList)
table.sort (AUCTIONATOR_SHOPPING_LISTS, Atr_SortSlists);
Atr_ShpList_SetToRecents()
Atr_AddToRecents("{ "..gTempShoppingList.name.." }") -- nice visual confirmation
gTempShoppingList = nil
Atr_SetUINeedsUpdate()
end
end
-----------------------------------------
function Atr_Adv_Search_Onclick ()
local searchText = Atr_Search_Box:GetText();
Atr_Adv_Search_Dialog:Show();
if (Atr_IsCompoundSearch (searchText)) then
local queryString, itemClass, itemSubclass, minLevel, maxLevel, minItemLevel, maxItemLevel = Atr_ParseCompoundSearch (searchText);
Atr_AS_Searchtext:SetText (queryString);
Atr_Dropdown_Refresh (Atr_ASDD_Class);
UIDropDownMenu_SetSelectedValue (Atr_ASDD_Class, itemClass);
Atr_Dropdown_Refresh (Atr_ASDD_Subclass);
UIDropDownMenu_SetSelectedValue (Atr_ASDD_Subclass, itemSubclass);
if (minLevel == nil) then minLevel = ""; end
if (maxLevel == nil) then maxLevel = ""; end
Atr_AS_Minlevel:SetText (minLevel);
Atr_AS_Maxlevel:SetText (maxLevel);
if (minItemLevel == nil) then minItemLevel = ""; end
if (maxItemLevel == nil) then maxItemLevel = ""; end
Atr_AS_MinItemlevel:SetText (minItemLevel);
Atr_AS_MaxItemlevel:SetText (maxItemLevel);
else
Atr_AS_Searchtext:SetText (searchText);
end
end
-----------------------------------------
function Atr_ASDD_Class_OnShow (self)
UIDropDownMenu_Initialize (self, Atr_ASDD_Class_Initialize);
UIDropDownMenu_SetSelectedValue (self, 0);
end
-----------------------------------------
function Atr_ASDD_Class_Initialize (self)
local itemClasses = Atr_GetAuctionClasses();
local n;
Atr_Dropdown_AddPick (Atr_ASDD_Subclass, "-------", 0);
if (#itemClasses > 0) then
local text;
for n, text in pairs(itemClasses) do
Atr_Dropdown_AddPick (self, text, n, Atr_ASDD_Class_OnClick);
end
end
end
-----------------------------------------
function Atr_ASDD_Class_OnClick (info)
UIDropDownMenu_SetSelectedValue(Atr_ASDD_Class, this.value);
Atr_Dropdown_Refresh (Atr_ASDD_Subclass);
end
-----------------------------------------
function Atr_ASDD_Subclass_OnShow (self)
UIDropDownMenu_Initialize (self, Atr_ASDD_Subclass_Initialize);
UIDropDownMenu_SetSelectedValue (self, 0);
end
-----------------------------------------
function Atr_ASDD_Subclass_Initialize (self)
local itemClass = UIDropDownMenu_GetSelectedValue (Atr_ASDD_Class);
Atr_Dropdown_AddPick (Atr_ASDD_Subclass, "-------", 0);
if (itemClass) then
local itemSubclasses = Atr_GetAuctionSubclasses(itemClass);
local n;
if (#itemSubclasses > 0) then
local text;
for n, text in pairs(itemSubclasses) do
Atr_Dropdown_AddPick (Atr_ASDD_Subclass, text, n);
end
end
end
if (itemClass and (itemClass == WEAPON or itemClass == ARMOR)) then
Atr_AS_ILevRange_Label:Show()
Atr_AS_ILevRange_Dash:Show()
Atr_AS_MinItemlevel:Show()
Atr_AS_MaxItemlevel:Show()
else
Atr_AS_ILevRange_Label:Hide()
Atr_AS_ILevRange_Dash:Hide()
Atr_AS_MinItemlevel:Hide()
Atr_AS_MaxItemlevel:Hide()
end
end
-----------------------------------------
function Atr_Adv_Search_Reset()
Atr_AS_Searchtext:SetText ("");
Atr_Dropdown_Refresh (Atr_ASDD_Class);
UIDropDownMenu_SetSelectedValue (Atr_ASDD_Class, 0);
Atr_Dropdown_Refresh (Atr_ASDD_Subclass);
UIDropDownMenu_SetSelectedValue (Atr_ASDD_Subclass, 0);
Atr_AS_Minlevel:SetText ("");
Atr_AS_Maxlevel:SetText ("");
Atr_AS_MinItemlevel:SetText ("");
Atr_AS_MaxItemlevel:SetText ("");
end
-----------------------------------------
function Atr_Adv_Search_Do()
local itemClass = UIDropDownMenu_GetSelectedValue (Atr_ASDD_Class);
local itemSublass = UIDropDownMenu_GetSelectedValue (Atr_ASDD_Subclass);
local itemClassList = Atr_GetAuctionClasses();
local itemSubclassList = Atr_GetAuctionSubclasses(itemClass);
local searchText = itemClassList[itemClass];
if (searchText == nil) then
zc.msg_anm ("|cffff0000Error getting itemClass from menu|r. itemClass = ", itemClass)
Atr_Adv_Search_Dialog:Hide()
return
end
if (itemSublass > 0) then
searchText = searchText.."/"..itemSubclassList[itemSublass];
end
local minLevel = Atr_AS_Minlevel:GetNumber ();
local maxLevel = Atr_AS_Maxlevel:GetNumber ();
local text = Atr_AS_Searchtext:GetText();
if (maxLevel > 0 and minLevel == 0) then
minLevel = 1;
end
if (minLevel > 0) then searchText = searchText.."/"..minLevel; end
if (maxLevel > 0) then searchText = searchText.."/"..maxLevel; end
if (itemClass and (itemClass == WEAPON or itemClass == ARMOR)) then
local minItemLevel = Atr_AS_MinItemlevel:GetNumber()
local maxItemLevel = Atr_AS_MaxItemlevel:GetNumber()
if (minItemLevel > 0) then searchText = searchText.."/i"..minItemLevel; end
if (maxItemLevel > 0) then searchText = searchText.."/i"..maxItemLevel; end
end
if (text ~= "") then searchText = searchText.."/"..text; end
-- handle category only search
if (not zc.StringContains (searchText, "/")) then
searchText = searchText.."/"
end
Atr_SetSearchText(searchText);
Atr_Search_Onclick();
Atr_Adv_Search_Dialog:Hide();
end
-----------------------------------------
local gSLgather
local gSuspendGathering = false
local gSLpermittedUser
local gShpListShareRequester
local gRequestSentTime = 0
-----------------------------------------
StaticPopupDialogs["ATR_SL_REQUEST_SHARING"] = {
text = "",
button1 = "Allow",
button2 = "Deny",
OnAccept = function(self)
gSLpermittedUser = gShpListShareRequester
Atr_Send_ShoppingListData (gShpListShareRequester)
SendAddonMessage ("ATR", "SLREQ_", "WHISPER", gShpListShareRequester)
return
end,
OnCancel = function(self)
gSLpermittedUser = nil
SendAddonMessage ("ATR", "SLPERM_DENIED_", "WHISPER", gShpListShareRequester)
return
end,
OnShow = function(self)
local s = string.format (ZT("|cffffbb00%s|r\nwould like to share Auctionator shopping lists."), gShpListShareRequester);
_G[this:GetName().."Text"]:SetText(s);
end,
timeout = 20,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
};
-----------------------------------------
StaticPopupDialogs["ATR_SL_REQUEST_DENIED"] = {
text = "",
button1 = "OK",
OnAccept = function(self)
gSLpermittedUser = nil
return
end,
OnShow = function(self)
local uname = zc.Val (gSLpermittedUser, "The player")
gSLpermittedUser = nil
local s = string.format (ZT("|cffffbb00%s|r\nhas turned down your request\nto share shopping lists."), uname);
_G[this:GetName().."Text"]:SetText(s);
end,
timeout = 0,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
};
-----------------------------------------
function Atr_OnChatMsgAddon_ShoppingListCmds (prefix, msg, distribution, sender)