vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Auctioneer Addon for World of Warcraft(tm).
3 Version: 3.9.0.1000 (Kangaroo)
4 Revision: $Id: AuctionFrameSearch.lua 980 2006-08-31 05:29:48Z mentalpower $
5  
6 Auctioneer Search Auctions tab
7  
8 License:
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13  
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18  
19 You should have received a copy of the GNU General Public License
20 along with this program(see GPL.txt); if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 --]]
23  
24 local TIME_LEFT_NAMES =
25 {
26 AUCTION_TIME_LEFT1, -- Short
27 AUCTION_TIME_LEFT2, -- Medium
28 AUCTION_TIME_LEFT3, -- Long
29 AUCTION_TIME_LEFT4 -- Very Long
30 };
31  
32 local AUCTION_STATUS_UNKNOWN = 1;
33 local AUCTION_STATUS_HIGH_BIDDER = 2;
34 local AUCTION_STATUS_NOT_FOUND = 3;
35 local AUCTION_STATUS_BIDDING = 4;
36  
37 -------------------------------------------------------------------------------
38 -------------------------------------------------------------------------------
39 function AuctionFrameSearch_OnLoad()
40 -- Methods
41 this.SearchBids = AuctionFrameSearch_SearchBids;
42 this.SearchBuyouts = AuctionFrameSearch_SearchBuyouts;
43 this.SearchCompetition = AuctionFrameSearch_SearchCompetition;
44 this.SearchPlain = AuctionFrameSearch_SearchPlain;
45 this.SelectResultByIndex = AuctionFrameSearch_SelectResultByIndex;
46  
47 -- Controls
48 this.savedSearchDropDown = getglobal(this:GetName().."SavedSearchDropDown");
49 this.searchDropDown = getglobal(this:GetName().."SearchDropDown");
50 this.bidFrame = getglobal(this:GetName().."Bid");
51 this.buyoutFrame = getglobal(this:GetName().."Buyout");
52 this.competeFrame = getglobal(this:GetName().."Compete");
53 this.plainFrame = getglobal(this:GetName().."Plain");
54 this.resultsList = getglobal(this:GetName().."List");
55 this.bidButton = getglobal(this:GetName().."BidButton");
56 this.buyoutButton = getglobal(this:GetName().."BuyoutButton");
57 this.pendingBidStatusText = getglobal(this:GetName().."PendingBidStatusText");
58  
59 -- Data members
60 this.results = {};
61 this.resultsType = nil;
62 this.selectedResult = nil;
63  
64 -- Initialize the Search drop down
65 AuctioneerDropDownMenu_Initialize(this.searchDropDown, AuctionFrameSearch_SearchDropDown_Initialize);
66 AuctionFrameSearch_SearchDropDownItem_SetSelectedID(this.searchDropDown, 1);
67  
68 -- Configure the logical columns
69 this.logicalColumns =
70 {
71 Quantity =
72 {
73 title = _AUCT("UiQuantityHeader");
74 dataType = "Number";
75 valueFunc = (function(record) return record.count end);
76 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
77 compareAscendingFunc = (function(record1, record2) return record1.count < record2.count end);
78 compareDescendingFunc = (function(record1, record2) return record1.count > record2.count end);
79 },
80 Name =
81 {
82 title = _AUCT("UiNameHeader");
83 dataType = "String";
84 valueFunc = (function(record) return record.name end);
85 colorFunc = AuctionFrameSearch_GetItemColor;
86 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
87 compareAscendingFunc = (function(record1, record2) return record1.name < record2.name end);
88 compareDescendingFunc = (function(record1, record2) return record1.name > record2.name end);
89 },
90 TimeLeft =
91 {
92 title = _AUCT("UiTimeLeftHeader");
93 dataType = "String";
94 valueFunc = (function(record) return Auctioneer.Util.GetTimeLeftString(record.timeLeft) end);
95 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
96 compareAscendingFunc = (function(record1, record2) return record1.timeLeft < record2.timeLeft end);
97 compareDescendingFunc = (function(record1, record2) return record1.timeLeft > record2.timeLeft end);
98 },
99 Bid =
100 {
101 title = _AUCT("UiBidHeader");
102 dataType = "Money";
103 valueFunc = (function(record) return record.bid end);
104 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
105 compareAscendingFunc = (function(record1, record2) return record1.bid < record2.bid end);
106 compareDescendingFunc = (function(record1, record2) return record1.bid > record2.bid end);
107 },
108 BidPer =
109 {
110 title = _AUCT("UiBidPerHeader");
111 dataType = "Money";
112 valueFunc = (function(record) return record.bidPer end);
113 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
114 compareAscendingFunc = (function(record1, record2) return record1.bidPer < record2.bidPer end);
115 compareDescendingFunc = (function(record1, record2) return record1.bidPer > record2.bidPer end);
116 },
117 Buyout =
118 {
119 title = _AUCT("UiBuyoutHeader");
120 dataType = "Money";
121 valueFunc = (function(record) return record.buyout end);
122 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
123 compareAscendingFunc = (function(record1, record2) return record1.buyout < record2.buyout end);
124 compareDescendingFunc = (function(record1, record2) return record1.buyout > record2.buyout end);
125 },
126 BuyoutPer =
127 {
128 title = _AUCT("UiBuyoutPerHeader");
129 dataType = "Money";
130 valueFunc = (function(record) return record.buyoutPer end);
131 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
132 compareAscendingFunc = (function(record1, record2) return record1.buyoutPer < record2.buyoutPer end);
133 compareDescendingFunc = (function(record1, record2) return record1.buyoutPer > record2.buyoutPer end);
134 },
135 Profit =
136 {
137 title = _AUCT("UiProfitHeader");
138 dataType = "Money";
139 valueFunc = (function(record) return record.profit end);
140 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
141 compareAscendingFunc = (function(record1, record2) return record1.profit < record2.profit end);
142 compareDescendingFunc = (function(record1, record2) return record1.profit > record2.profit end);
143 },
144 ProfitPer =
145 {
146 title = _AUCT("UiProfitPerHeader");
147 dataType = "Money";
148 valueFunc = (function(record) return record.profitPer end);
149 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
150 compareAscendingFunc = (function(record1, record2) return record1.profitPer < record2.profitPer end);
151 compareDescendingFunc = (function(record1, record2) return record1.profitPer > record2.profitPer end);
152 },
153 PercentLess =
154 {
155 title = _AUCT("UiPercentLessHeader");
156 dataType = "Number";
157 valueFunc = (function(record) return record.percentLess end);
158 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
159 compareAscendingFunc = (function(record1, record2) return record1.percentLess < record2.percentLess end);
160 compareDescendingFunc = (function(record1, record2) return record1.percentLess > record2.percentLess end);
161 },
162 ItemLevel =
163 {
164 title = _AUCT("UiItemLevelHeader");
165 dataType = "Number";
166 valueFunc = (function(record) return record.level end);
167 alphaFunc = AuctionFrameSearch_GetAuctionAlpha;
168 compareAscendingFunc = (function(record1, record2) return record1.level < record2.level end);
169 compareDescendingFunc = (function(record1, record2) return record1.level > record2.level end);
170 },
171 };
172  
173 -- Configure the bid search physical columns
174 this.bidSearchPhysicalColumns =
175 {
176 {
177 width = 50;
178 logicalColumn = this.logicalColumns.Quantity;
179 logicalColumns = { this.logicalColumns.Quantity };
180 sortAscending = true;
181 },
182 {
183 width = 160;
184 logicalColumn = this.logicalColumns.Name;
185 logicalColumns = { this.logicalColumns.Name };
186 sortAscending = true;
187 },
188 {
189 width = 90;
190 logicalColumn = this.logicalColumns.TimeLeft;
191 logicalColumns = { this.logicalColumns.TimeLeft };
192 sortAscending = true;
193 },
194 {
195 width = 130;
196 logicalColumn = this.logicalColumns.Bid;
197 logicalColumns =
198 {
199 this.logicalColumns.Bid,
200 this.logicalColumns.BidPer
201 };
202 sortAscending = true;
203 },
204 {
205 width = 130;
206 logicalColumn = this.logicalColumns.Profit;
207 logicalColumns =
208 {
209 this.logicalColumns.Profit,
210 this.logicalColumns.ProfitPer,
211 this.logicalColumns.Buyout,
212 this.logicalColumns.BuyoutPer
213 };
214 sortAscending = true;
215 },
216 {
217 width = 50;
218 logicalColumn = this.logicalColumns.PercentLess;
219 logicalColumns =
220 {
221 this.logicalColumns.PercentLess
222 };
223 sortAscending = true;
224 },
225 };
226  
227 -- Configure the buyout search physical columns
228 this.buyoutSearchPhysicalColumns =
229 {
230 {
231 width = 50;
232 logicalColumn = this.logicalColumns.Quantity;
233 logicalColumns = { this.logicalColumns.Quantity };
234 sortAscending = true;
235 },
236 {
237 width = 250;
238 logicalColumn = this.logicalColumns.Name;
239 logicalColumns = { this.logicalColumns.Name };
240 sortAscending = true;
241 },
242 {
243 width = 130;
244 logicalColumn = this.logicalColumns.Buyout;
245 logicalColumns =
246 {
247 this.logicalColumns.Bid,
248 this.logicalColumns.BidPer,
249 this.logicalColumns.Buyout,
250 this.logicalColumns.BuyoutPer
251 };
252 sortAscending = true;
253 },
254 {
255 width = 130;
256 logicalColumn = this.logicalColumns.Profit;
257 logicalColumns =
258 {
259 this.logicalColumns.Bid,
260 this.logicalColumns.BidPer,
261 this.logicalColumns.Profit,
262 this.logicalColumns.ProfitPer
263 };
264 sortAscending = true;
265 },
266 {
267 width = 50;
268 logicalColumn = this.logicalColumns.PercentLess;
269 logicalColumns =
270 {
271 this.logicalColumns.PercentLess
272 };
273 sortAscending = true;
274 },
275 };
276  
277 -- Configure the compete search physical columns
278 this.competeSearchPhysicalColumns =
279 {
280 {
281 width = 50;
282 logicalColumn = this.logicalColumns.Quantity;
283 logicalColumns = { this.logicalColumns.Quantity };
284 sortAscending = true;
285 },
286 {
287 width = 250;
288 logicalColumn = this.logicalColumns.Name;
289 logicalColumns = { this.logicalColumns.Name };
290 sortAscending = true;
291 },
292 {
293 width = 130;
294 logicalColumn = this.logicalColumns.Bid;
295 logicalColumns =
296 {
297 this.logicalColumns.Bid,
298 this.logicalColumns.BidPer
299 };
300 sortAscending = true;
301 },
302 {
303 width = 130;
304 logicalColumn = this.logicalColumns.Buyout;
305 logicalColumns =
306 {
307 this.logicalColumns.Buyout,
308 this.logicalColumns.BuyoutPer
309 };
310 sortAscending = true;
311 },
312 {
313 width = 50;
314 logicalColumn = this.logicalColumns.PercentLess;
315 logicalColumns =
316 {
317 this.logicalColumns.PercentLess
318 };
319 sortAscending = true;
320 },
321 };
322  
323 -- Configure the plain search physical columns
324 this.plainSearchPhysicalColumns =
325 {
326 {
327 width = 50;
328 logicalColumn = this.logicalColumns.Quantity;
329 logicalColumns = { this.logicalColumns.Quantity };
330 sortAscending = true;
331 },
332 {
333 width = 160;
334 logicalColumn = this.logicalColumns.Name;
335 logicalColumns = { this.logicalColumns.Name };
336 sortAscending = true;
337 },
338 {
339 width = 90;
340 logicalColumn = this.logicalColumns.TimeLeft;
341 logicalColumns = { this.logicalColumns.TimeLeft };
342 sortAscending = true;
343 },
344 {
345 width = 130;
346 logicalColumn = this.logicalColumns.Bid;
347 logicalColumns =
348 {
349 this.logicalColumns.Bid,
350 this.logicalColumns.BidPer,
351 this.logicalColumns.Buyout,
352 this.logicalColumns.BuyoutPer
353 };
354 sortAscending = true;
355 },
356 {
357 width = 130;
358 logicalColumn = this.logicalColumns.Buyout;
359 logicalColumns =
360 {
361 this.logicalColumns.Profit,
362 this.logicalColumns.ProfitPer,
363 this.logicalColumns.Buyout,
364 this.logicalColumns.BuyoutPer
365 };
366 sortAscending = true;
367 },
368 {
369 width = 50;
370 logicalColumn = this.logicalColumns.PercentLess;
371 logicalColumns =
372 {
373 this.logicalColumns.PercentLess,
374 this.logicalColumns.ItemLevel
375 };
376 sortAscending = true;
377 },
378 };
379  
380  
381 -- Initialize the list to show nothing at first.
382 ListTemplate_Initialize(this.resultsList, this.results, this.results);
383 this:SelectResultByIndex(nil);
384 end
385  
386 -------------------------------------------------------------------------------
387 -------------------------------------------------------------------------------
388 function AuctionFrameSearch_OnShow()
389 AuctionFrameSearch_UpdatePendingBidStatus(this);
390 end
391  
392 -------------------------------------------------------------------------------
393 -------------------------------------------------------------------------------
394 AUCTIONEER_SEARCH_TYPES = {}
395 function AuctionFrameSearch_SearchDropDown_Initialize()
396 local dropdown = this:GetParent();
397 local frame = dropdown:GetParent();
398  
399 AUCTIONEER_SEARCH_TYPES[1] = _AUCT("UiSearchTypeBids");
400 AUCTIONEER_SEARCH_TYPES[2] = _AUCT("UiSearchTypeBuyouts");
401 AUCTIONEER_SEARCH_TYPES[3] = _AUCT("UiSearchTypeCompetition");
402 AUCTIONEER_SEARCH_TYPES[4] = _AUCT("UiSearchTypePlain");
403  
404 for i=1, 4 do
405 UIDropDownMenu_AddButton({
406 text = AUCTIONEER_SEARCH_TYPES[i],
407 func = AuctionFrameSearch_SearchDropDownItem_OnClick,
408 owner = dropdown
409 })
410 end
411 end
412  
413 -------------------------------------------------------------------------------
414 -------------------------------------------------------------------------------
415 function AuctionFrameSearch_MinQualityDropDown_Initialize()
416 local dropdown = this:GetParent();
417 local frame = dropdown:GetParent();
418  
419 for i=0, 6 do
420 UIDropDownMenu_AddButton({
421 text = getglobal("ITEM_QUALITY"..i.."_DESC"),
422 func = AuctionFrameSearch_MinQualityDropDownItem_OnClick,
423 value = i,
424 owner = dropdown
425 });
426 end
427 end
428  
429 -------------------------------------------------------------------------------
430 -------------------------------------------------------------------------------
431 function AuctionFrameSearch_SavedSearchDropDownItem_OnClick()
432 local index = this:GetID();
433 local dropdown = this.owner;
434 local frame = dropdown:GetParent();
435 local frameName = frame:GetName();
436 local text = "";
437  
438 if (index > 1) then
439 text = this.value
440 local searchData = AuctionConfig.SavedSearches[text];
441 local searchParams = Auctioneer.Util.Split(searchData, "\t");
442  
443 local searchType = tonumber(searchParams[1])
444 getglobal(frameName.."SearchDropDown").selectedID = searchType;
445 getglobal(frameName.."SearchDropDownText"):SetText(AUCTIONEER_SEARCH_TYPES[searchType]);
446  
447 frame.bidFrame:Hide();
448 frame.buyoutFrame:Hide();
449 frame.competeFrame:Hide();
450 frame.plainFrame:Hide();
451 if (searchType == 1) then
452 -- Bid search
453 MoneyInputFrame_SetCopper(getglobal(frameName.."BidMinProfit"), tonumber(searchParams[2]))
454  
455 getglobal(frameName.."BidMinPercentLessEdit"):SetText(searchParams[3])
456  
457 local timeLeft = tonumber(searchParams[4]) or 2
458 AuctioneerDropDownMenu_Initialize(getglobal(frameName.."BidTimeLeftDropDown"), AuctionFrameSearch_TimeLeftDropDown_Initialize);
459 AuctioneerDropDownMenu_SetSelectedID(getglobal(frameName.."BidTimeLeftDropDown"), timeLeft);
460  
461 local catid = tonumber(searchParams[5]) or 1
462 local catName = ""
463 if (AuctionConfig.classes[catid-1]) then catName = AuctionConfig.classes[catid-1].name end
464 AuctioneerDropDownMenu_Initialize(getglobal(frameName.."BidCategoryDropDown"), AuctionFrameSearch_CategoryDropDown_Initialize);
465 AuctioneerDropDownMenu_SetSelectedID(getglobal(frameName.."BidCategoryDropDown"), catid);
466  
467 local quality = tonumber(searchParams[6]) or 1
468 AuctioneerDropDownMenu_Initialize(getglobal(frameName.."BidMinQualityDropDown"), AuctionFrameSearch_MinQualityDropDown_Initialize);
469 AuctioneerDropDownMenu_SetSelectedID(getglobal(frameName.."BidMinQualityDropDown"), quality);
470  
471 getglobal(frameName.."BidSearchEdit"):SetText(searchParams[7])
472  
473 frame.bidFrame:Show();
474 elseif (searchType == 2) then
475 -- Buyout search
476 MoneyInputFrame_SetCopper(getglobal(frameName.."BuyoutMinProfit"), tonumber(searchParams[2]))
477  
478 getglobal(frameName.."BuyoutMinPercentLessEdit"):SetText(searchParams[3])
479  
480 local catid = tonumber(searchParams[4]) or 1
481 local catName = ""
482 if (AuctionConfig.classes[catid-1]) then catName = AuctionConfig.classes[catid-1].name end
483 AuctioneerDropDownMenu_Initialize(getglobal(frameName.."BuyoutCategoryDropDown"), AuctionFrameSearch_CategoryDropDown_Initialize);
484 AuctioneerDropDownMenu_SetSelectedID(getglobal(frameName.."BuyoutCategoryDropDown"), catid);
485  
486 local quality = tonumber(searchParams[5]) or 1
487 AuctioneerDropDownMenu_Initialize(getglobal(frameName.."BuyoutMinQualityDropDown"), AuctionFrameSearch_MinQualityDropDown_Initialize);
488 AuctioneerDropDownMenu_SetSelectedID(getglobal(frameName.."BuyoutMinQualityDropDown"), quality);
489  
490 getglobal(frameName.."BuyoutSearchEdit"):SetText(searchParams[6])
491  
492 frame.buyoutFrame:Show();
493 elseif (searchType == 3) then
494 -- Compete search
495 MoneyInputFrame_SetCopper(getglobal(frameName.."CompeteUndercut"), tonumber(searchParams[2]))
496  
497 frame.competeFrame:Show();
498 elseif (searchType == 4) then
499 -- Plain search
500 MoneyInputFrame_SetCopper(getglobal(frameName.."PlainMaxPrice"), tonumber(searchParams[2]))
501  
502 local catid = tonumber(searchParams[3]) or 1
503 local catName = ""
504 if (AuctionConfig.classes[catid-1]) then catName = AuctionConfig.classes[catid-1].name end
505 AuctioneerDropDownMenu_Initialize(getglobal(frameName.."PlainCategoryDropDown"), AuctionFrameSearch_CategoryDropDown_Initialize);
506 AuctioneerDropDownMenu_SetSelectedID(getglobal(frameName.."PlainCategoryDropDown"), catid);
507  
508 local quality = tonumber(searchParams[4]) or 1
509 AuctioneerDropDownMenu_Initialize(getglobal(frameName.."PlainMinQualityDropDown"), AuctionFrameSearch_MinQualityDropDown_Initialize);
510 AuctioneerDropDownMenu_SetSelectedID(getglobal(frameName.."PlainMinQualityDropDown"), quality);
511  
512 getglobal(frameName.."PlainSearchEdit"):SetText(searchParams[5])
513  
514 frame.plainFrame:Show();
515 end
516 end
517 getglobal(frameName.."SaveSearchEdit"):SetText(text);
518 AuctioneerDropDownMenu_SetSelectedID(dropdown, index);
519 end
520  
521 -------------------------------------------------------------------------------
522 -------------------------------------------------------------------------------
523 function AuctionFrameSearch_SavedSearchDropDown_Initialize()
524 local dropdown = AuctionFrameSearchSavedSearchDropDown
525 local frame = dropdown:GetParent()
526  
527 if (not AuctionConfig.SavedSearches) then
528 UIDropDownMenu_AddButton({
529 text = "",
530 func = AuctionFrameSearch_SavedSearchDropDownItem_OnClick,
531 owner = dropdown
532 });
533 return
534 end
535  
536 local savedSearchDropDownElements = {}
537 for name, search in pairs(AuctionConfig.SavedSearches) do
538 table.insert(savedSearchDropDownElements, name);
539 end
540 table.sort(savedSearchDropDownElements);
541  
542 UIDropDownMenu_AddButton({
543 text = "",
544 func = AuctionFrameSearch_SavedSearchDropDownItem_OnClick,
545 owner = dropdown
546 });
547 for pos, name in pairs(savedSearchDropDownElements) do
548 UIDropDownMenu_AddButton({
549 text = name,
550 func = AuctionFrameSearch_SavedSearchDropDownItem_OnClick,
551 owner = dropdown
552 });
553 end
554 end
555  
556  
557 -------------------------------------------------------------------------------
558 -------------------------------------------------------------------------------
559 function AuctionFrameSearch_MinQualityDropDownItem_OnClick()
560 local index = this:GetID();
561 local dropdown = this.owner;
562 AuctioneerDropDownMenu_SetSelectedID(dropdown, index);
563 end
564  
565 -------------------------------------------------------------------------------
566 -------------------------------------------------------------------------------
567 function AuctionFrameSearch_SearchDropDownItem_OnClick()
568 local index = this:GetID();
569 local dropdown = this.owner;
570 AuctionFrameSearch_SearchDropDownItem_SetSelectedID(dropdown, index);
571 end
572  
573 -------------------------------------------------------------------------------
574 -------------------------------------------------------------------------------
575 function AuctionFrameSearch_SearchDropDownItem_SetSelectedID(dropdown, index)
576 local frame = dropdown:GetParent();
577 frame.bidFrame:Hide();
578 frame.buyoutFrame:Hide();
579 frame.competeFrame:Hide();
580 frame.plainFrame:Hide();
581 if (index == 1) then
582 frame.bidFrame:Show();
583 elseif (index == 2) then
584 frame.buyoutFrame:Show();
585 elseif (index == 3) then
586 frame.competeFrame:Show();
587 elseif (index == 4) then
588 frame.plainFrame:Show();
589 end
590 AuctioneerDropDownMenu_SetSelectedID(dropdown, index);
591 end
592  
593 -------------------------------------------------------------------------------
594 -------------------------------------------------------------------------------
595 function AuctionFrameSearch_RemoveSearchButton_OnClick(button)
596 local frame = button:GetParent();
597 local frameName = frame:GetName();
598  
599 local searchName = getglobal(frameName.."SaveSearchEdit"):GetText()
600 if (AuctionConfig.SavedSearches) then
601 AuctionConfig.SavedSearches[searchName] = nil
602 end
603 getglobal(frameName.."SaveSearchEdit"):SetText("")
604 end
605  
606 -------------------------------------------------------------------------------
607 -------------------------------------------------------------------------------
608 function AuctionFrameSearch_SaveSearchButton_OnClick(button)
609 local frame = button:GetParent();
610 local frameName = frame:GetName();
611 local searchDropdown = getglobal(frameName.."SearchDropDown")
612  
613 local searchType = UIDropDownMenu_GetSelectedID(searchDropdown);
614 local searchData = nil
615 if (searchType == 1) then
616 -- Bid-based search
617 searchData = string.format("%d\t%d\t%s\t%d\t%d\t%d\t%s",
618 searchType,
619 MoneyInputFrame_GetCopper(getglobal(frameName.."BidMinProfit")),
620 getglobal(frameName.."BidMinPercentLessEdit"):GetText(),
621 UIDropDownMenu_GetSelectedID(getglobal(frameName.."BidTimeLeftDropDown")),
622 UIDropDownMenu_GetSelectedID(getglobal(frameName.."BidCategoryDropDown")),
623 UIDropDownMenu_GetSelectedID(getglobal(frameName.."BidMinQualityDropDown")),
624 getglobal(frameName.."BidSearchEdit"):GetText()
625 );
626 elseif (searchType == 2) then
627 -- Buyout-based search
628 searchData = string.format("%d\t%d\t%s\t%d\t%d\t%s",
629 searchType,
630 MoneyInputFrame_GetCopper(getglobal(frameName.."BuyoutMinProfit")),
631 getglobal(frameName.."BuyoutMinPercentLessEdit"):GetText(),
632 UIDropDownMenu_GetSelectedID(getglobal(frameName.."BuyoutCategoryDropDown")),
633 UIDropDownMenu_GetSelectedID(getglobal(frameName.."BuyoutMinQualityDropDown")),
634 getglobal(frameName.."BuyoutSearchEdit"):GetText()
635 );
636 elseif (searchType == 3) then
637 -- Compete-based search
638 searchData = string.format("%d\t%d",
639 searchType,
640 MoneyInputFrame_GetCopper(getglobal(frameName.."CompeteUndercut"))
641 );
642 elseif (searchType == 4) then
643 -- Plain-based search
644 searchData = string.format("%d\t%d\t%d\t%d\t%s",
645 searchType,
646 MoneyInputFrame_GetCopper(getglobal(frameName.."PlainMaxPrice")),
647 UIDropDownMenu_GetSelectedID(getglobal(frameName.."PlainCategoryDropDown")),
648 UIDropDownMenu_GetSelectedID(getglobal(frameName.."PlainMinQualityDropDown")),
649 getglobal(frameName.."PlainSearchEdit"):GetText()
650 );
651 end
652  
653 if (searchData) then
654 local searchName = getglobal(frameName.."SaveSearchEdit"):GetText()
655 if (not AuctionConfig.SavedSearches) then
656 AuctionConfig.SavedSearches = {}
657 end
658  
659 AuctionConfig.SavedSearches[searchName] = searchData
660 end
661 end
662  
663 -------------------------------------------------------------------------------
664 -- The Bid button has been clicked
665 -------------------------------------------------------------------------------
666 function AuctionFrameSearch_BidButton_OnClick(button)
667 local frame = button:GetParent();
668 local result = frame.selectedResult;
669 if (result and result.name and result.count and result.bid) then
670 result.status = AUCTION_STATUS_BIDDING;
671 result.pendingBidCount = result.pendingBidCount + 1;
672 local bidLimit = Auctioneer.Command.GetFilterVal('bid-limit');
673 local context = { frame = frame, auction = result };
674 AucBidManager.BidAuction(result.bid, result.signature, bidLimit, AuctionFrameSearch_OnBidResult, context);
675 AuctionFrameSearch_UpdateButtons(frame);
676 AuctionFrameSearch_UpdatePendingBidStatus(frame);
677 ListTemplateScrollFrame_Update(getglobal(frame.resultsList:GetName().."ScrollFrame"));
678 end
679 end
680  
681 -------------------------------------------------------------------------------
682 -- The Buyout button has been clicked.
683 -------------------------------------------------------------------------------
684 function AuctionFrameSearch_BuyoutButton_OnClick(button)
685 local frame = button:GetParent();
686 local result = frame.selectedResult;
687 if (result and result.name and result.count and result.buyout) then
688 result.status = AUCTION_STATUS_BIDDING;
689 result.pendingBidCount = result.pendingBidCount + 1;
690 local bidLimit = Auctioneer.Command.GetFilterVal('bid-limit');
691 local context = { frame = frame, auction = result };
692 AucBidManager.BidAuction(result.buyout, result.signature, bidLimit, AuctionFrameSearch_OnBidResult, context);
693 AuctionFrameSearch_UpdateButtons(frame);
694 AuctionFrameSearch_UpdatePendingBidStatus(frame);
695 ListTemplateScrollFrame_Update(getglobal(frame.resultsList:GetName().."ScrollFrame"));
696 end
697 end
698  
699 -------------------------------------------------------------------------------
700 -- Updates the pending bid status text
701 -------------------------------------------------------------------------------
702 function AuctionFrameSearch_UpdatePendingBidStatus(frame)
703 local count = AucBidManager.GetRequestCount();
704 if (count == 1) then
705 frame.pendingBidStatusText:SetText(_AUCT('UiPendingBidInProgress'));
706 elseif (count > 1) then
707 local output = string.format(_AUCT('UiPendingBidsInProgress'), count);
708 frame.pendingBidStatusText:SetText(output);
709 elseif (frame.pendingBidStatusText:GetText() ~= "") then
710 frame.pendingBidStatusText:SetText(_AUCT('UiNoPendingBids'));
711 end
712 end
713  
714 -------------------------------------------------------------------------------
715 -- Returns the item color for the specified result
716 -------------------------------------------------------------------------------
717 function AuctionFrameSearch_GetItemColor(result)
718 _, _, rarity = GetItemInfo(result.item);
719 if (rarity) then
720 return ITEM_QUALITY_COLORS[rarity];
721 end
722 return { r = 1.0, g = 1.0, b = 1.0 };
723 end
724  
725 -------------------------------------------------------------------------------
726 -- Perform a bid search (aka bidBroker)
727 -------------------------------------------------------------------------------
728 function AuctionFrameSearch_SearchBids(frame, minProfit, minPercentLess, maxTimeLeft, category, minQuality, itemName)
729 -- Create the content from auctioneer.
730 frame.results = {};
731 local itemNames = Auctioneer.Util.Split(itemName, "|");
732 local bidWorthyAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.BidBrokerFilter, minProfit, maxTimeLeft, category, minQuality, itemNames);
733 if (bidWorthyAuctions) then
734 local player = UnitName("player");
735 for pos,a in pairs(bidWorthyAuctions) do
736 if (a.owner ~= player) then
737 local id,rprop,enchant,name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);
738 local itemKey = id .. ":" .. rprop..":"..enchant;
739 local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, Auctioneer.Util.GetAuctionKey());
740 local currentBid = Auctioneer.Statistic.GetCurrentBid(a.signature);
741 -- rounding down the hsp, to get a better selling price
742 local hspBuyout = Auctioneer.Statistic.RoundDownTo95(hsp * count);
743 local percentLess = 100 - math.floor(100 * currentBid / (hspBuyout));
744 if (percentLess >= minPercentLess) then
745 local auction = {};
746 auction.id = id;
747 auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);
748 auction.link = a.itemLink;
749 auction.name = name;
750 auction.count = count;
751 auction.owner = a.owner;
752 auction.timeLeft = a.timeLeft;
753 auction.bid = currentBid;
754 auction.bidPer = math.floor(auction.bid / count);
755 auction.buyout = buyout;
756 auction.buyoutPer = math.floor(auction.buyout / count);
757 auction.profit = hspBuyout - currentBid;
758 auction.profitPer = math.floor(auction.profit / count);
759 auction.percentLess = percentLess;
760 auction.signature = a.signature;
761 if (a.highBidder) then
762 auction.status = AUCTION_STATUS_HIGH_BIDDER;
763 else
764 auction.status = AUCTION_STATUS_UNKNOWN;
765 end
766 auction.pendingBidCount = 0;
767 table.insert(frame.results, auction);
768 end
769 end
770 end
771 end
772  
773 -- Hand the updated results to the list.
774 frame.resultsType = "BidSearch";
775 frame:SelectResultByIndex(nil);
776 ListTemplate_Initialize(frame.resultsList, frame.bidSearchPhysicalColumns, frame.auctioneerListLogicalColumns);
777 ListTemplate_SetContent(frame.resultsList, frame.results);
778 ListTemplate_Sort(frame.resultsList, 2);
779 ListTemplate_Sort(frame.resultsList, 3);
780 end
781  
782 -------------------------------------------------------------------------------
783 -- Perform a buyout search (aka percentLess)
784 -------------------------------------------------------------------------------
785 function AuctionFrameSearch_SearchBuyouts(frame, minProfit, minPercentLess, category, minQuality, itemName)
786 -- Create the content from auctioneer.
787 frame.results = {};
788 local itemNames = Auctioneer.Util.Split(itemName, "|");
789 local buyoutWorthyAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.PercentLessFilter, minPercentLess, category, minQuality, itemNames);
790 if (buyoutWorthyAuctions) then
791 local player = UnitName("player");
792 for pos,a in pairs(buyoutWorthyAuctions) do
793 if (a.owner ~= player) then
794 local id,rprop,enchant,name,count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);
795 local itemKey = id .. ":" .. rprop..":"..enchant;
796 local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, Auctioneer.Util.GetAuctionKey());
797 -- rounding down the hsp, to get a better selling price
798 local hspBuyout = Auctioneer.Statistic.RoundDownTo95(hsp * count);
799 local profit = hspBuyout - buyout;
800 if (profit >= minProfit) then
801 local auction = {};
802 auction.id = id;
803 auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);
804 auction.link = a.itemLink;
805 auction.name = name;
806 auction.count = count;
807 auction.owner = a.owner;
808 auction.timeLeft = a.timeLeft;
809 auction.buyout = buyout;
810 auction.buyoutPer = math.floor(auction.buyout / count);
811 auction.profit = profit;
812 auction.profitPer = math.floor(auction.profit / count);
813 auction.percentLess = 100 - math.floor(100 * buyout / hspBuyout);
814 auction.signature = a.signature;
815 if (a.highBidder) then
816 auction.status = AUCTION_STATUS_HIGH_BIDDER;
817 else
818 auction.status = AUCTION_STATUS_UNKNOWN;
819 end
820 auction.pendingBidCount = 0;
821 table.insert(frame.results, auction);
822 end
823 end
824 end
825 end
826  
827 -- Hand the updated content to the list.
828 frame.resultsType = "BuyoutSearch";
829 frame:SelectResultByIndex(nil);
830 ListTemplate_Initialize(frame.resultsList, frame.buyoutSearchPhysicalColumns, frame.auctioneerListLogicalColumns);
831 ListTemplate_SetContent(frame.resultsList, frame.results);
832 ListTemplate_Sort(frame.resultsList, 5);
833 end
834  
835 -------------------------------------------------------------------------------
836 -- Perform a competition search (aka compete)
837 -------------------------------------------------------------------------------
838 function AuctionFrameSearch_SearchCompetition(frame, minUndercut)
839 -- Create the content from auctioneer.
840 frame.results = {};
841  
842 -- Get the highest prices for my auctions.
843 local myAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.AuctionOwnerFilter, UnitName("player"));
844 local myHighestPrices = {}
845 local id,rprop,enchant,name,count,min,buyout,uniq,itemKey,competingAuctions,currentBid,buyoutForOne,bidForOne,bidPrice,myBuyout,buyPrice,myPrice,priceLess,lessPrice,output;
846 if (myAuctions) then
847 for pos,a in pairs(myAuctions) do
848 id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);
849 if (count > 1) then buyout = buyout/count; end
850 itemKey = id .. ":" .. rprop..":"..enchant;
851 if (not myHighestPrices[itemKey]) or (myHighestPrices[itemKey] < buyout) then
852 myHighestPrices[itemKey] = buyout;
853 end
854 end
855 end
856  
857 -- Search for competing auctions less than mine.
858 competingAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.CompetingFilter, minUndercut, myHighestPrices);
859 if (competingAuctions) then
860 table.sort(competingAuctions, Auctioneer.Statistic.ProfitComparisonSort);
861 for pos,a in pairs(competingAuctions) do
862 local id,rprop,enchant,name,count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);
863 local itemKey = id .. ":" .. rprop..":"..enchant;
864 local myBuyout = myHighestPrices[itemKey];
865 local currentBid = Auctioneer.Statistic.GetCurrentBid(a.signature);
866  
867 local auction = {};
868 auction.id = id;
869 auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);
870 auction.link = a.itemLink;
871 auction.name = name;
872 auction.count = count;
873 auction.owner = a.owner;
874 auction.timeLeft = a.timeLeft;
875 auction.bid = currentBid;
876 auction.bidPer = math.floor(auction.bid / count);
877 auction.buyout = buyout;
878 auction.buyoutPer = math.floor(auction.buyout / count);
879 auction.percentLess = math.floor(((myBuyout - auction.buyoutPer) / myBuyout) * 100);
880 auction.signature = a.signature;
881 if (a.highBidder) then
882 auction.status = AUCTION_STATUS_HIGH_BIDDER;
883 else
884 auction.status = AUCTION_STATUS_UNKNOWN;
885 end
886 auction.pendingBidCount = 0;
887 table.insert(frame.results, auction);
888 end
889 end
890  
891 -- Hand the updated content to the list.
892 frame.resultsType = "CompeteSearch";
893 frame:SelectResultByIndex(nil);
894 ListTemplate_Initialize(frame.resultsList, frame.competeSearchPhysicalColumns, frame.auctioneerListLogicalColumns);
895 ListTemplate_SetContent(frame.resultsList, frame.results);
896 end
897  
898 -------------------------------------------------------------------------------
899 -- Perform a plain search
900 -------------------------------------------------------------------------------
901 function AuctionFrameSearch_SearchPlain(frame, maxPrice, category, minQuality, itemName)
902 -- Create the content from auctioneer.
903 frame.results = {};
904 local itemNames = Auctioneer.Util.Split(itemName, "|");
905 local bidWorthyAuctions = Auctioneer.Filter.QuerySnapshot(Auctioneer.Filter.PlainFilter, maxPrice, category, minQuality, itemNames);
906 if (bidWorthyAuctions) then
907 local player = UnitName("player");
908 for pos,a in pairs(bidWorthyAuctions) do
909 if (a.owner ~= player) then
910 local id,rprop,enchant,name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(a.signature);
911 local itemKey = id .. ":" .. rprop..":"..enchant;
912 local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, Auctioneer.Util.GetAuctionKey());
913 local currentBid = Auctioneer.Statistic.GetCurrentBid(a.signature);
914 -- rounding down the hsp, to get a better selling price
915 local hspBuyout = Auctioneer.Statistic.RoundDownTo95(hsp * count);
916 local percentLess = 100 - math.floor(100 * currentBid / hspBuyout);
917  
918 local _,_,_,iLevel = GetItemInfo(id);
919  
920 local auction = {};
921 auction.id = id;
922 auction.item = string.format("item:%s:%s:%s:0", id, enchant, rprop);
923 auction.link = a.itemLink;
924 auction.level = iLevel;
925 auction.name = name;
926 auction.count = count;
927 auction.owner = a.owner;
928 auction.timeLeft = a.timeLeft;
929 auction.bid = currentBid;
930 auction.bidPer = math.floor(auction.bid / count);
931 auction.buyout = buyout;
932 auction.buyoutPer = math.floor(auction.buyout / count);
933 auction.profit = hspBuyout - currentBid;
934 auction.profitPer = math.floor(auction.profit / count);
935 auction.percentLess = percentLess;
936 auction.signature = a.signature;
937 if (a.highBidder) then
938 auction.status = AUCTION_STATUS_HIGH_BIDDER;
939 else
940 auction.status = AUCTION_STATUS_UNKNOWN;
941 end
942 auction.pendingBidCount = 0;
943 table.insert(frame.results, auction);
944 end
945 end
946 end
947  
948 -- Hand the updated results to the list.
949 frame.resultsType = "PlainSearch";
950 frame:SelectResultByIndex(nil);
951 ListTemplate_Initialize(frame.resultsList, frame.plainSearchPhysicalColumns, frame.auctioneerListLogicalColumns);
952 ListTemplate_SetContent(frame.resultsList, frame.results);
953 ListTemplate_Sort(frame.resultsList, 2);
954 ListTemplate_Sort(frame.resultsList, 3);
955 end
956  
957  
958 -------------------------------------------------------------------------------
959 -- Select a search result by index.
960 -------------------------------------------------------------------------------
961 function AuctionFrameSearch_SelectResultByIndex(frame, index)
962 if (index and index <= table.getn(frame.results) and frame.resultsType) then
963 -- Select the item
964 frame.selectedResult = frame.results[index];
965 ListTemplate_SelectRow(frame.resultsList, index);
966 else
967 -- Clear the selection
968 frame.selectedResult = nil;
969 ListTemplate_SelectRow(frame.resultsList, nil);
970 end
971  
972 AuctionFrameSearch_UpdateButtons(frame);
973 end
974  
975 -------------------------------------------------------------------------------
976 -- Update the enabled/disabled state of the Bid and Buyout buttons
977 -------------------------------------------------------------------------------
978 function AuctionFrameSearch_UpdateButtons(frame)
979 if (frame.selectedResult) then
980 if (frame.selectedResult.status == AUCTION_STATUS_UNKNOWN) then
981 if (frame.resultsType == "BidSearch") then
982 frame.bidButton:Enable();
983 frame.buyoutButton:Disable();
984 elseif (frame.resultsType == "BuyoutSearch") then
985 frame.bidButton:Disable();
986 frame.buyoutButton:Enable();
987 elseif (frame.resultsType == "CompeteSearch") then
988 frame.bidButton:Enable();
989 frame.buyoutButton:Enable();
990 elseif (frame.resultsType == "PlainSearch") then
991 frame.bidButton:Enable();
992 frame.buyoutButton:Enable();
993 else
994 frame.bidButton:Disable();
995 frame.buyoutButton:Disable();
996 end
997 else
998 frame.bidButton:Disable();
999 frame.buyoutButton:Disable();
1000 end
1001 else
1002 frame.bidButton:Disable();
1003 frame.buyoutButton:Disable();
1004 end
1005 end
1006  
1007 -------------------------------------------------------------------------------
1008 -- An item in the list is moused over.
1009 -------------------------------------------------------------------------------
1010 function AuctionFrameSearch_ListItem_OnEnter(row)
1011 local frame = this:GetParent():GetParent();
1012 local results = frame.results;
1013 if (results and row <= table.getn(results)) then
1014 local result = results[row];
1015 if (result) then
1016 local _, link, rarity = GetItemInfo(result.item);
1017 if (link) then
1018 local name = result.name;
1019 local count = result.count;
1020 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
1021 GameTooltip:SetHyperlink(link);
1022 GameTooltip:Show();
1023 EnhTooltip.TooltipCall(GameTooltip, name, result.link, rarity, count);
1024 end
1025 end
1026 end
1027 end
1028  
1029 -------------------------------------------------------------------------------
1030 -- An item in the list is clicked.
1031 -------------------------------------------------------------------------------
1032 function AuctionFrameSearch_ListItem_OnClick(row)
1033 local frame = this:GetParent():GetParent();
1034  
1035 -- Select the item clicked.
1036 frame:SelectResultByIndex(row);
1037  
1038 -- Bid or buyout the item if the alt key is down.
1039 if (frame.resultsType and IsAltKeyDown()) then
1040 if (IsShiftKeyDown()) then
1041 -- Bid or buyout the item.
1042 if (frame.resultsType == "BidSearch") then
1043 AuctionFrameSearch_BidButton_OnClick(frame.bidButton);
1044  
1045 elseif (frame.resultsType == "BuyoutSearch") then
1046 AuctionFrameSearch_BuyoutButton_OnClick(frame.buyoutButton);
1047 end
1048  
1049 else
1050 -- Search for the item and switch to the Browse tab.
1051 BrowseName:SetText(frame.results[row].name)
1052 BrowseMinLevel:SetText("")
1053 BrowseMaxLevel:SetText("")
1054 AuctionFrameBrowse.selectedInvtype = nil
1055 AuctionFrameBrowse.selectedInvtypeIndex = nil
1056 AuctionFrameBrowse.selectedClass = nil
1057 AuctionFrameBrowse.selectedClassIndex = nil
1058 AuctionFrameBrowse.selectedSubclass = nil
1059 AuctionFrameBrowse.selectedSubclassIndex = nil
1060 AuctionFrameFilters_Update()
1061 IsUsableCheckButton:SetChecked(0)
1062 UIDropDownMenu_SetSelectedValue(BrowseDropDown, -1)
1063 AuctionFrameBrowse_Search()
1064 AuctionFrameTab_OnClick(1);
1065 end
1066  
1067 --Thanks to Miravlix (from irc://irc.datavertex.com/cosmostesters) for the following codeblocks.
1068 elseif (IsControlKeyDown()) then
1069 DressUpItemLink(frame.results[row].item);
1070  
1071 elseif (IsShiftKeyDown() and ChatFrameEditBox:IsVisible()) then
1072 -- Trim leading whitespace
1073 ChatFrameEditBox:Insert(string.gsub(frame.results[row].link, " *(.*)", "%1"));
1074 end
1075 end
1076  
1077 -------------------------------------------------------------------------------
1078 -- Initialize the content of a Category dropdown list
1079 -------------------------------------------------------------------------------
1080 function AuctionFrameSearch_CategoryDropDown_Initialize()
1081 local dropdown = this:GetParent();
1082 local frame = dropdown:GetParent();
1083 UIDropDownMenu_AddButton({
1084 text = "",
1085 func = AuctionFrameSearch_CategoryDropDownItem_OnClick,
1086 owner = dropdown
1087 })
1088  
1089 if (AuctionConfig.classes) then
1090 for classid, cdata in pairs(AuctionConfig.classes) do
1091 UIDropDownMenu_AddButton({
1092 text = cdata.name,
1093 func = AuctionFrameSearch_CategoryDropDownItem_OnClick,
1094 owner = dropdown
1095 });
1096 end
1097 end
1098 end
1099  
1100 -------------------------------------------------------------------------------
1101 -- An item in a CategoryDrownDown has been clicked
1102 -------------------------------------------------------------------------------
1103 function AuctionFrameSearch_CategoryDropDownItem_OnClick()
1104 local index = this:GetID();
1105 local dropdown = this.owner;
1106 AuctioneerDropDownMenu_SetSelectedID(dropdown, index);
1107 end
1108  
1109 -------------------------------------------------------------------------------
1110 -- Initialize the content of a TimeLeft dropdown list
1111 -------------------------------------------------------------------------------
1112 function AuctionFrameSearch_TimeLeftDropDown_Initialize()
1113 local dropdown = this:GetParent();
1114 local frame = dropdown:GetParent();
1115 for index, value in pairs(TIME_LEFT_NAMES) do
1116 local info = {};
1117 info.text = value;
1118 info.func = AuctionFrameSearch_TimeLeftDropDownItem_OnClick;
1119 info.owner = dropdown;
1120 UIDropDownMenu_AddButton(info);
1121 end
1122 end
1123  
1124 -------------------------------------------------------------------------------
1125 -- An item a TimeLeftDrownDown has been clicked
1126 -------------------------------------------------------------------------------
1127 function AuctionFrameSearch_TimeLeftDropDownItem_OnClick()
1128 local index = this:GetID();
1129 local dropdown = this.owner;
1130 AuctioneerDropDownMenu_SetSelectedID(dropdown, index);
1131 end
1132  
1133 -------------------------------------------------------------------------------
1134 -------------------------------------------------------------------------------
1135 function AuctionFrameSearchBid_SearchButton_OnClick(button)
1136 local frame = button:GetParent();
1137 local frameName = frame:GetName();
1138 local profitMoneyFrame = getglobal(frameName.."MinProfit");
1139 local percentLessEdit = getglobal(frameName.."MinPercentLessEdit");
1140 local timeLeftDropDown = getglobal(frameName.."TimeLeftDropDown");
1141  
1142 local minProfit = MoneyInputFrame_GetCopper(profitMoneyFrame);
1143 local minPercentLess = percentLessEdit:GetNumber();
1144 local catID = (UIDropDownMenu_GetSelectedID(getglobal(frameName.."CategoryDropDown")) or 1) - 1;
1145 local minQuality = (UIDropDownMenu_GetSelectedID(getglobal(frameName.."MinQualityDropDown")) or 1) - 1;
1146 local itemName = getglobal(frameName.."SearchEdit"):GetText();
1147 if (itemName == "") then itemName = nil end
1148  
1149 local timeLeft = Auctioneer.Core.Constants.TimeLeft.Seconds[UIDropDownMenu_GetSelectedID(timeLeftDropDown)];
1150 frame:GetParent():SearchBids(minProfit, minPercentLess, timeLeft, catID, minQuality, itemName);
1151 end
1152  
1153 -------------------------------------------------------------------------------
1154 -------------------------------------------------------------------------------
1155 function AuctionFrameSearchBuyout_SearchButton_OnClick(button)
1156 local frame = button:GetParent();
1157 local frameName = frame:GetName();
1158 local profitMoneyFrame = getglobal(frame:GetName().."MinProfit");
1159 local percentLessEdit = getglobal(frame:GetName().."MinPercentLessEdit");
1160  
1161 local minProfit = MoneyInputFrame_GetCopper(profitMoneyFrame);
1162 local minPercentLess = percentLessEdit:GetNumber();
1163 local catID = (UIDropDownMenu_GetSelectedID(getglobal(frameName.."CategoryDropDown")) or 1) - 1
1164 local minQuality = (UIDropDownMenu_GetSelectedID(getglobal(frameName.."MinQualityDropDown")) or 1) - 1;
1165 local itemName = getglobal(frameName.."SearchEdit"):GetText();
1166 if (itemName == "") then itemName = nil end
1167  
1168 frame:GetParent():SearchBuyouts(minProfit, minPercentLess, catID, minQuality, itemName);
1169 end
1170  
1171 -------------------------------------------------------------------------------
1172 -------------------------------------------------------------------------------
1173 function AuctionFrameSearchPlain_SearchButton_OnClick(button)
1174 local frame = button:GetParent();
1175 local frameName = frame:GetName();
1176  
1177 local maxPrice = MoneyInputFrame_GetCopper(getglobal(frameName.."MaxPrice")) or 0
1178 local catID = (UIDropDownMenu_GetSelectedID(getglobal(frameName.."CategoryDropDown")) or 1) - 1
1179 local minQuality = (UIDropDownMenu_GetSelectedID(getglobal(frameName.."MinQualityDropDown")) or 1) - 1;
1180 local itemName = getglobal(frameName.."SearchEdit"):GetText();
1181 if (itemName == "") then itemName = nil end
1182  
1183 frame:GetParent():SearchPlain(maxPrice, catID, minQuality, itemName);
1184 end
1185  
1186 -------------------------------------------------------------------------------
1187 -------------------------------------------------------------------------------
1188 function AuctionFrameSearchCompete_SearchButton_OnClick(button)
1189 local frame = button:GetParent();
1190 local undercutMoneyFrame = getglobal(frame:GetName().."Undercut");
1191  
1192 local minUndercut = MoneyInputFrame_GetCopper(undercutMoneyFrame);
1193 frame:GetParent():SearchCompetition(minUndercut);
1194 end
1195  
1196 -------------------------------------------------------------------------------
1197 -------------------------------------------------------------------------------
1198 function AuctionFrameSearch_OnBidResult(context, bidRequest)
1199 context.auction.pendingBidCount = context.auction.pendingBidCount - 1;
1200 if (context.auction.pendingBidCount == 0) then
1201 if (table.getn(bidRequest.results) == 0) then
1202 -- No auctions matched.
1203 context.auction.status = AUCTION_STATUS_NOT_FOUND;
1204 else
1205 -- Assume we are now the high bidder on all the matching auctions
1206 -- until proven otherwise.
1207 context.auction.status = AUCTION_STATUS_HIGH_BIDDER;
1208 for _,result in pairs(bidRequest.results) do
1209 if (result ~= BidResultCodes["BidAccepted"] and
1210 result ~= BidResultCodes["AlreadyHighBidder"] and
1211 result ~= BidResultCodes["OwnAuction"]) then
1212 context.auction.status = AUCTION_STATUS_UNKNOWN;
1213 break;
1214 end
1215 end
1216 end
1217 AuctionFrameSearch_UpdateButtons(context.frame);
1218 ListTemplateScrollFrame_Update(getglobal(context.frame.resultsList:GetName().."ScrollFrame"));
1219 end
1220 AuctionFrameSearch_UpdatePendingBidStatus(context.frame);
1221 end
1222  
1223 -------------------------------------------------------------------------------
1224 -------------------------------------------------------------------------------
1225 function AuctionFrameSearch_GetAuctionAlpha(auction)
1226 local status = auction.status;
1227 if (status and (status == AUCTION_STATUS_NOT_FOUND or status == AUCTION_STATUS_HIGH_BIDDER)) then
1228 return 0.4;
1229 end
1230 return 1.0;
1231 end
1232  
1233