module refactoring
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
local tab = TAB 'Search'
|
||||
local tab = aux.tab 'Search'
|
||||
|
||||
StaticPopupDialogs.AUX_SEARCH_TABLE_FULL = {
|
||||
text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.',
|
||||
@@ -20,7 +17,7 @@ RESULTS = 1
|
||||
SAVED = 2
|
||||
FILTER = 3
|
||||
|
||||
function handle.LOAD()
|
||||
function aux.handle.LOAD()
|
||||
set_subtab(SAVED)
|
||||
end
|
||||
|
||||
@@ -73,7 +70,7 @@ end
|
||||
|
||||
function add_filter(filter_string)
|
||||
local old_filter_string = search_box:GetText()
|
||||
old_filter_string = trim(old_filter_string)
|
||||
old_filter_string = aux.trim(old_filter_string)
|
||||
|
||||
if old_filter_string ~= '' then
|
||||
old_filter_string = old_filter_string .. ';'
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
@@ -11,7 +11,7 @@ local post_filter_index = 0
|
||||
|
||||
function valid_level(str)
|
||||
local level = tonumber(str)
|
||||
return level and bounded(1, 60, level)
|
||||
return level and aux.bounded(1, 60, level)
|
||||
end
|
||||
|
||||
blizzard_query = setmetatable(T.acquire(), {
|
||||
@@ -99,7 +99,7 @@ function update_form()
|
||||
quality_dropdown.button:Enable()
|
||||
end
|
||||
|
||||
if any(T.temp-T.list('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then
|
||||
if aux.any(T.temp-T.list('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then
|
||||
exact_checkbox:Disable()
|
||||
else
|
||||
exact_checkbox:Enable()
|
||||
@@ -116,7 +116,7 @@ function get_filter_builder_query()
|
||||
end
|
||||
|
||||
local name = blizzard_query.name
|
||||
if not index(filter_util.parse_filter_string(name), 'blizzard', 'name') then
|
||||
if not aux.index(filter_util.parse_filter_string(name), 'blizzard', 'name') then
|
||||
name = filter_util.quote(name)
|
||||
end
|
||||
add((name ~= '' or blizzard_query.exact) and name)
|
||||
@@ -183,8 +183,8 @@ function clear_form()
|
||||
end
|
||||
|
||||
function import_filter_string()
|
||||
local filter, error = filter_util.parse_filter_string(select(3, strfind(search_box:GetText(), '^([^;]*)')))
|
||||
if filter or print(error) then
|
||||
local filter, error = filter_util.parse_filter_string(aux.select(3, strfind(search_box:GetText(), '^([^;]*)')))
|
||||
if filter or aux.print(error) then
|
||||
set_form(filter)
|
||||
end
|
||||
update_form()
|
||||
@@ -206,11 +206,11 @@ function formatted_post_filter(components)
|
||||
end
|
||||
str = str .. '</p><p>'
|
||||
for _ = 1, getn(stack) + 1 do
|
||||
str = str .. color.content.background'----'
|
||||
str = str .. aux.color.content.background'----'
|
||||
end
|
||||
no_line_break = component[1] == 'operator' and component[2] == 'not'
|
||||
|
||||
local filter_color = (post_filter_index == i and color.gold or color.orange)
|
||||
local filter_color = (post_filter_index == i and aux.color.gold or aux.color.orange)
|
||||
local component_text = filter_color(component[2])
|
||||
if component[1] == 'operator' and component[2] ~= 'not' then
|
||||
component_text = component_text .. filter_color(tonumber(component[3]) or '')
|
||||
@@ -283,7 +283,7 @@ function add_form_component()
|
||||
filter_input:HighlightText()
|
||||
filter_input:SetFocus()
|
||||
elseif error then
|
||||
print(error)
|
||||
aux.print(error)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -318,8 +318,8 @@ function set_filter_display_offset(x_offset, y_offset)
|
||||
local x_upper_bound = 0
|
||||
local y_lower_bound = 0
|
||||
local y_upper_bound = max(0, height - scroll_frame:GetHeight())
|
||||
scroll_frame:SetHorizontalScroll(bounded(x_lower_bound, x_upper_bound, x_offset))
|
||||
scroll_frame:SetVerticalScroll(bounded(y_lower_bound, y_upper_bound, y_offset))
|
||||
scroll_frame:SetHorizontalScroll(aux.bounded(x_lower_bound, x_upper_bound, x_offset))
|
||||
scroll_frame:SetVerticalScroll(aux.bounded(y_lower_bound, y_upper_bound, y_offset))
|
||||
end
|
||||
|
||||
function initialize_filter_dropdown()
|
||||
@@ -329,7 +329,7 @@ function initialize_filter_dropdown()
|
||||
'value', filter,
|
||||
'func', function()
|
||||
filter_input:SetText(this.value)
|
||||
if index(filter_util.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
||||
if aux.index(filter_util.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
||||
add_form_component()
|
||||
elseif filter_util.filters[this.value] then
|
||||
filter_parameter_input:Show()
|
||||
|
||||
+16
-16
@@ -1,7 +1,7 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local completion = require 'aux.util.completion'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
@@ -12,19 +12,19 @@ local auction_listing = require 'aux.gui.auction_listing'
|
||||
|
||||
local FILTER_SPACING = 28.5
|
||||
|
||||
frame = CreateFrame('Frame', nil, AuxFrame)
|
||||
frame = CreateFrame('Frame', nil, aux.frame)
|
||||
frame:SetAllPoints()
|
||||
frame:SetScript('OnUpdate', on_update)
|
||||
frame:Hide()
|
||||
|
||||
frame.filter = gui.panel(frame)
|
||||
frame.filter:SetAllPoints(AuxFrame.content)
|
||||
frame.filter:SetAllPoints(aux.frame.content)
|
||||
|
||||
frame.results = gui.panel(frame)
|
||||
frame.results:SetAllPoints(AuxFrame.content)
|
||||
frame.results:SetAllPoints(aux.frame.content)
|
||||
|
||||
frame.saved = CreateFrame('Frame', nil, frame)
|
||||
frame.saved:SetAllPoints(AuxFrame.content)
|
||||
frame.saved:SetAllPoints(aux.frame.content)
|
||||
|
||||
frame.saved.favorite = gui.panel(frame.saved)
|
||||
frame.saved.favorite:SetWidth(393)
|
||||
@@ -57,7 +57,7 @@ do
|
||||
local btn = gui.button(frame, gui.font_size.small)
|
||||
btn:SetHeight(25)
|
||||
btn:SetWidth(60)
|
||||
btn:SetText(color.label.enabled'Range:')
|
||||
btn:SetText(aux.color.label.enabled'Range:')
|
||||
btn:SetScript('OnClick', function()
|
||||
update_real_time(true)
|
||||
end)
|
||||
@@ -68,7 +68,7 @@ do
|
||||
btn:SetHeight(25)
|
||||
btn:SetWidth(60)
|
||||
btn:Hide()
|
||||
btn:SetText(color.label.enabled'Real Time')
|
||||
btn:SetText(aux.color.label.enabled'Real Time')
|
||||
btn:SetScript('OnClick', function()
|
||||
update_real_time(false)
|
||||
end)
|
||||
@@ -98,7 +98,7 @@ do
|
||||
editbox.change = change
|
||||
local label = gui.label(editbox, gui.font_size.medium)
|
||||
label:SetPoint('LEFT', editbox, 'RIGHT', 0, 0)
|
||||
label:SetTextColor(color.label.enabled())
|
||||
label:SetTextColor(aux.color.label.enabled())
|
||||
label:SetText('-')
|
||||
first_page_input = editbox
|
||||
end
|
||||
@@ -149,7 +149,7 @@ do
|
||||
local btn = gui.button(frame)
|
||||
btn:SetHeight(25)
|
||||
btn:SetPoint('RIGHT', start_button, 'LEFT', -4, 0)
|
||||
btn:SetBackdropColor(color.state.enabled())
|
||||
btn:SetBackdropColor(aux.color.state.enabled())
|
||||
btn:SetText('Resume')
|
||||
btn:SetScript('OnClick', function()
|
||||
execute(true)
|
||||
@@ -161,7 +161,7 @@ do
|
||||
editbox:EnableMouse(1)
|
||||
editbox.formatter = function(str)
|
||||
local queries = filter_util.queries(str)
|
||||
return queries and join(map(copy(queries), function(query) return query.prettified end), ';') or color.red(str)
|
||||
return queries and aux.join(aux.map(aux.copy(queries), function(query) return query.prettified end), ';') or aux.color.red(str)
|
||||
end
|
||||
editbox.complete = completion.complete_filter
|
||||
editbox.escape = function() this:SetText(get_current_search().filter_string or '') end
|
||||
@@ -184,7 +184,7 @@ do
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, gui.font_size.large)
|
||||
btn:SetPoint('BOTTOMLEFT', AuxFrame.content, 'TOPLEFT', 10, 8)
|
||||
btn:SetPoint('BOTTOMLEFT', aux.frame.content, 'TOPLEFT', 10, 8)
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Search Results')
|
||||
@@ -213,7 +213,7 @@ do
|
||||
local frame = CreateFrame('Frame', nil, frame)
|
||||
frame:SetWidth(265)
|
||||
frame:SetHeight(25)
|
||||
frame:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
|
||||
frame:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6)
|
||||
status_bar_frame = frame
|
||||
end
|
||||
do
|
||||
@@ -435,7 +435,7 @@ do
|
||||
input:SetPoint('CENTER', filter_dropdown, 'CENTER', 0, 0)
|
||||
input:SetWidth(150)
|
||||
input:SetScript('OnTabPressed', function() filter_parameter_input:SetFocus() end)
|
||||
input.complete = completion.complete(function() return T.temp-T.list('and', 'or', 'not', unpack(keys(filter_util.filters))) end)
|
||||
input.complete = completion.complete(function() return T.temp-T.list('and', 'or', 'not', unpack(aux.keys(filter_util.filters))) end)
|
||||
input.char = function() this:complete() end
|
||||
input.change = function()
|
||||
local text = this:GetText()
|
||||
@@ -478,7 +478,7 @@ do
|
||||
scroll_frame:EnableMouseWheel(true)
|
||||
scroll_frame:SetScript('OnMouseWheel', function()
|
||||
local child = this:GetScrollChild()
|
||||
child:SetFont('p', [[Fonts\ARIALN.TTF]], bounded(gui.font_size.small, gui.font_size.large, select(2, child:GetFont()) + arg1*2))
|
||||
child:SetFont('p', [[Fonts\ARIALN.TTF]], aux.bounded(gui.font_size.small, gui.font_size.large, aux.select(2, child:GetFont()) + arg1*2))
|
||||
update_filter_display()
|
||||
end)
|
||||
scroll_frame:RegisterForDrag('LeftButton')
|
||||
@@ -504,7 +504,7 @@ do
|
||||
local scroll_child = CreateFrame('SimpleHTML', nil, scroll_frame)
|
||||
scroll_frame:SetScrollChild(scroll_child)
|
||||
scroll_child:SetFont('p', [[Fonts\ARIALN.TTF]], gui.font_size.large)
|
||||
scroll_child:SetTextColor('p', color.label.enabled())
|
||||
scroll_child:SetTextColor('p', aux.color.label.enabled())
|
||||
scroll_child:SetWidth(1)
|
||||
scroll_child:SetHeight(1)
|
||||
scroll_child:SetScript('OnHyperlinkClick', data_link_click)
|
||||
@@ -531,7 +531,7 @@ for _ = 1, 5 do
|
||||
end
|
||||
end
|
||||
elseif button == 'RightButton' then
|
||||
set_tab(1)
|
||||
aux.set_tab(1)
|
||||
set_filter(strlower(info.item(this.record.item_id).name) .. '/exact')
|
||||
execute(nil, false)
|
||||
end
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan_util = require 'aux.util.scan'
|
||||
@@ -9,7 +9,7 @@ local scan = require 'aux.core.scan'
|
||||
|
||||
search_scan_id = 0
|
||||
|
||||
function handle.LOAD()
|
||||
function aux.handle.LOAD()
|
||||
new_search()
|
||||
end
|
||||
|
||||
@@ -175,7 +175,7 @@ function start_real_time_scan(query, search, continuation)
|
||||
map[record.sniping_signature] = record
|
||||
end
|
||||
T.release(new_records)
|
||||
new_records = values(map)
|
||||
new_records = aux.values(map)
|
||||
|
||||
if getn(new_records) > 2000 then
|
||||
StaticPopup_Show('AUX_SEARCH_TABLE_FULL')
|
||||
@@ -303,14 +303,14 @@ function M.execute(resume, real_time)
|
||||
|
||||
local queries, error = filter_util.queries(filter_string)
|
||||
if not queries then
|
||||
print('Invalid filter:', error)
|
||||
aux.print('Invalid filter:', error)
|
||||
return
|
||||
elseif real_time then
|
||||
if getn(queries) > 1 then
|
||||
print('Error: The real time mode does not support multi-queries')
|
||||
aux.print('Error: The real time mode does not support multi-queries')
|
||||
return
|
||||
elseif queries[1].blizzard_query.first_page or queries[1].blizzard_query.last_page then
|
||||
print('Error: The real time mode does not support page ranges')
|
||||
aux.print('Error: The real time mode does not support page ranges')
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -324,7 +324,7 @@ function M.execute(resume, real_time)
|
||||
else
|
||||
get_current_search().filter_string = filter_string
|
||||
end
|
||||
new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';'))
|
||||
new_recent_search(filter_string, aux.join(aux.map(aux.copy(queries), function(filter) return filter.prettified end), ';'))
|
||||
else
|
||||
local search = get_current_search()
|
||||
search.records = T.acquire()
|
||||
@@ -391,7 +391,7 @@ do
|
||||
if not record.high_bidder then
|
||||
bid_button:SetScript('OnClick', function()
|
||||
if scan_util.test(record, index) and search.table:ContainsRecord(record) then
|
||||
place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function()
|
||||
aux.place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function()
|
||||
info.bid_update(record)
|
||||
search.table:SetDatabase()
|
||||
end or function() search.table:RemoveAuctionRecord(record) end)
|
||||
@@ -405,7 +405,7 @@ do
|
||||
if record.buyout_price > 0 then
|
||||
buyout_button:SetScript('OnClick', function()
|
||||
if scan_util.test(record, index) and search.table:ContainsRecord(record) then
|
||||
place_bid('list', index, record.buyout_price, function() search.table:RemoveAuctionRecord(record) end)
|
||||
aux.place_bid('list', index, record.buyout_price, function() search.table:RemoveAuctionRecord(record) end)
|
||||
end
|
||||
end)
|
||||
buyout_button:Enable()
|
||||
@@ -432,7 +432,7 @@ do
|
||||
elseif state == FOUND and not scan_util.test(selection.record, found_index) then
|
||||
buyout_button:Disable()
|
||||
bid_button:Disable()
|
||||
if not bid_in_progress() then
|
||||
if not aux.bid_in_progress() then
|
||||
state = IDLE
|
||||
end
|
||||
end
|
||||
|
||||
+12
-12
@@ -1,12 +1,12 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
function handle.LOAD2()
|
||||
recent_searches, favorite_searches = realm_data'recent_searches', realm_data'favorite_searches'
|
||||
function aux.handle.LOAD2()
|
||||
recent_searches, favorite_searches = aux.realm_data'recent_searches', aux.realm_data'favorite_searches'
|
||||
end
|
||||
|
||||
function update_search_listings()
|
||||
@@ -15,7 +15,7 @@ function update_search_listings()
|
||||
local search = favorite_searches[i]
|
||||
local name = strsub(search.prettified, 1, 250)
|
||||
tinsert(favorite_search_rows, T.map(
|
||||
'cols', T.list(T.map('value', search.auto_buy and color.red'X' or ''), T.map('value', name)),
|
||||
'cols', T.list(T.map('value', search.auto_buy and aux.color.red'X' or ''), T.map('value', name)),
|
||||
'search', search,
|
||||
'index', i
|
||||
))
|
||||
@@ -92,12 +92,12 @@ function get_auto_buy_validator()
|
||||
if queries then
|
||||
tinsert(validators, queries[1].validator)
|
||||
else
|
||||
print('Invalid auto buy filter:', error)
|
||||
aux.print('Invalid auto buy filter:', error)
|
||||
end
|
||||
end
|
||||
end
|
||||
return function(record)
|
||||
return any(validators, function(validator) return validator(record) end)
|
||||
return aux.any(validators, function(validator) return validator(record) end)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -106,11 +106,11 @@ function add_favorite(filter_string)
|
||||
if queries then
|
||||
tinsert(favorite_searches, 1, T.map(
|
||||
'filter_string', filter_string,
|
||||
'prettified', join(map(queries, function(query) return query.prettified end), ';')
|
||||
'prettified', aux.join(aux.map(queries, function(query) return query.prettified end), ';')
|
||||
))
|
||||
update_search_listings()
|
||||
else
|
||||
print('Invalid filter:', error)
|
||||
aux.print('Invalid filter:', error)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -118,14 +118,14 @@ function enable_auto_buy(search)
|
||||
local queries, error = filter_util.queries(search.filter_string)
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
print('Error: Auto Buy does not support multi-queries')
|
||||
elseif size(queries[1].blizzard_query) > 0 and not filter_util.parse_filter_string(search.filter_string).blizzard.exact then
|
||||
print('Error: Auto Buy does not support Blizzard filters')
|
||||
aux.print('Error: Auto Buy does not support multi-queries')
|
||||
elseif aux.size(queries[1].blizzard_query) > 0 and not filter_util.parse_filter_string(search.filter_string).blizzard.exact then
|
||||
aux.print('Error: Auto Buy does not support Blizzard filters')
|
||||
else
|
||||
search.auto_buy = true
|
||||
end
|
||||
else
|
||||
print('Invalid filter:', error)
|
||||
aux.print('Invalid filter:', error)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user