module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-10-14 02:25:37 +02:00
parent e509d47242
commit fcdbe9cb2c
5 changed files with 23 additions and 23 deletions
+4 -4
View File
@@ -51,13 +51,13 @@ function LOAD()
text:SetFont(font, 14)
text:SetPoint('TOPLEFT', 18, 0)
text:SetPoint('BOTTOMRIGHT', -8, 0)
local highlight = _G['DropDownList1Button' .. i..'Highlight']
local highlight = _G['DropDownList1Button' .. i .. 'Highlight']
highlight:ClearAllPoints()
highlight:SetDrawLayer('OVERLAY')
highlight:SetHeight(14)
highlight:SetPoint('LEFT', 5, 0)
highlight:SetPoint('RIGHT', -3, 0)
local check = _G['DropDownList1Button' .. i..'Check']
local check = _G['DropDownList1Button' .. i .. 'Check']
check:SetWidth(16)
check:SetHeight(16)
check:SetPoint('LEFT', 3, -1)
@@ -73,10 +73,10 @@ function LOAD()
local text = button:GetFontString()
text:SetFont([[Fonts\FRIZQT__.ttf]], 10)
text:SetShadowOffset(1, -1)
local highlight = _G['DropDownList1Button' .. i..'Highlight']
local highlight = _G['DropDownList1Button' .. i .. 'Highlight']
highlight:SetAllPoints()
highlight:SetDrawLayer'BACKGROUND'
local check = _G['DropDownList1Button' .. i..'Check']
local check = _G['DropDownList1Button' .. i .. 'Check']
check:SetWidth(24)
check:SetHeight(24)
check:SetPoint('LEFT', 0, 0)
+7 -7
View File
@@ -5,11 +5,11 @@ function print(msg)
end
function format_key(k)
return type(k) == 'string' and k or '['..tostring(k)..']'
return type(k) == 'string' and k or '[' .. tostring(k) .. ']'
end
function format_value(v)
return type(v) == 'string' and '"'..v..'"' or tostring(v)
return type(v) == 'string' and '"' .. v .. '"' or tostring(v)
end
function print_table(t, depth)
@@ -27,12 +27,12 @@ local max_depth
function print_pair(k, v, depth)
local padding = strrep(' ', depth * 4)
print(padding..format_key(k)..' = '..format_value(v))
print(padding .. format_key(k) .. ' = ' .. format_value(v))
if type(v) == 'table' then
if next(v) then
print(padding..'{')
print(padding .. '{')
if depth == max_depth then
print(padding..' ...')
print(padding .. ' ...')
else
print_table(v, depth + 1)
end
@@ -55,9 +55,9 @@ local function setting(v)
if type(v) == 'number' then
max_depth = v
elseif type(v) == 'function' then
print('#'..v())
print('#' .. v())
else
print('#'..v)
print('#' .. v)
end
end
+1 -1
View File
@@ -399,6 +399,6 @@ function initialize_quality_dropdown()
end
UIDropDownMenu_AddButton(T('text', ALL, 'value', -1, 'func', on_click))
for i = 0, 4 do
UIDropDownMenu_AddButton(T('text', _G['ITEM_QUALITY' .. i..'_DESC'], 'value', i, 'func', on_click))
UIDropDownMenu_AddButton(T('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click))
end
end
+10 -10
View File
@@ -213,7 +213,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
@@ -302,9 +302,9 @@ function public.parse_filter_string(str)
if parts[i] == 'item' then
return nil, 'Invalid item name', 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]))
@@ -413,13 +413,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 aux_auctionable_items do
tinsert(suggestions, name..'/exact')
tinsert(suggestions, name .. '/exact')
end
end
@@ -433,7 +433,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
@@ -455,7 +455,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(cache.item_id(component[4])) or color.orange('['..component[4]..']'))
prettified.append(info.display_name(cache.item_id(component[4])) or color.orange('[' .. component[4] .. ']'))
elseif component[4] ~= '' then
prettified.append(color.orange(component[4]))
end
@@ -463,14 +463,14 @@ function prettified_filter_string(filter)
prettified.append(color.orange(component[3]))
end
elseif component[1] == 'operator' then
prettified.append(color.orange(component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')))
prettified.append(color.orange(component[2] .. (component[2] ~= 'not' and tonumber(component[3]) or '')))
elseif component[1] == 'filter' then
if component[2] ~= 'tooltip' then
prettified.append(color.orange(component[2]))
end
for parameter in present(component[3]) do
if component[2] == 'item' then
prettified.append(info.display_name(cache.item_id(parameter)) or color.label.enabled('['..parameter..']'))
prettified.append(info.display_name(cache.item_id(parameter)) or color.label.enabled('[' .. parameter .. ']'))
else
if filters[component[2]].input_type == 'money' then
prettified.append(money.to_string(money.from_string(parameter), nil, true, nil, inline_color.label.enabled))
@@ -566,7 +566,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 ''
+1 -1
View File
@@ -399,7 +399,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