search config redesign, removed naming of searches

This commit is contained in:
Manuel Simon Hirsig
2016-07-25 17:48:07 +02:00
parent 1f928eeaef
commit c533f8dae8
5 changed files with 107 additions and 135 deletions
+6 -2
View File
@@ -359,7 +359,9 @@ function private.SetItemRef(...)
local item_info = m.info.item(tonumber(({strfind(itemstring, '^item:(%d+)')})[3]))
if item_info then
m.search_tab.set_filter(strlower(item_info.name)..'/exact')
m.search_tab.real_time_checkbox:SetChecked(nil)
if m.real_time_button.on then
m.real_time_button:Click()
end
m.search_tab.execute()
return
end
@@ -378,7 +380,9 @@ function private.UseContainerItem(...)
item_info = item_info and m.info.item(item_info.item_id)
if item_info then
m.search_tab.set_filter(strlower(item_info.name)..'/exact')
m.search_tab.real_time_checkbox:SetChecked(nil)
if m.real_time_button.on then
m.real_time_button:Click()
end
m.search_tab.execute()
end
return
+3 -1
View File
@@ -655,7 +655,9 @@ local methods = {
elseif Aux.unmodified() and button == 'RightButton' then -- TODO not when alt (how?)
Aux.tab_group:set_tab(1)
Aux.search_tab.set_filter(strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact')
Aux.search_tab.real_time_checkbox:SetChecked(nil)
if m.real_time_button.on then
m.real_time_button:Click()
end
Aux.search_tab.execute()
else
local selection = this.rt:GetSelection()
+3 -1
View File
@@ -82,7 +82,9 @@ 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')
Aux.search_tab.real_time_checkbox:SetChecked(nil)
if m.real_time_button.on then
m.real_time_button:Click()
end
Aux.search_tab.execute()
end
end,
+48 -62
View File
@@ -7,25 +7,55 @@ aux_auto_buy_filter = ''
private.search_scan_id = 0
private.auto_buy_validator = nil
private.popup_info = {
rename = {}
StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = {
text = 'Table full!\nFurther results from this search will not be displayed.',
button1 = 'Ok',
showAlert = 1,
timeout = 0,
hideOnEscape = 1,
}
StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
text = 'Are you sure you want to activate automatic buyout?',
button1 = 'Yes',
button2 = 'No',
OnAccept = function()
m.auto_buy_button.on = true
m.auto_buy_button:SetBackdropColor(0.3, 0.7, 0.3)
end,
timeout = 0,
hideOnEscape = 1,
}
do
local function action()
m.popup_info.rename.name = getglobal(this:GetParent():GetName()..'EditBox'):GetText()
m.update_search_listings()
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
end
StaticPopupDialogs['AUX_SEARCH_SAVED_RENAME'] = {
text = 'Enter a new name for this search.',
StaticPopupDialogs['AUX_SEARCH_AUTO_BUY_FILTER'] = {
text = 'Enter a filter for automatic buyout.',
button1 = 'Accept',
button2 = 'Cancel',
hasEditBox = 1,
OnShow = function()
local rename_info = m.popup_info.rename
local edit_box = getglobal(this:GetName()..'EditBox')
edit_box:SetText(rename_info.name or '')
edit_box:SetMaxLetters(nil)
edit_box:SetFocus()
edit_box:HighlightText()
end,
@@ -41,50 +71,6 @@ do
hideOnEscape = 1,
}
end
StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = {
text = 'Table full!\nFurther results from this search will be discarded.',
button1 = 'Ok',
showAlert = 1,
timeout = 0,
hideOnEscape = 1,
}
StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
text = 'Are you sure you want to activate automatic buyout?',
button1 = 'Yes',
button2 = 'No',
OnAccept = function()
m.auto_buy_checkbox:SetChecked(1)
end,
timeout = 0,
hideOnEscape = 1,
}
StaticPopupDialogs['AUX_SEARCH_AUTO_BUY_FILTER'] = {
text = 'Are you sure you want to set this filter for automatic buyout?',
button1 = 'Yes',
button2 = 'No',
OnAccept = function()
local queries = Aux.scan_util.parse_filter_string(m.auto_buy_filter_editbox:GetText())
if queries then
if getn(queries) > 1 then
Aux.log('Error: The auto buy filter supports only one query')
return
end
if Aux.util.size(queries[1].blizzard_query) > 0 then
Aux.log('Error: The real time mode 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_checkbox:SetChecked(1)
m.auto_buy_filter_editbox:ClearFocus()
end
end,
timeout = 0,
hideOnEscape = 1,
}
private.RESULTS, private.SAVED, private.FILTER = 1, 2, 3
@@ -118,7 +104,7 @@ end
function private.update_search_listings()
local favorite_search_rows = {}
for i, favorite_search in ipairs(aux_favorite_searches) do
local name = favorite_search.name and LIGHTYELLOW_FONT_COLOR_CODE..favorite_search.name..FONT_COLOR_CODE_CLOSE or strsub(favorite_search.prettified, 1, 250)
local name = strsub(favorite_search.prettified, 1, 250)
tinsert(favorite_search_rows, {
cols = {{value=name}},
search = favorite_search,
@@ -130,7 +116,7 @@ function private.update_search_listings()
local recent_search_rows = {}
for i, recent_search in ipairs(aux_recent_searches) do
local name = recent_search.name and LIGHTYELLOW_FONT_COLOR_CODE..recent_search.name..FONT_COLOR_CODE_CLOSE or strsub(recent_search.prettified, 1, 250)
local name = strsub(recent_search.prettified, 1, 250)
tinsert(recent_search_rows, {
cols = {{value=name}},
search = recent_search,
@@ -294,7 +280,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_checkbox:GetChecked() then
if m.auto_buy_button.on then
ctrl.suspend()
Aux.place_bid('list', auction_record.index, auction_record.buyout_price, function() ctrl.resume(true) end)
else
@@ -386,7 +372,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_checkbox:GetChecked() then
if m.auto_buy_button.on 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
@@ -433,7 +419,7 @@ function public.execute(resume)
local queries = Aux.scan_util.parse_filter_string(filter_string)
if not queries then
return
elseif m.real_time_checkbox:GetChecked() then
elseif m.real_time_button.on then
if getn(queries) > 1 then
Aux.log('Invalid filter: The sniping mode does not support multiple queries')
return
@@ -450,7 +436,7 @@ function public.execute(resume)
if resume then
m.results_listing:SetSelectedRecord()
else
if m.current_search().real_time ~= m.real_time_checkbox:GetChecked() then
if m.current_search().real_time ~= m.real_time_button.on then
m.results_listing:Reset()
end
m.current_search().records = {}
@@ -464,8 +450,8 @@ function public.execute(resume)
m.close_settings()
m.update_tab(m.RESULTS)
m.current_search().real_time = m.real_time_checkbox:GetChecked()
if m.real_time_checkbox:GetChecked() then
m.current_search().real_time = m.real_time_button.on
if m.real_time_button.on then
m.start_real_time_scan(queries[1], nil, continuation)
else
for _, query in queries do
@@ -574,7 +560,7 @@ do
end
function private.update_continuation()
if m.current_search().continuation and m.current_search().real_time == m.real_time_checkbox:GetChecked() then
if m.current_search().continuation and m.current_search().real_time == m.real_time_button.on then
m.resume_button:Show()
m.search_box:SetPoint('RIGHT', m.resume_button, 'LEFT', -4, 0)
else
+47 -69
View File
@@ -73,7 +73,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
do
local editbox = Aux.gui.editbox(m.settings)
editbox:SetBackdropColor(unpack(Aux.gui.config.frame_color))
editbox:SetPoint('LEFT', 48, 0)
editbox:SetPoint('LEFT', 80, 0)
editbox:SetWidth(30)
editbox:SetNumeric(true)
editbox:SetMaxLetters(nil)
@@ -85,7 +85,7 @@ Aux.search_tab.FRAMES(function(m, public, private)
m.execute()
end)
local label = Aux.gui.label(editbox, 15)
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
label:SetPoint('RIGHT', editbox, 'LEFT', -5, 0)
label:SetText('Pages')
private.first_page_input = editbox
end
@@ -103,91 +103,72 @@ Aux.search_tab.FRAMES(function(m, public, private)
this:ClearFocus()
m.execute()
end)
local label = Aux.gui.label(editbox, 15)
local label = Aux.gui.label(editbox, 16)
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
label:SetText('-')
private.last_page_input = editbox
end
do
local checkbox = CreateFrame('CheckButton', nil, m.settings, 'UICheckButtonTemplate')
checkbox:SetWidth(22)
checkbox:SetHeight(22)
checkbox:SetPoint('LEFT', 192, 0)
checkbox:SetScript('OnClick', function()
m.update_continuation()
if this:GetChecked() then
local btn = Aux.gui.button(m.settings, 16)
btn:SetBackdropColor(unpack(Aux.gui.config.frame_color))
btn:SetPoint('LEFT', 240, 0)
btn:SetWidth(120)
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
m.update_continuation()
end)
local label = Aux.gui.label(checkbox, 15)
label:SetPoint('RIGHT', checkbox, 'LEFT', -1, 0)
label:SetText('Real Time')
public.real_time_checkbox = checkbox
public.real_time_button = btn
end
do
local checkbox = CreateFrame('CheckButton', nil, m.settings, 'UICheckButtonTemplate')
checkbox:SetWidth(22)
checkbox:SetHeight(22)
checkbox:SetPoint('LEFT', 278, 0)
checkbox:SetScript('OnClick', function()
if this:GetChecked() then
this:SetChecked(nil)
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)
btn:SetWidth(120)
btn:SetHeight(25)
btn:SetText('Auto Buy 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)
else
StaticPopup_Show('AUX_SEARCH_AUTO_BUY')
end
end)
local label = Aux.gui.label(checkbox, 15)
label:SetPoint('RIGHT', checkbox, 'LEFT', -1, 0)
label:SetText('Auto Buy')
private.auto_buy_checkbox = checkbox
private.auto_buy_button = btn
end
do
local checkbox = CreateFrame('CheckButton', nil, m.settings, 'UICheckButtonTemplate')
checkbox:SetWidth(22)
checkbox:SetHeight(22)
checkbox:SetPoint('LEFT', 398, 0)
checkbox:SetScript('OnClick', function()
if this:GetChecked() then
this:SetChecked(nil)
StaticPopup_Show('AUX_SEARCH_AUTO_BUY_FILTER')
else
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)
btn:SetWidth(120)
btn:SetHeight(25)
btn:SetText('Auto Buy Filter')
btn:SetBackdropColor(0.7, 0.3, 0.3)
btn:SetScript('OnClick', function()
if this.on then
this.on = false
m.auto_buy_validator = nil
this:SetBackdropColor(0.7, 0.3, 0.3)
else
StaticPopup_Show('AUX_SEARCH_AUTO_BUY_FILTER')
end
end)
local label = Aux.gui.label(checkbox, 15)
label:SetPoint('RIGHT', checkbox, 'LEFT', -1, 0)
label:SetText('Auto Buy Filter')
private.auto_buy_filter_checkbox = checkbox
end
do
local editbox = Aux.gui.editbox(m.settings)
editbox:SetBackdropColor(unpack(Aux.gui.config.frame_color))
editbox:SetMaxLetters(nil)
editbox:EnableMouse(1)
editbox.complete = Aux.completion.complete_filter
editbox:SetPoint('RIGHT', -11, 0)
editbox:SetWidth(295)
editbox:SetHeight(25)
editbox:SetScript('OnChar', function()
this:complete()
end)
editbox:SetScript('OnTabPressed', function()
this:HighlightText(0, 0)
end)
editbox:SetScript('OnEnterPressed', function()
this:HighlightText(0, 0)
this:ClearFocus()
end)
editbox:SetScript('OnTextChanged', function()
m.auto_buy_filter_checkbox:SetChecked(nil)
end)
editbox:SetText(aux_auto_buy_filter)
private.auto_buy_filter_editbox = editbox
private.auto_buy_filter_button = btn
end
do
local btn = Aux.gui.button(m.controls, 26)
@@ -267,7 +248,9 @@ 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')
m.real_time_checkbox:SetChecked(nil)
if m.real_time_button.on then
m.real_time_button:Click()
end
m.execute()
end
ClearCursor()
@@ -745,11 +728,6 @@ Aux.search_tab.FRAMES(function(m, public, private)
m.search_box:SetText(data.search.filter_string)
elseif button == 'RightButton' and IsShiftKeyDown() then
m.add_filter(data.search.filter_string)
elseif button == 'LeftButton' and IsAltKeyDown() then
m.popup_info.rename = data.search
StaticPopup_Show('AUX_SEARCH_SAVED_RENAME')
elseif button == 'RightButton' and IsAltKeyDown() then
-- unused
elseif button == 'LeftButton' and IsControlKeyDown() then
if st == m.favorite_searches_listing and data.index > 1 then
local temp = aux_favorite_searches[data.index - 1]