refactoring
This commit is contained in:
+57
-53
@@ -101,73 +101,77 @@ do
|
||||
end
|
||||
|
||||
local function insert_keys(t,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,k20,overflow)
|
||||
if k1 == nil then return t end; t[k1] = true
|
||||
if k2 == nil then return t end; t[k2] = true
|
||||
if k3 == nil then return t end; t[k3] = true
|
||||
if k4 == nil then return t end; t[k4] = true
|
||||
if k5 == nil then return t end; t[k5] = true
|
||||
if k6 == nil then return t end; t[k6] = true
|
||||
if k7 == nil then return t end; t[k7] = true
|
||||
if k8 == nil then return t end; t[k8] = true
|
||||
if k9 == nil then return t end; t[k9] = true
|
||||
if k10 == nil then return t end; t[k10] = true
|
||||
if k11 == nil then return t end; t[k11] = true
|
||||
if k12 == nil then return t end; t[k12] = true
|
||||
if k13 == nil then return t end; t[k13] = true
|
||||
if k14 == nil then return t end; t[k14] = true
|
||||
if k15 == nil then return t end; t[k15] = true
|
||||
if k16 == nil then return t end; t[k16] = true
|
||||
if k17 == nil then return t end; t[k17] = true
|
||||
if k18 == nil then return t end; t[k18] = true
|
||||
if k19 == nil then return t end; t[k19] = true
|
||||
if k20 == nil then return t end; t[k20] = true
|
||||
if k1 == nil then return end; t[k1] = true
|
||||
if k2 == nil then return end; t[k2] = true
|
||||
if k3 == nil then return end; t[k3] = true
|
||||
if k4 == nil then return end; t[k4] = true
|
||||
if k5 == nil then return end; t[k5] = true
|
||||
if k6 == nil then return end; t[k6] = true
|
||||
if k7 == nil then return end; t[k7] = true
|
||||
if k8 == nil then return end; t[k8] = true
|
||||
if k9 == nil then return end; t[k9] = true
|
||||
if k10 == nil then return end; t[k10] = true
|
||||
if k11 == nil then return end; t[k11] = true
|
||||
if k12 == nil then return end; t[k12] = true
|
||||
if k13 == nil then return end; t[k13] = true
|
||||
if k14 == nil then return end; t[k14] = true
|
||||
if k15 == nil then return end; t[k15] = true
|
||||
if k16 == nil then return end; t[k16] = true
|
||||
if k17 == nil then return end; t[k17] = true
|
||||
if k18 == nil then return end; t[k18] = true
|
||||
if k19 == nil then return end; t[k19] = true
|
||||
if k20 == nil then return end; t[k20] = true
|
||||
if overflow ~= nil then error('Overflow.') end
|
||||
end
|
||||
local function insert_values(t,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,overflow)
|
||||
local n = getn(t)
|
||||
if v1 == nil then return t end; t[n + 1] = v1
|
||||
if v2 == nil then return t end; t[n + 2] = v2
|
||||
if v3 == nil then return t end; t[n + 3] = v3
|
||||
if v4 == nil then return t end; t[n + 4] = v4
|
||||
if v5 == nil then return t end; t[n + 5] = v5
|
||||
if v6 == nil then return t end; t[n + 6] = v6
|
||||
if v7 == nil then return t end; t[n + 7] = v7
|
||||
if v8 == nil then return t end; t[n + 8] = v8
|
||||
if v9 == nil then return t end; t[n + 9] = v9
|
||||
if v10 == nil then return t end; t[n + 10] = v10
|
||||
if v11 == nil then return t end; t[n + 11] = v11
|
||||
if v12 == nil then return t end; t[n + 12] = v12
|
||||
if v13 == nil then return t end; t[n + 13] = v13
|
||||
if v14 == nil then return t end; t[n + 14] = v14
|
||||
if v15 == nil then return t end; t[n + 15] = v15
|
||||
if v16 == nil then return t end; t[n + 16] = v16
|
||||
if v17 == nil then return t end; t[n + 17] = v17
|
||||
if v18 == nil then return t end; t[n + 18] = v18
|
||||
if v19 == nil then return t end; t[n + 19] = v19
|
||||
if v20 == nil then return t end; t[n + 20] = v20
|
||||
if v2 == nil then table.setn(t, n + 1); return end; t[n + 2] = v2
|
||||
if v3 == nil then table.setn(t, n + 2); return end; t[n + 3] = v3
|
||||
if v4 == nil then table.setn(t, n + 3); return end; t[n + 4] = v4
|
||||
if v5 == nil then table.setn(t, n + 4); return end; t[n + 5] = v5
|
||||
if v6 == nil then table.setn(t, n + 5); return end; t[n + 6] = v6
|
||||
if v7 == nil then table.setn(t, n + 6); return end; t[n + 7] = v7
|
||||
if v8 == nil then table.setn(t, n + 7); return end; t[n + 8] = v8
|
||||
if v9 == nil then table.setn(t, n + 8); return end; t[n + 9] = v9
|
||||
if v10 == nil then table.setn(t, n + 9); return end; t[n + 10] = v10
|
||||
if v11 == nil then table.setn(t, n + 10); return end; t[n + 11] = v11
|
||||
if v12 == nil then table.setn(t, n + 11); return end; t[n + 12] = v12
|
||||
if v13 == nil then table.setn(t, n + 12); return end; t[n + 13] = v13
|
||||
if v14 == nil then table.setn(t, n + 13); return end; t[n + 14] = v14
|
||||
if v15 == nil then table.setn(t, n + 14); return end; t[n + 15] = v15
|
||||
if v16 == nil then table.setn(t, n + 15); return end; t[n + 16] = v16
|
||||
if v17 == nil then table.setn(t, n + 16); return end; t[n + 17] = v17
|
||||
if v18 == nil then table.setn(t, n + 17); return end; t[n + 18] = v18
|
||||
if v19 == nil then table.setn(t, n + 18); return end; t[n + 19] = v19
|
||||
if v20 == nil then table.setn(t, n + 19); return end; t[n + 20] = v20; table.setn(t, n + 20)
|
||||
if overflow ~= nil then error('Overflow.') end
|
||||
end
|
||||
local function insert_pairs(t,k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9,k10,v10,overflow)
|
||||
if k1 == nil then return t end t[k1] = v1
|
||||
if k2 == nil then return t end t[k2] = v2
|
||||
if k3 == nil then return t end t[k3] = v3
|
||||
if k4 == nil then return t end t[k4] = v4
|
||||
if k5 == nil then return t end t[k5] = v5
|
||||
if k6 == nil then return t end t[k6] = v6
|
||||
if k7 == nil then return t end t[k7] = v7
|
||||
if k8 == nil then return t end t[k8] = v8
|
||||
if k9 == nil then return t end t[k9] = v9
|
||||
if k10 == nil then return t end t[k10] = v10
|
||||
if k1 == nil then return end t[k1] = v1
|
||||
if k2 == nil then return end t[k2] = v2
|
||||
if k3 == nil then return end t[k3] = v3
|
||||
if k4 == nil then return end t[k4] = v4
|
||||
if k5 == nil then return end t[k5] = v5
|
||||
if k6 == nil then return end t[k6] = v6
|
||||
if k7 == nil then return end t[k7] = v7
|
||||
if k8 == nil then return end t[k8] = v8
|
||||
if k9 == nil then return end t[k9] = v9
|
||||
if k10 == nil then return end t[k10] = v10
|
||||
if overflow ~= nil then error('Overflow.') end
|
||||
end
|
||||
local function constructor_mt(insert)
|
||||
return {
|
||||
__call=function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,overflow)
|
||||
self.t, self.n = self.t or t, (self.n or 1) - 1
|
||||
insert(self.t,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,overflow)
|
||||
return self.n > 0 and self or self.t
|
||||
local t, n = rawget(self, 't') or t, rawget(self, 'n') or 1
|
||||
insert(t,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,overflow)
|
||||
if n > 1 then
|
||||
self.t, self.n = t, n - 1
|
||||
return self
|
||||
end
|
||||
return t
|
||||
end,
|
||||
__index=function(self, key) self.n = key end,
|
||||
__index=function(self, key) self.n = key; return self end,
|
||||
}
|
||||
end
|
||||
local set_mt, list_mt, table_mt = constructor_mt(insert_keys), constructor_mt(insert_values), constructor_mt(insert_pairs)
|
||||
|
||||
+3
-3
@@ -17,15 +17,15 @@ function process()
|
||||
end
|
||||
end)
|
||||
|
||||
return stack.start(state.item_key, state.stack_size, send_signal)
|
||||
return aux.stack.start(state.item_key, state.stack_size, send_signal)
|
||||
end
|
||||
|
||||
return stop()
|
||||
end
|
||||
|
||||
function post_auction(slot, k)
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info.item_key == state.item_key and aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
|
||||
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
|
||||
@@ -51,7 +51,7 @@ end
|
||||
|
||||
function test(record)
|
||||
return function(index)
|
||||
local auction_info = info.auction(index, 'owner')
|
||||
local auction_info = aux.info.auction(index, 'owner')
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
@@ -67,7 +67,7 @@ do
|
||||
|
||||
scan.abort(scan_id)
|
||||
state = SEARCHING
|
||||
scan_id = scan_util.find(
|
||||
scan_id = aux.scan_util.find(
|
||||
record,
|
||||
status_bar,
|
||||
function() state = IDLE end,
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@ end
|
||||
|
||||
function test(record)
|
||||
return function(index)
|
||||
local auction_info = info.auction(index, 'bidder')
|
||||
local auction_info = aux.info.auction(index, 'bidder')
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
@@ -67,7 +67,7 @@ do
|
||||
|
||||
scan.abort(scan_id)
|
||||
state = SEARCHING
|
||||
scan_id = scan_util.find(
|
||||
scan_id = aux.scan_util.find(
|
||||
record,
|
||||
status_bar,
|
||||
function() state = IDLE end,
|
||||
|
||||
+1
-1
@@ -409,7 +409,7 @@ function update_inventory_records()
|
||||
availability[i] = 0
|
||||
end
|
||||
availability[charge_class] = item_info.count
|
||||
auctionable_map[item_info.item_key] = T(
|
||||
auctionable_map[item_info.item_key] = T[2](
|
||||
'item_id', item_info.item_id,
|
||||
'suffix_id', item_info.suffix_id,
|
||||
'key', item_info.item_key,
|
||||
|
||||
@@ -313,7 +313,7 @@ function set_filter_display_offset(x_offset, y_offset)
|
||||
end
|
||||
|
||||
function initialize_filter_dropdown()
|
||||
for filter in temp-set('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity')('left', 'utilizable', 'discard') do
|
||||
for filter in temp-set[2]('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity')('left', 'utilizable', 'discard') do
|
||||
UIDropDownMenu_AddButton(T(
|
||||
'text', filter,
|
||||
'value', filter,
|
||||
|
||||
@@ -208,7 +208,7 @@ function create_frames()
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Stop')
|
||||
btn:SetScript('OnClick', function()
|
||||
scan.abort(search_scan_id)
|
||||
aux.scan.abort(search_scan_id)
|
||||
end)
|
||||
stop_button = btn
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
aux 'search_tab' local info = aux.info
|
||||
aux 'search_tab' local info, scan = aux.info, aux.scan
|
||||
|
||||
_G.aux_auto_buy_filter = ''
|
||||
|
||||
@@ -396,7 +396,7 @@ do
|
||||
|
||||
scan.abort(scan_id)
|
||||
state = SEARCHING
|
||||
scan_id = scan_util.find(
|
||||
scan_id = aux.scan_util.find(
|
||||
record,
|
||||
current_search.status_bar,
|
||||
function()
|
||||
|
||||
+12
-14
@@ -220,45 +220,43 @@ do
|
||||
self.max_level = self.max_level or self.min_level
|
||||
return self
|
||||
end
|
||||
if self.exact then
|
||||
return
|
||||
end
|
||||
if self.exact then return end
|
||||
for number in present(tonumber(select(3, strfind(str, '^(%d+)$')))) do
|
||||
if number >= 1 and number <= 60 then
|
||||
for filter in temp-set('min_level', 'max_level') do
|
||||
if not self[filter] then
|
||||
self[filter] = {str, number}
|
||||
self[filter] = list(str, number)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, parser in list(
|
||||
list('class', info.item_class_index),
|
||||
list('subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)),
|
||||
list('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)),
|
||||
list('quality', info.item_quality_index)
|
||||
for _, parser in temp-list(
|
||||
temp-list('class', info.item_class_index),
|
||||
temp-list('subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)),
|
||||
temp-list('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)),
|
||||
temp-list('quality', info.item_quality_index)
|
||||
) do
|
||||
if not self[parser[1]] then
|
||||
tinsert(parser, str)
|
||||
for index, label in present(parser[2](select(3, unpack(parser)))) do
|
||||
self[parser[1]] = {label, index}
|
||||
local index, label = parser[2](select(3, unpack(parser)))
|
||||
if index then
|
||||
self[parser[1]] = list(label, index)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not self[str] and (str == 'usable' or str == 'exact' and self.name and size(self) == 1) then
|
||||
self[str] = {str, 1}
|
||||
self[str] = list(str, 1)
|
||||
elseif i == 1 and strlen(str) <= 63 then
|
||||
self.name = list(str, unquote(str))
|
||||
-- return nil, 'The name filter must not be longer than 63 characters'
|
||||
-- return nil, 'The name filter must not be longer than 63 characters' TODO
|
||||
else
|
||||
return
|
||||
end
|
||||
return true
|
||||
end,
|
||||
}
|
||||
|
||||
function blizzard_filter_parser()
|
||||
return setmetatable(t, mt)
|
||||
end
|
||||
|
||||
+4
-3
@@ -371,7 +371,8 @@ function public.item(item_id, suffix_id)
|
||||
end
|
||||
|
||||
function public.item_class_index(item_class)
|
||||
for i, class in temp-{GetAuctionItemClasses()} do
|
||||
for i, class in temp-list(GetAuctionItemClasses()) do
|
||||
if item_class == nil then error() end
|
||||
if strupper(class) == strupper(item_class) then
|
||||
return i, class
|
||||
end
|
||||
@@ -379,7 +380,7 @@ function public.item_class_index(item_class)
|
||||
end
|
||||
|
||||
function public.item_subclass_index(class_index, item_subclass)
|
||||
for i, subclass in temp-{GetAuctionItemSubClasses(class_index)} do
|
||||
for i, subclass in temp-list(GetAuctionItemSubClasses(class_index)) do
|
||||
if strupper(subclass) == strupper(item_subclass) then
|
||||
return i, subclass
|
||||
end
|
||||
@@ -387,7 +388,7 @@ function public.item_subclass_index(class_index, item_subclass)
|
||||
end
|
||||
|
||||
function public.item_slot_index(class_index, subclass_index, slot_name)
|
||||
for i, slot in temp-{GetAuctionInvTypes(class_index, subclass_index)} do
|
||||
for i, slot in temp-list(GetAuctionInvTypes(class_index, subclass_index)) do
|
||||
if strupper(_G[slot]) == strupper(slot_name) then
|
||||
return i, _G[slot]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user