big module refactoring
This commit is contained in:
+22
-22
@@ -6,12 +6,12 @@ private.MAX_ITEM_ID = 30000
|
||||
private.items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
|
||||
private.merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'} }
|
||||
|
||||
aux_items = {}
|
||||
aux_item_ids = {}
|
||||
aux_auctionable_items = {}
|
||||
aux_merchant_buy = {}
|
||||
aux_merchant_sell = {}
|
||||
aux_characters = {}
|
||||
_G.aux_items = {}
|
||||
_G.aux_item_ids = {}
|
||||
_G.aux_auctionable_items = {}
|
||||
_G.aux_merchant_buy = {}
|
||||
_G.aux_merchant_sell = {}
|
||||
_G.aux_characters = {}
|
||||
|
||||
function m.LOAD()
|
||||
m.scan_wdb()
|
||||
@@ -26,7 +26,7 @@ function m.LOAD()
|
||||
aux.control.event_listener('NEW_AUCTION_UPDATE', function()
|
||||
for _, info in {aux.info.auction_sell_item()} do
|
||||
for _, item_id in {aux.cache.item_id(info.name)} do
|
||||
aux_merchant_sell[aux.cache.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count)
|
||||
_G.aux_merchant_sell[aux.cache.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -78,15 +78,15 @@ end
|
||||
|
||||
function public.merchant_info(item_id)
|
||||
local buy_info
|
||||
if aux_merchant_buy[item_id] then
|
||||
buy_info = aux.persistence.read(m.merchant_buy_schema, aux_merchant_buy[item_id])
|
||||
if _G.aux_merchant_buy[item_id] then
|
||||
buy_info = aux.persistence.read(m.merchant_buy_schema, _G.aux_merchant_buy[item_id])
|
||||
end
|
||||
|
||||
return 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 = aux_items[item_id]
|
||||
local data_string = _G.aux_items[item_id]
|
||||
if data_string then
|
||||
local cached_data = aux.persistence.read(m.items_schema, data_string)
|
||||
return {
|
||||
@@ -104,7 +104,7 @@ function public.item_info(item_id)
|
||||
end
|
||||
|
||||
function public.item_id(item_name)
|
||||
return aux_item_ids[strlower(item_name)]
|
||||
return _G.aux_item_ids[strlower(item_name)]
|
||||
end
|
||||
|
||||
function private.merchant_buy_scan()
|
||||
@@ -116,8 +116,8 @@ function private.merchant_buy_scan()
|
||||
if link then
|
||||
local item_id = aux.info.parse_hyperlink(link)
|
||||
local new_unit_price, new_limited = price / count, stock >= 0
|
||||
if aux_merchant_buy[item_id] then
|
||||
local buy_info = aux.persistence.read(m.merchant_buy_schema, aux_merchant_buy[item_id])
|
||||
if _G.aux_merchant_buy[item_id] then
|
||||
local buy_info = aux.persistence.read(m.merchant_buy_schema, _G.aux_merchant_buy[item_id])
|
||||
|
||||
local unit_price
|
||||
if buy_info.limited and not new_limited then
|
||||
@@ -128,12 +128,12 @@ function private.merchant_buy_scan()
|
||||
unit_price = min(buy_info.unit_price, new_unit_price)
|
||||
end
|
||||
|
||||
aux_merchant_buy[item_id] = aux.persistence.write(m.merchant_buy_schema, {
|
||||
_G.aux_merchant_buy[item_id] = aux.persistence.write(m.merchant_buy_schema, {
|
||||
unit_price = unit_price,
|
||||
limited = buy_info.limited and new_limited,
|
||||
})
|
||||
else
|
||||
aux_merchant_buy[item_id] = aux.persistence.write(m.merchant_buy_schema, {
|
||||
_G.aux_merchant_buy[item_id] = aux.persistence.write(m.merchant_buy_schema, {
|
||||
unit_price = new_unit_price,
|
||||
limited = new_limited,
|
||||
})
|
||||
@@ -150,7 +150,7 @@ function private.merchant_sell_scan()
|
||||
for slot in aux.util.inventory() do
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
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
|
||||
@@ -162,9 +162,9 @@ function private.scan_wdb(item_id)
|
||||
while processed <= 100 and item_id <= m.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 aux_item_ids[strlower(name)] then
|
||||
aux_item_ids[strlower(name)] = item_id
|
||||
aux_items[item_id] = aux.persistence.write(m.items_schema, {
|
||||
if name and not _G.aux_item_ids[strlower(name)] then
|
||||
_G.aux_item_ids[strlower(name)] = item_id
|
||||
_G.aux_items[item_id] = aux.persistence.write(m.items_schema, {
|
||||
name = name,
|
||||
quality = quality,
|
||||
level = level,
|
||||
@@ -176,7 +176,7 @@ function private.scan_wdb(item_id)
|
||||
})
|
||||
local tooltip = aux.info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
|
||||
if aux.info.auctionable(tooltip, quality) then
|
||||
tinsert(aux_auctionable_items, strlower(name))
|
||||
tinsert(_G.aux_auctionable_items, strlower(name))
|
||||
end
|
||||
processed = processed + 1
|
||||
end
|
||||
@@ -187,7 +187,7 @@ function private.scan_wdb(item_id)
|
||||
local t0 = GetTime()
|
||||
aux.control.thread(aux.control.when, function() return GetTime() - t0 > 0.1 end, m.scan_wdb, item_id)
|
||||
else
|
||||
sort(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
@@ -145,7 +145,7 @@ function private.scan_page(i)
|
||||
end
|
||||
|
||||
local auction_info = aux.info.auction(i, m.state.params.type)
|
||||
if auction_info and (auction_info.owner or m.state.params.ignore_owner or aux_ignore_owner) then
|
||||
if auction_info and (auction_info.owner or m.state.params.ignore_owner or _G.aux_ignore_owner) then
|
||||
auction_info.index = i
|
||||
auction_info.page = m.state.page
|
||||
auction_info.blizzard_query = m.query.blizzard_query
|
||||
@@ -216,7 +216,7 @@ function private.wait_for_list_results(send_signal, signal_received)
|
||||
last_update = GetTime()
|
||||
updated = true
|
||||
end)
|
||||
local ignore_owner = m.state.params.ignore_owner or aux_ignore_owner
|
||||
local ignore_owner = m.state.params.ignore_owner or _G.aux_ignore_owner
|
||||
return aux.control.thread(aux.control.when, function()
|
||||
-- short circuiting order important, owner_data_complete must be called iif an update has happened.
|
||||
local ok = updated and (ignore_owner or m.owner_data_complete('list')) or last_update and GetTime() - last_update > 5
|
||||
|
||||
+29
-29
@@ -9,71 +9,71 @@ function SlashCmdList.AUX(command)
|
||||
aux.persistence.load_dataset().post = nil
|
||||
aux.log 'Post settings cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
|
||||
aux_datasets = {}
|
||||
_G.aux_datasets = {}
|
||||
aux.log 'Datasets cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
||||
aux_merchant_buy = {}
|
||||
_G.aux_merchant_buy = {}
|
||||
aux.log 'Merchant buy prices cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
||||
aux_merchant_sell = {}
|
||||
_G.aux_merchant_sell = {}
|
||||
aux.log 'Merchant sell prices cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
||||
aux_items = {}
|
||||
aux_item_ids = {}
|
||||
aux_auctionable_items = {}
|
||||
_G.aux_items = {}
|
||||
_G.aux_item_ids = {}
|
||||
_G.aux_auctionable_items = {}
|
||||
aux.log 'Item cache cleared.'
|
||||
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
||||
aux.cache.populate_wdb()
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
||||
aux_tooltip_value = not aux_tooltip_value
|
||||
aux.log('Historical value in tooltip '..(aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_tooltip_value = not _G.aux_tooltip_value
|
||||
aux.log('Historical value in tooltip '..(_G.aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
||||
aux_tooltip_daily = not aux_tooltip_daily
|
||||
aux.log('Market value in tooltip '..(aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_tooltip_daily = not _G.aux_tooltip_daily
|
||||
aux.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
|
||||
aux_tooltip_vendor_buy = not aux_tooltip_vendor_buy
|
||||
aux.log('Vendor buy price in tooltip '..(aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_tooltip_vendor_buy = not _G.aux_tooltip_vendor_buy
|
||||
aux.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
|
||||
aux_tooltip_vendor_sell = not aux_tooltip_vendor_sell
|
||||
aux.log('Vendor sell price in tooltip '..(aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_tooltip_vendor_sell = not _G.aux_tooltip_vendor_sell
|
||||
aux.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
|
||||
aux_tooltip_disenchant_value = not aux_tooltip_disenchant_value
|
||||
aux.log('Disenchant value in tooltip '..(aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_tooltip_disenchant_value = not _G.aux_tooltip_disenchant_value
|
||||
aux.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
|
||||
aux_tooltip_disenchant_distribution = not aux_tooltip_disenchant_distribution
|
||||
aux.log('Disenchant distribution in tooltip '..(aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_tooltip_disenchant_distribution = not _G.aux_tooltip_disenchant_distribution
|
||||
aux.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
|
||||
aux_tooltip_disenchant_source = not aux_tooltip_disenchant_source
|
||||
aux.log('Disenchant source in tooltip '..(aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_tooltip_disenchant_source = not _G.aux_tooltip_disenchant_source
|
||||
aux.log('Disenchant source in tooltip '..(_G.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
|
||||
aux_ignore_owner = not aux_ignore_owner
|
||||
aux.log('Ignoring of owner '..(aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||
_G.aux_ignore_owner = not _G.aux_ignore_owner
|
||||
aux.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'
|
||||
aux_characters[realm] = aux_characters[realm] or {}
|
||||
_G.aux_characters[realm] = _G.aux_characters[realm] or {}
|
||||
for i=3,getn(arguments) do
|
||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if not aux_characters[realm][name] then
|
||||
aux_characters[realm][name] = true
|
||||
if not _G.aux_characters[realm][name] then
|
||||
_G.aux_characters[realm][name] = true
|
||||
aux.log('Character "'..name..'" added.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
|
||||
local realm = GetCVar 'realmName'
|
||||
if not aux_characters[realm] then
|
||||
if not _G.aux_characters[realm] then
|
||||
return
|
||||
end
|
||||
for i=3,getn(arguments) do
|
||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if aux_characters[realm][name] then
|
||||
aux_characters[realm][name] = nil
|
||||
if _G.aux_characters[realm][name] then
|
||||
_G.aux_characters[realm][name] = nil
|
||||
aux.log('Character "'..name..'" removed.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' then
|
||||
local realm = GetCVar 'realmName'
|
||||
local chars = {}
|
||||
for name, _ in aux_characters[realm] or {} do
|
||||
for name, _ in _G.aux_characters[realm] or {} do
|
||||
tinsert(chars, name)
|
||||
end
|
||||
if getn(chars) > 0 then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
aux.module 'tooltip'
|
||||
|
||||
aux_tooltip_value = true
|
||||
_G.aux_tooltip_value = true
|
||||
|
||||
private.game_tooltip_hooks = {}
|
||||
private.hooked_setter = nil
|
||||
@@ -47,7 +47,7 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
local item_id, suffix_id = aux.info.parse_hyperlink(hyperlink)
|
||||
quantity = IsShiftKeyDown() and quantity or 1
|
||||
|
||||
if aux_tooltip_disenchant_source then
|
||||
if _G.aux_tooltip_disenchant_source then
|
||||
local color = {r=0.7, g=0.7, b=0.7}
|
||||
|
||||
local type, range = aux.disenchant.source(item_id)
|
||||
@@ -69,7 +69,7 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
|
||||
if getn(distribution) > 0 then
|
||||
|
||||
if aux_tooltip_disenchant_distribution then
|
||||
if _G.aux_tooltip_disenchant_distribution then
|
||||
local color = {r=0.8, g=0.8, b=0.2}
|
||||
|
||||
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
|
||||
@@ -79,7 +79,7 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
if aux_tooltip_disenchant_value then
|
||||
if _G.aux_tooltip_disenchant_value then
|
||||
local color = {r=0.1, g=0.6, b=0.6}
|
||||
|
||||
local disenchant_value = aux.disenchant.value(item_info.slot, item_info.quality, item_info.level)
|
||||
@@ -88,7 +88,7 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
if aux_tooltip_vendor_buy then
|
||||
if _G.aux_tooltip_vendor_buy then
|
||||
local color = {r=0.8, g=0.5, b=0.1}
|
||||
|
||||
local _, price, limited = aux.cache.merchant_info(item_id)
|
||||
@@ -96,7 +96,7 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..aux.money.format(price * quantity), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
if aux_tooltip_vendor_sell then
|
||||
if _G.aux_tooltip_vendor_sell then
|
||||
local color = {r=0.8, g=0.5, b=0.1}
|
||||
|
||||
local price = aux.cache.merchant_info(item_id)
|
||||
@@ -112,10 +112,10 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
|
||||
local value = aux.history.value(item_key)
|
||||
if auctionable then
|
||||
if aux_tooltip_value then
|
||||
if _G.aux_tooltip_value then
|
||||
tooltip:AddLine('Value: '..(value and aux.money.format(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
if aux_tooltip_daily then
|
||||
if _G.aux_tooltip_daily then
|
||||
local market_value = aux.history.market_value(item_key)
|
||||
tooltip:AddLine('Today: '..(market_value and aux.money.format(market_value * quantity)..' ('..aux.auction_listing.percentage_historical(aux.util.round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user