some search changes
This commit is contained in:
@@ -399,6 +399,7 @@ function Aux.SetItemRef(...)
|
||||
local item_info = Aux.info.item(tonumber(({strfind(itemstring, '^item:(%d+)')})[3]))
|
||||
if item_info then
|
||||
Aux.search_frame.set_filter(strlower(item_info.name)..'/exact')
|
||||
Aux.search_frame.disable_sniping()
|
||||
Aux.search_frame.execute()
|
||||
return
|
||||
end
|
||||
@@ -417,6 +418,7 @@ function Aux.UseContainerItem(...)
|
||||
item_info = item_info and Aux.info.item(item_info.item_id)
|
||||
if item_info then
|
||||
Aux.search_frame.set_filter(strlower(item_info.name)..'/exact')
|
||||
Aux.search_frame.disable_sniping()
|
||||
Aux.search_frame.execute()
|
||||
end
|
||||
return
|
||||
|
||||
@@ -55,6 +55,7 @@ function Aux.post_frame.create_frames(private, public)
|
||||
elseif arg1 == 'RightButton' then
|
||||
Aux.tab_group:set_tab(1)
|
||||
Aux.search_frame.set_filter(strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
|
||||
Aux.search_frame.disable_sniping()
|
||||
Aux.search_frame.execute()
|
||||
end
|
||||
end,
|
||||
|
||||
+56
-32
@@ -4,7 +4,7 @@ Aux.search_frame = public
|
||||
aux_favorite_searches = {}
|
||||
aux_recent_searches = {}
|
||||
|
||||
local search_scan_id = 0
|
||||
private.search_scan_id = 0
|
||||
|
||||
private.popup_info = {
|
||||
rename = {}
|
||||
@@ -215,17 +215,41 @@ end
|
||||
|
||||
function public.on_load()
|
||||
public.create_frames(private, public)
|
||||
public:disable_sniping()
|
||||
private.update_search()
|
||||
private.update_tab(private.SAVED)
|
||||
end
|
||||
|
||||
function private.discard_continuation()
|
||||
Aux.scan.abort(search_scan_id)
|
||||
Aux.scan.abort(private.search_scan_id)
|
||||
private.current_search().continuation = nil
|
||||
private.disable_resume()
|
||||
private.update_resume()
|
||||
end
|
||||
|
||||
function private.snipe(query, search)
|
||||
function private:enable_stop()
|
||||
Aux.scan.abort(private.search_scan_id)
|
||||
private.stop_button:Show()
|
||||
private.start_button:Hide()
|
||||
end
|
||||
|
||||
function private:enable_start()
|
||||
private.start_button:Show()
|
||||
private.stop_button:Hide()
|
||||
end
|
||||
|
||||
function public.enable_sniping()
|
||||
Aux.scan.abort(private.search_scan_id)
|
||||
private.snipe = true
|
||||
private.snipe_button:LockHighlight()
|
||||
end
|
||||
|
||||
function public.disable_sniping()
|
||||
Aux.scan.abort(private.search_scan_id)
|
||||
private.snipe = false
|
||||
private.snipe_button:UnlockHighlight()
|
||||
end
|
||||
|
||||
function private.start_sniping(query, search)
|
||||
|
||||
local ignore_page
|
||||
if not search then
|
||||
@@ -241,7 +265,7 @@ function private.snipe(query, search)
|
||||
end
|
||||
|
||||
local next_page
|
||||
search_scan_id = Aux.scan.start{
|
||||
private.search_scan_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
queries = {query},
|
||||
on_scan_start = function()
|
||||
@@ -276,7 +300,7 @@ function private.snipe(query, search)
|
||||
|
||||
query.blizzard_query.first_page = next_page
|
||||
query.blizzard_query.last_page = next_page
|
||||
private.snipe(query, search)
|
||||
private.start_sniping(query, search)
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
@@ -286,17 +310,19 @@ function private.snipe(query, search)
|
||||
if private.current_search() == search then
|
||||
private.update_resume()
|
||||
end
|
||||
|
||||
private:enable_start()
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function private.search(queries, resume)
|
||||
function private.start_search(queries, continuation)
|
||||
local current_query, current_page, total_queries, start_query, start_page
|
||||
|
||||
total_queries = getn(queries)
|
||||
|
||||
if resume then
|
||||
start_query, start_page = unpack(private.current_search().continuation)
|
||||
if continuation then
|
||||
start_query, start_page = unpack(continuation)
|
||||
for i=1,start_query-1 do
|
||||
tremove(queries, 1)
|
||||
end
|
||||
@@ -305,10 +331,9 @@ function private.search(queries, resume)
|
||||
else
|
||||
start_query, start_page = 1, 1
|
||||
end
|
||||
private.discard_continuation()
|
||||
|
||||
local search = private.current_search()
|
||||
search_scan_id = Aux.scan.start{
|
||||
private.search_scan_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
queries = queries,
|
||||
on_scan_start = function()
|
||||
@@ -349,6 +374,8 @@ function private.search(queries, resume)
|
||||
if private.current_search() == search and AuxSearchFrameResults:IsVisible() and getn(search.records) == 0 then
|
||||
private.update_tab(private.SAVED)
|
||||
end
|
||||
|
||||
private:enable_start()
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
@@ -362,11 +389,13 @@ function private.search(queries, resume)
|
||||
if private.current_search() == search then
|
||||
private.update_resume()
|
||||
end
|
||||
|
||||
private:enable_start()
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
function public.execute(snipe, resume)
|
||||
function public.execute(resume)
|
||||
if resume then
|
||||
private.search_box:SetText(private.current_search().filter_string)
|
||||
end
|
||||
@@ -375,7 +404,7 @@ function public.execute(snipe, resume)
|
||||
local queries = Aux.scan_util.parse_filter_string(filter_string)
|
||||
if not queries then
|
||||
return
|
||||
elseif snipe then
|
||||
elseif private.snipe then
|
||||
if getn(queries) > 1 then
|
||||
Aux.log('Invalid filter: The sniping mode does not support multiple queries')
|
||||
return
|
||||
@@ -392,7 +421,7 @@ function public.execute(snipe, resume)
|
||||
if resume then
|
||||
private.results_listing:SetSelectedRecord()
|
||||
else
|
||||
if private.current_search().snipe ~= snipe then
|
||||
if private.current_search().snipe ~= private.snipe then
|
||||
private.results_listing:Reset()
|
||||
end
|
||||
private.current_search().records = {}
|
||||
@@ -400,14 +429,17 @@ function public.execute(snipe, resume)
|
||||
end
|
||||
end
|
||||
|
||||
local continuation = private.current_search().continuation
|
||||
private.discard_continuation()
|
||||
private:enable_stop()
|
||||
|
||||
private.update_tab(private.RESULTS)
|
||||
if snipe then
|
||||
if private.snipe then
|
||||
private.current_search().snipe = true
|
||||
private.discard_continuation()
|
||||
private.snipe(queries[1])
|
||||
private.start_sniping(queries[1])
|
||||
else
|
||||
private.current_search().snipe = false
|
||||
private.search(queries, resume)
|
||||
private.start_search(queries, resume and continuation)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -504,21 +536,13 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function private.enable_resume()
|
||||
private.resume_button:Show()
|
||||
private.search_box:SetPoint('RIGHT', private.resume_button, 'LEFT', -4, 0)
|
||||
end
|
||||
|
||||
function private.disable_resume()
|
||||
private.resume_button:Hide()
|
||||
private.search_box:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
|
||||
end
|
||||
|
||||
function private.update_resume()
|
||||
if private.current_search().continuation and private.current_search().snipe == private.snipe_button.enabled then
|
||||
private.enable_resume()
|
||||
if private.current_search().continuation and private.current_search().snipe == private.snipe then
|
||||
private.resume_button:Show()
|
||||
private.search_box:SetPoint('RIGHT', private.resume_button, 'LEFT', -4, 0)
|
||||
else
|
||||
private.disable_resume()
|
||||
private.resume_button:Hide()
|
||||
private.search_box:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -534,7 +558,7 @@ do
|
||||
end
|
||||
|
||||
function private.update_search()
|
||||
Aux.scan.abort(search_scan_id)
|
||||
Aux.scan.abort(private.search_scan_id)
|
||||
private.search_box:ClearFocus()
|
||||
private.search_box:SetText(searches[search_index].filter_string)
|
||||
private.results_listing:Reset()
|
||||
|
||||
+27
-16
@@ -8,11 +8,10 @@ function Aux.search_frame.create_frames(private, public)
|
||||
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
|
||||
btn:SetScript('OnClick', function()
|
||||
if arg1 == 'LeftButton' then
|
||||
this.enabled = not this.enabled
|
||||
if this.enabled then
|
||||
this:LockHighlight()
|
||||
if private.snipe then
|
||||
public.disable_sniping()
|
||||
else
|
||||
this:UnlockHighlight()
|
||||
public.enable_sniping()
|
||||
end
|
||||
private.update_resume()
|
||||
elseif arg1 == 'RightButton' then
|
||||
@@ -24,7 +23,6 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end
|
||||
end
|
||||
end)
|
||||
btn.enabled = false
|
||||
btn.auto = false
|
||||
private.snipe_button = btn
|
||||
end
|
||||
@@ -54,10 +52,22 @@ function Aux.search_frame.create_frames(private, public)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Start')
|
||||
btn:SetScript('OnClick', function()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
end)
|
||||
private.start_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 22)
|
||||
btn:SetPoint('TOPRIGHT', -5, -8)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Stop')
|
||||
btn:SetScript('OnClick', function()
|
||||
Aux.scan.abort(private.search_scan_id)
|
||||
end)
|
||||
btn:Hide()
|
||||
private.stop_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxSearchFrame, 22)
|
||||
btn:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
|
||||
@@ -65,7 +75,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText(GREEN_FONT_COLOR_CODE..'Resume'..FONT_COLOR_CODE_CLOSE)
|
||||
btn:SetScript('OnClick', function()
|
||||
public.execute(private.snipe_button.enabled, true)
|
||||
public.execute(true)
|
||||
end)
|
||||
private.resume_button = btn
|
||||
end
|
||||
@@ -85,13 +95,14 @@ function Aux.search_frame.create_frames(private, public)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:HighlightText(0, 0)
|
||||
this:ClearFocus()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
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.set_filter(strlower(item_info.name)..'/exact')
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.disable_sniping()
|
||||
public.execute()
|
||||
end
|
||||
ClearCursor()
|
||||
end)
|
||||
@@ -192,7 +203,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
private.search_box:SetText('')
|
||||
private.add_filter()
|
||||
private.clear_form()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
end)
|
||||
|
||||
local btn2 = Aux.gui.button(AuxSearchFrameFilter, 16)
|
||||
@@ -234,7 +245,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
@@ -265,7 +276,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
@@ -286,7 +297,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
|
||||
@@ -373,7 +384,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
@@ -395,7 +406,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 13)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
|
||||
@@ -635,7 +646,7 @@ function Aux.search_frame.create_frames(private, public)
|
||||
end
|
||||
elseif button == 'LeftButton' then
|
||||
private.search_box:SetText(data.search.filter_string)
|
||||
public.execute(private.snipe_button.enabled)
|
||||
public.execute()
|
||||
elseif button == 'RightButton' then
|
||||
if st == private.recent_searches_listing then
|
||||
tinsert(aux_favorite_searches, 1, data.search)
|
||||
|
||||
@@ -656,6 +656,7 @@ local methods = {
|
||||
elseif Aux.unmodified() and button == 'RightButton' then -- TODO not when alt (how?)
|
||||
Aux.tab_group:set_tab(1)
|
||||
Aux.search_frame.set_filter(strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact')
|
||||
Aux.search_frame.disable_sniping()
|
||||
Aux.search_frame.execute()
|
||||
else
|
||||
local selection = this.rt:GetSelection()
|
||||
|
||||
Reference in New Issue
Block a user