module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-09-23 09:07:56 +02:00
parent 1344ae0d23
commit 240589eef1
32 changed files with 525 additions and 499 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
aux 'core'
COLORS = {
local COLORS = {
text = {enabled = {255, 254, 250, 1}, disabled = {147, 151, 139, 1}},
label = {enabled = {216, 225, 211, 1}, disabled = {150, 148, 140, 1}},
link = {153, 255, 255, 1},
@@ -31,9 +31,9 @@ do
return self.private.callback(color)
end
end
function color_accessor(callback)
function private.color_accessor(callback)
return function()
return index_function({callback=callback, table=COLORS}, index_handler)
return index_function({ callback=callback, table=COLORS }, index_handler)
end
end
end
+2 -2
View File
@@ -67,7 +67,7 @@ function public.vararg.select(arg)
end
end
public.join = _G.table.concat
public.join = table.concat
function public.range(arg1, arg2)
local i, n = arg2 and arg1 or 1, arg2 or arg1
@@ -91,7 +91,7 @@ do
end
end
function public.vararg.partial(arg)
function public.vararg.papply(arg)
local f, arg1 = tremove(arg, 1), perm-arg
return vararg(function(arg)
for i = 1, getn(arg) do
+12 -12
View File
@@ -1,6 +1,6 @@
aux 'filter_util' local info = aux.info
function default_filter(str)
function private.default_filter(str)
return {
input_type = '',
validator = function()
@@ -200,7 +200,7 @@ public.filters = {
},
}
function operator(str)
function private.operator(str)
local operator = str == 'not' and A('operator', 'not', 1)
for name in temp-S('and', 'or') do
for arity in present(select(3, strfind(str, '^' .. name .. '(%d*)$'))) do
@@ -231,8 +231,8 @@ do
end
for _, parser in temp-A(
temp-A('class', info.item_class_index),
temp-A('subclass', partial(info.item_subclass_index, index(self.class, 2) or 0)),
temp-A('slot', partial(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0)),
temp-A('subclass', papply(info.item_subclass_index, index(self.class, 2) or 0)),
temp-A('slot', papply(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0)),
temp-A('quality', info.item_quality_index)
) do
if not self[parser[1]] then
@@ -254,12 +254,12 @@ do
end
end,
}
function blizzard_filter_parser()
function private.blizzard_filter_parser()
return setmetatable(t, mt)
end
end
function parse_parameter(input_type, str)
function private.parse_parameter(input_type, str)
if input_type == 'money' then
local money = aux.money.from_string(str)
return money and money > 0 and money or nil
@@ -290,7 +290,7 @@ function public.parse_filter_string(str)
if input_type ~= '' then
if not parts[i + 1] or not parse_parameter(input_type, parts[i + 1]) then
if parts[i] == 'item' then
return nil, 'Invalid item name', _G.aux_auctionable_items
return nil, 'Invalid item name', aux_auctionable_items
elseif type(input_type) == 'table' then
return nil, 'Invalid choice for ' .. parts[i], input_type
else
@@ -370,7 +370,7 @@ function public.queries(filter_string)
return queries
end
function suggestions(filter)
function private.suggestions(filter)
local suggestions = t
if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end
@@ -408,7 +408,7 @@ function suggestions(filter)
-- item names
if getn(filter.components) == 0 then
for _, name in _G.aux_auctionable_items do
for _, name in aux_auctionable_items do
tinsert(suggestions, name .. '/exact')
end
end
@@ -438,7 +438,7 @@ function public.filter_string(components)
return query_builder.get()
end
function prettified_filter_string(filter)
function private.prettified_filter_string(filter)
local prettified = query_builder()
for _, component in filter.components do
@@ -486,7 +486,7 @@ function public.unquote(name)
return select(3, strfind(name, '^<(.*)>$')) or name
end
function blizzard_query(filter)
function private.blizzard_query(filter)
local filters = filter.blizzard
local query = T('name', filters.name and filters.name[2])
local item_info, class_index, subclass_index, slot_index
@@ -514,7 +514,7 @@ function blizzard_query(filter)
return query
end
function validator(filter)
function private.validator(filter)
local validators = t
for i, component in filter.post do
+4 -4
View File
@@ -120,8 +120,8 @@ function public.auction(index, query_type)
'link', link,
'itemstring', item_info.itemstring,
'item_key', item_id .. ':' .. suffix_id,
'search_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), _G.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _G.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')), ':'),
'search_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')), ':'),
'name', name,
'texture', texture,
@@ -165,7 +165,7 @@ function public.bid_update(auction_record)
auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity
auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity
auction_record.high_bidder = 1
auction_record.search_signature = join(temp-A(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, _G.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
auction_record.search_signature = join(temp-A(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
end
function public.set_tooltip(itemstring, owner, anchor)
@@ -283,7 +283,7 @@ function public.tooltip(setter)
return tooltip, AuxTooltip.money
end
function item_charges(tooltip)
function private.item_charges(tooltip)
for _, line in tooltip do
local pattern = '^' .. gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
+2 -2
View File
@@ -4,8 +4,8 @@ public.GOLD_TEXT = '|cffffd70ag|r'
public.SILVER_TEXT = '|cffc7c7cfs|r'
public.COPPER_TEXT = '|cffeda55fc|r'
COPPER_PER_GOLD = 10000
COPPER_PER_SILVER = 100
local COPPER_PER_GOLD = 10000
local COPPER_PER_SILVER = 100
function public.to_gsc(money)
local gold = floor(money / COPPER_PER_GOLD)
+3 -3
View File
@@ -1,14 +1,14 @@
aux 'persistence'
_G.aux_datasets = t
aux_datasets = t
do
local dataset
function public.dataset.get()
if not dataset then
local dataset_key = format('%s|%s', GetCVar 'realmName', UnitFactionGroup 'player')
dataset = _G.aux_datasets[dataset_key] or t
_G.aux_datasets[dataset_key] = dataset
dataset = aux_datasets[dataset_key] or t
aux_datasets[dataset_key] = dataset
end
return dataset
end