big refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-21 06:17:53 +02:00
parent e94eaac52c
commit 40753f2ac5
31 changed files with 709 additions and 742 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ function public:complete_filter()
local filter_string = this:GetText()
local completed_filter_string = ({strfind(filter_string, '([^;]*)/[^/;]*$')})[3]
local _, suggestions = aux.filter.query(completed_filter_string or '')
local _, suggestions = filter.query(completed_filter_string or '')
local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$')
current_modifier = current_modifier or ''
+11 -11
View File
@@ -1,6 +1,6 @@
aux.module 'util'
local temp, recycle, getn = temp, recycle, g.getn
local temp, recycle, getn = g.temp, g.recycle, g.getn
function public.copy(t)
local copy = {}
@@ -9,6 +9,12 @@ function public.copy(t)
return copy
end
public.join = g.table.concat
function public.replicate(count, value)
if count > 0 then return value, replicate(count - 1, value) end
end
do
local value, charges
local function setter(n)
@@ -18,7 +24,7 @@ do
return v
end
end
for i=1,9 do public[join(replicate(i, 'x'))] = setter(i) end
for i=1,9 do public[join{replicate(i, 'x')}] = setter(i) end
function public.accessor.__()
assert(charges > 0)
charges = charges - 1
@@ -183,10 +189,6 @@ function public.all(xs, p)
return true
end
function public.replicate(count, value)
return value, replicate(count - 1, value)
end
function public.filter(xs, p)
local ys = {}
for k, x in xs do
@@ -233,8 +235,6 @@ function public.split(str, separator)
end
end
public.join = g.table.concat
function public.tokenize(str)
local tokens = {}
for token in string.gfind(str, '%S+') do tinsert(tokens, token) end
@@ -265,9 +265,9 @@ function public.bag_type(bag)
return 1
end
for link in present(GetInventoryItemLink('player', ContainerIDToInventoryID(bag))) do
local item_id = aux.info.parse_link(link)
local item_info = aux.info.item(item_id)
return aux.info.item_subclass_index(3, item_info.subclass)
local item_id = info.parse_link(link)
local item_info = info.item(item_id)
return info.item_subclass_index(3, item_info.subclass)
end
end
+33 -33
View File
@@ -19,7 +19,7 @@ public.filters = {
input_type = '',
validator = function()
return function(auction_record)
return auction_record.usable and not aux.info.tooltip_match(ITEM_SPELL_KNOWN, auction_record.tooltip)
return auction_record.usable and not info.tooltip_match(ITEM_SPELL_KNOWN, auction_record.tooltip)
end
end,
},
@@ -35,7 +35,7 @@ public.filters = {
input_type = 'string',
validator = function(name)
return function(auction_record)
return strlower(aux.info.item(auction_record.item_id).name) == name
return strlower(info.item(auction_record.item_id).name) == name
end
end
},
@@ -117,8 +117,8 @@ public.filters = {
validator = function(pct)
return function(auction_record)
return auction_record.unit_buyout_price > 0
and aux.history.value(auction_record.item_key)
and auction_record.unit_buyout_price / aux.history.value(auction_record.item_key) * 100 <= pct
and history.value(auction_record.item_key)
and auction_record.unit_buyout_price / history.value(auction_record.item_key) * 100 <= pct
end
end
},
@@ -128,8 +128,8 @@ public.filters = {
validator = function(pct)
return function(auction_record)
return auction_record.unit_buyout_price > 0
and aux.history.value(auction_record.item_key)
and auction_record.unit_buyout_price / aux.history.value(auction_record.item_key) * 100 <= pct
and history.value(auction_record.item_key)
and auction_record.unit_buyout_price / history.value(auction_record.item_key) * 100 <= pct
end
end
},
@@ -138,7 +138,7 @@ public.filters = {
input_type = 'money',
validator = function(amount)
return function(auction_record)
return aux.history.value(auction_record.item_key) and aux.history.value(auction_record.item_key) * auction_record.aux_quantity - auction_record.bid_price >= amount
return history.value(auction_record.item_key) and history.value(auction_record.item_key) * auction_record.aux_quantity - auction_record.bid_price >= amount
end
end
},
@@ -147,7 +147,7 @@ public.filters = {
input_type = 'money',
validator = function(amount)
return function(auction_record)
return auction_record.buyout_price > 0 and aux.history.value(auction_record.item_key) and aux.history.value(auction_record.item_key) * auction_record.aux_quantity - auction_record.buyout_price >= amount
return auction_record.buyout_price > 0 and history.value(auction_record.item_key) and history.value(auction_record.item_key) * auction_record.aux_quantity - auction_record.buyout_price >= amount
end
end
},
@@ -156,7 +156,7 @@ public.filters = {
input_type = 'money',
validator = function(amount)
return function(auction_record)
local disenchant_value = aux.disenchant.value(auction_record.slot, auction_record.quality, auction_record.level)
local disenchant_value = disenchant.value(auction_record.slot, auction_record.quality, auction_record.level)
return disenchant_value and disenchant_value - auction_record.bid_price >= amount
end
end
@@ -166,7 +166,7 @@ public.filters = {
input_type = 'money',
validator = function(amount)
return function(auction_record)
local disenchant_value = aux.disenchant.value(auction_record.slot, auction_record.quality, auction_record.level)
local disenchant_value = disenchant.value(auction_record.slot, auction_record.quality, auction_record.level)
return auction_record.buyout_price > 0 and disenchant_value and disenchant_value - auction_record.buyout_price >= amount
end
end
@@ -176,7 +176,7 @@ public.filters = {
input_type = 'money',
validator = function(amount)
return function(auction_record)
local vendor_price = aux.cache.merchant_info(auction_record.item_id)
local vendor_price = cache.merchant_info(auction_record.item_id)
return vendor_price and vendor_price * auction_record.aux_quantity - auction_record.bid_price >= amount
end
end
@@ -186,7 +186,7 @@ public.filters = {
input_type = 'money',
validator = function(amount)
return function(auction_record)
local vendor_price = aux.cache.merchant_info(auction_record.item_id)
local vendor_price = cache.merchant_info(auction_record.item_id)
return auction_record.buyout_price > 0 and vendor_price and vendor_price * auction_record.aux_quantity - auction_record.buyout_price >= amount
end
end
@@ -234,10 +234,10 @@ do
end
end
for _, parser in {
{'class', aux.info.item_class_index},
{'subclass', L(aux.info.item_subclass_index, index(self.class, 2) or 0, _1)},
{'slot', L(aux.info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)},
{'quality', aux.info.item_quality_index},
{'class', info.item_class_index},
{'subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)},
{'slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)},
{'quality', info.item_quality_index},
} do
if not self[parser[1]] then
tinsert(parser, str)
@@ -266,7 +266,7 @@ end
function parse_parameter(input_type, str)
if input_type == 'money' then
local money = aux.money.from_string(str)
local money = money.from_string(str)
return money and money > 0 and money or nil
elseif input_type == 'number' then
local number = tonumber(str)
@@ -444,8 +444,8 @@ function public.query_string(components)
elseif component[1] == 'filter' then
query_builder.append(component[2])
for _, parameter in {component[3]} do
if aux.filter.filters[component[2]].input_type == 'money' then
parameter = aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, nil, true)
if filter.filters[component[2]].input_type == 'money' then
parameter = money.to_string(money.from_string(parameter), nil, true, nil, nil, true)
end
query_builder.append(parameter)
end
@@ -460,38 +460,38 @@ function prettified_query_string(components)
for key, filter in components.blizzard do
if key == 'exact' then
prettified.prepend(aux.info.display_name(aux.cache.item_id(components.blizzard.name[2])) or aux.gui.color.blizzard('['..components.blizzard.name[2]..']'))
prettified.prepend(info.display_name(cache.item_id(components.blizzard.name[2])) or gui.color.blizzard('['..components.blizzard.name[2]..']'))
elseif key ~= 'name' then
prettified.append(aux.gui.color.blizzard(filter[1]))
prettified.append(gui.color.blizzard(filter[1]))
end
end
if components.blizzard.name and not components.blizzard.exact and components.blizzard.name[2] ~= '' then
prettified.prepend(aux.gui.color.blizzard(components.blizzard.name[2]))
prettified.prepend(gui.color.blizzard(components.blizzard.name[2]))
end
for _, component in components.post do
if component[1] == 'operator' then
prettified.append(aux.gui.color.aux(component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')))
prettified.append(gui.color.aux(component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')))
elseif component[1] == 'filter' then
if component[2] ~= 'tooltip' then
prettified.append(aux.gui.color.aux(component[2]))
prettified.append(gui.color.aux(component[2]))
end
for parameter in present(component[3]) do
if component[2] == 'item' then
prettified.append(aux.info.display_name(aux.cache.item_id(parameter)) or aux.gui.color.label.enabled('['..parameter..']'))
prettified.append(info.display_name(cache.item_id(parameter)) or gui.color.label.enabled('['..parameter..']'))
else
if filters[component[2]].input_type == 'money' then
prettified.append(aux.money.to_string(aux.money.from_string(parameter), nil, true, nil, aux.gui.inline_color.label.enabled))
prettified.append(money.to_string(money.from_string(parameter), nil, true, nil, gui.inline_color.label.enabled))
else
prettified.append(aux.gui.color.label.enabled(parameter))
prettified.append(gui.color.label.enabled(parameter))
end
end
end
end
end
if prettified.get() == '' then
return aux.gui.color.blizzard'<>'
return gui.color.blizzard'<>'
else
return prettified.get()
end
@@ -511,11 +511,11 @@ function blizzard_query(components)
local query = {name=filters.name and filters.name[2]}
local item_info, class_index, subclass_index, slot_index
if filters.exact and x(aux.cache.item_id(filters.name[2])) and x(aux.info.item(__)) then
if filters.exact and x(cache.item_id(filters.name[2])) and x(info.item(__)) then
item_info = __
class_index = aux.info.item_class_index(item_info.class)
subclass_index = aux.info.item_subclass_index(class_index or 0, item_info.subclass)
slot_index = aux.info.item_slot_index(class_index or 0, subclass_index or 0, item_info.slot)
class_index = info.item_class_index(item_info.class)
subclass_index = info.item_subclass_index(class_index or 0, item_info.subclass)
slot_index = info.item_slot_index(class_index or 0, subclass_index or 0, item_info.slot)
end
if item_info then
@@ -544,7 +544,7 @@ function validator(components)
end
return function(record)
if components.blizzard.exact and strlower(aux.info.item(record.item_id).name) ~= components.blizzard.name[2] then
if components.blizzard.exact and strlower(info.item(record.item_id).name) ~= components.blizzard.name[2] then
return false
end
local stack = {}
+6 -6
View File
@@ -121,8 +121,8 @@ function public.auction(index, query_type)
link = link,
itemstring = item_info.itemstring,
item_key = item_id..':'..suffix_id,
search_signature = join({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 (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
sniping_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, g.aux_ignore_owner and (aux.is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'),
search_signature = join({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({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 '?')}, ':'),
name = name,
texture = texture,
@@ -161,12 +161,12 @@ end
function public.bid_update(auction_record)
auction_record.high_bid = auction_record.bid_price
auction_record.blizzard_bid = auction_record.bid_price
auction_record.min_increment = aux.min_bid_increment(auction_record.bid_price)
auction_record.min_increment = min_bid_increment(auction_record.bid_price)
auction_record.bid_price = auction_record.bid_price + auction_record.min_increment
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 = table.concat({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 (aux.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':')
auction_record.search_signature = table.concat({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 '?')}, ':')
end
function public.set_tooltip(itemstring, owner, anchor)
@@ -244,7 +244,7 @@ function public.load_tooltip(frame, tooltip)
end
function public.display_name(item_id, no_brackets, no_color)
for item_info in present(aux.info.item(item_id)) do
for item_info in present(info.item(item_id)) do
local name = item_info.name
if not no_brackets then
name = '['..name..']'
@@ -368,7 +368,7 @@ function public.item(item_id, suffix_id)
texture = texture,
}
end
return aux.cache.item_info(item_id)
return cache.item_info(item_id)
end
function public.item_class_index(item_class)
+1 -1
View File
@@ -6,7 +6,7 @@ do
local realm, faction
function LOAD()
aux.control.thread(aux.control.when, function() faction = UnitFactionGroup 'player' return faction end, function() end)
control.thread(control.when, function() faction = UnitFactionGroup 'player' return faction end, function() end)
realm = GetCVar 'realmName'
end
+4 -4
View File
@@ -3,7 +3,7 @@ aux.module 'scan_util'
function public.find(auction_record, status_bar, on_abort, on_failure, on_success)
local function test(index)
local auction_info = aux.info.auction(index, auction_record.query_type)
local auction_info = info.auction(index, auction_record.query_type)
return auction_info and auction_info.search_signature == auction_record.search_signature
end
@@ -36,7 +36,7 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
local found
return aux.scan.start{
return scan.start{
type = auction_record.query_type,
queries = queries,
on_scan_start = function()
@@ -72,10 +72,10 @@ end
function public.item_query(item_id, first_page, last_page)
local item_info = aux.info.item(item_id)
local item_info = info.item(item_id)
if item_info then
local query = aux.filter.query(item_info.name..'/exact')
local query = filter.query(item_info.name..'/exact')
query.blizzard_query.first_page = first_page
query.blizzard_query.last_page = last_page
return {