working on sniping mode
This commit is contained in:
+7
-7
@@ -5,14 +5,14 @@ local PAGE_SIZE = 50
|
|||||||
local state
|
local state
|
||||||
local threads = {}
|
local threads = {}
|
||||||
|
|
||||||
function private.total_pages(total_count)
|
function private.total_pages(total_auctions)
|
||||||
return math.ceil(total_count / PAGE_SIZE)
|
return math.ceil(total_auctions / PAGE_SIZE)
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.last_page(total_count)
|
function private.last_page(total_auctions)
|
||||||
local last_page = max(m.total_pages(total_count) - 1, 0)
|
local last_page = max(m.total_pages(total_auctions) - 1, 0)
|
||||||
local last_page_limit = Aux.util.safe_index(m.current_query().blizzard_query, 'last_page')
|
local last_page_limit = Aux.util.safe_index(m.current_query().blizzard_query, 'last_page') or last_page
|
||||||
return last_page_limit and min(last_page_limit, last_page) or last_page
|
return min(last_page_limit, last_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.current_query()
|
function private.current_query()
|
||||||
@@ -236,7 +236,7 @@ function private.submit_query(k)
|
|||||||
m.current_thread().params.on_page_loaded,
|
m.current_thread().params.on_page_loaded,
|
||||||
m.current_thread().page - (m.current_query().blizzard_query.first_page or 0) + 1,
|
m.current_thread().page - (m.current_query().blizzard_query.first_page or 0) + 1,
|
||||||
m.last_page(m.current_thread().total_auctions) - (m.current_query().blizzard_query.first_page or 0) + 1,
|
m.last_page(m.current_thread().total_auctions) - (m.current_query().blizzard_query.first_page or 0) + 1,
|
||||||
m.total_pages(m.current_thread().total_auctions),
|
m.total_pages(m.current_thread().total_auctions) - 1,
|
||||||
k
|
k
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|||||||
+17
-10
@@ -222,7 +222,11 @@ function public.execute(mode, filter_string)
|
|||||||
Aux.log('Invalid filter: The sniping mode does not support page range filters')
|
Aux.log('Invalid filter: The sniping mode does not support page range filters')
|
||||||
end
|
end
|
||||||
|
|
||||||
private.new_search(filter_string, Aux.util.join(Aux.util.map(queries, function(filter) return filter.prettified end), ';'))
|
if filter_string ~= private.current_search().filter_string then
|
||||||
|
private.new_search(filter_string, Aux.util.join(Aux.util.map(queries, function(filter) return filter.prettified end), ';'))
|
||||||
|
else
|
||||||
|
private.results_listing:SetSelectedRecord()
|
||||||
|
end
|
||||||
|
|
||||||
private.sniping_helper(private.current_search(), queries[1])
|
private.sniping_helper(private.current_search(), queries[1])
|
||||||
end
|
end
|
||||||
@@ -240,6 +244,7 @@ function private.sniping_helper(search, query)
|
|||||||
|
|
||||||
private.update_tab(private.RESULTS)
|
private.update_tab(private.RESULTS)
|
||||||
|
|
||||||
|
local next_page
|
||||||
search_scan_id = Aux.scan.start{
|
search_scan_id = Aux.scan.start{
|
||||||
type = 'list',
|
type = 'list',
|
||||||
queries = {query},
|
queries = {query},
|
||||||
@@ -248,9 +253,8 @@ function private.sniping_helper(search, query)
|
|||||||
private.status_bar:set_text('Sniping ...')
|
private.status_bar:set_text('Sniping ...')
|
||||||
end,
|
end,
|
||||||
on_page_loaded = function(_, _, last_page)
|
on_page_loaded = function(_, _, last_page)
|
||||||
query.blizzard_query.first_page = last_page - 1
|
next_page = last_page
|
||||||
query.blizzard_query.last_page = last_page - 1
|
if last_page == 0 then
|
||||||
if last_page == 1 then
|
|
||||||
ignore_page = false
|
ignore_page = false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -270,6 +274,8 @@ function private.sniping_helper(search, query)
|
|||||||
private.results_listing:SetDatabase(search.records)
|
private.results_listing:SetDatabase(search.records)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
query.blizzard_query.first_page = next_page
|
||||||
|
query.blizzard_query.last_page = next_page
|
||||||
private.sniping_helper(search, query)
|
private.sniping_helper(search, query)
|
||||||
end,
|
end,
|
||||||
on_abort = function()
|
on_abort = function()
|
||||||
@@ -342,13 +348,13 @@ function public.snipe(mode, filter_string)
|
|||||||
private.status_bar:set_text('Resuming scan...')
|
private.status_bar:set_text('Resuming scan...')
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_page_loaded = function(_, total_pages)
|
on_page_loaded = function(_, total_scan_pages)
|
||||||
current_page = current_page + 1
|
current_page = current_page + 1
|
||||||
total_pages = total_pages + (start_page - 1)
|
total_scan_pages = total_scan_pages + (start_page - 1)
|
||||||
total_pages = max(total_pages, 1)
|
total_scan_pages = max(total_scan_pages, 1)
|
||||||
current_page = min(current_page, total_pages)
|
current_page = min(current_page, total_scan_pages)
|
||||||
private.status_bar:update_status(100 * (current_query - 1) / getn(queries), 100 * (current_page - 1) / total_pages)
|
private.status_bar:update_status(100 * (current_query - 1) / getn(queries), 100 * (current_page - 1) / total_scan_pages)
|
||||||
private.status_bar:set_text(format('Scanning %d / %d (Page %d / %d)', current_query, total_queries, current_page, total_pages))
|
private.status_bar:set_text(format('Scanning %d / %d (Page %d / %d)', current_query, total_queries, current_page, total_scan_pages))
|
||||||
end,
|
end,
|
||||||
on_page_scanned = function()
|
on_page_scanned = function()
|
||||||
private.results_listing:SetDatabase()
|
private.results_listing:SetDatabase()
|
||||||
@@ -545,6 +551,7 @@ do
|
|||||||
tinsert(searches, search_index + 1, {
|
tinsert(searches, search_index + 1, {
|
||||||
filter_string = filter_string,
|
filter_string = filter_string,
|
||||||
records = {},
|
records = {},
|
||||||
|
-- sniping = private.snipe_button:GetChecked() TODO
|
||||||
})
|
})
|
||||||
while getn(searches) > search_index + 1 do
|
while getn(searches) > search_index + 1 do
|
||||||
tremove(searches)
|
tremove(searches)
|
||||||
|
|||||||
Reference in New Issue
Block a user