-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdwin.lua
More file actions
1900 lines (1172 loc) · 43.4 KB
/
Edwin.lua
File metadata and controls
1900 lines (1172 loc) · 43.4 KB
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
--[[
---- TODOs ----
* TODO#1 -- DONE
Make money columns bigger, test with "ggggg ss cc"
* TODO#2 -- DONE
Look into swapping around columns.
icon - name - unitprice - amount - buyout
may not be easiest, perhaps its easier with
icon - amount - name - buyout - unitprice?
* TODO#3 -- Possibly DONE, still no true reproduction to make it happen
Fix textures not always showing.. this is probably rather
complex but I want it to work proper and consistent.
Consider doing a full debug of the creation, initiation
retirement and reinstatement of the listItem frames to
identify any problems with wildgrowth in unrecognised
frame attributes like frame level and strata and what not
* TODO#4 -- DONE
Fix sorting items function with 0 buyout
* TODO#5
Release all objects and frames back to the core object
and frame pools respectively
* TODO#6 -- DONE
Make greenies with suffixes search for all suffixes
* TODO#7 -- DONE
Make selecting an item set the bid and buyout based on current count * unitprice * 0.95 instead of copying over the actual buyout
... OOPS =P
Put a single item in the AH and click a listed item wich a count higher than 1 -> buyout is not unit price.
* TODO#8 -- DONE
Make Edwin Hide and show when the AH panel is hidden or shown.
* TODO#9 -- DONE
Make hiding and showing available in slashcommands (not using activation!)
Remember DB updates and everything!
* TODO#10
Make lock/unlock as well as Hide/Show buttons in interface?
* TODO#11 -- DONE
Mark items with bids and buyout below vendor price!
* TODO#12 -- DONE
Mark items with bids and buyout below vendor price!
--]]
----------------------------------------------------------------
-- "UP VALUES" FOR SPEED ---------------------------------------
----------------------------------------------------------------
local ceil = math.ceil
local floor = math.floor
local find = string.find
local format = string.format
local getTime = GetTime
local max = math.max
local min = math.min
local sub = string.sub
local tgetn = table.getn
local tinsert = table.insert
local tostring = tostring
local tremove = table.remove
local tsort = table.sort
local type = type
----------------------------------------------------------------
-- CONSTANTS THAT SHOULD BE GLOBAL PROBABLY --------------------
----------------------------------------------------------------
local TYPE_BOOLEAN = "boolean"
local TYPE_STRING = "string"
local TYPE_NUMBER = "number"
local TYPE_TABLE = "table"
local SCRIPTHANDLER_ON_EVENT = "OnEvent"
local SCRIPTHANDLER_ON_UPDATE = "OnUpdate"
local SCRIPTHANDLER_ON_DRAG_START = "OnDragStart"
local SCRIPTHANDLER_ON_DRAG_STOP = "OnDragStop"
local EVENT_PLAYER_LOGIN = "PLAYER_LOGIN"
local EVENT_PLAYER_LOGOUT = "PLAYER_LOGOUT"
local EVENT_ADDON_LOADED = "ADDON_LOADED"
local EVENT_NEW_AUCTION_UPDATE = "NEW_AUCTION_UPDATE"
local EVENT_AUCTION_ITEM_LIST_UPDATE = "AUCTION_ITEM_LIST_UPDATE"
local EVENT_AUCTION_HOUSE_SHOW = "AUCTION_HOUSE_SHOW"
local EVENT_AUCTION_HOUSE_CLOSED = "AUCTION_HOUSE_CLOSED"
----------------------------------------------------------------
-- HELPER FUNCTIONS --------------------------------------------
----------------------------------------------------------------
-- These should be moved into the core at one point.
--------
local function isBoolean(value)
return (type(value) == TYPE_BOOLEAN)
end
--------
local function isString(value)
return (type(value) == TYPE_STRING)
end
--------
local function isNumber(value)
return (type(value) == TYPE_NUMBER)
end
--------
local function isTable(value)
return (type(value) == TYPE_TABLE)
end
--------
local function isFunction(value)
return (type(value) == "function")
end
--------
local function throwError(error_message)
if not isString(error_message) then
throwError("throwError requires a non-empty string on argument position 1")
return
end
error(error_message)
end
--------
local function merge(left, right)
local t = {}
if not isTable(left) or not isTable(right) then
throwError("Usage: merge(left <table>, right <table>)")
end
-- copy left into temp table.
for k, v in pairs(left) do
t[k] = v
end
-- Add or overwrite right values.
for k, v in pairs(right) do
t[k] = v
end
return t
end
--------
local function toColourisedString(value)
local result;
if isString(value) then
result = "|cffffffff" .. value .. "|r"
elseif isNumber(value) then
result = "|cffffff33" .. tostring(value) .. "|r"
elseif isBoolean(value) then
result = "|cff9999ff" .. tostring(value) .. "|r"
end
return result
end
--------
local function prt(proposed_message)
local message = tostring(proposed_message)
if not isString(message) then
throwError("prt requires a non-empty string on argument position 1")
return
end
DEFAULT_CHAT_FRAME:AddMessage(message)
end
--------
----------------------------------------------------------------
-- EDWIN ADDON ------------------------------------------------
----------------------------------------------------------------
Edwin = CreateFrame("FRAME", "Edwin", UIParent)
local base = Edwin
----------------------------------------------------------------
-- INTERNAL CONSTANTS ------------------------------------------
----------------------------------------------------------------
local PAGE_READY_FOR_SCANNING = "Page is ready for scanning"
local PAGE_IS_BEING_SCANNED = "Page is being scanned"
local PAGE_HAS_BEEN_SCANNED = "Page has been scanned"
local PAGE_SCAN_FAILED = "Page scan failed"
local EMPTY_PAGE_SEARCH_NAME = "Empty page"
----------------------------------------------------------------
-- DATABASE KEYS -----------------------------------------------
----------------------------------------------------------------
-- IF ANY OF THE >>VALUES<< CHANGE YOU WILL RESET THE STORED
-- VARIABLES OF THE PLAYER. EFFECTIVELY DELETING THEIR CUSTOM-
-- ISATION SETTINGS!!!
--
-- Changing the constant itself may cause errors in some cases.
-- Or outright kill the addon alltogether.
-- #TODO: Make these version specific, allowing full
-- backwards-compatability. Though doing so manually
-- is very error prone. Not sure how to do this auto-
-- matically. Yet.
--
-- Consider doing something like a property list.
-- When changing a property using the slash-cmds or
-- perhaps an in-game editor, we can change the version
-- and keep a record per version.
local IS_ADDON_ACTIVATED = "addon is active"
local IS_ADDON_LOCKED = "addon is locked"
local POSITION_POINT = "positioning point"
local POSITION_X = "X position"
local POSITION_Y = "Y position"
local DB_VERSION = "DB version"
local DB_ITEMS = "Stored item database"
local default_db = {
[IS_ADDON_ACTIVATED] = false,
[IS_ADDON_LOCKED] = true,
[POSITION_POINT] = "CENTER",
[POSITION_X] = 0,
[POSITION_Y] = 0,
[DB_VERSION] = 2,
[DB_ITEMS] = {}
}
----------------------------------------------------------------
-- PRIVATE VARIABLES -------------------------------------------
----------------------------------------------------------------
local initialisation_event = EVENT_ADDON_LOADED
local threshold
local frames_per_second = 30
local t_current
local step_size = (1 / frames_per_second)
local render_jobs
local unit_name
local realm_name
local profile_id
local local_db
local event_handlers
local command_list
local default_width = 400
local default_height = 600
local listItem_height = 20
local listItem_margin_top = 1
local auctionFrameHeader
local auctionFrameList
local auctionFrameListItems
local current_scroll_position = 0
local edwin_is_scanning = false
local current_page
local last_page
local waiting_period
local disconnection_prevention_buffer
local current_item_index
local auctions_this_page
local auctions_total
local amount_of_pages
local specific_item_name
local auctioning_item_count
local auctioning_item_vendor_price
local num_created_item_objects
-- Local tables we use for stuff
local scanned_pages
local retired_item_objects
local retired_list_items
local scan_results
local showing_results
local active_list_items
local known_suffixes
----------------------------------------------------------------
-- PRIVATE FUNCTIONS -------------------------------------------
----------------------------------------------------------------
local function report(label, message)
local label = tostring(label)
if not isString(label) then
throwError("report requires a non-empty string at argument position 1")
return
end
local message = tostring(message)
if not isString(message) then
throwError("report requires a non-empty string at argument position 2")
end
local str = "|cff22ff22Edwin|r - |cff999999" .. label .. ":|r " .. message
DEFAULT_CHAT_FRAME:AddMessage(str)
end
--------
local function addEvent(event_name, eventHandler)
if (not event_name)
or (event_name == "")
or (not eventHandler)
or (not isFunction(eventHandler)) then
throwError("Usage: addEvent(event_name <string>, eventHandler <function>)")
end
event_handlers[event_name] = eventHandler
base:RegisterEvent(event_name)
end
--------
local function removeEvent(event_name)
local eventHandler = event_handlers[event_name]
if eventHandler then
-- GC should pick this up when a new assignment happens
event_handlers[event_name] = nil
end
base:UnregisterEvent(event_name)
end
--------
-- #TODO: This looks an awefull lot like a class... again.
local function addSlashCommand(name, command, command_description, db_property)
-- prt("Adding a slash command");
if not isString(name)
or name == ""
or not isFunction(command)
or not command_description
or command_description == "" then
throwError("Usage: addSlashCommand(name <string>, command <function>, command_description <string> [, db_property <string>])")
end
-- prt("Creating a slash command object into the command list");
command_list[name] = {
["execute"] = command,
["description"] = command_description
};
if (db_property) then
if (not isString(db_property) or db_property == "") then
throwError("db_property must be a non-empty string.")
end
if (local_db[db_property] == nil) then
throwError('The internal database property: "' .. db_property .. '" could not be found.')
end
-- prt("Add the database property to the command list");
command_list[name]["value"] = db_property
end
end
--------
local function finishInitialisation()
-- we only need this once
base:UnregisterEvent(EVENT_PLAYER_LOGIN)
end
--------
local function storeLocalDatabaseToSavedVariables()
-- #OPTION: We could have local variables for lots of DB
-- stuff that we can load into the local_db Object
-- before we store it.
--
-- Should probably make a list of variables to keep
-- track of which changed and should be updated.
-- Something we can just loop through so load and
-- unload never desync.
-- Commit to local storage
EdwinDB[profile_id] = local_db
end
--------
local function eventCoordinator()
-- given:
-- event <string> The event name that triggered.
-- arg1, arg2, ..., arg9 <*> Given arguments specific to the event.
local eventHandler = event_handlers[event]
if eventHandler then
eventHandler(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
end
end
--------
local function removeEvents()
for event_name, eventHandler in pairs(event_handlers) do
if event_name then
removeEvent(event_name)
end
end
end
--------
local function reinstateRetiredItemObject()
return tremove(retired_item_objects)
end
--------
local function retireItemObject(itemObject)
tinsert(retired_item_objects, itemObject)
end
--------
local function newItemObject(name, texture, count, minimum_bid, buyout)
local default_name = "itemObject"..num_created_item_objects
local default_texture = "Interface/ICONS/INV_Misc_QuestionMark"
local default_count = 1
local default_minimum_bid = 0
local default_buyout = 0
local item = reinstateRetiredItemObject()
if not item then
item = {}
num_created_item_objects = num_created_item_objects + 1
end
item["name"] = name or default_name
item["texture"] = texture or default_texture
item["count"] = count or default_count
item["minimum_bid"] = minimum_bid or default_minimum_bid
item["buyout"] = buyout or default_buyout
item["unit_bid"] = floor(item["minimum_bid"] / count + 0.5)
item["unit_price"] = floor(item["buyout"] / count + 0.5)
return item
end
--------
local function addItemToDataStorage(index)
-- local itemlink = GetAuctionItemLink("list", index)
local name, texture, count, quality, _, level, minimum_bid, _,buyout_price = GetAuctionItemInfo("list", index)
if not name then
-- report("Item scan failed", "page "..current_page.." | row "..index)
return
end
-- local lowest_bid, highest_bid
-- local lowest_buyout, highest_buyout
-- local last_scan_time = getTime()
-- local cur_min_bid = minimum_bid
-- local cur_max_bid = minimum_bid
-- local cur_min_buyout = buyout_price
-- local cur_max_buyout = buyout_price
-- local times_scanned = 1
-- local day_worth_in_seconds = 24*60*60
-- local previously_scanned_item_data = local_db[DB_ITEMS][name]
-- if previously_scanned_item_data then
-- last_scan_time = previously_scanned_item_data["last_scan_time"] or last_scan_time
-- cur_min_bid = previously_scanned_item_data["lowest_bid"] or cur_min_bid
-- cur_max_bid = previously_scanned_item_data["highest_bid"] or cur_max_bid
-- cur_min_buyout = previously_scanned_item_data["lowest_buyout"] or cur_min_buyout
-- cur_max_buyout = previously_scanned_item_data["highest_buyout"] or cur_max_buyout
-- times_scanned = previously_scanned_item_data["last_scan_time"] or times_scanned
-- end
-- lowest_bid = min(minimum_bid, cur_min_bid)
-- highest_bid = max(minimum_bid, cur_max_bid)
-- lowest_buyout = min(buyout_price, cur_min_buyout)
-- highest_buyout = max(buyout_price, cur_max_buyout)
-- if getTime() > day_worth_in_seconds + last_scan_time then
-- times_scanned = times_scanned + 1;
-- end
if showing_results then
local item = newItemObject(name, texture, count, minimum_bid, buyout_price)
tinsert(scan_results, item)
end
-- prt("|cff22ff22scanned|r - "..name)
-- log({
-- ["name"] = name,
-- ["texture"] = texture,
-- ["itemlinke"] = itemlink,
-- ["lowest_bid"] = lowest_bid,
-- ["highest_bid"] = highest_bid,
-- ["lowest_buyout"] = lowest_buyout,
-- ["highest_buyout"] = highest_buyout,
-- ["times_scanned"] = times_scanned,
-- ["last_scan_time"] = last_scan_time
-- })
-- local_db[DB_ITEMS][name] = {
-- ["name"] = name,
-- ["texture"] = texture,
-- ["itemlinke"] = itemlink,
-- ["lowest_bid"] = lowest_bid,
-- ["highest_bid"] = highest_bid,
-- ["lowest_buyout"] = lowest_buyout,
-- ["highest_buyout"] = highest_buyout,
-- ["times_scanned"] = times_scanned,
-- ["last_scan_time"] = last_scan_time
-- }
end
--------
local function queryCurrentPage()
QueryAuctionItems(specific_item_name, nil, nil, 0, 0, 0, current_page - 1)
current_item_index = 1
end
--------
local function convertValueToGSC(value)
local str = tostring(floor(value + 0.5))
local gold = sub(str, 1, -5)
local silver = sub(str, -4, -3)
local copper = sub(str, -2, -1)
return gold, silver, copper
end
--------
local function toColourisedCurrency(value)
if not isNumber(value) then
throwError("Expected: 'number' | Received: "..type(value))
end
local gold = ""
local silver = ""
local copper = ""
local possible_gold, possible_silver, possible_copper = convertValueToGSC(value)
if possible_gold ~= "" then
gold = "|cffffff00" .. possible_gold .. "|r "
end
if possible_silver ~= "" then
silver = "|cffccccdd" .. possible_silver .. "|r "
end
copper = "|cffffaa33" .. possible_copper .. "|r"
return format("%s%s%s", gold, silver, copper)
end
--------
local function sortScanResults(item_one, item_two)
if item_one["unit_price"] == 0 then
return false
end
if item_two["unit_price"] == 0 then
return true
end
return item_one["unit_price"] < item_two["unit_price"]
end
--------
local function retireListItem(listItem)
listItem:Hide()
listItem:SetParent(nil)
listItem:ClearAllPoints()
tinsert(retired_list_items, listItem)
end
--------
local function reinstateRetiredListItem(parent)
local listItem = tremove(retired_list_items)
if not listItem then
return nil
end
listItem:Show()
listItem:SetParent(parent)
return listItem
end
--------
local function getNewListItem()
local listItem = reinstateRetiredListItem( auctionFrameListItems )
if not listItem then
listItem = CreateFrame( "Frame", nil, auctionFrameListItems )
listItem:SetWidth( auctionFrameListItems:GetWidth() )
listItem:SetHeight( listItem_height )
listItem:SetBackdrop( { ["bgFile"] = "Interface/CHATFRAME/CHATFRAMEBACKGROUND" } )
listItem:SetBackdropColor( 0, 0, 0, 1 )
listItem:EnableMouse( true )
listItem:SetScript( "OnEnter", function ()
listItem:SetBackdropColor( 1, 1, 0, 0.2 )
end )
listItem:SetScript( "OnLeave", function ()
listItem:SetBackdropColor( 0, 0, 0, 1 )
end )
listItem:SetScript( "OnMouseDown", function ()
local undercut_buyout = ( listItem.itemObject.unit_price * auctioning_item_count ) * 0.95
local gold, silver, copper = convertValueToGSC( undercut_buyout * 0.8 )
StartPriceGold:SetText( gold )
StartPriceSilver:SetText( silver )
StartPriceCopper:SetText( copper )
gold, silver, copper = convertValueToGSC( undercut_buyout )
BuyoutPriceGold:SetText( gold )
BuyoutPriceSilver:SetText( silver )
BuyoutPriceCopper:SetText( copper )
AuctionsShortAuctionButton:SetChecked( 0 )
AuctionsMediumAuctionButton:SetChecked( 0 )
AuctionsLongAuctionButton:SetChecked( 1 )
AuctionFrameAuctions.duration = 1440
end )
local texture = listItem:CreateTexture( nil, "BACKGROUND" )
local name = listItem:CreateFontString()
local unitPrice = listItem:CreateFontString()
local amount = listItem:CreateFontString()
local buyout = listItem:CreateFontString()
local texture_size = listItem:GetHeight() - 4
local font_size = 10
texture:SetTexture( "Interface/ICONS/INV_Misc_QuestionMark" )
texture:SetWidth( texture_size )
texture:SetHeight( texture_size )
texture:SetPoint( "LEFT", listItem, "LEFT", 2, 0 )
texture:SetDrawLayer( "ARTWORK" )
amount:SetFont( "Fonts\\FRIZQT__.TTF", font_size )
amount:SetPoint( "LEFT", texture, "RIGHT", 2, 0 )
amount:SetWidth( 15 )
amount:SetJustifyH( "RIGHT" )
name:SetFont( "Fonts\\FRIZQT__.TTF", font_size )
name:SetPoint( "LEFT", amount, "RIGHT", 5, 0 )
name:SetPoint( "RIGHT", unitPrice, "LEFT", -5, 0 )
name:SetJustifyH( "LEFT" )
unitPrice:SetFont( "Fonts\\FRIZQT__.TTF", font_size )
unitPrice:SetPoint( "RIGHT", buyout, "LEFT", -5, 0 )
unitPrice:SetWidth( 65 )
unitPrice:SetJustifyH( "RIGHT" )
buyout:SetFont( "Fonts\\FRIZQT__.TTF", font_size )
buyout:SetPoint( "RIGHT", listItem, "RIGHT", -5, 0 )
buyout:SetWidth( 65 )
buyout:SetJustifyH( "RIGHT" )
function listItem:SetItem( item )
local buyout_price = item.buyout
local vendor_price = 0
-- local buyout_price = 133379595 -- Test for checking column spacing
if auctioning_item_vendor_price then
vendor_price = auctioning_item_vendor_price / auctioning_item_count
end
if item.unit_price <= vendor_price then
name:SetText( "|cff666666" .. item.name .. "|r" )
elseif item.unit_bid <= vendor_price then
name:SetText( "|cffcc0000" .. item.name .. "|r" )
else
name:SetText( "|cffcccccc" .. item.name .. "|r" )
end
texture:SetTexture( item.texture )
unitPrice:SetText( toColourisedCurrency( buyout_price / item.count ) )
amount:SetText( toColourisedString( item.count ) )
buyout:SetText( toColourisedCurrency( buyout_price ) )
listItem[ "itemObject" ] = item
end
end
return listItem
end
--------
local function updateAuctionFrameListItems()
local listItem
local previous_list_item
local num_results
local undercut_buyout
local gold, silver, copper
for item_index, item in ipairs( scan_results ) do
listItem = active_list_items[ item_index ]
if not listItem then
listItem = getNewListItem()
if not previous_list_item then
listItem:SetPoint( "TOPLEFT",
auctionFrameListItems, "TOPLEFT",
0, -listItem_margin_top
)
else
listItem:SetPoint( "TOPLEFT",
previous_list_item, "BOTTOMLEFT",
0, -listItem_margin_top
)
end
tinsert( active_list_items, listItem )
end
listItem:SetItem( item )
previous_list_item = listItem
end
num_results = tgetn( scan_results )
auctionFrameListItems:SetHeight( max(
num_results * (listItem_height + listItem_margin_top),
auctionFrameList:GetHeight()
) )
while num_results < tgetn( active_list_items ) do
retireListItem( tremove( active_list_items ) )
end
end
--------
local function finishUpCurrentScan()
--TODO: Change this to 'finished scanning <item name>' That requires us to
-- have th item name in scope here.
report( "finished scanning", "page " .. current_page .. " / " .. amount_of_pages )
last_page = current_page
current_page = last_page + 1
if current_page > amount_of_pages then
edwin_is_scanning = false
if showing_results then
tsort( scan_results, sortScanResults )
tinsert( render_jobs, updateAuctionFrameListItems )
end
else
scanned_pages[ current_page ] = PAGE_READY_FOR_SCANNING
end
end
--------
local function queryNextItem()
addItemToDataStorage(current_item_index)
waiting_period = waiting_period + disconnection_prevention_buffer
current_item_index = current_item_index + 1
if current_item_index > auctions_this_page then
scanned_pages[current_page] = PAGE_HAS_BEEN_SCANNED
end
end
--------
local function doScanLogic()
if scanned_pages[current_page] == PAGE_IS_BEING_SCANNED and getTime() > waiting_period then