big refactoring
This commit is contained in:
+20
-20
@@ -16,17 +16,17 @@ g.aux_characters = {}
|
||||
function LOAD()
|
||||
scan_wdb()
|
||||
|
||||
aux.control.event_listener('MERCHANT_SHOW', on_merchant_show)
|
||||
aux.control.event_listener('MERCHANT_CLOSED', on_merchant_closed)
|
||||
aux.control.event_listener('MERCHANT_UPDATE', on_merchant_update)
|
||||
aux.control.event_listener('BAG_UPDATE', on_bag_update)
|
||||
control.event_listener('MERCHANT_SHOW', on_merchant_show)
|
||||
control.event_listener('MERCHANT_CLOSED', on_merchant_closed)
|
||||
control.event_listener('MERCHANT_UPDATE', on_merchant_update)
|
||||
control.event_listener('BAG_UPDATE', on_bag_update)
|
||||
|
||||
CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', merchant_on_update)
|
||||
|
||||
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
|
||||
g.aux_merchant_sell[aux.cache.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count)
|
||||
control.event_listener('NEW_AUCTION_UPDATE', function()
|
||||
for _, info in {info.auction_sell_item()} do
|
||||
for _, item_id in {cache.item_id(info.name)} do
|
||||
g.aux_merchant_sell[cache.item_id(info.name)] = info.vendor_price / (info.max_item_charges(item_id) or info.count)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -79,7 +79,7 @@ end
|
||||
function public.merchant_info(item_id)
|
||||
local buy_info
|
||||
if g.aux_merchant_buy[item_id] then
|
||||
buy_info = aux.persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id])
|
||||
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
|
||||
@@ -88,7 +88,7 @@ end
|
||||
function public.item_info(item_id)
|
||||
local data_string = g.aux_items[item_id]
|
||||
if data_string then
|
||||
local cached_data = aux.persistence.read(items_schema, data_string)
|
||||
local cached_data = persistence.read(items_schema, data_string)
|
||||
return {
|
||||
name = cached_data.name,
|
||||
itemstring = 'item:'..item_id..':0:0:0',
|
||||
@@ -114,10 +114,10 @@ function merchant_buy_scan()
|
||||
local _, _, price, count, stock = GetMerchantItemInfo(i)
|
||||
local link = GetMerchantItemLink(i)
|
||||
if link then
|
||||
local item_id = aux.info.parse_link(link)
|
||||
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 = aux.persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id])
|
||||
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
|
||||
@@ -128,12 +128,12 @@ function merchant_buy_scan()
|
||||
unit_price = min(buy_info.unit_price, new_unit_price)
|
||||
end
|
||||
|
||||
g.aux_merchant_buy[item_id] = aux.persistence.write(merchant_buy_schema, {
|
||||
g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
|
||||
unit_price = unit_price,
|
||||
limited = buy_info.limited and new_limited,
|
||||
})
|
||||
else
|
||||
g.aux_merchant_buy[item_id] = aux.persistence.write(merchant_buy_schema, {
|
||||
g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
|
||||
unit_price = new_unit_price,
|
||||
limited = new_limited,
|
||||
})
|
||||
@@ -148,7 +148,7 @@ end
|
||||
|
||||
function merchant_sell_scan()
|
||||
for slot in inventory do
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
local item_info = 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
|
||||
end
|
||||
@@ -164,7 +164,7 @@ function scan_wdb(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] = aux.persistence.write(items_schema, {
|
||||
g.aux_items[item_id] = persistence.write(items_schema, {
|
||||
name = name,
|
||||
quality = quality,
|
||||
level = level,
|
||||
@@ -174,8 +174,8 @@ function scan_wdb(item_id)
|
||||
max_stack = max_stack,
|
||||
texture = texture,
|
||||
})
|
||||
local tooltip = aux.info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
|
||||
if aux.info.auctionable(tooltip, quality) then
|
||||
local tooltip = info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
|
||||
if info.auctionable(tooltip, quality) then
|
||||
tinsert(g.aux_auctionable_items, strlower(name))
|
||||
end
|
||||
processed = processed + 1
|
||||
@@ -185,7 +185,7 @@ function scan_wdb(item_id)
|
||||
|
||||
if item_id <= MAX_ITEM_ID then
|
||||
local t0 = GetTime()
|
||||
aux.control.thread(aux.control.when, function() return GetTime() - t0 > 0.1 end, scan_wdb, item_id)
|
||||
control.thread(control.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)
|
||||
end
|
||||
@@ -204,5 +204,5 @@ function public.populate_wdb(item_id)
|
||||
AuxTooltip:SetHyperlink('item:'..item_id)
|
||||
end
|
||||
|
||||
aux.control.thread(populate_wdb, item_id + 1)
|
||||
control.thread(populate_wdb, item_id + 1)
|
||||
end
|
||||
Reference in New Issue
Block a user