refactoring
This commit is contained in:
+2
-2
@@ -42,7 +42,7 @@ do
|
||||
function public.modifier(f)
|
||||
local function apply(_, value) return f(value) end
|
||||
return setmetatable(t, {
|
||||
__index=apply, __call=apply, __add=apply, __sub=apply, __mul=apply, __div=apply, __pow=apply, __concat=apply, __lt=apply, __le=apply,
|
||||
__index=apply, __call=apply, __add=apply, __sub=apply, __mul=apply, __div=apply, __pow=apply, __concat=apply,
|
||||
__newindex=function(_, _, value) return f(value) end, __unm=function(self) return self end,
|
||||
})
|
||||
end
|
||||
@@ -133,7 +133,7 @@ tab_info = t
|
||||
do
|
||||
local data = -list :search_tab 'Search' :post_tab 'Post' :auctions_tab 'Auctions' :bids_tab 'Bids'
|
||||
for i=1,7,2 do
|
||||
local tab = perm<-object :name(data[i + 1]);
|
||||
local tab = perm/-object :name(data[i + 1]);
|
||||
local env = (function() module(data[i]) return _m end)()
|
||||
function env.mutator.OPEN(f) tab.OPEN = f end
|
||||
function env.mutator.CLOSE(f) tab.CLOSE = f end
|
||||
|
||||
@@ -38,6 +38,7 @@ do
|
||||
end
|
||||
|
||||
function accessor.state()
|
||||
log (thread_id)
|
||||
local _, state = next(filter(scan_states, function(state) return state.id == thread_id end))
|
||||
return state
|
||||
end
|
||||
|
||||
+3
-3
@@ -2,9 +2,9 @@ local type, setmetatable, setfenv, unpack, mask, _g = type, setmetatable, setfen
|
||||
local PRIVATE, PUBLIC, MUTABLE, PROPERTY, ACCESSOR, MUTATOR = 0, 1, 2, 4, 8, 16
|
||||
local error, import_error, modifier_error, property_error, immutable_error, collision_error, set_property, env_mt, interface_mt, declarator_mt, importer_mt
|
||||
local _state, _modules = {}, {}
|
||||
function error(message, ...) return function() _g.error(format(message, unpack(arg))..'\n'..debugstack(3, 10, 0), 0) end end
|
||||
import_error, modifier_error, property_error = error 'Invalid modifiers.', error 'Invalid modifiers.', error 'Accessor/Mutator must be function.'
|
||||
immutable_error, collision_error = function(key) return error('Field "%s" is immutable.', key) end, function(key) return error('Field "%s" already exists.', key) end
|
||||
function error(message, ...) return _g.error(format(message, unpack(arg))..'\n'..debugstack(1, 10, 0), 0) end
|
||||
import_error, modifier_error, property_error = function() error 'Invalid modifiers.' end, function() error 'Invalid modifiers.' end, function() error 'Accessor/Mutator must be function.' end
|
||||
immutable_error, collision_error = function(key) error('Field "%s" is immutable.', key) end, function(key) error('Field "%s" already exists.', key) end
|
||||
importer_mt = {__metatable=false}
|
||||
function importer_mt.__index(self, key)
|
||||
if type(key) ~= 'string' then import_error() end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module 'auctions_tab'
|
||||
module 'auctions_tab' import 'scan'
|
||||
|
||||
auction_records = nil
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
module 'bids_tab'
|
||||
module 'bids_tab' import 'scan'
|
||||
|
||||
auction_records = nil
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
module 'post_tab'
|
||||
module 'post_tab' import 'scan' 'post'
|
||||
|
||||
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
||||
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
||||
@@ -88,7 +88,7 @@ end
|
||||
|
||||
function update_inventory_listing()
|
||||
if not ACTIVE then return end
|
||||
item_listing.populate(item_listing, values(filter(inventory_records, function(record)
|
||||
inventory_listing.populate(inventory_listing, values(filter(inventory_records, function(record)
|
||||
local settings = read_settings(record.key)
|
||||
return record.aux_quantity > 0 and (not settings.hidden or show_hidden_checkbox:GetChecked())
|
||||
end)))
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ function create_frames()
|
||||
|
||||
gui.horizontal_line(frame.inventory, -48)
|
||||
|
||||
item_listing = item_listing.create(
|
||||
inventory_listing = item_listing.create(
|
||||
frame.inventory,
|
||||
function()
|
||||
if arg1 == 'LeftButton' then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module 'search_tab'
|
||||
module 'search_tab' import 'scan'
|
||||
|
||||
StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = {
|
||||
text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.',
|
||||
|
||||
+11
-11
@@ -1,4 +1,4 @@
|
||||
module 'search_tab'
|
||||
module 'search_tab' import 'filter_util'
|
||||
|
||||
function valid_level(str)
|
||||
local level = tonumber(str)
|
||||
@@ -109,8 +109,8 @@ function get_filter_builder_query()
|
||||
end
|
||||
|
||||
local name = blizzard_query.name
|
||||
if not index(filter.parse_query_string(name), 'blizzard', 'name') then
|
||||
name = filter.quote(name)
|
||||
if not index(filter_util.parse_query_string(name), 'blizzard', 'name') then
|
||||
name = filter_util.quote(name)
|
||||
end
|
||||
add((name ~= '' or blizzard_query.exact) and name)
|
||||
|
||||
@@ -134,7 +134,7 @@ function get_filter_builder_query()
|
||||
add(strlower(_g['ITEM_QUALITY'..quality..'_DESC']))
|
||||
end
|
||||
|
||||
local post_filter_string = filter.query_string{blizzard={}, post=post_filter}
|
||||
local post_filter_string = filter_util.query_string{blizzard={}, post=post_filter}
|
||||
add(post_filter_string ~= '' and post_filter_string)
|
||||
|
||||
return query_string or ''
|
||||
@@ -171,7 +171,7 @@ function clear_form()
|
||||
end
|
||||
|
||||
function import_query_string()
|
||||
local components, error = filter.parse_query_string(select(3, strfind(search_box:GetText(), '^([^;]*)')))
|
||||
local components, error = filter_util.parse_query_string(select(3, strfind(search_box:GetText(), '^([^;]*)')))
|
||||
if components then
|
||||
set_form(components)
|
||||
else
|
||||
@@ -209,7 +209,7 @@ function public.formatted_post_filter(components)
|
||||
for parameter in present(component[3]) do
|
||||
if component[2] == 'item' then
|
||||
parameter = info.display_name(cache.item_id(parameter)) or '['..parameter..']'
|
||||
elseif filter.filters[component[2]].input_type == 'money' then
|
||||
elseif filter_util.filters[component[2]].input_type == 'money' then
|
||||
parameter = money.to_string(money.from_string(parameter), nil, true)
|
||||
end
|
||||
component_text = component_text..filter_color(': ')..parameter
|
||||
@@ -262,13 +262,13 @@ end
|
||||
|
||||
function add_post_filter()
|
||||
for str in present(filter_input:GetText()) do
|
||||
for filter in present(filter.filters[str]) do
|
||||
for filter in present(filter_util.filters[str]) do
|
||||
if filter.input_type ~= '' then
|
||||
str = str..'/'..filter_parameter_input:GetText()
|
||||
end
|
||||
end
|
||||
|
||||
local components, error, suggestions = filter.parse_query_string(str)
|
||||
local components, error, suggestions = filter_util.parse_query_string(str)
|
||||
|
||||
if components and getn(components.blizzard) == 0 and getn(components.post) == 1 then
|
||||
add_component(components.post[1])
|
||||
@@ -319,15 +319,15 @@ function set_filter_display_offset(x_offset, y_offset)
|
||||
end
|
||||
|
||||
function initialize_filter_dropdown()
|
||||
for _, filter in {'and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity', 'left', 'utilizable', 'discard'} do
|
||||
for _, filter in -list 'and' 'or' 'not' 'min-unit-bid' 'min-unit-buy' 'max-unit-bid' 'max-unit-buy' 'bid-profit' 'buy-profit' 'bid-vend-profit' 'buy-vend-profit' 'bid-dis-profit' 'buy-dis-profit' 'bid-pct' 'buy-pct' 'item' 'tooltip' 'min-lvl' 'max-lvl' 'rarity' 'left' 'utilizable' 'discard' do
|
||||
UIDropDownMenu_AddButton{
|
||||
text = filter,
|
||||
value = filter,
|
||||
func = function()
|
||||
filter_input:SetText(this.value)
|
||||
if index(filter.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
||||
if index(filter_util.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
||||
add_post_filter()
|
||||
elseif filter.filters[this.value] then
|
||||
elseif filter_util.filters[this.value] then
|
||||
filter_parameter_input:Show()
|
||||
filter_parameter_input:SetFocus()
|
||||
else
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module 'search_tab' import 'gui' [''] 'core' 'completion' 'listing' 'auction_listing'
|
||||
module 'search_tab' import 'gui' [''] 'core' 'completion' 'listing' 'auction_listing' 'filter_util'
|
||||
|
||||
FILTER_SPACING = 28.5
|
||||
|
||||
@@ -311,7 +311,7 @@ function create_frames()
|
||||
btn:SetHeight(24)
|
||||
btn:SetText 'Favorite'
|
||||
btn:SetScript('OnClick', function()
|
||||
local filters = filter.queries(search_box:GetText())
|
||||
local filters = filter_util.queries(search_box:GetText())
|
||||
if filters then
|
||||
tinsert(_g.aux_favorite_searches, 1, {
|
||||
filter_string = search_box:GetText(),
|
||||
@@ -510,13 +510,13 @@ function create_frames()
|
||||
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 {'and', 'or', 'not', unpack(keys(filter.filters))} end)
|
||||
input.complete = completion.complete(function() return {'and', 'or', 'not', unpack(keys(filter_util.filters))} end)
|
||||
input.char = function() this:complete() end
|
||||
input.change = function()
|
||||
local filter = this:GetText()
|
||||
if filter.filters[filter] and filter.filters[filter].input_type ~= '' then
|
||||
local _, _, suggestions = filter.parse_query_string(filter..'/')
|
||||
filter_parameter_input:SetNumeric(filter.filters[filter].input_type == 'number')
|
||||
local text = this:GetText()
|
||||
if filter_util.filters[text] and filter_util.filters[text].input_type ~= '' then
|
||||
local _, _, suggestions = filter_util.parse_query_string(text..'/')
|
||||
filter_parameter_input:SetNumeric(filter_util.filters[text].input_type == 'number')
|
||||
filter_parameter_input.complete = completion.complete(function() return suggestions or {} end)
|
||||
filter_parameter_input:Show()
|
||||
else
|
||||
|
||||
@@ -113,7 +113,7 @@ end
|
||||
|
||||
function update_auto_buy_filter()
|
||||
if _g.aux_auto_buy_filter ~= '' then
|
||||
local queries = filter.queries(_g.aux_auto_buy_filter)
|
||||
local queries = filter_util.queries(_g.aux_auto_buy_filter)
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
log 'Error: The automatic buyout filter does not support multi-queries'
|
||||
@@ -308,7 +308,7 @@ function public.execute(resume, real_time)
|
||||
end
|
||||
local filter_string = search_box:GetText()
|
||||
|
||||
local queries = filter.queries(filter_string)
|
||||
local queries = filter_util.queries(filter_string)
|
||||
if not queries then
|
||||
return
|
||||
elseif real_time then
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ function public:complete_filter()
|
||||
local filter_string = this:GetText()
|
||||
|
||||
local completed_filter_string = ({strfind(filter_string, '([^;]*)/[^/;]*$')})[3]
|
||||
local _, suggestions = filter.query(completed_filter_string or '')
|
||||
local _, suggestions = filter_util.query(completed_filter_string or '')
|
||||
|
||||
local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$')
|
||||
current_modifier = current_modifier or ''
|
||||
|
||||
+12
-7
@@ -42,6 +42,7 @@ do
|
||||
local arg1 = arg
|
||||
return function(...) return helper(body, arg1, arg) end
|
||||
else
|
||||
error(debugstack(1, 10))
|
||||
body = gsub(body, '_([ab])', function(char) return '_'..a1b2[char] end)
|
||||
local lambda = loadstring 'return function(_1,_2,_3,_4,_5,_6,_7,_8,_9)'..f..' end'
|
||||
setfenv(lambda, getfenv(2))
|
||||
@@ -51,11 +52,15 @@ do
|
||||
end
|
||||
|
||||
function public.call(f, ...) temp=arg
|
||||
if f then return f(unpack(arg)) end
|
||||
if f then
|
||||
return f(unpack(arg))
|
||||
end
|
||||
end
|
||||
|
||||
function public.index(t, ...) temp=arg
|
||||
for i=1,arg.n do t = t and t[arg[i]] end
|
||||
for i=1,arg.n do
|
||||
t = t and t[arg[i]]
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
@@ -105,12 +110,12 @@ function public.select(i, ...) temp=arg
|
||||
return tremove(arg, 1), unpack(arg)
|
||||
end
|
||||
|
||||
function public.collect(t, ...) temp=arg
|
||||
local T = T
|
||||
for _, v in t do
|
||||
tinsert(T, arg[v])
|
||||
function public.collect(indices, ...) temp=arg
|
||||
local t = _m.t
|
||||
for _, v in indices do
|
||||
tinsert(t, arg[v])
|
||||
end
|
||||
return T
|
||||
return t
|
||||
end
|
||||
|
||||
function public.hashset(t)
|
||||
|
||||
+5
-1
@@ -1,4 +1,8 @@
|
||||
module 'filter'
|
||||
module 'filter_util' import 'info' 'cache'
|
||||
|
||||
function LOAD()
|
||||
import 'cache'
|
||||
end
|
||||
|
||||
function default_filter(str)
|
||||
return {
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ function public.item_query(item_id, first_page, last_page)
|
||||
local item_info = info.item(item_id)
|
||||
|
||||
if item_info then
|
||||
local query = filter.query(item_info.name..'/exact')
|
||||
local query = filter_util.query(item_info.name..'/exact')
|
||||
query.blizzard_query.first_page = first_page
|
||||
query.blizzard_query.last_page = last_page
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user