greent refactoring
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
module 'aux.util.completion'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
local filter_util = require 'aux.util.filter'
|
||||
|
||||
+14
-14
@@ -1,6 +1,6 @@
|
||||
module 'aux.util.filter'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
@@ -265,7 +265,7 @@ do
|
||||
end,
|
||||
}
|
||||
function blizzard_filter_parser()
|
||||
return setmetatable(t, mt)
|
||||
return setmetatable(T, mt)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -284,10 +284,10 @@ function parse_parameter(input_type, str)
|
||||
end
|
||||
|
||||
function M.parse_filter_string(str)
|
||||
local filter, post_filter = t, t
|
||||
local filter, post_filter = T, T
|
||||
local blizzard_filter_parser = blizzard_filter_parser()
|
||||
|
||||
local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or t
|
||||
local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or T
|
||||
|
||||
local i = 1
|
||||
while parts[i] do
|
||||
@@ -327,14 +327,14 @@ function M.parse_filter_string(str)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return T('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
return O('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
end
|
||||
|
||||
function M.query(filter_string)
|
||||
local filter, error, suggestions = parse_filter_string(filter_string)
|
||||
|
||||
if not filter then
|
||||
return nil, suggestions or t, error
|
||||
return nil, suggestions or T, error
|
||||
end
|
||||
|
||||
local polish_notation_counter = 0
|
||||
@@ -348,7 +348,7 @@ function M.query(filter_string)
|
||||
end
|
||||
|
||||
if polish_notation_counter > 0 then
|
||||
local suggestions = t
|
||||
local suggestions = T
|
||||
for key in filters do
|
||||
tinsert(suggestions, strlower(key))
|
||||
end
|
||||
@@ -367,7 +367,7 @@ end
|
||||
|
||||
function M.queries(filter_string)
|
||||
local parts = split(filter_string, ';')
|
||||
local queries = t
|
||||
local queries = T
|
||||
for _, str in parts do
|
||||
str = trim(str)
|
||||
local query, _, error = query(str)
|
||||
@@ -381,7 +381,7 @@ function M.queries(filter_string)
|
||||
end
|
||||
|
||||
function suggestions(filter)
|
||||
local suggestions = t
|
||||
local suggestions = T
|
||||
|
||||
if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end
|
||||
|
||||
@@ -498,7 +498,7 @@ end
|
||||
|
||||
function blizzard_query(filter)
|
||||
local filters = filter.blizzard
|
||||
local query = T('name', filters.name and filters.name[2])
|
||||
local query = O('name', filters.name and filters.name[2])
|
||||
local item_info, class_index, subclass_index, slot_index
|
||||
local item_id = filters.name and cache.item_id(filters.name[2])
|
||||
item_info = item_id and info.item(item_id)
|
||||
@@ -526,7 +526,7 @@ end
|
||||
|
||||
function validator(filter)
|
||||
|
||||
local validators = t
|
||||
local validators = T
|
||||
for i, component in filter.post do
|
||||
local type, name, param = unpack(component)
|
||||
if type == 'filter' then
|
||||
@@ -538,11 +538,11 @@ function validator(filter)
|
||||
if filter.blizzard.exact and strlower(info.item(record.item_id).name) ~= filter.blizzard.name[2] then
|
||||
return false
|
||||
end
|
||||
local stack = tt
|
||||
local stack = temp-T
|
||||
for i = getn(filter.post), 1, -1 do
|
||||
local type, name, param = unpack(filter.post[i])
|
||||
if type == 'operator' then
|
||||
local args = tt
|
||||
local args = temp-T
|
||||
while (not param or param > 0) and getn(stack) > 0 do
|
||||
tinsert(args, tremove(stack))
|
||||
param = param and param - 1
|
||||
@@ -564,7 +564,7 @@ end
|
||||
|
||||
function M.query_builder()
|
||||
local filter
|
||||
return T(
|
||||
return O(
|
||||
'append', function(part)
|
||||
filter = not filter and part or filter .. '/' .. part
|
||||
end,
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
module 'aux.util.info'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
local cache = require 'aux.core.cache'
|
||||
@@ -38,7 +38,7 @@ do
|
||||
INVTYPE_TABARD = {19},
|
||||
}
|
||||
function M.inventory_index(slot)
|
||||
return unpack(inventory_index_map[slot] or tt)
|
||||
return unpack(inventory_index_map[slot] or temp-T)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,7 +53,7 @@ function M.container_item(bag, slot)
|
||||
local max_charges = max_item_charges(item_id)
|
||||
local charges = max_charges and item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
return T(
|
||||
return O(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -88,7 +88,7 @@ end
|
||||
|
||||
function M.auction_sell_item()
|
||||
for name, texture, count, quality, usable, vendor_price in GetAuctionSellItemInfo do
|
||||
return T(
|
||||
return O(
|
||||
'name', name,
|
||||
'texture', texture,
|
||||
'quality', quality,
|
||||
@@ -116,7 +116,7 @@ function M.auction(index, query_type)
|
||||
local blizzard_bid = high_bid > 0 and high_bid or start_price
|
||||
local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price
|
||||
|
||||
return T(
|
||||
return O(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -180,7 +180,7 @@ end
|
||||
|
||||
function M.set_shopping_tooltip(slot)
|
||||
local index1, index2 = inventory_index(slot)
|
||||
local tooltips = tt
|
||||
local tooltips = temp-T
|
||||
if index1 then
|
||||
local tooltip = tooltip('inventory', 'player', index1)
|
||||
if getn(tooltip) > 0 then
|
||||
@@ -195,7 +195,7 @@ function M.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[1] then
|
||||
tinsert(tooltips[1], 1, temp-T('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[1], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT')
|
||||
load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
ShoppingTooltip1:Show()
|
||||
@@ -203,7 +203,7 @@ function M.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[2] then
|
||||
tinsert(tooltips[2], 1, temp-T('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[2], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT')
|
||||
load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
ShoppingTooltip2:Show()
|
||||
@@ -283,9 +283,9 @@ function M.tooltip(setter, arg1, arg2)
|
||||
elseif setter == 'link' then
|
||||
AuxTooltip:SetHyperlink(arg1)
|
||||
end
|
||||
local tooltip = t
|
||||
local tooltip = T
|
||||
for i = 1, AuxTooltip:NumLines() do
|
||||
tinsert(tooltip, weak-T(
|
||||
tinsert(tooltip, weak-O(
|
||||
'left_text', _G['AuxTooltipTextLeft' .. i]:GetText(),
|
||||
'left_color', weak-A(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'right_text', _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(),
|
||||
@@ -367,7 +367,7 @@ end
|
||||
function M.item(item_id, suffix_id)
|
||||
local itemstring = 'item:' .. (item_id or 0) .. ':0:' .. (suffix_id or 0) .. ':0'
|
||||
local name, itemstring, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
return name and T(
|
||||
return name and O(
|
||||
'name', name,
|
||||
'itemstring', itemstring,
|
||||
'quality', quality,
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
module 'aux.util.money'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
M.GOLD_TEXT = '|cffffd70ag|r'
|
||||
@@ -83,7 +83,7 @@ function M.to_string(money, pad, trim, decimal_points, color, no_color)
|
||||
|
||||
local text
|
||||
if trim then
|
||||
local parts = tt
|
||||
local parts = temp-T
|
||||
if gold > 0 then
|
||||
tinsert(parts, format_number(gold, false, nil, color) .. gold_text)
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
module 'aux.util.persistence'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
_G.aux_datasets = t
|
||||
_G.aux_datasets = T
|
||||
|
||||
do
|
||||
local dataset
|
||||
function M.get_dataset()
|
||||
if not dataset then
|
||||
local dataset_key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player')
|
||||
dataset = aux_datasets[dataset_key] or t
|
||||
dataset = aux_datasets[dataset_key] or T
|
||||
aux_datasets[dataset_key] = dataset
|
||||
end
|
||||
return dataset
|
||||
@@ -50,7 +50,7 @@ function M.write(schema, obj)
|
||||
end
|
||||
|
||||
function read_list(schema, str)
|
||||
if str == '' then return t end
|
||||
if str == '' then return T end
|
||||
local separator = schema[2]
|
||||
local element_type = schema[3]
|
||||
return map(split(str, separator), function(part)
|
||||
@@ -69,7 +69,7 @@ end
|
||||
|
||||
function read_tuple(schema, str)
|
||||
local separator = schema[2]
|
||||
local tuple = t
|
||||
local tuple = T
|
||||
local parts = temp-split(str, separator)
|
||||
for i = 3, getn(schema) do
|
||||
local key, type = next(schema[i])
|
||||
@@ -80,7 +80,7 @@ end
|
||||
|
||||
function write_tuple(schema, tuple)
|
||||
local separator = schema[2]
|
||||
local parts = tt
|
||||
local parts = temp-T
|
||||
for i = 3 , getn(schema) do
|
||||
local key, type = next(schema[i])
|
||||
tinsert(parts, write(type, tuple[key]))
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
module 'aux.util.scan'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
@@ -14,19 +14,19 @@ end
|
||||
|
||||
function M.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
|
||||
local queries = A(t)
|
||||
local queries = A(T)
|
||||
|
||||
if auction_record.blizzard_query then
|
||||
local blizzard_query1 = copy(auction_record.blizzard_query)
|
||||
blizzard_query1.first_page = auction_record.page
|
||||
blizzard_query1.last_page = auction_record.page
|
||||
tinsert(queries, T('blizzard_query', blizzard_query1))
|
||||
tinsert(queries, O('blizzard_query', blizzard_query1))
|
||||
|
||||
if auction_record.page > 0 then
|
||||
local blizzard_query2 = copy(auction_record.blizzard_query)
|
||||
blizzard_query2.first_page = auction_record.page - 1
|
||||
blizzard_query2.last_page = auction_record.page - 1
|
||||
tinsert(queries, T('blizzard_query', blizzard_query2))
|
||||
tinsert(queries, O('blizzard_query', blizzard_query2))
|
||||
end
|
||||
|
||||
local item_query = item_query(auction_record.item_id, 0, 0)
|
||||
@@ -77,6 +77,6 @@ function M.item_query(item_id, first_page, last_page)
|
||||
local query = filter_util.query(item_info.name .. '/exact')
|
||||
query.blizzard_query.first_page = first_page
|
||||
query.blizzard_query.last_page = last_page
|
||||
return T('validator', query.validator, 'blizzard_query', query.blizzard_query)
|
||||
return O('validator', query.validator, 'blizzard_query', query.blizzard_query)
|
||||
end
|
||||
end
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
module 'aux.util.sort'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
M.EQ = 0
|
||||
|
||||
Reference in New Issue
Block a user