added item query abstraction
This commit is contained in:
+7
-18
@@ -548,31 +548,20 @@ function public.start_search()
|
||||
refresh = true
|
||||
|
||||
local item_id = private.item_id
|
||||
local item_info = Aux.static.item_info(item_id)
|
||||
|
||||
-- local class_index = Aux.item_class_index(item_info.class)
|
||||
-- local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) -- TODO test if needed
|
||||
|
||||
local query = {
|
||||
type = 'list',
|
||||
start_page = AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() and 0 or AuxItemSearchFrameItemPageEditBox:GetNumber(),
|
||||
next_page = function(page, total_pages)
|
||||
local query = Aux.scan_util.create_item_query(
|
||||
item_id,
|
||||
'list',
|
||||
AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() and 0 or AuxItemSearchFrameItemPageEditBox:GetNumber(),
|
||||
function(page, total_pages)
|
||||
if AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() then
|
||||
local last_page = max(total_pages - 1, 0)
|
||||
if page < last_page then
|
||||
return page + 1
|
||||
end
|
||||
end
|
||||
end,
|
||||
name = item_info.name,
|
||||
min_level = item_info.level,
|
||||
min_level = item_info.level,
|
||||
slot = item_info.slot,
|
||||
class = Aux.item_class_index(item_info.class),
|
||||
subclass = item_info.subclass,
|
||||
quality = item_info.quality,
|
||||
usable = item_info.usable,
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
Aux.scan.start{
|
||||
queries = { query },
|
||||
|
||||
+7
-19
@@ -618,32 +618,20 @@ function private.refresh_entries()
|
||||
if selected_item then
|
||||
local item_id, suffix_id = selected_item.item_id, selected_item.suffix_id
|
||||
local item_key = item_id..':'..suffix_id
|
||||
local item_info = Aux.info.item(item_id, suffix_id)
|
||||
|
||||
existing_auctions[item_key] = nil
|
||||
|
||||
|
||||
local class_index = Aux.item_class_index(item_info.class)
|
||||
local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass)
|
||||
|
||||
local query = {
|
||||
type = 'list',
|
||||
start_page = 0,
|
||||
next_page = function(page, total_pages)
|
||||
local query = Aux.scan_util.create_item_query(
|
||||
item_id,
|
||||
'list',
|
||||
0,
|
||||
function(page, total_pages)
|
||||
local last_page = max(total_pages - 1, 0)
|
||||
if page < last_page then
|
||||
return page + 1
|
||||
end
|
||||
end,
|
||||
name = Aux.info.item(item_id).name, -- blizzard doesn't support queries with name suffixes
|
||||
min_level = item_info.level,
|
||||
min_level = item_info.level,
|
||||
slot = item_info.slot,
|
||||
class = class_index,
|
||||
subclass = subclass_index,
|
||||
quality = item_info.quality,
|
||||
usable = item_info.usable,
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
+23
-1
@@ -11,7 +11,6 @@ function m.find(test, query, page, status_bar, on_failure, on_success)
|
||||
local pages = page > 0 and { page, page - 1 } or { page }
|
||||
|
||||
query = Aux.util.copy_table(query)
|
||||
query.page = page
|
||||
query.next_page = function()
|
||||
if getn(pages) == 1 then
|
||||
status_bar:update_status(50, 50)
|
||||
@@ -42,4 +41,27 @@ function m.find(test, query, page, status_bar, on_failure, on_success)
|
||||
end,
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
||||
function m.create_item_query(item_id, type, start_page, next_page)
|
||||
local item_info = Aux.static.item_info(item_id)
|
||||
|
||||
-- local class_index = Aux.item_class_index(item_info.class)
|
||||
-- local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) -- TODO test if needed
|
||||
|
||||
return item_info and {
|
||||
type = type,
|
||||
start_page = start_page,
|
||||
next_page = next_page,
|
||||
name = item_info.name,
|
||||
min_level = item_info.level,
|
||||
min_level = item_info.level,
|
||||
slot = item_info.slot,
|
||||
-- class = class_index,
|
||||
-- subclass = subclass_index,
|
||||
-- class = Aux.item_class_index(item_info.class),
|
||||
-- subclass = item_info.subclass,
|
||||
quality = item_info.quality,
|
||||
usable = item_info.usable,
|
||||
}
|
||||
end
|
||||
Reference in New Issue
Block a user