filter bugfix

This commit is contained in:
Manuel Simon Hirsig
2016-08-11 19:14:17 +02:00
parent 4ee99e43e8
commit dba5dcdf8d
8 changed files with 55 additions and 68 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ end
function public.event_listener(event, cb)
local listener_id = m.id()
m.listeners[listener_id] = { event=event, cb=cb, kill=function(...) if arg.n == 0 or arg[1] then m.kill_listener(listener_id) end end }
m.listeners[listener_id] = {event=event, cb=cb, kill=function(...) if arg.n == 0 or arg[1] then m.kill_listener(listener_id) end end}
m.event_frame:RegisterEvent(event)
return listener_id
end
@@ -78,7 +78,7 @@ end
function public.thread(k, ...)
local thread_id = m.id()
m.threads[thread_id] = { k = aux._(k, unpack(arg)) }
m.threads[thread_id] = {k = aux._(k, unpack(arg))}
return thread_id
end
+1 -1
View File
@@ -398,7 +398,7 @@ function public.index(t, ...)
return t
end
public.huge = 2^100000
public.huge = 1.8*10^308
function public.log(...)
local msg = '[aux]'
+2 -2
View File
@@ -1,4 +1,4 @@
local addon = aux_module()
local addon = {aux_module()}
aux = tremove(addon, 1)
local m, public, private = unpack(addon)
@@ -16,7 +16,7 @@ function public.module(path)
local qualified_name = prefix and prefix..'.'..name or name
module = m.modules[qualified_name]
if not module then
module = aux_module()
module = {aux_module()}
module[4].LOAD = nil
(prefix and m.modules[prefix] or addon)[2][name] = tremove(module, 1)
m.modules[qualified_name] = module
+19 -41
View File
@@ -1,62 +1,40 @@
local PUBLIC, PRIVATE = 1, 2
local state = {}
local public_interface_mt = {
__newindex = function()
error('Unsupported operation.', 2)
end,
local interface_mt = {
__index = function(self, key)
if state[self].public[key] then
return state[self].data[key]
else
error('Read of undeclared "'..key..'".', 2)
end
end,
}
local private_interface_mt = {
__newindex = function(self, key, value)
if not state[self].declared[key] then
error('Write of undeclared "'..key..'".', 2)
end
state[self].data[key] = value
end,
__index = function(self, key)
if not state[self].declared[key] then
if not state[self].access[state[self].type][key] then
error('Read of undeclared "'..key..'".', 2)
end
return state[self].data[key]
end,
}
local public_declarator_mt = {
__newindex = function(self, key, value)
if state[self].declared[key] then
error('Multiple declarations of "'..key..'".', 2)
if state[self].type == PUBLIC then
error('Unsupported operation.', 2)
elseif not state[self].access[PRIVATE][key] then
error('Write of undeclared "'..key..'".', 2)
end
state[self].data[key] = value
state[self].public[key] = true
state[self].declared[key] = true
end,
}
local declarator_mt = {
__index = function()
error('Unsupported operation.', 2)
end,
}
local private_declarator_mt = {
__newindex = function(self, key, value)
if state[self].declared[key] then
if state[self].access[PRIVATE][key] then
error('Multiple declarations of "'..key..'".', 2)
end
state[self].data[key] = value
state[self].declared[key] = true
end,
__index = function()
error('Unsupported operation.', 2)
state[self].access[PRIVATE][key] = true
state[self].access[state[self].type][key] = true
end,
}
function aux_module()
local new_state = {data={}, public={}, declared={}}
local module = {setmetatable({}, public_interface_mt), setmetatable({}, private_interface_mt), setmetatable({}, public_declarator_mt), setmetatable({}, private_declarator_mt)}
for _, component in module do
state[component] = new_state
end
return module
local data, access = {}, {{}, {}}
local public_state, private_state = {type=PUBLIC, data=data, access=access}, {type=PRIVATE, data=data, access=access}
local public_interface, private_interface = setmetatable({}, interface_mt), setmetatable({}, interface_mt)
local public_declarator, private_declarator = setmetatable({}, declarator_mt), setmetatable({}, declarator_mt)
state[public_interface], state[private_interface] = public_state, private_state
state[public_declarator], state[private_declarator] = public_state, private_state
return public_interface, private_interface, public_declarator, private_declarator
end
+1 -8
View File
@@ -116,14 +116,7 @@ end
function private.blizzard_page_index(str)
if tonumber(str) then
return aux.util.round(max(0, tonumber(str) - 1))
return max(0, tonumber(str) - 1)
end
end
function private.blizzard_level(str)
if tonumber(str) then
return aux.util.round(aux.util.bound(1, 60, tonumber(str)))
end
end
+12 -8
View File
@@ -54,13 +54,17 @@ private.blizzard_query = setmetatable({}, {
elseif key == 'usable' then
return m.usable_checkbox:GetChecked()
elseif key == 'class' then
return UIDropDownMenu_GetSelectedValue(m.class_dropdown)
local class_index = UIDropDownMenu_GetSelectedValue(m.class_dropdown)
return (class_index or 0) > 0 and class_index or nil
elseif key == 'subclass' then
return UIDropDownMenu_GetSelectedValue(m.subclass_dropdown)
local subclass_index = UIDropDownMenu_GetSelectedValue(m.subclass_dropdown)
return (subclass_index or 0) > 0 and subclass_index or nil
elseif key == 'slot' then
return UIDropDownMenu_GetSelectedValue(m.slot_dropdown)
local slot_index = UIDropDownMenu_GetSelectedValue(m.slot_dropdown)
return (slot_index or 0) > 0 and slot_index or nil
elseif key == 'quality' then
return UIDropDownMenu_GetSelectedValue(m.quality_dropdown)
local quality_code = UIDropDownMenu_GetSelectedValue(m.quality_dropdown)
return (quality_code or -1) >= 0 and quality_code or nil
end
end,
})
@@ -126,13 +130,13 @@ function private.get_form_query()
add(m.blizzard_query.max_level)
add(m.blizzard_query.usable and 'usable')
for _, class in {m.blizzard_query.class ~= 0 and m.blizzard_query.class} do
for _, class in {m.blizzard_query.class} do
local classes = {GetAuctionItemClasses()}
add(strlower(classes[class]))
for _, subclass in {m.blizzard_query.subclass ~= 0 and m.blizzard_query.subclass} do
for _, subclass in {m.blizzard_query.subclass} do
local subclasses = {GetAuctionItemSubClasses(class)}
add(strlower(subclasses[subclass]))
add(m.blizzard_query.slot ~= 0 and m.blizzard_query.slot and strlower(getglobal(m.blizzard_query.slot)))
add(m.blizzard_query.slot and strlower(getglobal(m.blizzard_query.slot)))
end
end
@@ -141,7 +145,7 @@ function private.get_form_query()
add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC')))
end
return query_string
return query_string or ''
end
function private.set_form(components)
+16
View File
@@ -80,6 +80,14 @@ function private.create_frames()
m.execute()
end)
editbox:SetScript('OnTextChanged', function()
local page = tonumber(this:GetText())
local valid_input = page and tostring(max(1, page)) or ''
if this:GetText() ~= valid_input then
this:SetText(valid_input)
end
if (tonumber(m.last_page_input:GetText()) or aux.huge) < (tonumber(this:GetText()) or 1) then
m.last_page_input:SetText(tonumber(this:GetText()))
end
if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then
this:SetBackdropColor(unpack(aux.gui.color.state.enabled))
else
@@ -106,6 +114,14 @@ function private.create_frames()
m.execute()
end)
editbox:SetScript('OnTextChanged', function()
local page = tonumber(this:GetText())
local valid_input = page and tostring(max(1, page)) or ''
if this:GetText() ~= valid_input then
this:SetText(valid_input)
end
if (tonumber(m.first_page_input:GetText()) or 1) > (tonumber(this:GetText()) or aux.huge) then
m.first_page_input:SetText(tonumber(this:GetText()))
end
if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then
this:SetBackdropColor(unpack(aux.gui.color.state.enabled))
else
+2 -6
View File
@@ -1,11 +1,7 @@
local m, public, private = aux.module'util'
function public.either(p, a, b)
if p then
return a
else
return b
end
function public.present(value)
return value ~= nil and {[value]=true} or {}
end
function public.unpack(array, ...)