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)
|
||||
end
|
||||
|
||||
function public.vararg.thread(arg)
|
||||
public.thread = vararg-function(arg)
|
||||
local k = tremove(arg, 1)
|
||||
local thread_id = unique_id
|
||||
threads[thread_id] = T('k', papply(k, unpack(arg)))
|
||||
return thread_id
|
||||
end
|
||||
|
||||
function public.vararg.wait(arg)
|
||||
public.wait = vararg-function(arg)
|
||||
local k = tremove(arg, 1)
|
||||
if type(k) == 'number' then
|
||||
when(function() k = k - 1 return k <= 1 end, unpack(arg))
|
||||
@@ -103,7 +103,7 @@ function public.vararg.wait(arg)
|
||||
end
|
||||
end
|
||||
|
||||
function public.vararg.when(arg)
|
||||
public.when = vararg-function(arg)
|
||||
local c = tremove(arg, 1)
|
||||
local k = tremove(arg, 1)
|
||||
if c() then
|
||||
|
||||
+1
-5
@@ -59,7 +59,7 @@ function private.query.get()
|
||||
return state.params.queries[state.query_index]
|
||||
end
|
||||
|
||||
function private.vararg.wait_for_callback(arg)
|
||||
private.wait_for_callback = vararg-function(arg)
|
||||
local send_signal, signal_received = signal()
|
||||
local suspended, ret
|
||||
|
||||
@@ -71,10 +71,6 @@ function private.vararg.wait_for_callback(arg)
|
||||
'suspend', function() suspended = true end,
|
||||
'resume', send_signal
|
||||
))
|
||||
-- tinsert(arg, -pairs TODO
|
||||
-- :suspend (function() suspended = true end)
|
||||
-- :resume (send_signal)
|
||||
-- )
|
||||
f(unpack(arg))
|
||||
end
|
||||
if not suspended then send_signal() end
|
||||
|
||||
@@ -141,7 +141,6 @@ do
|
||||
end
|
||||
public.vararg = setmetatable({}, {
|
||||
__metatable = false,
|
||||
__call = function(_, v) return vararg(v) end,
|
||||
__sub = function(_, v) return vararg(v) 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 }
|
||||
end
|
||||
|
||||
local _module, _access, _modifiers = {}, {}, {}
|
||||
local _module, _access, _name = {}, {}, {}
|
||||
|
||||
local definition_helper_mt = { __metatable=false }
|
||||
function definition_helper_mt:__index(k)
|
||||
tinsert(_modifiers[self], k)
|
||||
_name[self] = _name[self] and error('Invalid modifier "%s".', k) or k
|
||||
return self
|
||||
end
|
||||
function definition_helper_mt:__newindex(k, v) local module, modifiers = _module[self], _modifiers[self]
|
||||
local name = META[k] and (tremove(modifiers) or error'Definition missing identifier.') or k
|
||||
function definition_helper_mt:__newindex(k, v) local module = _module[self]
|
||||
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
|
||||
local type = META[k] or FIELD
|
||||
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
|
||||
setn(modifiers, 0)
|
||||
_access[self], _name[self] = nil, nil
|
||||
end
|
||||
|
||||
local function include(self, interface)
|
||||
@@ -53,7 +52,7 @@ local env = setmetatable({}, {
|
||||
__newindex = function(_, k)
|
||||
if _G[k] then _G.error(nil) end
|
||||
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 }
|
||||
mutators = setmetatable({ _=nop }, { __index=function(_, k) return function(v) _G[k] = v end end })
|
||||
fields = setmetatable(
|
||||
@@ -75,7 +74,6 @@ local env = setmetatable({}, {
|
||||
[PUBLIC+FIELD] = public_fields,
|
||||
}
|
||||
_module[definition_helper], _module[interface] = module, module
|
||||
_modifiers[definition_helper] = modifiers
|
||||
_G[k] = interface
|
||||
setfenv(2, environment)
|
||||
end,
|
||||
|
||||
@@ -25,35 +25,6 @@ StaticPopupDialogs.AUX_SEARCH_AUTO_BUY = {
|
||||
timeout = 0,
|
||||
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.SAVED = 2
|
||||
@@ -62,8 +33,6 @@ private.FILTER = 3
|
||||
function LOAD()
|
||||
aux_search_tab_frame.create()
|
||||
subtab = SAVED
|
||||
aux_search_tab_results.update_auto_buy_filter()
|
||||
aux_search_tab_results.new_search('')
|
||||
current_search.placeholder = true
|
||||
end
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ include (aux_util)
|
||||
include (aux_control)
|
||||
include (aux_util_color)
|
||||
|
||||
function LOAD()
|
||||
include (aux_search_tab)
|
||||
end
|
||||
|
||||
local filter_util = aux_filter_util
|
||||
|
||||
function private.valid_level(str)
|
||||
|
||||
+42
-6
@@ -6,10 +6,46 @@ include (aux_util)
|
||||
include (aux_control)
|
||||
include (aux_util_color)
|
||||
|
||||
function LOAD()
|
||||
include (aux_search_tab)
|
||||
update_auto_buy_filter()
|
||||
new_search('')
|
||||
end
|
||||
|
||||
local info, scan = aux_info, aux_scan
|
||||
|
||||
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
|
||||
local id = 0
|
||||
function public.search_scan_id.get() return id end
|
||||
@@ -54,7 +90,7 @@ do
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
function public.new_search(filter_string)
|
||||
function private.new_search(filter_string)
|
||||
while getn(searches) > search_index do
|
||||
tremove(searches)
|
||||
end
|
||||
@@ -62,16 +98,16 @@ do
|
||||
tinsert(searches, search)
|
||||
if getn(searches) > 5 then
|
||||
tremove(searches, 1)
|
||||
tinsert(aux_search_tab.status_bars, tremove(aux_search_tab.status_bars, 1))
|
||||
tinsert(aux_search_tab.tables, tremove(aux_search_tab.tables, 1))
|
||||
tinsert(status_bars, tremove(status_bars, 1))
|
||||
tinsert(tables, tremove(tables, 1))
|
||||
search_index = 4
|
||||
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: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:Reset()
|
||||
search.table:SetDatabase(search.records)
|
||||
@@ -124,7 +160,7 @@ function update_start_stop()
|
||||
end
|
||||
end
|
||||
|
||||
function public.update_auto_buy_filter()
|
||||
function private.update_auto_buy_filter()
|
||||
if aux_auto_buy_filter ~= '' then
|
||||
local queries, error = aux_filter_util.queries(aux_auto_buy_filter)
|
||||
if queries then
|
||||
|
||||
@@ -6,6 +6,10 @@ include (aux_util)
|
||||
include (aux_control)
|
||||
include (aux_util_color)
|
||||
|
||||
function LOAD()
|
||||
include (aux_search_tab)
|
||||
end
|
||||
|
||||
aux_favorite_searches = t
|
||||
aux_recent_searches = t
|
||||
|
||||
@@ -19,7 +23,7 @@ function private.update_search_listings()
|
||||
index = i,
|
||||
})
|
||||
end
|
||||
aux_search_tab.favorite_searches_listing:SetData(favorite_search_rows)
|
||||
favorite_searches_listing:SetData(favorite_search_rows)
|
||||
|
||||
local recent_search_rows = t
|
||||
for i, recent_search in aux_recent_searches do
|
||||
@@ -30,7 +34,7 @@ function private.update_search_listings()
|
||||
index = i,
|
||||
})
|
||||
end
|
||||
aux_search_tab.recent_searches_listing:SetData(recent_search_rows)
|
||||
recent_searches_listing:SetData(recent_search_rows)
|
||||
end
|
||||
|
||||
function public.new_recent_search(filter_string, prettified)
|
||||
|
||||
+5
-5
@@ -45,7 +45,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function public.vararg.select(arg)
|
||||
public.select = vararg-function(arg)
|
||||
for _ = 1, arg[1] do
|
||||
tremove(arg, 1)
|
||||
end
|
||||
@@ -80,17 +80,17 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function public.vararg.papply(arg)
|
||||
public.papply = vararg-function(arg)
|
||||
local f, arg1 = tremove(arg, 1), perm-arg
|
||||
return vararg(function(arg)
|
||||
return vararg-function(arg)
|
||||
for i = 1, getn(arg) do
|
||||
tinsert(arg1, arg[i])
|
||||
end
|
||||
return f(unpack(arg1))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function public.vararg.index(arg)
|
||||
public.index = vararg-function(arg)
|
||||
local t = tremove(arg, 1)
|
||||
for i = 1, getn(arg) do t = t and t[arg[i]] end return t
|
||||
end
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ function public.compare(a, b, desc)
|
||||
end
|
||||
end
|
||||
|
||||
function public.vararg.multi_lt(arg)
|
||||
public.multi_lt = vararg-function(arg)
|
||||
for i = 1, getn(arg), 2 do
|
||||
if arg[i] and arg[i + 1] and arg[i] ~= arg[i + 1] then
|
||||
return arg[i] < arg[i + 1]
|
||||
|
||||
Reference in New Issue
Block a user