filter bugfix
This commit is contained in:
+2
-2
@@ -64,7 +64,7 @@ end
|
|||||||
|
|
||||||
function public.event_listener(event, cb)
|
function public.event_listener(event, cb)
|
||||||
local listener_id = m.id()
|
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)
|
m.event_frame:RegisterEvent(event)
|
||||||
return listener_id
|
return listener_id
|
||||||
end
|
end
|
||||||
@@ -78,7 +78,7 @@ end
|
|||||||
|
|
||||||
function public.thread(k, ...)
|
function public.thread(k, ...)
|
||||||
local thread_id = m.id()
|
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
|
return thread_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ function public.index(t, ...)
|
|||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
public.huge = 2^100000
|
public.huge = 1.8*10^308
|
||||||
|
|
||||||
function public.log(...)
|
function public.log(...)
|
||||||
local msg = '[aux]'
|
local msg = '[aux]'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local addon = aux_module()
|
local addon = {aux_module()}
|
||||||
aux = tremove(addon, 1)
|
aux = tremove(addon, 1)
|
||||||
local m, public, private = unpack(addon)
|
local m, public, private = unpack(addon)
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ function public.module(path)
|
|||||||
local qualified_name = prefix and prefix..'.'..name or name
|
local qualified_name = prefix and prefix..'.'..name or name
|
||||||
module = m.modules[qualified_name]
|
module = m.modules[qualified_name]
|
||||||
if not module then
|
if not module then
|
||||||
module = aux_module()
|
module = {aux_module()}
|
||||||
module[4].LOAD = nil
|
module[4].LOAD = nil
|
||||||
(prefix and m.modules[prefix] or addon)[2][name] = tremove(module, 1)
|
(prefix and m.modules[prefix] or addon)[2][name] = tremove(module, 1)
|
||||||
m.modules[qualified_name] = module
|
m.modules[qualified_name] = module
|
||||||
|
|||||||
+19
-41
@@ -1,62 +1,40 @@
|
|||||||
|
local PUBLIC, PRIVATE = 1, 2
|
||||||
local state = {}
|
local state = {}
|
||||||
|
local interface_mt = {
|
||||||
local public_interface_mt = {
|
|
||||||
__newindex = function()
|
|
||||||
error('Unsupported operation.', 2)
|
|
||||||
end,
|
|
||||||
__index = function(self, key)
|
__index = function(self, key)
|
||||||
if state[self].public[key] then
|
if not state[self].access[state[self].type][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
|
|
||||||
error('Read of undeclared "'..key..'".', 2)
|
error('Read of undeclared "'..key..'".', 2)
|
||||||
end
|
end
|
||||||
return state[self].data[key]
|
return state[self].data[key]
|
||||||
end,
|
end,
|
||||||
}
|
|
||||||
local public_declarator_mt = {
|
|
||||||
__newindex = function(self, key, value)
|
__newindex = function(self, key, value)
|
||||||
if state[self].declared[key] then
|
if state[self].type == PUBLIC then
|
||||||
error('Multiple declarations of "'..key..'".', 2)
|
error('Unsupported operation.', 2)
|
||||||
|
elseif not state[self].access[PRIVATE][key] then
|
||||||
|
error('Write of undeclared "'..key..'".', 2)
|
||||||
end
|
end
|
||||||
state[self].data[key] = value
|
state[self].data[key] = value
|
||||||
state[self].public[key] = true
|
|
||||||
state[self].declared[key] = true
|
|
||||||
end,
|
end,
|
||||||
|
}
|
||||||
|
local declarator_mt = {
|
||||||
__index = function()
|
__index = function()
|
||||||
error('Unsupported operation.', 2)
|
error('Unsupported operation.', 2)
|
||||||
end,
|
end,
|
||||||
}
|
|
||||||
local private_declarator_mt = {
|
|
||||||
__newindex = function(self, key, value)
|
__newindex = function(self, key, value)
|
||||||
if state[self].declared[key] then
|
if state[self].access[PRIVATE][key] then
|
||||||
error('Multiple declarations of "'..key..'".', 2)
|
error('Multiple declarations of "'..key..'".', 2)
|
||||||
end
|
end
|
||||||
state[self].data[key] = value
|
state[self].data[key] = value
|
||||||
state[self].declared[key] = true
|
state[self].access[PRIVATE][key] = true
|
||||||
end,
|
state[self].access[state[self].type][key] = true
|
||||||
__index = function()
|
|
||||||
error('Unsupported operation.', 2)
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
function aux_module()
|
function aux_module()
|
||||||
local new_state = {data={}, public={}, declared={}}
|
local data, access = {}, {{}, {}}
|
||||||
local module = {setmetatable({}, public_interface_mt), setmetatable({}, private_interface_mt), setmetatable({}, public_declarator_mt), setmetatable({}, private_declarator_mt)}
|
local public_state, private_state = {type=PUBLIC, data=data, access=access}, {type=PRIVATE, data=data, access=access}
|
||||||
for _, component in module do
|
local public_interface, private_interface = setmetatable({}, interface_mt), setmetatable({}, interface_mt)
|
||||||
state[component] = new_state
|
local public_declarator, private_declarator = setmetatable({}, declarator_mt), setmetatable({}, declarator_mt)
|
||||||
end
|
state[public_interface], state[private_interface] = public_state, private_state
|
||||||
return module
|
state[public_declarator], state[private_declarator] = public_state, private_state
|
||||||
|
return public_interface, private_interface, public_declarator, private_declarator
|
||||||
end
|
end
|
||||||
@@ -116,14 +116,7 @@ end
|
|||||||
|
|
||||||
function private.blizzard_page_index(str)
|
function private.blizzard_page_index(str)
|
||||||
if tonumber(str) then
|
if tonumber(str) then
|
||||||
return aux.util.round(max(0, tonumber(str) - 1))
|
return max(0, tonumber(str) - 1)
|
||||||
end
|
end
|
||||||
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
@@ -54,13 +54,17 @@ private.blizzard_query = setmetatable({}, {
|
|||||||
elseif key == 'usable' then
|
elseif key == 'usable' then
|
||||||
return m.usable_checkbox:GetChecked()
|
return m.usable_checkbox:GetChecked()
|
||||||
elseif key == 'class' then
|
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
|
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
|
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
|
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
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@@ -126,13 +130,13 @@ function private.get_form_query()
|
|||||||
add(m.blizzard_query.max_level)
|
add(m.blizzard_query.max_level)
|
||||||
add(m.blizzard_query.usable and 'usable')
|
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()}
|
local classes = {GetAuctionItemClasses()}
|
||||||
add(strlower(classes[class]))
|
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)}
|
local subclasses = {GetAuctionItemSubClasses(class)}
|
||||||
add(strlower(subclasses[subclass]))
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -141,7 +145,7 @@ function private.get_form_query()
|
|||||||
add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC')))
|
add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC')))
|
||||||
end
|
end
|
||||||
|
|
||||||
return query_string
|
return query_string or ''
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.set_form(components)
|
function private.set_form(components)
|
||||||
|
|||||||
@@ -80,6 +80,14 @@ function private.create_frames()
|
|||||||
m.execute()
|
m.execute()
|
||||||
end)
|
end)
|
||||||
editbox:SetScript('OnTextChanged', function()
|
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
|
if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then
|
||||||
this:SetBackdropColor(unpack(aux.gui.color.state.enabled))
|
this:SetBackdropColor(unpack(aux.gui.color.state.enabled))
|
||||||
else
|
else
|
||||||
@@ -106,6 +114,14 @@ function private.create_frames()
|
|||||||
m.execute()
|
m.execute()
|
||||||
end)
|
end)
|
||||||
editbox:SetScript('OnTextChanged', function()
|
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
|
if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then
|
||||||
this:SetBackdropColor(unpack(aux.gui.color.state.enabled))
|
this:SetBackdropColor(unpack(aux.gui.color.state.enabled))
|
||||||
else
|
else
|
||||||
|
|||||||
+2
-6
@@ -1,11 +1,7 @@
|
|||||||
local m, public, private = aux.module'util'
|
local m, public, private = aux.module'util'
|
||||||
|
|
||||||
function public.either(p, a, b)
|
function public.present(value)
|
||||||
if p then
|
return value ~= nil and {[value]=true} or {}
|
||||||
return a
|
|
||||||
else
|
|
||||||
return b
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.unpack(array, ...)
|
function public.unpack(array, ...)
|
||||||
|
|||||||
Reference in New Issue
Block a user