sniping mode finished
This commit is contained in:
@@ -49,7 +49,7 @@ end
|
||||
|
||||
Aux = Aux_addon()
|
||||
|
||||
Aux.version = '2.15.10'
|
||||
Aux.version = '2.16.0'
|
||||
Aux.blizzard_ui_shown = false
|
||||
Aux.orig = {}
|
||||
|
||||
@@ -398,8 +398,8 @@ function Aux.SetItemRef(...)
|
||||
if AuxSearchFrame:IsVisible() and button == 'RightButton' then
|
||||
local item_info = Aux.info.item(tonumber(({strfind(itemstring, '^item:(%d+)')})[3]))
|
||||
if item_info then
|
||||
Aux.search_frame.set_filter(item_info.name..'/exact')
|
||||
Aux.search_frame.execute('search')
|
||||
Aux.search_frame.set_filter(strlower(item_info.name)..'/exact')
|
||||
Aux.search_frame.execute()
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -416,7 +416,8 @@ function Aux.UseContainerItem(...)
|
||||
local item_info = Aux.info.container_item(bag, slot)
|
||||
item_info = item_info and Aux.info.item(item_info.item_id)
|
||||
if item_info then
|
||||
Aux.search_frame.execute('search', strlower(item_info.name)..'/exact')
|
||||
Aux.search_frame.set_filter(strlower(item_info.name)..'/exact')
|
||||
Aux.search_frame.execute()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -368,10 +368,10 @@ function m.horizontal_line(parent, y_offset, inverted_color)
|
||||
return texture
|
||||
end
|
||||
|
||||
function m.vertical_line(parent, x_offset, inverted_color)
|
||||
function m.vertical_line(parent, x_offset, top_offset, bottom_offset, inverted_color)
|
||||
local texture = parent:CreateTexture()
|
||||
texture:SetPoint('TOPLEFT', parent, 'TOPLEFT', x_offset, -2)
|
||||
texture:SetPoint('BOTTOMLEFT', parent, 'BOTTOMLEFT', x_offset, 2)
|
||||
texture:SetPoint('TOPLEFT', parent, 'TOPLEFT', x_offset, top_offset or -2)
|
||||
texture:SetPoint('BOTTOMLEFT', parent, 'BOTTOMLEFT', x_offset, bottom_offset or 2)
|
||||
texture:SetWidth(2)
|
||||
if inverted_color then
|
||||
texture:SetTexture(unpack(m.config.frame_color))
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
local m, private , public = Aux:module('scan')
|
||||
local m, private, public = Aux:module('scan')
|
||||
|
||||
local PAGE_SIZE = 50
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ function Aux.post_frame.create_frames(private, public)
|
||||
private.set_item(this.item_record)
|
||||
elseif arg1 == 'RightButton' then
|
||||
Aux.tab_group:set_tab(1)
|
||||
Aux.search_frame.execute('search', strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
|
||||
Aux.search_frame.set_filter(strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
|
||||
Aux.search_frame.execute()
|
||||
end
|
||||
end,
|
||||
function()
|
||||
|
||||
+75
-80
@@ -207,43 +207,27 @@ function public.on_load()
|
||||
private.update_tab(private.SAVED)
|
||||
end
|
||||
|
||||
function public.execute(mode, filter_string)
|
||||
|
||||
filter_string = filter_string or private.search_box:GetText()
|
||||
private.search_box:SetText(filter_string)
|
||||
|
||||
local queries = Aux.scan_util.parse_filter_string(filter_string)
|
||||
if not queries then
|
||||
return
|
||||
elseif getn(queries) > 1 then
|
||||
Aux.log('Invalid filter: The sniping mode does not support multiple queries')
|
||||
end
|
||||
if queries[1].blizzard_query.first_page or queries[1].blizzard_query.last_page then
|
||||
Aux.log('Invalid filter: The sniping mode does not support page range filters')
|
||||
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])
|
||||
function private.discard_continuation()
|
||||
Aux.scan.abort(search_scan_id)
|
||||
private.current_search().continuation = nil
|
||||
private.disable_resume()
|
||||
end
|
||||
|
||||
function private.sniping_helper(search, query)
|
||||
function private.snipe(query, search)
|
||||
|
||||
local ignore_page = not query.blizzard_query.first_page
|
||||
query.blizzard_query.first_page = query.blizzard_query.first_page or 0
|
||||
query.blizzard_query.last_page = query.blizzard_query.last_page or 0
|
||||
local ignore_page
|
||||
if not search then
|
||||
search = private.current_search()
|
||||
query.blizzard_query.first_page = 0
|
||||
query.blizzard_query.last_page = 0
|
||||
ignore_page = true
|
||||
end
|
||||
|
||||
local sniping_map = {}
|
||||
for _, record in search.records do
|
||||
sniping_map[record.sniping_signature] = record
|
||||
end
|
||||
|
||||
private.update_tab(private.RESULTS)
|
||||
|
||||
local next_page
|
||||
search_scan_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
@@ -276,43 +260,27 @@ function private.sniping_helper(search, query)
|
||||
|
||||
query.blizzard_query.first_page = next_page
|
||||
query.blizzard_query.last_page = next_page
|
||||
private.sniping_helper(search, query)
|
||||
private.snipe(query, search)
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Sniping')
|
||||
|
||||
search.continuation = true
|
||||
if private.current_search() == search then
|
||||
private.enable_resume()
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function public.snipe(mode, filter_string)
|
||||
function private.search(queries, resume)
|
||||
local current_query, current_page, total_queries, start_query, start_page
|
||||
|
||||
filter_string = filter_string or private.search_box:GetText()
|
||||
private.search_box:SetText(filter_string)
|
||||
|
||||
if mode == 'search' and private.search_box:GetText() == private.current_search().filter_string then
|
||||
mode = 'refresh'
|
||||
end
|
||||
|
||||
local queries, current_query, current_page, total_queries, start_page, start_query
|
||||
|
||||
if mode == 'refresh' or mode == 'resume' then
|
||||
private.search_box:ClearFocus()
|
||||
private.search_box:SetText(private.current_search().filter_string)
|
||||
end
|
||||
if mode == 'refresh' then
|
||||
private.current_search().records = {}
|
||||
private.results_listing:SetDatabase(private.current_search().records)
|
||||
end
|
||||
|
||||
queries = Aux.scan_util.parse_filter_string(filter_string)
|
||||
if not queries then
|
||||
return
|
||||
end
|
||||
total_queries = getn(queries)
|
||||
|
||||
if mode == 'resume' then
|
||||
start_query, start_page = unpack(private.current_search().next)
|
||||
if resume then
|
||||
start_query, start_page = unpack(private.current_search().continuation)
|
||||
for i=1,start_query-1 do
|
||||
tremove(queries, 1)
|
||||
end
|
||||
@@ -321,18 +289,7 @@ function public.snipe(mode, filter_string)
|
||||
else
|
||||
start_query, start_page = 1, 1
|
||||
end
|
||||
|
||||
if mode == 'search' then
|
||||
private.new_search(filter_string, Aux.util.join(Aux.util.map(queries, function(filter) return filter.prettified end), ';'))
|
||||
end
|
||||
|
||||
if mode == 'resume' or mode == 'refresh' then
|
||||
Aux.scan.abort(search_scan_id)
|
||||
private.current_search().next = nil
|
||||
private.disable_resume()
|
||||
end
|
||||
|
||||
private.update_tab(private.RESULTS)
|
||||
private.discard_continuation()
|
||||
|
||||
local search = private.current_search()
|
||||
search_scan_id = Aux.scan.start{
|
||||
@@ -340,12 +297,10 @@ function public.snipe(mode, filter_string)
|
||||
queries = queries,
|
||||
on_scan_start = function()
|
||||
private.status_bar:update_status(0,0)
|
||||
if mode == 'search' then
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
elseif mode == 'refresh' then
|
||||
private.status_bar:set_text('Rescanning auctions...')
|
||||
elseif mode == 'resume' then
|
||||
if resume then
|
||||
private.status_bar:set_text('Resuming scan...')
|
||||
else
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
end
|
||||
end,
|
||||
on_page_loaded = function(_, total_scan_pages)
|
||||
@@ -384,11 +339,10 @@ function public.snipe(mode, filter_string)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
|
||||
if current_query then
|
||||
search.next = {current_query, current_page + 1}
|
||||
search.continuation = {current_query, current_page + 1}
|
||||
else
|
||||
search.next = {start_query, start_page}
|
||||
search.continuation = {start_query, start_page}
|
||||
end
|
||||
|
||||
if private.current_search() == search then
|
||||
private.enable_resume()
|
||||
end
|
||||
@@ -396,6 +350,51 @@ function public.snipe(mode, filter_string)
|
||||
}
|
||||
end
|
||||
|
||||
function public.execute(snipe, resume)
|
||||
if resume then
|
||||
private.search_box:SetText(private.current_search().filter_string)
|
||||
end
|
||||
local filter_string = private.search_box:GetText()
|
||||
|
||||
local queries = Aux.scan_util.parse_filter_string(filter_string)
|
||||
if not queries then
|
||||
return
|
||||
elseif snipe then
|
||||
if getn(queries) > 1 then
|
||||
Aux.log('Invalid filter: The sniping mode does not support multiple queries')
|
||||
return
|
||||
elseif queries[1].blizzard_query.first_page or queries[1].blizzard_query.last_page then
|
||||
Aux.log('Invalid filter: The sniping mode does not support page range filters')
|
||||
return
|
||||
end
|
||||
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.search_box:ClearFocus()
|
||||
if resume then
|
||||
private.results_listing:SetSelectedRecord()
|
||||
else
|
||||
if private.current_search().snipe ~= snipe then
|
||||
private.results_listing:Reset()
|
||||
end
|
||||
private.current_search().records = {}
|
||||
private.results_listing:SetDatabase(private.current_search().records)
|
||||
end
|
||||
end
|
||||
|
||||
private.update_tab(private.RESULTS)
|
||||
if snipe then
|
||||
private.current_search().snipe = true
|
||||
private.discard_continuation()
|
||||
private.snipe(queries[1])
|
||||
else
|
||||
private.current_search().snipe = false
|
||||
private.search(queries, resume)
|
||||
end
|
||||
end
|
||||
|
||||
function private.test(record)
|
||||
return function(index)
|
||||
local auction_info = Aux.info.auction(index)
|
||||
@@ -496,7 +495,7 @@ end
|
||||
|
||||
function private.disable_resume()
|
||||
private.resume_button:Hide()
|
||||
private.search_box:SetPoint('RIGHT', private.refresh_button, 'LEFT', -4, 0)
|
||||
private.search_box:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
|
||||
end
|
||||
|
||||
do
|
||||
@@ -528,10 +527,7 @@ do
|
||||
private.next_button:Show()
|
||||
private.search_box:SetPoint('LEFT', private.next_button, 'RIGHT', 4, 0)
|
||||
end
|
||||
if search_index > 0 then
|
||||
private.refresh_button:Enable()
|
||||
end
|
||||
if searches[search_index].next then
|
||||
if searches[search_index].continuation and searches[search_index].snipe == private.snipe_button.enabled then
|
||||
private.enable_resume()
|
||||
else
|
||||
private.disable_resume()
|
||||
@@ -551,7 +547,6 @@ do
|
||||
tinsert(searches, search_index + 1, {
|
||||
filter_string = filter_string,
|
||||
records = {},
|
||||
-- sniping = private.snipe_button:GetChecked() TODO
|
||||
})
|
||||
while getn(searches) > search_index + 1 do
|
||||
tremove(searches)
|
||||
|
||||
+40
-17
@@ -1,7 +1,30 @@
|
||||
function Aux.search_frame.create_frames(private, public)
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 26)
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 22)
|
||||
btn:SetPoint('TOPLEFT', 5, -8)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Snipe')
|
||||
btn:SetScript('OnClick', function()
|
||||
this.enabled = not this.enabled
|
||||
if this.enabled then
|
||||
this:LockHighlight()
|
||||
else
|
||||
this:UnlockHighlight()
|
||||
end
|
||||
if private.current_search().continuation and private.current_search().snipe == private.snipe_button.enabled then
|
||||
private.enable_resume()
|
||||
else
|
||||
private.disable_resume()
|
||||
end
|
||||
end)
|
||||
btn.enabled = false
|
||||
private.snipe_button = btn
|
||||
end
|
||||
Aux.gui.vertical_line(AuxSearchFrame, 80, nil, 408)
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 26)
|
||||
btn:SetPoint('LEFT', private.snipe_button, 'RIGHT', 12, 0)
|
||||
btn:SetWidth(30)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('<')
|
||||
@@ -22,21 +45,20 @@ function Aux.search_frame.create_frames(private, public)
|
||||
btn:SetPoint('TOPRIGHT', -5, -8)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Refresh')
|
||||
btn:SetText('Start')
|
||||
btn:SetScript('OnClick', function()
|
||||
public.execute('refresh')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
btn:Disable()
|
||||
private.refresh_button = btn
|
||||
private.start_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 22)
|
||||
btn:SetPoint('RIGHT', private.refresh_button, 'LEFT', -4, 0)
|
||||
btn:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText(GREEN_FONT_COLOR_CODE..'Resume'..FONT_COLOR_CODE_CLOSE)
|
||||
btn:SetScript('OnClick', function()
|
||||
public.execute('resume')
|
||||
public.execute(private.snipe_button.enabled, true)
|
||||
end)
|
||||
private.resume_button = btn
|
||||
end
|
||||
@@ -45,7 +67,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
editbox:SetMaxLetters(nil)
|
||||
editbox:EnableMouse(1)
|
||||
editbox.complete = Aux.completion.complete
|
||||
editbox:SetPoint('RIGHT', private.refresh_button, 'LEFT', -4, 0)
|
||||
editbox:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetScript('OnChar', function()
|
||||
this:complete()
|
||||
@@ -56,12 +78,13 @@ function Aux.search_frame.create_frames(private, public)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:HighlightText(0, 0)
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
editbox:SetScript('OnReceiveDrag', function()
|
||||
local item_info = Aux.cursor_item() and Aux.info.item(Aux.cursor_item().item_id)
|
||||
if item_info then
|
||||
public.execute('search', strlower(item_info.name)..'/exact')
|
||||
public.set_filter(strlower(item_info.name)..'/exact')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end
|
||||
ClearCursor()
|
||||
end)
|
||||
@@ -162,7 +185,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
private.search_box:SetText('')
|
||||
private.add_filter()
|
||||
private.clear_form()
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
|
||||
local btn2 = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
@@ -204,7 +227,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
@@ -235,7 +258,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
@@ -256,7 +279,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
|
||||
@@ -343,7 +366,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
@@ -365,7 +388,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
|
||||
@@ -605,7 +628,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end
|
||||
elseif button == 'LeftButton' then
|
||||
private.search_box:SetText(data.search.filter_string)
|
||||
public.execute('search')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
elseif button == 'RightButton' then
|
||||
if st == private.recent_searches_listing then
|
||||
tinsert(aux_favorite_searches, 1, data.search)
|
||||
|
||||
@@ -655,7 +655,8 @@ local methods = {
|
||||
ChatFrameEditBox:Insert(this.row.data.record.hyperlink)
|
||||
elseif Aux.unmodified() and button == 'RightButton' then -- TODO not when alt (how?)
|
||||
Aux.tab_group:set_tab(1)
|
||||
Aux.search_frame.execute('search', strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact')
|
||||
Aux.search_frame.set_filter(strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact')
|
||||
Aux.search_frame.execute()
|
||||
else
|
||||
local selection = this.rt:GetSelection()
|
||||
if not selection or selection.record ~= this.row.data.record then
|
||||
|
||||
Reference in New Issue
Block a user