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