refactoring
This commit is contained in:
+3
-3
@@ -87,14 +87,14 @@ function public.on_next_event(event, callback)
|
|||||||
event_listener(event, function(kill) callback(); kill() end)
|
event_listener(event, function(kill) callback(); kill() end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.vararg.thread(arg)
|
public.thread = vararg-function(arg)
|
||||||
local k = tremove(arg, 1)
|
local k = tremove(arg, 1)
|
||||||
local thread_id = unique_id
|
local thread_id = unique_id
|
||||||
threads[thread_id] = T('k', papply(k, unpack(arg)))
|
threads[thread_id] = T('k', papply(k, unpack(arg)))
|
||||||
return thread_id
|
return thread_id
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.vararg.wait(arg)
|
public.wait = vararg-function(arg)
|
||||||
local k = tremove(arg, 1)
|
local k = tremove(arg, 1)
|
||||||
if type(k) == 'number' then
|
if type(k) == 'number' then
|
||||||
when(function() k = k - 1 return k <= 1 end, unpack(arg))
|
when(function() k = k - 1 return k <= 1 end, unpack(arg))
|
||||||
@@ -103,7 +103,7 @@ function public.vararg.wait(arg)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.vararg.when(arg)
|
public.when = vararg-function(arg)
|
||||||
local c = tremove(arg, 1)
|
local c = tremove(arg, 1)
|
||||||
local k = tremove(arg, 1)
|
local k = tremove(arg, 1)
|
||||||
if c() then
|
if c() then
|
||||||
|
|||||||
+1
-5
@@ -59,7 +59,7 @@ function private.query.get()
|
|||||||
return state.params.queries[state.query_index]
|
return state.params.queries[state.query_index]
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.vararg.wait_for_callback(arg)
|
private.wait_for_callback = vararg-function(arg)
|
||||||
local send_signal, signal_received = signal()
|
local send_signal, signal_received = signal()
|
||||||
local suspended, ret
|
local suspended, ret
|
||||||
|
|
||||||
@@ -71,10 +71,6 @@ function private.vararg.wait_for_callback(arg)
|
|||||||
'suspend', function() suspended = true end,
|
'suspend', function() suspended = true end,
|
||||||
'resume', send_signal
|
'resume', send_signal
|
||||||
))
|
))
|
||||||
-- tinsert(arg, -pairs TODO
|
|
||||||
-- :suspend (function() suspended = true end)
|
|
||||||
-- :resume (send_signal)
|
|
||||||
-- )
|
|
||||||
f(unpack(arg))
|
f(unpack(arg))
|
||||||
end
|
end
|
||||||
if not suspended then send_signal() end
|
if not suspended then send_signal() end
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ do
|
|||||||
end
|
end
|
||||||
public.vararg = setmetatable({}, {
|
public.vararg = setmetatable({}, {
|
||||||
__metatable = false,
|
__metatable = false,
|
||||||
__call = function(_, v) return vararg(v) end,
|
|
||||||
__sub = function(_, v) return vararg(v) end,
|
__sub = function(_, v) return vararg(v) end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
+6
-8
@@ -18,21 +18,20 @@ local function proxy_mt(fields, mutators, lt)
|
|||||||
return { __metatable=false, __index=fields, __newindex=function(_, k, v) return mutators[k](v) end, __lt=lt }
|
return { __metatable=false, __index=fields, __newindex=function(_, k, v) return mutators[k](v) end, __lt=lt }
|
||||||
end
|
end
|
||||||
|
|
||||||
local _module, _access, _modifiers = {}, {}, {}
|
local _module, _access, _name = {}, {}, {}
|
||||||
|
|
||||||
local definition_helper_mt = { __metatable=false }
|
local definition_helper_mt = { __metatable=false }
|
||||||
function definition_helper_mt:__index(k)
|
function definition_helper_mt:__index(k)
|
||||||
tinsert(_modifiers[self], k)
|
_name[self] = _name[self] and error('Invalid modifier "%s".', k) or k
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
function definition_helper_mt:__newindex(k, v) local module, modifiers = _module[self], _modifiers[self]
|
function definition_helper_mt:__newindex(k, v) local module = _module[self]
|
||||||
local name = META[k] and (tremove(modifiers) or error'Definition missing identifier.') or k
|
local name = META[k] and (_name[self] or error'Definition missing identifier.') or k
|
||||||
if type(name) ~= 'string' or not strfind(name, '^[_%a][_%w]*') then error('Invalid identifier "%s".', name) end
|
if type(name) ~= 'string' or not strfind(name, '^[_%a][_%w]*') then error('Invalid identifier "%s".', name) end
|
||||||
local type = META[k] or FIELD
|
local type = META[k] or FIELD
|
||||||
module.defined[name .. OPERATION[type]] = module.defined[name .. OPERATION[type]] and error('Duplicate identifier "%s".', name) or true
|
module.defined[name .. OPERATION[type]] = module.defined[name .. OPERATION[type]] and error('Duplicate identifier "%s".', name) or true
|
||||||
for i = getn(modifiers), 1, -1 do v = module[FIELD][modifiers[i]](v) end
|
|
||||||
module[type][name], module[_access[self]+type][name] = v, v
|
module[type][name], module[_access[self]+type][name] = v, v
|
||||||
setn(modifiers, 0)
|
_access[self], _name[self] = nil, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function include(self, interface)
|
local function include(self, interface)
|
||||||
@@ -53,7 +52,7 @@ local env = setmetatable({}, {
|
|||||||
__newindex = function(_, k)
|
__newindex = function(_, k)
|
||||||
if _G[k] then _G.error(nil) end
|
if _G[k] then _G.error(nil) end
|
||||||
local module, environment, interface, definition_helper, modifiers, accessors, mutators, fields, public_accessors, public_mutators, public_fields
|
local module, environment, interface, definition_helper, modifiers, accessors, mutators, fields, public_accessors, public_mutators, public_fields
|
||||||
environment, interface, definition_helper, modifiers = {}, {}, setmetatable({}, definition_helper_mt), {}
|
environment, interface, definition_helper = {}, {}, setmetatable({}, definition_helper_mt)
|
||||||
accessors = { private=function() _access[definition_helper] = PRIVATE; return definition_helper end, public=function() _access[definition_helper] = PUBLIC; return definition_helper end }
|
accessors = { private=function() _access[definition_helper] = PRIVATE; return definition_helper end, public=function() _access[definition_helper] = PUBLIC; return definition_helper end }
|
||||||
mutators = setmetatable({ _=nop }, { __index=function(_, k) return function(v) _G[k] = v end end })
|
mutators = setmetatable({ _=nop }, { __index=function(_, k) return function(v) _G[k] = v end end })
|
||||||
fields = setmetatable(
|
fields = setmetatable(
|
||||||
@@ -75,7 +74,6 @@ local env = setmetatable({}, {
|
|||||||
[PUBLIC+FIELD] = public_fields,
|
[PUBLIC+FIELD] = public_fields,
|
||||||
}
|
}
|
||||||
_module[definition_helper], _module[interface] = module, module
|
_module[definition_helper], _module[interface] = module, module
|
||||||
_modifiers[definition_helper] = modifiers
|
|
||||||
_G[k] = interface
|
_G[k] = interface
|
||||||
setfenv(2, environment)
|
setfenv(2, environment)
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -25,35 +25,6 @@ StaticPopupDialogs.AUX_SEARCH_AUTO_BUY = {
|
|||||||
timeout = 0,
|
timeout = 0,
|
||||||
hideOnEscape = 1,
|
hideOnEscape = 1,
|
||||||
}
|
}
|
||||||
do
|
|
||||||
local function action()
|
|
||||||
aux_auto_buy_filter = _G[this:GetParent():GetName() .. 'EditBox']:GetText()
|
|
||||||
aux_search_tab_results.update_auto_buy_filter()
|
|
||||||
end
|
|
||||||
|
|
||||||
StaticPopupDialogs.AUX_SEARCH_AUTO_BUY_FILTER = {
|
|
||||||
text = 'Enter a filter for automatic buyout.',
|
|
||||||
button1 = 'Accept',
|
|
||||||
button2 = 'Cancel',
|
|
||||||
hasEditBox = 1,
|
|
||||||
OnShow = function()
|
|
||||||
local edit_box = _G[this:GetName() .. 'EditBox']
|
|
||||||
edit_box:SetMaxLetters(nil)
|
|
||||||
edit_box:SetFocus()
|
|
||||||
edit_box:HighlightText()
|
|
||||||
end,
|
|
||||||
OnAccept = action,
|
|
||||||
EditBoxOnEnterPressed = function()
|
|
||||||
action()
|
|
||||||
this:GetParent():Hide()
|
|
||||||
end,
|
|
||||||
EditBoxOnEscapePressed = function()
|
|
||||||
this:GetParent():Hide()
|
|
||||||
end,
|
|
||||||
timeout = 0,
|
|
||||||
hideOnEscape = 1,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
private.RESULTS = 1
|
private.RESULTS = 1
|
||||||
private.SAVED = 2
|
private.SAVED = 2
|
||||||
@@ -62,8 +33,6 @@ private.FILTER = 3
|
|||||||
function LOAD()
|
function LOAD()
|
||||||
aux_search_tab_frame.create()
|
aux_search_tab_frame.create()
|
||||||
subtab = SAVED
|
subtab = SAVED
|
||||||
aux_search_tab_results.update_auto_buy_filter()
|
|
||||||
aux_search_tab_results.new_search('')
|
|
||||||
current_search.placeholder = true
|
current_search.placeholder = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ include (aux_util)
|
|||||||
include (aux_control)
|
include (aux_control)
|
||||||
include (aux_util_color)
|
include (aux_util_color)
|
||||||
|
|
||||||
|
function LOAD()
|
||||||
|
include (aux_search_tab)
|
||||||
|
end
|
||||||
|
|
||||||
local filter_util = aux_filter_util
|
local filter_util = aux_filter_util
|
||||||
|
|
||||||
function private.valid_level(str)
|
function private.valid_level(str)
|
||||||
|
|||||||
+42
-6
@@ -6,10 +6,46 @@ include (aux_util)
|
|||||||
include (aux_control)
|
include (aux_control)
|
||||||
include (aux_util_color)
|
include (aux_util_color)
|
||||||
|
|
||||||
|
function LOAD()
|
||||||
|
include (aux_search_tab)
|
||||||
|
update_auto_buy_filter()
|
||||||
|
new_search('')
|
||||||
|
end
|
||||||
|
|
||||||
local info, scan = aux_info, aux_scan
|
local info, scan = aux_info, aux_scan
|
||||||
|
|
||||||
aux_auto_buy_filter = ''
|
aux_auto_buy_filter = ''
|
||||||
|
|
||||||
|
do
|
||||||
|
local function action()
|
||||||
|
aux_auto_buy_filter = _G[this:GetParent():GetName() .. 'EditBox']:GetText()
|
||||||
|
update_auto_buy_filter()
|
||||||
|
end
|
||||||
|
|
||||||
|
StaticPopupDialogs.AUX_SEARCH_AUTO_BUY_FILTER = {
|
||||||
|
text = 'Enter a filter for automatic buyout.',
|
||||||
|
button1 = 'Accept',
|
||||||
|
button2 = 'Cancel',
|
||||||
|
hasEditBox = 1,
|
||||||
|
OnShow = function()
|
||||||
|
local edit_box = _G[this:GetName() .. 'EditBox']
|
||||||
|
edit_box:SetMaxLetters(nil)
|
||||||
|
edit_box:SetFocus()
|
||||||
|
edit_box:HighlightText()
|
||||||
|
end,
|
||||||
|
OnAccept = action,
|
||||||
|
EditBoxOnEnterPressed = function()
|
||||||
|
action()
|
||||||
|
this:GetParent():Hide()
|
||||||
|
end,
|
||||||
|
EditBoxOnEscapePressed = function()
|
||||||
|
this:GetParent():Hide()
|
||||||
|
end,
|
||||||
|
timeout = 0,
|
||||||
|
hideOnEscape = 1,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local id = 0
|
local id = 0
|
||||||
function public.search_scan_id.get() return id end
|
function public.search_scan_id.get() return id end
|
||||||
@@ -54,7 +90,7 @@ do
|
|||||||
update_continuation()
|
update_continuation()
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.new_search(filter_string)
|
function private.new_search(filter_string)
|
||||||
while getn(searches) > search_index do
|
while getn(searches) > search_index do
|
||||||
tremove(searches)
|
tremove(searches)
|
||||||
end
|
end
|
||||||
@@ -62,16 +98,16 @@ do
|
|||||||
tinsert(searches, search)
|
tinsert(searches, search)
|
||||||
if getn(searches) > 5 then
|
if getn(searches) > 5 then
|
||||||
tremove(searches, 1)
|
tremove(searches, 1)
|
||||||
tinsert(aux_search_tab.status_bars, tremove(aux_search_tab.status_bars, 1))
|
tinsert(status_bars, tremove(status_bars, 1))
|
||||||
tinsert(aux_search_tab.tables, tremove(aux_search_tab.tables, 1))
|
tinsert(tables, tremove(tables, 1))
|
||||||
search_index = 4
|
search_index = 4
|
||||||
end
|
end
|
||||||
|
|
||||||
search.status_bar = aux_search_tab.status_bars[getn(searches)]
|
search.status_bar = status_bars[getn(searches)]
|
||||||
search.status_bar:update_status(100, 100)
|
search.status_bar:update_status(100, 100)
|
||||||
search.status_bar:set_text('')
|
search.status_bar:set_text('')
|
||||||
|
|
||||||
search.table = aux_search_tab.tables[getn(searches)]
|
search.table = tables[getn(searches)]
|
||||||
search.table:SetSort(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
search.table:SetSort(1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||||
search.table:Reset()
|
search.table:Reset()
|
||||||
search.table:SetDatabase(search.records)
|
search.table:SetDatabase(search.records)
|
||||||
@@ -124,7 +160,7 @@ function update_start_stop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.update_auto_buy_filter()
|
function private.update_auto_buy_filter()
|
||||||
if aux_auto_buy_filter ~= '' then
|
if aux_auto_buy_filter ~= '' then
|
||||||
local queries, error = aux_filter_util.queries(aux_auto_buy_filter)
|
local queries, error = aux_filter_util.queries(aux_auto_buy_filter)
|
||||||
if queries then
|
if queries then
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ include (aux_util)
|
|||||||
include (aux_control)
|
include (aux_control)
|
||||||
include (aux_util_color)
|
include (aux_util_color)
|
||||||
|
|
||||||
|
function LOAD()
|
||||||
|
include (aux_search_tab)
|
||||||
|
end
|
||||||
|
|
||||||
aux_favorite_searches = t
|
aux_favorite_searches = t
|
||||||
aux_recent_searches = t
|
aux_recent_searches = t
|
||||||
|
|
||||||
@@ -19,7 +23,7 @@ function private.update_search_listings()
|
|||||||
index = i,
|
index = i,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
aux_search_tab.favorite_searches_listing:SetData(favorite_search_rows)
|
favorite_searches_listing:SetData(favorite_search_rows)
|
||||||
|
|
||||||
local recent_search_rows = t
|
local recent_search_rows = t
|
||||||
for i, recent_search in aux_recent_searches do
|
for i, recent_search in aux_recent_searches do
|
||||||
@@ -30,7 +34,7 @@ function private.update_search_listings()
|
|||||||
index = i,
|
index = i,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
aux_search_tab.recent_searches_listing:SetData(recent_search_rows)
|
recent_searches_listing:SetData(recent_search_rows)
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.new_recent_search(filter_string, prettified)
|
function public.new_recent_search(filter_string, prettified)
|
||||||
|
|||||||
+5
-5
@@ -45,7 +45,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.vararg.select(arg)
|
public.select = vararg-function(arg)
|
||||||
for _ = 1, arg[1] do
|
for _ = 1, arg[1] do
|
||||||
tremove(arg, 1)
|
tremove(arg, 1)
|
||||||
end
|
end
|
||||||
@@ -80,17 +80,17 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.vararg.papply(arg)
|
public.papply = vararg-function(arg)
|
||||||
local f, arg1 = tremove(arg, 1), perm-arg
|
local f, arg1 = tremove(arg, 1), perm-arg
|
||||||
return vararg(function(arg)
|
return vararg-function(arg)
|
||||||
for i = 1, getn(arg) do
|
for i = 1, getn(arg) do
|
||||||
tinsert(arg1, arg[i])
|
tinsert(arg1, arg[i])
|
||||||
end
|
end
|
||||||
return f(unpack(arg1))
|
return f(unpack(arg1))
|
||||||
end)
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.vararg.index(arg)
|
public.index = vararg-function(arg)
|
||||||
local t = tremove(arg, 1)
|
local t = tremove(arg, 1)
|
||||||
for i = 1, getn(arg) do t = t and t[arg[i]] end return t
|
for i = 1, getn(arg) do t = t and t[arg[i]] end return t
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ function public.compare(a, b, desc)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.vararg.multi_lt(arg)
|
public.multi_lt = vararg-function(arg)
|
||||||
for i = 1, getn(arg), 2 do
|
for i = 1, getn(arg), 2 do
|
||||||
if arg[i] and arg[i + 1] and arg[i] ~= arg[i + 1] then
|
if arg[i] and arg[i + 1] and arg[i] ~= arg[i + 1] then
|
||||||
return arg[i] < arg[i + 1]
|
return arg[i] < arg[i + 1]
|
||||||
|
|||||||
Reference in New Issue
Block a user