search config design improvements
This commit is contained in:
@@ -82,7 +82,7 @@ Aux.post_tab.FRAMES(function(m, public, private)
|
||||
elseif arg1 == 'RightButton' then
|
||||
Aux.tab_group:set_tab(1)
|
||||
Aux.search_tab.set_filter(strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
|
||||
if m.real_time_button.on then
|
||||
if m.real_time_button:GetChecked() then
|
||||
m.real_time_button:Click()
|
||||
end
|
||||
Aux.search_tab.execute()
|
||||
|
||||
+53
-41
@@ -19,33 +19,15 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
|
||||
button1 = 'Yes',
|
||||
button2 = 'No',
|
||||
OnAccept = function()
|
||||
m.auto_buy_button.on = true
|
||||
m.auto_buy_button:SetBackdropColor(0.3, 0.7, 0.3)
|
||||
m.auto_buy_button:SetChecked(true)
|
||||
end,
|
||||
timeout = 0,
|
||||
hideOnEscape = 1,
|
||||
}
|
||||
do
|
||||
local function action()
|
||||
local queries = Aux.scan_util.parse_filter_string(getglobal(this:GetParent():GetName()..'EditBox'):GetText())
|
||||
if queries then
|
||||
|
||||
if getn(queries) > 1 then
|
||||
Aux.log('Error: The automatic buyout filter may contain only one query')
|
||||
return
|
||||
end
|
||||
|
||||
if Aux.util.size(queries[1].blizzard_query) > 0 then
|
||||
Aux.log('Error: The automatic buyout filter does not support Blizzard filters')
|
||||
return
|
||||
end
|
||||
|
||||
aux_auto_buy_filter = m.auto_buy_filter_editbox:GetText()
|
||||
m.auto_buy_validator = queries[1].validator
|
||||
m.auto_buy_filter_button.on = true
|
||||
m.auto_buy_button:SetBackdropColor(0.3, 0.7, 0.3)
|
||||
m.auto_buy_filter_editbox:ClearFocus()
|
||||
end
|
||||
aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText()
|
||||
m.update_auto_buy_filter()
|
||||
end
|
||||
|
||||
StaticPopupDialogs['AUX_SEARCH_AUTO_BUY_FILTER'] = {
|
||||
@@ -88,6 +70,7 @@ function public.LOAD()
|
||||
m.create_frames(m, public, private)
|
||||
m.update_search()
|
||||
m.update_tab(m.SAVED)
|
||||
m.update_auto_buy_filter()
|
||||
end
|
||||
|
||||
function public.OPEN()
|
||||
@@ -167,6 +150,25 @@ function private.add_filter(filter_string, replace)
|
||||
m.search_box:SetText((old_filter_string or '')..filter_string)
|
||||
end
|
||||
|
||||
function private.update_auto_buy_filter()
|
||||
if aux_auto_buy_filter then
|
||||
local queries = Aux.scan_util.parse_filter_string(aux_auto_buy_filter)
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
Aux.log('Error: The automatic buyout filter may contain only one query')
|
||||
elseif Aux.util.size(queries[1].blizzard_query) > 0 then
|
||||
Aux.log('Error: The automatic buyout filter does not support Blizzard filters')
|
||||
else
|
||||
m.auto_buy_validator = queries[1].validator
|
||||
m.auto_buy_filter_button.prettified = queries[1].prettified
|
||||
m.auto_buy_filter_button:SetChecked(true)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
aux_auto_buy_filter = nil
|
||||
end
|
||||
|
||||
function private.close_settings()
|
||||
if m.settings_button.open then
|
||||
m.settings_button:Click()
|
||||
@@ -198,12 +200,14 @@ function private.get_form_filter()
|
||||
add('exact')
|
||||
end
|
||||
|
||||
if tonumber(m.min_level_input:GetText()) then
|
||||
add(max(1, min(60, tonumber(m.min_level_input:GetText()))))
|
||||
local min_level = m.blizzard_level(m.min_level_input:GetText())
|
||||
if min_level then
|
||||
add(min_level)
|
||||
end
|
||||
|
||||
if tonumber(m.max_level_input:GetText()) then
|
||||
add(max(1, min(60, tonumber(m.max_level_input:GetText()))))
|
||||
local max_level = m.blizzard_level(m.min_level_input:GetText())
|
||||
if max_level then
|
||||
add(max_level)
|
||||
end
|
||||
|
||||
if m.usable_checkbox:GetChecked() then
|
||||
@@ -265,7 +269,7 @@ function private.start_real_time_scan(query, search, continuation)
|
||||
m.search_scan_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
queries = {query},
|
||||
auto_buy_validator = m.auto_buy_validator,
|
||||
auto_buy_validator = m.auto_buy_filter_button:GetChecked() and aux_auto_buy_filter and m.auto_buy_validator, -- some redundancy but why not to be save
|
||||
on_scan_start = function()
|
||||
m.status_bar:update_status(99.99, 99.99)
|
||||
m.status_bar:set_text('Scanning last page ...')
|
||||
@@ -278,7 +282,7 @@ function private.start_real_time_scan(query, search, continuation)
|
||||
end,
|
||||
on_auction = function(auction_record, ctrl)
|
||||
if not ignore_page then
|
||||
if m.auto_buy_button.on then
|
||||
if m.auto_buy_button:GetChecked() then
|
||||
ctrl.suspend()
|
||||
Aux.place_bid('list', auction_record.index, auction_record.buyout_price, function() ctrl.resume(true) end)
|
||||
else
|
||||
@@ -370,7 +374,7 @@ function private.start_search(queries, continuation)
|
||||
current_page = current_page and 0 or start_page - 1
|
||||
end,
|
||||
on_auction = function(auction_record, ctrl)
|
||||
if m.auto_buy_button.on then
|
||||
if m.auto_buy_button:GetChecked() then
|
||||
ctrl.suspend()
|
||||
Aux.place_bid('list', auction_record.index, auction_record.buyout_price, function() ctrl.resume(true) end)
|
||||
elseif getn(search.records) < 1000 then
|
||||
@@ -417,12 +421,12 @@ function public.execute(resume)
|
||||
local queries = Aux.scan_util.parse_filter_string(filter_string)
|
||||
if not queries then
|
||||
return
|
||||
elseif m.real_time_button.on then
|
||||
elseif m.real_time_button:GetChecked() then
|
||||
if getn(queries) > 1 then
|
||||
Aux.log('Invalid filter: The sniping mode does not support multiple queries')
|
||||
Aux.log('Invalid filter: The real time 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')
|
||||
Aux.log('Invalid filter: The real time mode does not support page range filters')
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -434,7 +438,7 @@ function public.execute(resume)
|
||||
if resume then
|
||||
m.results_listing:SetSelectedRecord()
|
||||
else
|
||||
if m.current_search().real_time ~= m.real_time_button.on then
|
||||
if m.current_search().real_time ~= m.real_time_button:GetChecked() then
|
||||
m.results_listing:Reset()
|
||||
end
|
||||
m.current_search().records = {}
|
||||
@@ -448,22 +452,30 @@ function public.execute(resume)
|
||||
|
||||
m.close_settings()
|
||||
m.update_tab(m.RESULTS)
|
||||
m.current_search().real_time = m.real_time_button.on
|
||||
if m.real_time_button.on then
|
||||
m.current_search().real_time = m.real_time_button:GetChecked()
|
||||
if m.real_time_button:GetChecked() then
|
||||
m.start_real_time_scan(queries[1], nil, continuation)
|
||||
else
|
||||
for _, query in queries do
|
||||
if tonumber(m.first_page_input:GetText()) then
|
||||
query.blizzard_query.first_page = Aux.round(max(0, m.first_page_input:GetNumber() - 1))
|
||||
end
|
||||
if tonumber(m.last_page_input:GetText()) then
|
||||
query.blizzard_query.last_page = Aux.round(max(0, m.last_page_input:GetNumber() - 1))
|
||||
end
|
||||
query.blizzard_query.first_page = m.blizzard_page_index(m.first_page_input:GetText())
|
||||
query.blizzard_query.last_page = m.blizzard_page_index(m.last_page_input:GetText())
|
||||
end
|
||||
m.start_search(queries, continuation)
|
||||
end
|
||||
end
|
||||
|
||||
function private.blizzard_page_index(str)
|
||||
if tonumber(str) then
|
||||
return Aux.round(max(0, tonumber(str) - 1))
|
||||
end
|
||||
end
|
||||
|
||||
function private.blizzard_level(str)
|
||||
if tonumber(str) then
|
||||
return Aux.round(max(1, min(60, tonumber(str))))
|
||||
end
|
||||
end
|
||||
|
||||
function private.test(record)
|
||||
return function(index)
|
||||
local auction_info = Aux.info.auction(index)
|
||||
@@ -558,7 +570,7 @@ do
|
||||
end
|
||||
|
||||
function private.update_continuation()
|
||||
if m.current_search().continuation and m.current_search().real_time == m.real_time_button.on then
|
||||
if m.current_search().continuation and m.current_search().real_time == m.real_time_button:GetChecked() then
|
||||
m.resume_button:Show()
|
||||
m.search_box:SetPoint('RIGHT', m.resume_button, 'LEFT', -4, 0)
|
||||
else
|
||||
|
||||
+56
-52
@@ -27,21 +27,6 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
btn:SetPoint('TOPLEFT', 0, 0)
|
||||
btn:SetWidth(42)
|
||||
btn:SetHeight(42)
|
||||
local t1 = btn:CreateTexture()
|
||||
t1:SetTexture(unpack(Aux.gui.config.text_color.enabled))
|
||||
t1:SetWidth(20)
|
||||
t1:SetHeight(2.5)
|
||||
t1:SetPoint('CENTER', 0, 6.7)
|
||||
local t2 = btn:CreateTexture()
|
||||
t2:SetTexture(unpack(Aux.gui.config.text_color.enabled))
|
||||
t2:SetWidth(20)
|
||||
t2:SetHeight(2.5)
|
||||
t2:SetPoint('CENTER', 0, 0)
|
||||
local t3 = btn:CreateTexture()
|
||||
t3:SetTexture(unpack(Aux.gui.config.text_color.enabled))
|
||||
t3:SetWidth(20)
|
||||
t3:SetHeight(2.5)
|
||||
t3:SetPoint('CENTER', 0, -6.7)
|
||||
btn:SetScript('OnClick', function()
|
||||
if this.open then
|
||||
m.settings:Hide()
|
||||
@@ -53,6 +38,15 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
end
|
||||
this.open = not this.open
|
||||
end)
|
||||
|
||||
for _, offset in {15, 10, 5} do
|
||||
local fake_icon_part = btn:CreateFontString()
|
||||
fake_icon_part:SetFont([[Fonts\FRIZQT__.TTF]], 23)
|
||||
fake_icon_part:SetPoint('CENTER', 0, offset)
|
||||
fake_icon_part:SetText('_')
|
||||
-- fake_icon:SetTextHeight(28)
|
||||
end
|
||||
|
||||
private.settings_button = btn
|
||||
end
|
||||
do
|
||||
@@ -72,9 +66,8 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(m.settings)
|
||||
editbox:SetBackdropColor(unpack(Aux.gui.config.frame_color))
|
||||
editbox:SetPoint('LEFT', 80, 0)
|
||||
editbox:SetWidth(30)
|
||||
editbox:SetPoint('LEFT', 70, 0)
|
||||
editbox:SetWidth(50)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetMaxLetters(nil)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
@@ -84,16 +77,23 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
this:ClearFocus()
|
||||
m.execute()
|
||||
end)
|
||||
editbox:SetScript('OnTextChanged', function()
|
||||
if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then
|
||||
this:SetBackdropColor(unpack(Aux.gui.config.on_color))
|
||||
else
|
||||
this:SetBackdropColor(unpack(Aux.gui.config.off_color))
|
||||
end
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 15)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -5, 0)
|
||||
label:SetText('Pages')
|
||||
label:SetTextColor(unpack(Aux.gui.config.text_color.enabled))
|
||||
private.first_page_input = editbox
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(m.settings)
|
||||
editbox:SetBackdropColor(unpack(Aux.gui.config.frame_color))
|
||||
editbox:SetPoint('LEFT', m.first_page_input, 'RIGHT', 10, 0)
|
||||
editbox:SetWidth(30)
|
||||
editbox:SetWidth(50)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetMaxLetters(nil)
|
||||
editbox:SetScript('OnTabPressed', function()
|
||||
@@ -103,48 +103,44 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
this:ClearFocus()
|
||||
m.execute()
|
||||
end)
|
||||
editbox:SetScript('OnTextChanged', function()
|
||||
if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then
|
||||
this:SetBackdropColor(unpack(Aux.gui.config.on_color))
|
||||
else
|
||||
this:SetBackdropColor(unpack(Aux.gui.config.off_color))
|
||||
end
|
||||
end)
|
||||
local label = Aux.gui.label(editbox, 16)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
|
||||
label:SetText('-')
|
||||
label:SetTextColor(unpack(Aux.gui.config.text_color.enabled))
|
||||
private.last_page_input = editbox
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(m.settings, 16)
|
||||
btn:SetBackdropColor(unpack(Aux.gui.config.frame_color))
|
||||
btn:SetPoint('LEFT', 240, 0)
|
||||
local btn = Aux.gui.checkbutton(m.settings, 16)
|
||||
btn:SetPoint('LEFT', 230, 0)
|
||||
btn:SetWidth(140)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Real Time Mode')
|
||||
btn:SetBackdropColor(0.7, 0.3, 0.3)
|
||||
btn:SetScript('OnClick', function()
|
||||
this.on = not this.on
|
||||
if this.on then
|
||||
this:SetBackdropColor(0.3, 0.7, 0.3)
|
||||
m.first_page_input:EnableMouse(nil)
|
||||
m.last_page_input:EnableMouse(nil)
|
||||
m.first_page_input:ClearFocus()
|
||||
m.last_page_input:ClearFocus()
|
||||
else
|
||||
this:SetBackdropColor(0.7, 0.3, 0.3)
|
||||
m.first_page_input:EnableMouse(true)
|
||||
m.last_page_input:EnableMouse(true)
|
||||
end
|
||||
this:SetChecked(not this:GetChecked())
|
||||
this = m.first_page_input
|
||||
m.first_page_input:GetScript('OnTextChanged')()
|
||||
this = m.last_page_input
|
||||
m.last_page_input:GetScript('OnTextChanged')()
|
||||
m.update_continuation()
|
||||
end)
|
||||
public.real_time_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(m.settings, 16)
|
||||
btn:SetBackdropColor(unpack(Aux.gui.config.frame_color))
|
||||
btn:SetPoint('LEFT', m.real_time_button, 'RIGHT', 30, 0)
|
||||
local btn = Aux.gui.checkbutton(m.settings, 16)
|
||||
btn:SetPoint('LEFT', m.real_time_button, 'RIGHT', 15, 0)
|
||||
btn:SetWidth(140)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Auto Buyout Mode')
|
||||
btn:SetBackdropColor(0.7, 0.3, 0.3)
|
||||
btn:SetScript('OnClick', function()
|
||||
if this.on then
|
||||
this.on = false
|
||||
this:SetBackdropColor(0.7, 0.3, 0.3)
|
||||
if this:GetChecked() then
|
||||
this:SetChecked(false)
|
||||
else
|
||||
StaticPopup_Show('AUX_SEARCH_AUTO_BUY')
|
||||
end
|
||||
@@ -152,22 +148,31 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
private.auto_buy_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(m.settings, 16)
|
||||
btn:SetBackdropColor(unpack(Aux.gui.config.frame_color))
|
||||
btn:SetPoint('LEFT', m.auto_buy_button, 'RIGHT', 30, 0)
|
||||
local btn = Aux.gui.checkbutton(m.settings, 16)
|
||||
btn:SetPoint('LEFT', m.auto_buy_button, 'RIGHT', 15, 0)
|
||||
btn:SetWidth(140)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Auto Buyout Filter')
|
||||
btn:SetBackdropColor(0.7, 0.3, 0.3)
|
||||
btn:SetScript('OnClick', function()
|
||||
if this.on then
|
||||
this.on = false
|
||||
if this:GetChecked() then
|
||||
this:SetChecked(false)
|
||||
aux_auto_buy_filter = nil
|
||||
this.prettified = nil
|
||||
m.auto_buy_validator = nil
|
||||
this:SetBackdropColor(0.7, 0.3, 0.3)
|
||||
else
|
||||
StaticPopup_Show('AUX_SEARCH_AUTO_BUY_FILTER')
|
||||
end
|
||||
end)
|
||||
btn:SetScript('OnEnter', function()
|
||||
if this.prettified then
|
||||
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
|
||||
GameTooltip:AddLine(gsub(this.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true)
|
||||
GameTooltip:Show()
|
||||
end
|
||||
end)
|
||||
btn:SetScript('OnLeave', function()
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
private.auto_buy_filter_button = btn
|
||||
end
|
||||
do
|
||||
@@ -248,7 +253,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
local item_info = Aux.cursor_item() and Aux.info.item(Aux.cursor_item().item_id)
|
||||
if item_info then
|
||||
m.set_filter(strlower(item_info.name)..'/exact')
|
||||
if m.real_time_button.on then
|
||||
if m.real_time_button:GetChecked() then
|
||||
m.real_time_button:Click()
|
||||
end
|
||||
m.execute()
|
||||
@@ -759,7 +764,6 @@ Aux.search_tab.FRAMES(function(m, public, private)
|
||||
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
|
||||
GameTooltip:AddLine(gsub(data.search.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true)
|
||||
GameTooltip:Show()
|
||||
GameTooltip:Show()
|
||||
end,
|
||||
OnLeave = function()
|
||||
GameTooltip:ClearLines()
|
||||
|
||||
Reference in New Issue
Block a user