refactoring
This commit is contained in:
+9
-9
@@ -1,6 +1,6 @@
|
||||
module 'core'
|
||||
|
||||
public.join = _g.table.concat
|
||||
public.join = _G.table.concat
|
||||
|
||||
function public.replicate(count, value)
|
||||
if count > 0 then return value, replicate(count - 1, value) end
|
||||
@@ -23,7 +23,7 @@ do
|
||||
for i=1,9 do
|
||||
local key = '_'..i
|
||||
public[key] = t
|
||||
formal_parameters[_m[key]] = i
|
||||
formal_parameters[M[key]] = i
|
||||
end
|
||||
local function helper(f, arg1, arg2)
|
||||
local params = t
|
||||
@@ -99,7 +99,7 @@ function public.expand(array, ...) temp=arg
|
||||
end
|
||||
|
||||
function public.copy(t)
|
||||
local copy = _m.t
|
||||
local copy = M.t
|
||||
for k, v in t do copy[k] = v end
|
||||
table.setn(copy, getn(t))
|
||||
return setmetatable(copy, getmetatable(t))
|
||||
@@ -111,7 +111,7 @@ function public.select(i, ...) temp=arg
|
||||
end
|
||||
|
||||
function public.collect(indices, ...) temp=arg
|
||||
local t = _m.t
|
||||
local t = M.t
|
||||
for _, v in indices do
|
||||
tinsert(t, arg[v])
|
||||
end
|
||||
@@ -119,7 +119,7 @@ function public.collect(indices, ...) temp=arg
|
||||
end
|
||||
|
||||
function public.hashset(t)
|
||||
local set = _m.t
|
||||
local set = M.t
|
||||
for _, v in t do
|
||||
set[v] = true
|
||||
end
|
||||
@@ -139,13 +139,13 @@ function public.key(value, t)
|
||||
end
|
||||
|
||||
function public.keys(t)
|
||||
local keys = _m.t
|
||||
local keys = M.t
|
||||
for k in t do tinsert(keys, k) end
|
||||
return keys
|
||||
end
|
||||
|
||||
function public.values(t)
|
||||
local values = _m.t
|
||||
local values = M.t
|
||||
for _, v in t do tinsert(values, v) end
|
||||
return values
|
||||
end
|
||||
@@ -190,7 +190,7 @@ function public.all(t, p)
|
||||
end
|
||||
|
||||
function public.filter(t, p)
|
||||
local filtered = _m.t
|
||||
local filtered = M.t
|
||||
for k, v in t do
|
||||
if p(v, k) then
|
||||
filtered[k] = v
|
||||
@@ -200,7 +200,7 @@ function public.filter(t, p)
|
||||
end
|
||||
|
||||
function public.map(t, f)
|
||||
local mapped = _m.t
|
||||
local mapped = M.t
|
||||
for k, v in t do mapped[k] = f(v, k) end
|
||||
return mapped
|
||||
end
|
||||
|
||||
+5
-5
@@ -297,7 +297,7 @@ function public.parse_query_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', _G.aux_auctionable_items
|
||||
elseif type(input_type) == 'table' then
|
||||
return nil, 'Invalid choice for '..parts[i], input_type
|
||||
else
|
||||
@@ -354,7 +354,7 @@ function public.query(query_string)
|
||||
blizzard_query = blizzard_query(components),
|
||||
validator = validator(components),
|
||||
prettified = prettified_query_string(components),
|
||||
}, _m.suggestions(components)
|
||||
}, M.suggestions(components)
|
||||
end
|
||||
|
||||
function public.queries(query_string)
|
||||
@@ -397,7 +397,7 @@ function suggestions(components)
|
||||
-- slots
|
||||
if not components.blizzard.slot then
|
||||
for _, invtype in temp-{GetAuctionInvTypes(index(components.blizzard.class, 2) or 0, index(components.blizzard.subclass, 2) or 0)} do
|
||||
tinsert(suggestions, _g[invtype])
|
||||
tinsert(suggestions, _G[invtype])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -406,12 +406,12 @@ function suggestions(components)
|
||||
|
||||
-- rarities
|
||||
if not components.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 size(components.blizzard) + getn(components.post) == 1 and components.blizzard.name == '' then
|
||||
for _, name in _g.aux_auctionable_items do
|
||||
for _, name in _G.aux_auctionable_items do
|
||||
tinsert(suggestions, name..'/exact')
|
||||
end
|
||||
end
|
||||
|
||||
+12
-12
@@ -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-{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 '?')}, ':'),
|
||||
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 '?')}, ':'),
|
||||
|
||||
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-{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-{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)
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -388,15 +388,15 @@ end
|
||||
|
||||
function public.item_slot_index(class_index, subclass_index, slot_name)
|
||||
for i, slot in temp-{GetAuctionInvTypes(class_index, subclass_index)} do
|
||||
if strupper(_g[slot]) == strupper(slot_name) then
|
||||
return i, _g[slot]
|
||||
if strupper(_G[slot]) == strupper(slot_name) then
|
||||
return i, _G[slot]
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
module 'persistence'
|
||||
|
||||
_g.aux_datasets = t
|
||||
_G.aux_datasets = t
|
||||
|
||||
do
|
||||
local dataset
|
||||
function public.accessor.dataset()
|
||||
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 = _G.aux_datasets[dataset_key] or t
|
||||
_G.aux_datasets[dataset_key] = dataset
|
||||
end
|
||||
return dataset
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user