refactoring
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
if module then return end
|
||||||
|
local typeof, setmetatable, setfenv, unpack, next, pcall, _G = type, setmetatable, setfenv, unpack, next, pcall, getfenv(0)
|
||||||
|
|
||||||
|
local PUBLIC, PRIVATE = 1, 2
|
||||||
|
local INDEX, NEWINDEX, CALL = 1, 2, 3
|
||||||
|
|
||||||
|
local function error(msg, ...) return _G.error(format(msg or '', unpack(arg))..'\n'..debugstack(), 0) end
|
||||||
|
local function import_error() error 'Invalid imports.' end
|
||||||
|
local function declaration_error() error 'Invalid declaration.' end
|
||||||
|
local function collision_error(key) error('"%s" already exists.', key) end
|
||||||
|
|
||||||
|
local function nop() end
|
||||||
|
local function id(v) return v end
|
||||||
|
local function const(v) return function() return v end end
|
||||||
|
|
||||||
|
local _state = {}
|
||||||
|
|
||||||
|
local env_mt, start_declaration
|
||||||
|
|
||||||
|
local interface_mt = {__metatable=false}
|
||||||
|
function interface_mt:__index(key)
|
||||||
|
return generic_function end
|
||||||
|
|
||||||
|
|
||||||
|
local state=_state[self]
|
||||||
|
if state.access[key] == PUBLIC then
|
||||||
|
local index = state[INDEX][key]
|
||||||
|
if index then return index() else return state[CALL][key] end
|
||||||
|
end
|
||||||
|
|
||||||
|
function interface_mt:__newindex(key, value) local state=_state[self]
|
||||||
|
if state.access[key] == PUBLIC then (state[NEWINDEX][key] or state[CALL][key])(value) end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function class()
|
||||||
|
local self = {}
|
||||||
|
|
||||||
|
return self, create_new_object
|
||||||
|
end
|
||||||
|
|
||||||
|
local _
|
||||||
|
|
||||||
|
local message
|
||||||
|
|
||||||
|
function handle() end
|
||||||
+23
-15
@@ -24,8 +24,8 @@ blizzard_query = setmetatable(t, {
|
|||||||
local subclass_index = UIDropDownMenu_GetSelectedValue(subclass_dropdown)
|
local subclass_index = UIDropDownMenu_GetSelectedValue(subclass_dropdown)
|
||||||
return (subclass_index or 0) > 0 and subclass_index or nil
|
return (subclass_index or 0) > 0 and subclass_index or nil
|
||||||
elseif key == 'slot' then
|
elseif key == 'slot' then
|
||||||
local slot_token = UIDropDownMenu_GetSelectedValue(slot_dropdown)
|
local slot_index = UIDropDownMenu_GetSelectedValue(slot_dropdown)
|
||||||
return slot_token ~= '' and slot_token or nil
|
return (slot_index or 0) > 0 and slot_index or nil
|
||||||
elseif key == 'quality' then
|
elseif key == 'quality' then
|
||||||
local quality_code = UIDropDownMenu_GetSelectedValue(quality_dropdown)
|
local quality_code = UIDropDownMenu_GetSelectedValue(quality_dropdown)
|
||||||
return (quality_code or -1) >= 0 and quality_code or nil
|
return (quality_code or -1) >= 0 and quality_code or nil
|
||||||
@@ -43,12 +43,16 @@ blizzard_query = setmetatable(t, {
|
|||||||
elseif key == 'usable' then
|
elseif key == 'usable' then
|
||||||
usable_checkbox:SetChecked(value)
|
usable_checkbox:SetChecked(value)
|
||||||
elseif key == 'class' then
|
elseif key == 'class' then
|
||||||
|
UIDropDownMenu_Initialize(class_dropdown, initialize_class_dropdown)
|
||||||
UIDropDownMenu_SetSelectedValue(class_dropdown, value)
|
UIDropDownMenu_SetSelectedValue(class_dropdown, value)
|
||||||
elseif key == 'subclass' then
|
elseif key == 'subclass' then
|
||||||
|
UIDropDownMenu_Initialize(subclass_dropdown, initialize_subclass_dropdown)
|
||||||
UIDropDownMenu_SetSelectedValue(subclass_dropdown, value)
|
UIDropDownMenu_SetSelectedValue(subclass_dropdown, value)
|
||||||
elseif key == 'slot' then
|
elseif key == 'slot' then
|
||||||
|
UIDropDownMenu_Initialize(slot_dropdown, initialize_slot_dropdown)
|
||||||
UIDropDownMenu_SetSelectedValue(slot_dropdown, value)
|
UIDropDownMenu_SetSelectedValue(slot_dropdown, value)
|
||||||
elseif key == 'quality' then
|
elseif key == 'quality' then
|
||||||
|
UIDropDownMenu_Initialize(quality_dropdown, initialize_quality_dropdown)
|
||||||
UIDropDownMenu_SetSelectedValue(quality_dropdown, value)
|
UIDropDownMenu_SetSelectedValue(quality_dropdown, value)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -115,13 +119,16 @@ function get_filter_builder_query()
|
|||||||
add(blizzard_query.max_level)
|
add(blizzard_query.max_level)
|
||||||
add(blizzard_query.usable and 'usable')
|
add(blizzard_query.usable and 'usable')
|
||||||
|
|
||||||
for class in present(blizzard_query.class) do
|
for class_index in present(blizzard_query.class) do
|
||||||
local classes = temp-list(GetAuctionItemClasses())
|
local classes = temp-list(GetAuctionItemClasses())
|
||||||
add(strlower(classes[class]))
|
add(strlower(classes[class_index]))
|
||||||
for subclass in present(blizzard_query.subclass) do
|
for subclass_index in present(blizzard_query.subclass) do
|
||||||
local subclasses = temp-list(GetAuctionItemSubClasses(class))
|
local subclasses = temp-list(GetAuctionItemSubClasses(class_index))
|
||||||
add(strlower(subclasses[subclass]))
|
add(strlower(subclasses[subclass_index]))
|
||||||
add(blizzard_query.slot and strlower(_G[blizzard_query.slot]))
|
for slot_index in present(blizzard_query.slot) do
|
||||||
|
local slots = temp-list(GetAuctionInvTypes(class_index, subclass_index))
|
||||||
|
add(strlower(_G[slots[slot_index]]))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -138,11 +145,12 @@ end
|
|||||||
|
|
||||||
function set_form(filter)
|
function set_form(filter)
|
||||||
clear_form()
|
clear_form()
|
||||||
for key, filter in filter.blizzard do
|
for _, component in filter.components do
|
||||||
blizzard_query[key] = filter[2]
|
if component[1] == 'blizzard' then
|
||||||
end
|
blizzard_query[component[2]] = component[4]
|
||||||
for _, component in filter.post do
|
else
|
||||||
add_component(component)
|
add_component(component)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
update_filter_display()
|
update_filter_display()
|
||||||
end
|
end
|
||||||
@@ -372,8 +380,8 @@ function initialize_slot_dropdown()
|
|||||||
local subclass_index = UIDropDownMenu_GetSelectedValue(subclass_dropdown)
|
local subclass_index = UIDropDownMenu_GetSelectedValue(subclass_dropdown)
|
||||||
if subclass_index and GetAuctionInvTypes(class_index, subclass_index) then
|
if subclass_index and GetAuctionInvTypes(class_index, subclass_index) then
|
||||||
UIDropDownMenu_AddButton(T('text', ALL, 'value', '', 'func', on_click))
|
UIDropDownMenu_AddButton(T('text', ALL, 'value', '', 'func', on_click))
|
||||||
for _, slot in temp-list(GetAuctionInvTypes(class_index, subclass_index)) do
|
for i, slot in temp-list(GetAuctionInvTypes(class_index, subclass_index)) do
|
||||||
UIDropDownMenu_AddButton(T('text', _G[slot], 'value', slot, 'func', on_click))
|
UIDropDownMenu_AddButton(T('text', _G[slot], 'value', i, 'func', on_click))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user