refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-25 01:20:44 +02:00
parent 0a2bf75f2b
commit a4e3068557
20 changed files with 194 additions and 194 deletions
+5 -5
View File
@@ -164,7 +164,7 @@ do
-- TODO test __lt
else
_m[event]()
M[event]()
end
end)
end
@@ -181,7 +181,7 @@ do
for i=1,getn(data),2 do
log(data[i], data[i + 1])
local tab = -object('name', data[i + 1])
local env = (function() module(data[i]) return _m end)()
local env = (function() module(data[i]) return M end)()
function env.mutator.OPEN(f) tab.OPEN = f end
function env.mutator.CLOSE(f) tab.CLOSE = f end
function env.mutator.USE_ITEM(f) tab.USE_ITEM = f end
@@ -219,13 +219,13 @@ function UseContainerItem(...) temp=arg
end
end
public.orig = setmetatable({[_g]=t}, {__index=function(self, key) return self[_g][key] end})
public.orig = setmetatable({[_G]=t}, {__index=function(self, key) return self[_G][key] end})
function public.hook(...) temp=arg
local name, object, handler
if arg.n == 3 then
name, object, handler = unpack(arg)
else
object, name, handler = _g, unpack(arg)
object, name, handler = _G, unpack(arg)
end
handler = handler or getfenv(2)[name]
orig[object] = orig[object] or t
@@ -273,7 +273,7 @@ end
function public.is_player(name, current)
local realm = GetCVar 'realmName'
return not current and index(_g.aux_characters, realm, name) or UnitName 'player' == name
return not current and index(_G.aux_characters, realm, name) or UnitName 'player' == name
end
function public.neutral_faction()
+22 -22
View File
@@ -8,12 +8,12 @@ MAX_ITEM_ID = 30000
items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'}}
_g.aux_items = t
_g.aux_item_ids = t
_g.aux_auctionable_items = t
_g.aux_merchant_buy = t
_g.aux_merchant_sell = t
_g.aux_characters = t
_G.aux_items = t
_G.aux_item_ids = t
_G.aux_auctionable_items = t
_G.aux_merchant_buy = t
_G.aux_merchant_sell = t
_G.aux_characters = t
function LOAD()
import 'persistence' 'info'
@@ -29,7 +29,7 @@ function LOAD()
event_listener('NEW_AUCTION_UPDATE', function()
for info in present(info.auction_sell_item()) do
for item_id in present(item_id(info.name)) do
_g.aux_merchant_sell[_m.item_id(info.name)] = info.vendor_price / (_m.info.max_item_charges(item_id) or info.count)
_G.aux_merchant_sell[M.item_id(info.name)] = info.vendor_price / (M.info.max_item_charges(item_id) or info.count)
end
end
end)
@@ -76,15 +76,15 @@ end
function public.merchant_info(item_id)
local buy_info
if _g.aux_merchant_buy[item_id] then
buy_info = persistence.read(merchant_buy_schema, _g.aux_merchant_buy[item_id])
if _G.aux_merchant_buy[item_id] then
buy_info = persistence.read(merchant_buy_schema, _G.aux_merchant_buy[item_id])
end
return _g.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
return _G.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
end
function public.item_info(item_id)
local data_string = _g.aux_items[item_id]
local data_string = _G.aux_items[item_id]
if data_string then
local cached_data = persistence.read(items_schema, data_string)
return -object(
@@ -102,7 +102,7 @@ function public.item_info(item_id)
end
function public.item_id(item_name)
return _g.aux_item_ids[strlower(item_name)]
return _G.aux_item_ids[strlower(item_name)]
end
function merchant_buy_scan()
@@ -114,8 +114,8 @@ function merchant_buy_scan()
if link then
local item_id = info.parse_link(link)
local new_unit_price, new_limited = price / count, stock >= 0
if _g.aux_merchant_buy[item_id] then
local buy_info = persistence.read(merchant_buy_schema, _g.aux_merchant_buy[item_id])
if _G.aux_merchant_buy[item_id] then
local buy_info = persistence.read(merchant_buy_schema, _G.aux_merchant_buy[item_id])
local unit_price
if buy_info.limited and not new_limited then
@@ -126,12 +126,12 @@ function merchant_buy_scan()
unit_price = min(buy_info.unit_price, new_unit_price)
end
_g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, -object(
_G.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, -object(
'unit_price', unit_price,
'limited', buy_info.limited and new_limited
))
else
_g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, -object(
_G.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, -object(
'unit_price', new_unit_price,
'limited', new_limited
))
@@ -148,7 +148,7 @@ function merchant_sell_scan()
for slot in info.inventory do temp=slot
local item_info = temp-info.container_item(unpack(slot))
if item_info then
_g.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
_G.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
end
end
end
@@ -160,9 +160,9 @@ function scan_wdb(item_id)
while processed <= 100 and item_id <= MAX_ITEM_ID do
local itemstring = 'item:'..item_id
local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
if name and not _g.aux_item_ids[strlower(name)] then
_g.aux_item_ids[strlower(name)] = item_id
_g.aux_items[item_id] = persistence.write(items_schema, -object(
if name and not _G.aux_item_ids[strlower(name)] then
_G.aux_item_ids[strlower(name)] = item_id
_G.aux_items[item_id] = persistence.write(items_schema, -object(
'name', name,
'quality', quality,
'level', level,
@@ -174,7 +174,7 @@ function scan_wdb(item_id)
))
local tooltip = info.tooltip(function(tooltip) tooltip:SetHyperlink(itemstring) end)
if info.auctionable(tooltip, quality) then
tinsert(_g.aux_auctionable_items, strlower(name))
tinsert(_G.aux_auctionable_items, strlower(name))
end
processed = processed + 1
end
@@ -185,7 +185,7 @@ function scan_wdb(item_id)
local t0 = GetTime()
thread(when, function() return GetTime() - t0 > 0.1 end, scan_wdb, item_id)
else
sort(_g.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
sort(_G.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
end
end
+2 -2
View File
@@ -147,7 +147,7 @@ function scan_page(i)
end
local auction_info = info.auction(i, state.params.type)
if auction_info and (auction_info.owner or state.params.ignore_owner or _g.aux_ignore_owner) then
if auction_info and (auction_info.owner or state.params.ignore_owner or _G.aux_ignore_owner) then
auction_info.index = i
auction_info.page = state.page
auction_info.blizzard_query = query.blizzard_query
@@ -218,7 +218,7 @@ function wait_for_list_results(send_signal, signal_received)
last_update = GetTime()
updated = true
end)
local ignore_owner = state.params.ignore_owner or _g.aux_ignore_owner
local ignore_owner = state.params.ignore_owner or _G.aux_ignore_owner
return thread(when, function()
-- short circuiting order important, owner_data_complete must be called iif an update has happened.
local ok = updated and (ignore_owner or owner_data_complete('list')) or last_update and GetTime() - last_update > 5
+31 -31
View File
@@ -1,7 +1,7 @@
module 'slash' import 'persistence'
_g.SLASH_AUX1 = '/aux'
function _g.SlashCmdList.AUX(command)
_G.SLASH_AUX1 = '/aux'
function _G.SlashCmdList.AUX(command)
if not command then return end
local arguments = tokenize(command)
if arguments[1] == 'clear' and arguments[2] == 'history' then
@@ -11,71 +11,71 @@ function _g.SlashCmdList.AUX(command)
persistence.dataset.post = nil
log 'Post settings cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
_g.aux_datasets = {}
_G.aux_datasets = {}
log 'Datasets cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
_g.aux_merchant_buy = {}
_G.aux_merchant_buy = {}
log 'Merchant buy prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
_g.aux_merchant_sell = {}
_G.aux_merchant_sell = {}
log 'Merchant sell prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
_g.aux_items = {}
_g.aux_item_ids = {}
_g.aux_auctionable_items = {}
_G.aux_items = {}
_G.aux_item_ids = {}
_G.aux_auctionable_items = {}
log 'Item cache cleared.'
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
cache.populate_wdb()
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
_g.aux_tooltip_value = not _g.aux_tooltip_value
log('Historical value in tooltip '..(_g.aux_tooltip_value and 'enabled' or 'disabled')..'.')
_G.aux_tooltip_value = not _G.aux_tooltip_value
log('Historical value in tooltip '..(_G.aux_tooltip_value and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
_g.aux_tooltip_daily = not _g.aux_tooltip_daily
log('Market value in tooltip '..(_g.aux_tooltip_daily and 'enabled' or 'disabled')..'.')
_G.aux_tooltip_daily = not _G.aux_tooltip_daily
log('Market value in tooltip '..(_G.aux_tooltip_daily and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then
_g.aux_tooltip_vendor_buy = not _g.aux_tooltip_vendor_buy
log('Vendor buy price in tooltip '..(_g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
_G.aux_tooltip_vendor_buy = not _G.aux_tooltip_vendor_buy
log('Vendor buy price in tooltip '..(_G.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then
_g.aux_tooltip_vendor_sell = not _g.aux_tooltip_vendor_sell
log('Vendor sell price in tooltip '..(_g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
_G.aux_tooltip_vendor_sell = not _G.aux_tooltip_vendor_sell
log('Vendor sell price in tooltip '..(_G.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
_g.aux_tooltip_disenchant_value = not _g.aux_tooltip_disenchant_value
log('Disenchant value in tooltip '..(_g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
_G.aux_tooltip_disenchant_value = not _G.aux_tooltip_disenchant_value
log('Disenchant value in tooltip '..(_G.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then
_g.aux_tooltip_disenchant_distribution = not _g.aux_tooltip_disenchant_distribution
log('Disenchant distribution in tooltip '..(_g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
_G.aux_tooltip_disenchant_distribution = not _G.aux_tooltip_disenchant_distribution
log('Disenchant distribution in tooltip '..(_G.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then
_g.aux_tooltip_disenchant_source = not _g.aux_tooltip_disenchant_source
log('Disenchant source in tooltip '..(_g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
_G.aux_tooltip_disenchant_source = not _G.aux_tooltip_disenchant_source
log('Disenchant source in tooltip '..(_G.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
_g.aux_ignore_owner = not _g.aux_ignore_owner
log('Ignoring of owner '..(_g.aux_ignore_owner and 'enabled' or 'disabled')..'.')
_G.aux_ignore_owner = not _G.aux_ignore_owner
log('Ignoring of owner '..(_G.aux_ignore_owner and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
local realm = GetCVar 'realmName'
_g.aux_characters[realm] = _g.aux_characters[realm] or {}
_G.aux_characters[realm] = _G.aux_characters[realm] or {}
for i=3,getn(arguments) do
local name = gsub(strlower(arguments[i]), '^%l', strupper)
if not _g.aux_characters[realm][name] then
_g.aux_characters[realm][name] = true
if not _G.aux_characters[realm][name] then
_G.aux_characters[realm][name] = true
log('Character "'..name..'" added.')
end
end
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
local realm = GetCVar 'realmName'
if not _g.aux_characters[realm] then
if not _G.aux_characters[realm] then
return
end
for i=3,getn(arguments) do
local name = gsub(strlower(arguments[i]), '^%l', strupper)
if _g.aux_characters[realm][name] then
_g.aux_characters[realm][name] = nil
if _G.aux_characters[realm][name] then
_G.aux_characters[realm][name] = nil
log('Character "'..name..'" removed.')
end
end
elseif arguments[1] == 'chars' then
local realm = GetCVar 'realmName'
local chars = {}
for name in _g.aux_characters[realm] or {} do
for name in _G.aux_characters[realm] or {} do
tinsert(chars, name)
end
if getn(chars) > 0 then
+9 -9
View File
@@ -1,6 +1,6 @@
module 'tooltip' import 'info' 'disenchant' 'cache' 'money' 'history'
_g.aux_tooltip_value = true
_G.aux_tooltip_value = true
game_tooltip_hooks = t
mutable.hooked_setter = nil
@@ -9,7 +9,7 @@ mutable.game_tooltip_money = nil
function LOAD()
for name, f in game_tooltip_hooks do
local name, f = name, f
_m.hook(name, GameTooltip, function(...) temp=arg
M.hook(name, GameTooltip, function(...) temp=arg
hooked_setter = true
game_tooltip_money = 0
local ret = {orig[GameTooltip][name](unpack(arg))}
@@ -42,7 +42,7 @@ end
function extend_tooltip(tooltip, link, quantity)
local item_id, suffix_id = info.parse_link(link)
quantity = IsShiftKeyDown() and quantity or 1
if _g.aux_tooltip_disenchant_source then
if _G.aux_tooltip_disenchant_source then
local color = {r=.7, g=.7, b=.7}
local type, range = disenchant.source(item_id)
if type == 'CRYSTAL' then
@@ -58,7 +58,7 @@ function extend_tooltip(tooltip, link, quantity)
for item_info in present(info.item(item_id)) do
local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
if getn(distribution) > 0 then
if _g.aux_tooltip_disenchant_distribution then
if _G.aux_tooltip_disenchant_distribution then
local color = {r=.8, g=.8, b=.2}
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
@@ -67,7 +67,7 @@ function extend_tooltip(tooltip, link, quantity)
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:'..event.item_id, event.min_quantity, event.max_quantity), color.r, color.g, color.b)
end
end
if _g.aux_tooltip_disenchant_value then
if _G.aux_tooltip_disenchant_value then
local color = {r=.1, g=.6, b=.6}
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
@@ -75,14 +75,14 @@ function extend_tooltip(tooltip, link, quantity)
end
end
end
if _g.aux_tooltip_vendor_buy then
if _G.aux_tooltip_vendor_buy then
local color = {r=.8, g=.5, b=.1}
local _, price, limited = cache.merchant_info(item_id)
if price then
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..money.to_string2(price * quantity), color.r, color.g, color.b)
end
end
if _g.aux_tooltip_vendor_sell then
if _G.aux_tooltip_vendor_sell then
local color = {r=.8, g=.5, b=.1}
local price = cache.merchant_info(item_id)
if price ~= 0 then
@@ -94,10 +94,10 @@ function extend_tooltip(tooltip, link, quantity)
local item_key = (item_id or 0)..':'..(suffix_id or 0)
local value = history.value(item_key)
if auctionable then
if _g.aux_tooltip_value then
if _G.aux_tooltip_value then
tooltip:AddLine('Value: '..(value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
end
if _g.aux_tooltip_daily then
if _G.aux_tooltip_daily then
local market_value = history.market_value(item_key)
tooltip:AddLine('Today: '..(market_value and money.to_string2(market_value * quantity)..' ('..auction_listing.percentage_historical(round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
end
+34 -34
View File
@@ -1,6 +1,6 @@
module 'auction_listing' import 'gui' 'sorting' 'history' 'money' 'info'
_g.aux_price_per_unit = false
_G.aux_price_per_unit = false
local RT_COUNT = 1
local HEAD_HEIGHT = 27
@@ -166,24 +166,24 @@ public.search_config = {
end
local price
if record.high_bidder then
price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = _g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
price = _G.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell:SetText(money.to_string(price, true, false, nil, color))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = _g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
price_a = _G.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
end
local price_b
if record_b.high_bidder then
price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = _g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
price_b = _G.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
end
return sorting.compare(price_a, price_b, desc)
end,
@@ -194,12 +194,12 @@ public.search_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = _g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
price_a = price_a > 0 and price_a or (desc and -huge or huge)
price_b = price_b > 0 and price_b or (desc and -huge or huge)
@@ -308,24 +308,24 @@ public.auctions_config = {
fill = function(cell, record)
local price
if record.high_bidder then
price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = _g.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
price = _G.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
end
cell:SetText(money.to_string(price, true, false))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = _g.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price
price_a = _G.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price
end
local price_b
if record_b.high_bidder then
price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = _g.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
price_b = _G.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
end
return sorting.compare(price_a, price_b, desc)
end,
@@ -336,12 +336,12 @@ public.auctions_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = _g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
price_a = price_a > 0 and price_a or (desc and -huge or huge)
price_b = price_b > 0 and price_b or (desc and -huge or huge)
@@ -461,24 +461,24 @@ public.bids_config = {
fill = function(cell, record)
local price
if record.high_bidder then
price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = _g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
price = _G.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell:SetText(money.to_string(price))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = _g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
price_a = _G.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
end
local price_b
if record_b.high_bidder then
price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = _g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
price_b = _G.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
end
return sorting.compare(price_a, price_b, desc)
end,
@@ -489,12 +489,12 @@ public.bids_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = _g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
price_a = price_a > 0 and price_a or (desc and -huge or huge)
price_b = price_b > 0 and price_b or (desc and -huge or huge)
@@ -567,10 +567,10 @@ local methods = {
if rt.disabled then return end
if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then
_g.aux_price_per_unit = not _g.aux_price_per_unit
_G.aux_price_per_unit = not _G.aux_price_per_unit
for _, cell in rt.headCells do
if cell.info.isPrice then
cell:SetText(cell.info.title[_g.aux_price_per_unit and 1 or 2])
cell:SetText(cell.info.title[_G.aux_price_per_unit and 1 or 2])
end
end
rt:SetSort()
@@ -1009,7 +1009,7 @@ function public.CreateAuctionResultsTable(parent, config)
rt:SetScript('OnShow', function()
for _, cell in this.headCells do
if cell.info.isPrice then
cell:SetText(cell.info.title[_g.aux_price_per_unit and 1 or 2])
cell:SetText(cell.info.title[_G.aux_price_per_unit and 1 or 2])
end
end
end)
@@ -1031,7 +1031,7 @@ function public.CreateAuctionResultsTable(parent, config)
rt.scrollFrame = scrollFrame
FauxScrollFrame_Update(rt.scrollFrame, 0, numRows, rt.ROW_HEIGHT)
local scrollBar = _g[scrollFrame:GetName()..'ScrollBar']
local scrollBar = _G[scrollFrame:GetName()..'ScrollBar']
scrollBar:ClearAllPoints()
scrollBar:SetPoint('BOTTOMRIGHT', rt, -4, 4)
scrollBar:SetPoint('TOPRIGHT', rt, -4, -HEAD_HEIGHT)
@@ -1041,8 +1041,8 @@ function public.CreateAuctionResultsTable(parent, config)
thumbTex:SetTexture(color.content.background())
thumbTex:SetHeight(150)
thumbTex:SetWidth(scrollBar:GetWidth())
_g[scrollBar:GetName()..'ScrollUpButton']:Hide()
_g[scrollBar:GetName()..'ScrollDownButton']:Hide()
_G[scrollBar:GetName()..'ScrollUpButton']:Hide()
_G[scrollBar:GetName()..'ScrollDownButton']:Hide()
-- create the header cells
rt.headCells = {}
+14 -14
View File
@@ -15,7 +15,7 @@ function LOAD()
blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
hook('ToggleDropDownMenu', function(...) temp=arg
local ret = {orig.ToggleDropDownMenu(unpack(arg)) }
local dropdown = _g[arg[4] or ''] or this:GetParent()
local dropdown = _G[arg[4] or ''] or this:GetParent()
if strfind(dropdown:GetName() or '', '^aux_frame%d+$') then
set_aux_dropdown_style(dropdown)
else
@@ -33,20 +33,20 @@ function LOAD()
DropDownList1:ClearAllPoints()
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
local button = _g['DropDownList1Button'..i]
local button = _G['DropDownList1Button'..i]
button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
local text = button:GetFontString()
text:SetFont(font, font_size.small2)
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)
@@ -58,14 +58,14 @@ function LOAD()
aux_border:Hide()
aux_background:Hide()
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
local button = _g['DropDownList1Button'..i]
local button = _G['DropDownList1Button'..i]
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)
@@ -453,13 +453,13 @@ function public.item(parent)
btn:SetPoint('LEFT', 2, .5)
btn:SetHighlightTexture(nil)
btn:RegisterForClicks()
item.texture = _g[btn:GetName()..'Icon']
item.texture = _G[btn:GetName()..'Icon']
item.texture:SetTexCoord(.06, .94, .06, .94)
item.name = label(btn, 15)
item.name:SetJustifyH 'LEFT'
item.name:SetPoint('LEFT', btn, 'RIGHT', 10, 0)
item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5)
item.count = _g[btn:GetName()..'Count']
item.count = _G[btn:GetName()..'Count']
item.count:SetTextHeight(17)
return item
end
@@ -501,17 +501,17 @@ function public.dropdown(parent)
local dropdown = CreateFrame('Frame', name, parent, 'UIDropDownMenuTemplate')
set_content_style(dropdown, 0, 0, 4, 4)
_g[dropdown:GetName()..'Left']:Hide()
_g[dropdown:GetName()..'Middle']:Hide()
_g[dropdown:GetName()..'Right']:Hide()
_G[dropdown:GetName()..'Left']:Hide()
_G[dropdown:GetName()..'Middle']:Hide()
_G[dropdown:GetName()..'Right']:Hide()
local button = _g[dropdown:GetName()..'Button']
local button = _G[dropdown:GetName()..'Button']
button:ClearAllPoints()
button:SetScale(0.9)
button:SetPoint('RIGHT', dropdown, 0, 0)
dropdown.button = button
local text = _g[dropdown:GetName()..'Text']
local text = _G[dropdown:GetName()..'Text']
text:ClearAllPoints()
text:SetPoint('RIGHT', button, 'LEFT', -2, 0)
text:SetPoint('LEFT', 8, 0)
+3 -3
View File
@@ -48,15 +48,15 @@ function public.create(parent, on_click, selected)
scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15)
scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15)
local scrollBar = _g[scroll_frame:GetName()..'ScrollBar']
local scrollBar = _G[scroll_frame:GetName()..'ScrollBar']
scrollBar:SetWidth(12)
local thumbTex = scrollBar:GetThumbTexture()
thumbTex:SetPoint('CENTER', 0, 0)
thumbTex:SetTexture(color.content.background())
thumbTex:SetHeight(50)
thumbTex:SetWidth(12)
_g[scrollBar:GetName()..'ScrollUpButton']:Hide()
_g[scrollBar:GetName()..'ScrollDownButton']:Hide()
_G[scrollBar:GetName()..'ScrollUpButton']:Hide()
_G[scrollBar:GetName()..'ScrollDownButton']:Hide()
local rows = t
local row_index = 1
+3 -3
View File
@@ -424,7 +424,7 @@ function public.CreateScrollingTable(parent)
scrollFrame:SetAllPoints(contentFrame)
st.scrollFrame = scrollFrame
local scrollBar = _g[scrollFrame:GetName()..'ScrollBar']
local scrollBar = _G[scrollFrame:GetName()..'ScrollBar']
scrollBar:SetWidth(12)
st.scrollBar = scrollBar
local thumbTex = scrollBar:GetThumbTexture()
@@ -432,8 +432,8 @@ function public.CreateScrollingTable(parent)
thumbTex:SetTexture(color.content.background())
thumbTex:SetHeight(50)
thumbTex:SetWidth(12)
_g[scrollBar:GetName()..'ScrollUpButton']:Hide()
_g[scrollBar:GetName()..'ScrollDownButton']:Hide()
_G[scrollBar:GetName()..'ScrollUpButton']:Hide()
_G[scrollBar:GetName()..'ScrollDownButton']:Hide()
-- create head line at default position
st.headLine = gui.horizontal_line(st, 0)
+6 -6
View File
@@ -1,6 +1,6 @@
local type, setmetatable, setfenv, unpack, next, mask, pcall, _g = type, setmetatable, setfenv, unpack, next, bit.band, pcall, getfenv(0)
local type, setmetatable, setfenv, unpack, next, mask, pcall, _G = type, setmetatable, setfenv, unpack, next, bit.band, pcall, getfenv(0)
local PRIVATE, PUBLIC, MUTABLE, DYNAMIC, PROPERTY = 0, 1, 2, 4, 8
local function error(message, ...) return _g.error(format(message or '', unpack(arg))..'\n'..debugstack(), 0) end
local function error(message, ...) return _G.error(format(message or '', unpack(arg))..'\n'..debugstack(), 0) end
local import_error, declaration_error = function() error 'Invalid import statement.' end, function() error 'Invalid declaration.' end
local collision_error, mutability_error = function(key) error('Field "%s" already exists.', key) end, function(key) error('Field "%s" is immutable.', key) end
local declare, env_mt, interface_mt, declarator_mt, importer_mt
@@ -82,7 +82,7 @@ do
elseif masked == access then
return state.data[key]
elseif not public then
return _g[key]
return _G[key]
end
end
end
@@ -115,12 +115,12 @@ function module(name)
env, interface, declarator, importer = setmetatable({}, env_mt), setmetatable({}, interface_mt), setmetatable({}, declarator_mt), setmetatable({}, importer_mt)
getters = {
private=function() state.modifiers=PRIVATE; state.property=nil return declarator end, public=function() state.modifiers=PUBLIC; state.property=nil return declarator end,
mutable=function() state.modifiers=MUTABLE; state.property=nil return declarator end,
mutable=function() state.modifiers=MUTABLE; state.property=nil return declarator end, property=function() state.modifiers=MUTABLE; state.property=nil return declarator end,
}
state = {
env=env, interface=interface, modifiers=PRIVATE,
metadata = {_=MUTABLE, _g=PRIVATE, _m=PRIVATE, _i=PRIVATE, error=PRIVATE, import=PRIVATE, private=PROPERTY, public=PROPERTY, mutable=PROPERTY, accessor=PROPERTY, mutator=PROPERTY},
data = {_g=_g, _m=env, _i=interface, error=error, import=importer}, getters=getters, setters={},
metadata = {_=MUTABLE, _G=PRIVATE, M=PRIVATE, error=PRIVATE, import=PRIVATE, private=PROPERTY, public=PROPERTY, mutable=PROPERTY, property=PROPERTY},
data = {_G=_G, M=env, error=error, import=importer}, getters=getters, setters={},
}
_modules[name], _state[env], _state[interface], _state[declarator], _state[importer] = state, state, state, state, state
importer [''] 'core'
+1 -1
View File
@@ -216,7 +216,7 @@ function create_frames()
local frame = CreateFrame('Frame', nil, frame.parameters)
start_price_frame = frame
gui.set_content_style(frame)
frame:SetPoint('TOPRIGHT', _m.frame.parameters, 'TOPRIGHT', -71, -60)
frame:SetPoint('TOPRIGHT', M.frame.parameters, 'TOPRIGHT', -71, -60)
frame:SetWidth(180)
frame:SetHeight(22)
local editbox = gui.editbox(frame)
+2 -2
View File
@@ -19,7 +19,7 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
}
do
local function action()
_g.aux_auto_buy_filter = _g[this:GetParent():GetName()..'EditBox']:GetText()
_G.aux_auto_buy_filter = _G[this:GetParent():GetName()..'EditBox']:GetText()
update_auto_buy_filter()
end
@@ -29,7 +29,7 @@ do
button2 = 'Cancel',
hasEditBox = 1,
OnShow = function()
local edit_box = _g[this:GetName()..'EditBox']
local edit_box = _G[this:GetName()..'EditBox']
edit_box:SetMaxLetters(nil)
edit_box:SetFocus()
edit_box:HighlightText()
+7 -7
View File
@@ -73,7 +73,7 @@ function update_form()
if blizzard_query.exact then
for key in -temp-set('class', 'subclass', 'slot', 'quality') do
_m[key..'_dropdown'].button:Disable()
M[key..'_dropdown'].button:Disable()
end
else
class_dropdown.button:Enable()
@@ -81,9 +81,9 @@ function update_form()
end
for key in -temp-set('min_level', 'max_level') do
if blizzard_query.exact then
_m[key..'_input']:Disable()
M[key..'_input']:Disable()
else
_m[key..'_input']:Enable()
M[key..'_input']:Enable()
end
end
if blizzard_query.exact then
@@ -125,13 +125,13 @@ function get_filter_builder_query()
for subclass in present(blizzard_query.subclass) do
local subclasses = temp-{GetAuctionItemSubClasses(class)}
add(strlower(subclasses[subclass]))
add(blizzard_query.slot and strlower(_g[blizzard_query.slot]))
add(blizzard_query.slot and strlower(_G[blizzard_query.slot]))
end
end
local quality = blizzard_query.quality
if quality and quality >= 0 then
add(strlower(_g['ITEM_QUALITY'..quality..'_DESC']))
add(strlower(_G['ITEM_QUALITY'..quality..'_DESC']))
end
local post_filter_string = filter_util.query_string(-temp-object('blizzard', tt, 'post', post_filter))
@@ -377,7 +377,7 @@ function initialize_slot_dropdown()
if subclass_index and GetAuctionInvTypes(class_index, subclass_index) then
UIDropDownMenu_AddButton(-object('text', ALL, 'value', '', 'func', on_click))
for _, slot in {GetAuctionInvTypes(class_index, subclass_index)} do
UIDropDownMenu_AddButton(-object('text', _g[slot], 'value', slot, 'func', on_click))
UIDropDownMenu_AddButton(-object('text', _G[slot], 'value', slot, 'func', on_click))
end
end
end
@@ -389,6 +389,6 @@ function initialize_quality_dropdown()
end
UIDropDownMenu_AddButton(-object('text', ALL, 'value', -1, 'func', on_click))
for i=0,4 do
UIDropDownMenu_AddButton(-object('text', _g['ITEM_QUALITY'..i..'_DESC'], 'value', i, 'func', on_click))
UIDropDownMenu_AddButton(-object('text', _G['ITEM_QUALITY'..i..'_DESC'], 'value', i, 'func', on_click))
end
end
+15 -15
View File
@@ -118,9 +118,9 @@ function create_frames()
btn:SetText('Real Time Mode')
btn:SetScript('OnClick', function()
this:SetChecked(not this:GetChecked())
_g.this = first_page_input
_G.this = first_page_input
first_page_input:GetScript('OnTextChanged')()
_g.this = last_page_input
_G.this = last_page_input
last_page_input:GetScript('OnTextChanged')()
end)
public.real_time_button = btn
@@ -149,7 +149,7 @@ function create_frames()
btn:SetScript('OnClick', function()
if this:GetChecked() then
this:SetChecked(false)
_g.aux_auto_buy_filter = nil
_G.aux_auto_buy_filter = nil
this.prettified = nil
auto_buy_validator = nil
else
@@ -313,7 +313,7 @@ function create_frames()
btn:SetScript('OnClick', function()
local filters = filter_util.queries(search_box:GetText())
if filters then
tinsert(_g.aux_favorite_searches, 1, {
tinsert(_G.aux_favorite_searches, 1, {
filter_string = search_box:GetText(),
prettified = join(map(filters, function(filter) return filter.prettified end), ';'),
})
@@ -345,7 +345,7 @@ function create_frames()
end
do
local editbox = gui.editbox(frame.filter)
editbox.complete_item = completion.complete(function() return _g.aux_auctionable_items end)
editbox.complete_item = completion.complete(function() return _G.aux_auctionable_items end)
editbox:SetPoint('TOPLEFT', 14, -FILTER_SPACING)
editbox:SetWidth(260)
editbox.char = function()
@@ -499,7 +499,7 @@ function create_frames()
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, initialize_filter_dropdown)
end)
_g[dropdown:GetName()..'Text']:Hide()
_G[dropdown:GetName()..'Text']:Hide()
local label = gui.label(dropdown, gui.font_size.medium)
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
label:SetText('Post Filter')
@@ -623,16 +623,16 @@ function create_frames()
add_filter(data.search.filter_string)
elseif button == 'LeftButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index > 1 then
local temp = _g.aux_favorite_searches[data.index - 1]
_g.aux_favorite_searches[data.index - 1] = data.search
_g.aux_favorite_searches[data.index] = temp
local temp = _G.aux_favorite_searches[data.index - 1]
_G.aux_favorite_searches[data.index - 1] = data.search
_G.aux_favorite_searches[data.index] = temp
update_search_listings()
end
elseif button == 'RightButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index < getn(_g.aux_favorite_searches) then
local temp = _g.aux_favorite_searches[data.index + 1]
_g.aux_favorite_searches[data.index + 1] = data.search
_g.aux_favorite_searches[data.index] = temp
if st == favorite_searches_listing and data.index < getn(_G.aux_favorite_searches) then
local temp = _G.aux_favorite_searches[data.index + 1]
_G.aux_favorite_searches[data.index + 1] = data.search
_G.aux_favorite_searches[data.index] = temp
update_search_listings()
end
elseif button == 'LeftButton' then
@@ -640,9 +640,9 @@ function create_frames()
execute()
elseif button == 'RightButton' then
if st == recent_searches_listing then
tinsert(_g.aux_favorite_searches, 1, data.search)
tinsert(_G.aux_favorite_searches, 1, data.search)
elseif st == favorite_searches_listing then
tremove(_g.aux_favorite_searches, data.index)
tremove(_G.aux_favorite_searches, data.index)
end
update_search_listings()
end
+4 -4
View File
@@ -1,6 +1,6 @@
module 'search_tab' import 'info'
_g.aux_auto_buy_filter = ''
_G.aux_auto_buy_filter = ''
mutable.search_scan_id = 0
mutable.auto_buy_validator = nil
@@ -109,8 +109,8 @@ function update_start_stop()
end
function update_auto_buy_filter()
if _g.aux_auto_buy_filter ~= '' then
local queries = filter_util.queries(_g.aux_auto_buy_filter)
if _G.aux_auto_buy_filter ~= '' then
local queries = filter_util.queries(_G.aux_auto_buy_filter)
if queries then
if getn(queries) > 1 then
log 'Error: The automatic buyout filter does not support multi-queries'
@@ -124,7 +124,7 @@ function update_auto_buy_filter()
end
end
end
_g.aux_auto_buy_filter = ''
_G.aux_auto_buy_filter = ''
end
function start_real_time_scan(query, search, continuation)
+7 -7
View File
@@ -1,11 +1,11 @@
module 'search_tab'
_g.aux_favorite_searches = {}
_g.aux_recent_searches = {}
_G.aux_favorite_searches = {}
_G.aux_recent_searches = {}
function update_search_listings()
local favorite_search_rows = {}
for i, favorite_search in _g.aux_favorite_searches do
for i, favorite_search in _G.aux_favorite_searches do
local name = strsub(favorite_search.prettified, 1, 250)
tinsert(favorite_search_rows, {
cols = {{value=name}},
@@ -16,7 +16,7 @@ function update_search_listings()
favorite_searches_listing:SetData(favorite_search_rows)
local recent_search_rows = {}
for i, recent_search in _g.aux_recent_searches do
for i, recent_search in _G.aux_recent_searches do
local name = strsub(recent_search.prettified, 1, 250)
tinsert(recent_search_rows, {
cols = {{value=name}},
@@ -28,12 +28,12 @@ function update_search_listings()
end
function new_recent_search(filter_string, prettified)
tinsert(_g.aux_recent_searches, 1, {
tinsert(_G.aux_recent_searches, 1, {
filter_string = filter_string,
prettified = prettified,
})
while getn(_g.aux_recent_searches) > 50 do
tremove(_g.aux_recent_searches)
while getn(_G.aux_recent_searches) > 50 do
tremove(_G.aux_recent_searches)
end
update_search_listings()
end
+9 -9
View File
@@ -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
View File
@@ -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
View File
@@ -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
+3 -3
View File
@@ -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