post listing changed

This commit is contained in:
Manuel Simon Hirsig
2016-03-22 18:05:45 +01:00
parent 8fdab2ed13
commit 178aa574ce
6 changed files with 34 additions and 60 deletions
+1 -5
View File
@@ -98,11 +98,7 @@ function public.scan_auctions()
private.update_listing() private.update_listing()
Aux.scan.start{ Aux.scan.start{
type = 'owner', type = 'owner',
queries = { queries = {{ blizzard_query = {} }},
{
start_page = 0,
}
},
on_page_loaded = function(page, total_pages) on_page_loaded = function(page, total_pages)
private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages) private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages)
private.status_bar:set_text(format('Scanning (Page %d / %d)', page + 1, total_pages)) private.status_bar:set_text(format('Scanning (Page %d / %d)', page + 1, total_pages))
+1 -5
View File
@@ -118,11 +118,7 @@ function public.scan_bids()
private.update_listing() private.update_listing()
Aux.scan.start{ Aux.scan.start{
type = 'bidder', type = 'bidder',
queries = { queries = {{ blizzard_query = {} }},
{
start_page = 0,
}
},
on_page_loaded = function(page, total_pages) on_page_loaded = function(page, total_pages)
private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages) private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages)
private.status_bar:set_text(format('Scanning (Page %d / %d)', page + 1, total_pages)) private.status_bar:set_text(format('Scanning (Page %d / %d)', page + 1, total_pages))
+14 -18
View File
@@ -144,8 +144,7 @@ function private.update_auction_listing()
tinsert(auction_rows, { tinsert(auction_rows, {
cols = { cols = {
{ value=auction_record.count }, { value=auction_record.own and GREEN_FONT_COLOR_CODE..auction_record.count..FONT_COLOR_CODE_CLOSE or auction_record.count },
{ value=auction_record.yours > 0 and GREEN_FONT_COLOR_CODE..auction_record.yours..FONT_COLOR_CODE_CLOSE or auction_record.yours },
{ value=Aux.auction_listing.time_left(auction_record.duration) }, { value=Aux.auction_listing.time_left(auction_record.duration) },
{ value=auction_record.stack_size == stack_size and GREEN_FONT_COLOR_CODE..auction_record.stack_size..FONT_COLOR_CODE_CLOSE or auction_record.stack_size }, { value=auction_record.stack_size == stack_size and GREEN_FONT_COLOR_CODE..auction_record.stack_size..FONT_COLOR_CODE_CLOSE or auction_record.stack_size },
{ value=Aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) }, { value=Aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) },
@@ -159,8 +158,7 @@ function private.update_auction_listing()
a.record.unit_buyout_price, b.record.unit_buyout_price, a.record.unit_buyout_price, b.record.unit_buyout_price,
a.record.unit_blizzard_bid, b.record.unit_blizzard_bid, a.record.unit_blizzard_bid, b.record.unit_blizzard_bid,
a.record.stack_size, b.record.stack_size, a.record.stack_size, b.record.stack_size,
a.record.count - a.record.yours, b.record.count - b.record.yours, b.record.own and 1 or 0, a.record.own and 1 or 0,
b.record.yours, a.record.yours,
a.record.duration, b.record.duration a.record.duration, b.record.duration
) end) ) end)
end end
@@ -224,23 +222,22 @@ function public.on_load()
private.auction_listing = Aux.listing.CreateScrollingTable(AuxSellAuctions) private.auction_listing = Aux.listing.CreateScrollingTable(AuxSellAuctions)
private.auction_listing:SetColInfo({ private.auction_listing:SetColInfo({
{ name='Auctions', width=.12, align='CENTER' }, { name='Auctions', width=.14, align='CENTER' },
{ name='Yours', width=.12, align='CENTER' }, { name='Left', width=.12, align='CENTER' },
{ name='Left', width=.1, align='CENTER' }, { name='Qty', width=.1, align='CENTER' },
{ name='Qty', width=.08, align='CENTER' }, { name='Bid/ea', width=.25, align='RIGHT' },
{ name='Bid/ea', width=.23, align='RIGHT' }, { name='Buy/ea', width=.25, align='RIGHT' },
{ name='Buy/ea', width=.23, align='RIGHT' }, { name='Pct', width=.14, align='CENTER' }
{ name='Pct', width=.12, align='CENTER' }
}) })
private.auction_listing:DisableSelection(true) private.auction_listing:DisableSelection(true)
private.auction_listing:SetHandler('OnClick', function(table, row_data, column, button) private.auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
local column_index = Aux.util.index_of(column, column.row.cols) local column_index = Aux.util.index_of(column, column.row.cols)
local unit_start_price, unit_buyout_price = private.undercut(row_data.record, private.stack_size_slider:GetValue(), button == 'RightButton') local unit_start_price, unit_buyout_price = private.undercut(row_data.record, private.stack_size_slider:GetValue(), button == 'RightButton')
if column_index == 4 then if column_index == 3 then
private.stack_size_slider:SetValue(row_data.record.stack_size) private.stack_size_slider:SetValue(row_data.record.stack_size)
elseif column_index == 5 then elseif column_index == 4 then
private.set_unit_start_price(unit_start_price) private.set_unit_start_price(unit_start_price)
elseif column_index == 6 then elseif column_index == 5 then
private.set_unit_buyout_price(unit_buyout_price) private.set_unit_buyout_price(unit_buyout_price)
end end
end) end)
@@ -721,7 +718,7 @@ function private.undercut(record, stack_size, stack)
local start_price = Aux.round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size)) local start_price = Aux.round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
local buyout_price = Aux.round(record.unit_buyout_price * (stack and record.stack_size or stack_size)) local buyout_price = Aux.round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
if record.yours < record.count then if not record.own then
start_price = max(0, start_price - 1) start_price = max(0, start_price - 1)
buyout_price = max(0, buyout_price - 1) buyout_price = max(0, buyout_price - 1)
end end
@@ -929,7 +926,7 @@ function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyou
existing_auctions[key] = existing_auctions[key] or {} existing_auctions[key] = existing_auctions[key] or {}
local entry local entry
for _, existing_entry in ipairs(existing_auctions[key]) do for _, existing_entry in ipairs(existing_auctions[key]) do
if unit_blizzard_bid == existing_entry.unit_blizzard_bid and unit_buyout_price == existing_entry.unit_buyout_price and aux_quantity == existing_entry.stack_size and duration == existing_entry.duration then if unit_blizzard_bid == existing_entry.unit_blizzard_bid and unit_buyout_price == existing_entry.unit_buyout_price and aux_quantity == existing_entry.stack_size and duration == existing_entry.duration and Aux.is_player(owner) == existing_entry.own then
entry = existing_entry entry = existing_entry
end end
end end
@@ -941,14 +938,13 @@ function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyou
unit_blizzard_bid = unit_blizzard_bid, unit_blizzard_bid = unit_blizzard_bid,
unit_buyout_price = unit_buyout_price, unit_buyout_price = unit_buyout_price,
duration = duration, duration = duration,
own = Aux.is_player(owner),
count = 0, count = 0,
yours = 0,
} }
tinsert(existing_auctions[key], entry) tinsert(existing_auctions[key], entry)
end end
entry.count = entry.count + 1 entry.count = entry.count + 1
entry.yours = entry.yours + (Aux.is_player(owner) and 1 or 0)
return entry return entry
end end
+14 -17
View File
@@ -18,7 +18,7 @@ function private.current_query()
end end
function private.current_thread() function private.current_thread()
for _, thread in pairs(threads) do for _, thread in threads do
if thread.id == Aux.control.thread_id then if thread.id == Aux.control.thread_id then
return thread return thread
end end
@@ -26,7 +26,7 @@ function private.current_thread()
end end
function public.start(params) function public.start(params)
public.abort(params.type) public.abort(Aux.util.safe_index(threads[params.type], 'id'))
local thread_id = Aux.control.new_thread(private.scan) local thread_id = Aux.control.new_thread(private.scan)
threads[params.type] = { threads[params.type] = {
@@ -131,13 +131,10 @@ end
function private.scan() function private.scan()
private.wait_for_callback(private.current_thread().params.on_start_scan, function() private.wait_for_callback(private.current_thread().params.on_start_scan, function()
local start_query_index = private.current_thread().params.start_query_index or 1 private.current_thread().query_index = private.current_thread().query_index and private.current_thread().query_index + 1 or 1
local next_query_index = private.current_thread().params.next_query_index or function(query_index) return query_index + 1 end
private.current_thread().query_index = private.current_thread().query_index and next_query_index(private.current_thread().query_index) or start_query_index
if private.current_query() then if private.current_query() then
private.wait_for_callback(private.current_thread().params.on_start_query, private.current_thread().query_index, function() private.wait_for_callback(private.current_thread().params.on_start_query, private.current_thread().query_index, function()
private.current_thread().page = private.current_query().start_page private.current_thread().page = private.current_query().start_page or 0
return private.process_query() return private.process_query()
end) end)
else else
@@ -206,7 +203,7 @@ function private.scan_auctions_helper(i, n, k)
end end
function private.submit_query(k) function private.submit_query(k)
if private.current_thread().blizzard_query then if private.current_query().blizzard_query then
Aux.control.wait_until(function() return private.current_thread().params.type ~= 'list' or CanSendAuctionQuery() end, function() Aux.control.wait_until(function() return private.current_thread().params.type ~= 'list' or CanSendAuctionQuery() end, function()
if private.current_thread().params.on_submit_query then if private.current_thread().params.on_submit_query then
@@ -218,15 +215,15 @@ function private.submit_query(k)
GetOwnerAuctionItems(private.current_thread().page) GetOwnerAuctionItems(private.current_thread().page)
else else
QueryAuctionItems( QueryAuctionItems(
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'name'), Aux.util.safe_index(private.current_query().blizzard_query, 'name'),
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'min_level'), Aux.util.safe_index(private.current_query().blizzard_query, 'min_level'),
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'max_level'), Aux.util.safe_index(private.current_query().blizzard_query, 'max_level'),
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'slot'), Aux.util.safe_index(private.current_query().blizzard_query, 'slot'),
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'class'), Aux.util.safe_index(private.current_query().blizzard_query, 'class'),
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'subclass'), Aux.util.safe_index(private.current_query().blizzard_query, 'subclass'),
private.current_thread().page, private.current_thread().page,
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'usable'), Aux.util.safe_index(private.current_query().blizzard_query, 'usable'),
Aux.util.safe_index(private.current_query(), 'blizzard_query', 'quality') Aux.util.safe_index(private.current_query().blizzard_query, 'quality')
) )
end end
private.wait_for_results(function() private.wait_for_results(function()
@@ -242,7 +239,7 @@ function private.submit_query(k)
end) end)
end) end)
else else
private.current_thread().total_pages = 0 private.current_thread().total_pages = 1
return k() return k()
end end
end end
+4 -4
View File
@@ -316,13 +316,13 @@ function m.find(auction_record, status_bar, on_abort, on_failure, on_success)
return auction_info and auction_info.search_signature == auction_record.search_signature return auction_info and auction_info.search_signature == auction_record.search_signature
end end
local pages = auction_record.page > 0 and { auction_record.page, auction_record.page - 1 } or { auction_record.page }
local queries = {} local queries = {}
tinsert(queries, {}) tinsert(queries, {})
if auction_record.blizzard_query then if auction_record.blizzard_query then
tinsert(queries, { local pages = auction_record.page > 0 and { auction_record.page - 1 } or {}
tinsert(queries, {
blizzard_query = auction_record.blizzard_query, blizzard_query = auction_record.blizzard_query,
start_page = auction_record.page,
next_page = function() next_page = function()
if getn(pages) == 1 then if getn(pages) == 1 then
status_bar:update_status(50, 50) status_bar:update_status(50, 50)
@@ -394,7 +394,7 @@ function m.item_query(item_id, page, single_page)
if item_info then if item_info then
local filter = m.filter_from_string(item_info.name..'/exact') local filter = m.filter_from_string(item_info.name..'/exact')
return { return {
start_page = page or 0, start_page = page,
next_page = single_page and Aux.util.pass, next_page = single_page and Aux.util.pass,
validator = filter.validator, validator = filter.validator,
blizzard_query = filter.blizzard_query, blizzard_query = filter.blizzard_query,
-11
View File
@@ -795,7 +795,6 @@ function public.start_search(filter_string, resume)
queries = Aux.util.map(filters, function(filter) queries = Aux.util.map(filters, function(filter)
return { return {
start_page = 0,
blizzard_query = filter.blizzard_query, blizzard_query = filter.blizzard_query,
validator = filter.validator, validator = filter.validator,
} }
@@ -980,16 +979,6 @@ do
end end
end end
-- if auction_info.current_bid == 0 then
-- status = 'No Bid'
-- elseif auction_info.high_bidder then
-- status = GREEN_FONT_COLOR_CODE..'Your Bid'..FONT_COLOR_CODE_CLOSE
-- else
-- status = 'Other Bidder'
-- end
function private.initialize_class_dropdown() function private.initialize_class_dropdown()
local function on_click() local function on_click()
if this.value ~= UIDropDownMenu_GetSelectedValue(private.class_dropdown) then if this.value ~= UIDropDownMenu_GetSelectedValue(private.class_dropdown) then