refactoring
This commit is contained in:
+1
-1
@@ -43,7 +43,7 @@ do
|
||||
__call = function(self, text)
|
||||
local r, g, b, a = unpack(self)
|
||||
if text then
|
||||
return format('|c%02X%02X%02X%02X', a, r*255, g*255, b*255)..text..FONT_COLOR_CODE_CLOSE
|
||||
return format('|c%02X%02X%02X%02X', a, r*255, g*255, b*255) .. text .. FONT_COLOR_CODE_CLOSE
|
||||
else
|
||||
return r, g, b, a
|
||||
end
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ function public:complete_filter()
|
||||
|
||||
for _, suggestion in suggestions do
|
||||
if strsub(strupper(suggestion), 1, strlen(current_modifier)) == strupper(current_modifier) then
|
||||
this:SetText(strlower(strsub(filter_string, 1, start_index - 1).. suggestion))
|
||||
this:SetText(strlower(strsub(filter_string, 1, start_index - 1) .. suggestion))
|
||||
this:HighlightText(strlen(filter_string), -1)
|
||||
return
|
||||
end
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ end
|
||||
do
|
||||
local formal_parameters = t
|
||||
for i = 1, 9 do
|
||||
local key = '_'..i
|
||||
local key = '_' .. i
|
||||
public[key] = t
|
||||
formal_parameters[M[key]] = i
|
||||
end
|
||||
@@ -44,9 +44,9 @@ do
|
||||
local arg1 = arg
|
||||
return function(...) return helper(body, arg1, arg) end
|
||||
else
|
||||
-- body = gsub(body, '_([ab])', function(char) return '_'.. end)
|
||||
-- local lambda = loadstring('return function(_1,_2,_3,_4,_5,_6,_7,_8,_9)'..body..' end')
|
||||
local lambda = loadstring('return '..body) or loadstring(body)
|
||||
-- body = gsub(body, '_([ab])', function(char) return '_' .. end)
|
||||
-- local lambda = loadstring('return function(_1,_2,_3,_4,_5,_6,_7,_8,_9)' .. body .. ' end')
|
||||
local lambda = loadstring('return ' .. body) or loadstring(body)
|
||||
setfenv(lambda, getfenv(2))
|
||||
return lambda
|
||||
end
|
||||
|
||||
+11
-11
@@ -205,7 +205,7 @@ public.filters = {
|
||||
function 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
|
||||
for arity in present(select(3, strfind(str, '^' .. name .. '(%d*)$'))) do
|
||||
arity = tonumber(arity)
|
||||
operator = not (arity and arity < 2) and A('operator', name, arity)
|
||||
end
|
||||
@@ -294,9 +294,9 @@ function public.parse_filter_string(str)
|
||||
if parts[i] == 'item' then
|
||||
return nil, 'Invalid item name', _G.aux_auctionable_items
|
||||
elseif type(input_type) == 'table' then
|
||||
return nil, 'Invalid choice for '..parts[i], input_type
|
||||
return nil, 'Invalid choice for ' .. parts[i], input_type
|
||||
else
|
||||
return nil, 'Invalid input for '..parts[i]..'. Expecting: '..input_type
|
||||
return nil, 'Invalid input for ' .. parts[i] .. '. Expecting: ' .. input_type
|
||||
end
|
||||
end
|
||||
tinsert(post_filter, A('filter', parts[i], parts[i + 1]))
|
||||
@@ -406,13 +406,13 @@ function suggestions(filter)
|
||||
|
||||
-- rarities
|
||||
if not filter.blizzard.quality then
|
||||
for i = 0, 4 do tinsert(suggestions, _G['ITEM_QUALITY'..i..'_DESC']) end
|
||||
for i = 0, 4 do tinsert(suggestions, _G['ITEM_QUALITY' .. i..'_DESC']) end
|
||||
end
|
||||
|
||||
-- item names
|
||||
if getn(filter.components) == 0 then
|
||||
for _, name in _G.aux_auctionable_items do
|
||||
tinsert(suggestions, name..'/exact')
|
||||
tinsert(suggestions, name .. '/exact')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -426,7 +426,7 @@ function public.filter_string(components)
|
||||
if component[1] == 'blizzard' then
|
||||
query_builder.append(filter[4] or filter[3])
|
||||
elseif component[1] == 'operator' then
|
||||
query_builder.append(component[2]..(component[2] ~= 'not' and tonumber(component[3]) or ''))
|
||||
query_builder.append(component[2] .. (component[2] ~= 'not' and tonumber(component[3]) or ''))
|
||||
elseif component[1] == 'filter' then
|
||||
query_builder.append(component[2])
|
||||
for parameter in present(component[3]) do
|
||||
@@ -448,7 +448,7 @@ function prettified_filter_string(filter)
|
||||
if component[1] == 'blizzard' then
|
||||
if component[2] == 'name' then
|
||||
if filter.blizzard.exact then
|
||||
prettified.append(info.display_name(aux.cache.item_id(component[4])) or color.blizzard('['..component[4]..']'))
|
||||
prettified.append(info.display_name(aux.cache.item_id(component[4])) or color.blizzard('[' .. component[4] .. ']'))
|
||||
elseif component[4] ~= '' then
|
||||
prettified.append(color.blizzard(component[4]))
|
||||
end
|
||||
@@ -456,14 +456,14 @@ function prettified_filter_string(filter)
|
||||
prettified.append(color.blizzard(component[3]))
|
||||
end
|
||||
elseif component[1] == 'operator' then
|
||||
prettified.append(color.aux(component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')))
|
||||
prettified.append(color.aux(component[2] .. (component[2] ~= 'not' and tonumber(component[3]) or '')))
|
||||
elseif component[1] == 'filter' then
|
||||
if component[2] ~= 'tooltip' then
|
||||
prettified.append(color.aux(component[2]))
|
||||
end
|
||||
for parameter in present(component[3]) do
|
||||
if component[2] == 'item' then
|
||||
prettified.append(info.display_name(aux.cache.item_id(parameter)) or color.label.enabled('['..parameter..']'))
|
||||
prettified.append(info.display_name(aux.cache.item_id(parameter)) or 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, inline_color.label.enabled))
|
||||
@@ -482,7 +482,7 @@ function prettified_filter_string(filter)
|
||||
end
|
||||
|
||||
function public.quote(name)
|
||||
return '<'..name..'>'
|
||||
return '<' .. name .. '>'
|
||||
end
|
||||
|
||||
function public.unquote(name)
|
||||
@@ -559,7 +559,7 @@ function public.query_builder()
|
||||
local filter
|
||||
return T(
|
||||
'append', function(part)
|
||||
filter = not filter and part or filter..'/'..part
|
||||
filter = not filter and part or filter .. '/' .. part
|
||||
end,
|
||||
'get', function()
|
||||
return filter or ''
|
||||
|
||||
+16
-16
@@ -56,7 +56,7 @@ function public.container_item(bag, slot)
|
||||
|
||||
'link', link,
|
||||
'itemstring', item_info.itemstring,
|
||||
'item_key', item_id..':'..suffix_id,
|
||||
'item_key', item_id .. ':' .. suffix_id,
|
||||
|
||||
'name', item_info.name,
|
||||
'texture', texture,
|
||||
@@ -119,7 +119,7 @@ function public.auction(index, query_type)
|
||||
|
||||
'link', link,
|
||||
'itemstring', item_info.itemstring,
|
||||
'item_key', item_id..':'..suffix_id,
|
||||
'item_key', item_id .. ':' .. suffix_id,
|
||||
'search_signature', join(temp-{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-{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 '?')}, ':'),
|
||||
|
||||
@@ -237,8 +237,8 @@ function public.load_tooltip(frame, tooltip)
|
||||
end
|
||||
end
|
||||
for i = 1, getn(tooltip) do -- TODO why is this needed?
|
||||
_G[frame:GetName()..'TextLeft'..i]:SetJustifyH('LEFT')
|
||||
_G[frame:GetName()..'TextRight'..i]:SetJustifyH('LEFT')
|
||||
_G[frame:GetName() .. 'TextLeft' .. i]:SetJustifyH('LEFT')
|
||||
_G[frame:GetName() .. 'TextRight' .. i]:SetJustifyH('LEFT')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -246,10 +246,10 @@ function public.display_name(item_id, no_brackets, no_color)
|
||||
for item_info in present(item(item_id)) do
|
||||
local name = item_info.name
|
||||
if not no_brackets then
|
||||
name = '['..name..']'
|
||||
name = '[' .. name .. ']'
|
||||
end
|
||||
if not no_color then
|
||||
name = select(4, GetItemQualityColor(item_info.quality))..name..FONT_COLOR_CODE_CLOSE
|
||||
name = select(4, GetItemQualityColor(item_info.quality)) .. name .. FONT_COLOR_CODE_CLOSE
|
||||
end
|
||||
return name
|
||||
end
|
||||
@@ -275,10 +275,10 @@ function public.tooltip(setter)
|
||||
local tooltip = t
|
||||
for i = 1, AuxTooltip:NumLines() do
|
||||
tinsert(tooltip, {
|
||||
left_text = _G['AuxTooltipTextLeft'..i]:GetText(),
|
||||
left_color = {_G['AuxTooltipTextLeft'..i]:GetTextColor()},
|
||||
right_text = _G['AuxTooltipTextRight'..i]:IsVisible() and _G['AuxTooltipTextRight'..i]:GetText(),
|
||||
right_color = {_G['AuxTooltipTextRight'..i]:GetTextColor()},
|
||||
left_text = _G['AuxTooltipTextLeft' .. i]:GetText(),
|
||||
left_color = {_G['AuxTooltipTextLeft' .. i]:GetTextColor()},
|
||||
right_text = _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(),
|
||||
right_color = {_G['AuxTooltipTextRight' .. i]:GetTextColor()},
|
||||
})
|
||||
end
|
||||
|
||||
@@ -287,7 +287,7 @@ end
|
||||
|
||||
function item_charges(tooltip)
|
||||
for _, line in tooltip do
|
||||
local pattern = '^'..gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)')..'$'
|
||||
local pattern = '^' .. gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
|
||||
|
||||
local _, _, left_charges_string = strfind(line.left_text or '', pattern)
|
||||
local _, _, right_charges_string = strfind(line.right_text or '', pattern)
|
||||
@@ -329,7 +329,7 @@ end
|
||||
|
||||
function public.durability(tooltip)
|
||||
for _, line in tooltip do
|
||||
local pattern = '^'..gsub(gsub(DURABILITY_TEMPLATE, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)')..'$'
|
||||
local pattern = '^' .. gsub(gsub(DURABILITY_TEMPLATE, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
|
||||
local _, _, left_durability_string, left_max_durability_string = strfind(line.left_text or '', pattern)
|
||||
local _, _, right_durability_string, right_max_durability_string = strfind(line.right_text or '', pattern)
|
||||
local durability = tonumber(left_durability_string) or tonumber(right_durability_string)
|
||||
@@ -342,7 +342,7 @@ end
|
||||
|
||||
function public.item_key(link)
|
||||
local item_id, suffix_id = parse_link(link)
|
||||
return item_id..':'..suffix_id
|
||||
return item_id .. ':' .. suffix_id
|
||||
end
|
||||
|
||||
function public.parse_link(link)
|
||||
@@ -351,11 +351,11 @@ function public.parse_link(link)
|
||||
end
|
||||
|
||||
function public.itemstring(item_id, suffix_id, unique_id, enchant_id)
|
||||
return 'item:'..(item_id or 0)..':'..(enchant_id or 0)..':'..(suffix_id or 0)..':'..(unique_id or 0)
|
||||
return 'item:' .. (item_id or 0) .. ':' .. (enchant_id or 0) .. ':' .. (suffix_id or 0) .. ':' .. (unique_id or 0)
|
||||
end
|
||||
|
||||
function public.item(item_id, suffix_id)
|
||||
local itemstring = 'item:'..(item_id or 0)..':0:'..(suffix_id or 0)..':0'
|
||||
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 {
|
||||
name = name,
|
||||
@@ -397,7 +397,7 @@ end
|
||||
|
||||
function public.item_quality_index(item_quality)
|
||||
for i = 0, 4 do
|
||||
local quality = _G['ITEM_QUALITY'..i..'_DESC']
|
||||
local quality = _G['ITEM_QUALITY' .. i..'_DESC']
|
||||
if strupper(item_quality) == strupper(quality) then
|
||||
return i, quality
|
||||
end
|
||||
|
||||
+17
-17
@@ -28,9 +28,9 @@ function public.to_string2(money, exact, color)
|
||||
local GOLD = 'ffd100'
|
||||
local SILVER = 'e6e6e6'
|
||||
local COPPER = 'c8602c'
|
||||
local START = '|cff%s%d'..FONT_COLOR_CODE_CLOSE
|
||||
local PART = color..'.|cff%s%02d'..FONT_COLOR_CODE_CLOSE
|
||||
local NONE = '|cffa0a0a0'..TEXT_NONE..FONT_COLOR_CODE_CLOSE
|
||||
local START = '|cff%s%d' .. FONT_COLOR_CODE_CLOSE
|
||||
local PART = color .. '.|cff%s%02d' .. FONT_COLOR_CODE_CLOSE
|
||||
local NONE = '|cffa0a0a0' .. TEXT_NONE .. FONT_COLOR_CODE_CLOSE
|
||||
|
||||
if not exact and money >= 10000 then
|
||||
-- Round to nearest silver
|
||||
@@ -42,15 +42,15 @@ function public.to_string2(money, exact, color)
|
||||
|
||||
local fmt = START
|
||||
if g > 0 then
|
||||
str = str..format(fmt, GOLD, g)
|
||||
str = str .. format(fmt, GOLD, g)
|
||||
fmt = PART
|
||||
end
|
||||
if s > 0 or c > 0 then
|
||||
str = str..format(fmt, SILVER, s)
|
||||
str = str .. format(fmt, SILVER, s)
|
||||
fmt = PART
|
||||
end
|
||||
if c > 0 then
|
||||
str = str..format(fmt, COPPER, c)
|
||||
str = str .. format(fmt, COPPER, c)
|
||||
end
|
||||
if str == '' then
|
||||
str = NONE
|
||||
@@ -70,7 +70,7 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
||||
|
||||
-- rounding
|
||||
if decimal_points then
|
||||
copper = tonumber(format('%.'..decimal_points..'f', copper))
|
||||
copper = tonumber(format('%.' .. decimal_points .. 'f', copper))
|
||||
end
|
||||
|
||||
local gold_text, silver_text, copper_text
|
||||
@@ -84,30 +84,30 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
||||
if trim then
|
||||
local parts = tt
|
||||
if gold > 0 then
|
||||
tinsert(parts, format_number(gold, false, nil, color)..gold_text)
|
||||
tinsert(parts, format_number(gold, false, nil, color) .. gold_text)
|
||||
end
|
||||
if silver > 0 then
|
||||
tinsert(parts, format_number(silver, pad, nil, color)..silver_text)
|
||||
tinsert(parts, format_number(silver, pad, nil, color) .. silver_text)
|
||||
end
|
||||
if copper > 0 or gold == 0 and silver == 0 then
|
||||
tinsert(parts, format_number(copper, pad, decimal_points, color)..copper_text)
|
||||
tinsert(parts, format_number(copper, pad, decimal_points, color) .. copper_text)
|
||||
end
|
||||
text = join(parts, ' ')
|
||||
else
|
||||
if gold > 0 then
|
||||
text = format_number(gold, false, nil, color)..gold_text..' '..format_number(silver, pad, nil, color)..silver_text..' '..format_number(copper, pad, decimal_points, color)..copper_text
|
||||
text = format_number(gold, false, nil, color) .. gold_text .. ' ' .. format_number(silver, pad, nil, color) .. silver_text .. ' ' .. format_number(copper, pad, decimal_points, color) .. copper_text
|
||||
elseif silver > 0 then
|
||||
text = format_number(silver, false, nil, color)..silver_text..' '..format_number(copper, pad, decimal_points, color)..copper_text
|
||||
text = format_number(silver, false, nil, color) .. silver_text .. ' ' .. format_number(copper, pad, decimal_points, color) .. copper_text
|
||||
else
|
||||
text = format_number(copper, false, decimal_points, color)..copper_text
|
||||
text = format_number(copper, false, decimal_points, color) .. copper_text
|
||||
end
|
||||
end
|
||||
|
||||
if is_negative then
|
||||
if color then
|
||||
text = color..'-'..FONT_COLOR_CODE_CLOSE..text
|
||||
text = color .. '-' .. FONT_COLOR_CODE_CLOSE .. text
|
||||
else
|
||||
text = '-'..text
|
||||
text = '-' .. text
|
||||
end
|
||||
end
|
||||
|
||||
@@ -140,9 +140,9 @@ end
|
||||
|
||||
function public.format_number(num, pad, decimal_padding, color)
|
||||
local padding = pad and 2 + (decimal_padding and decimal_padding + 1 or 0) or 0
|
||||
num = format('%0'..padding..'.0'..(decimal_padding or 0)..'f', num)
|
||||
num = format('%0' .. padding .. '.0' .. (decimal_padding or 0) .. 'f', num)
|
||||
if color then
|
||||
return color..num..FONT_COLOR_CODE_CLOSE
|
||||
return color .. num .. FONT_COLOR_CODE_CLOSE
|
||||
else
|
||||
return num
|
||||
end
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ end
|
||||
|
||||
function public.item_query(item_id, first_page, last_page)
|
||||
for item_info in present(info.item(item_id)) do
|
||||
local query = filter_util.query(item_info.name..'/exact')
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user