editbox changes

This commit is contained in:
Manuel Simon Hirsig
2016-08-19 16:03:29 +02:00
parent 829483900e
commit 37e789184b
18 changed files with 422 additions and 404 deletions
+41 -41
View File
@@ -6,27 +6,27 @@ 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 = {}
_G.aux_item_ids = {}
_G.aux_auctionable_items = {}
_G.aux_merchant_buy = {}
_G.aux_merchant_sell = {}
_G.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()
function LOAD()
scan_wdb()
aux.control.event_listener('MERCHANT_SHOW', m.on_merchant_show)
aux.control.event_listener('MERCHANT_CLOSED', m.on_merchant_closed)
aux.control.event_listener('MERCHANT_UPDATE', m.on_merchant_update)
aux.control.event_listener('BAG_UPDATE', m.on_bag_update)
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)
CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', m.merchant_on_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)
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)
@@ -36,8 +36,8 @@ do
local sell_scan_countdown, incomplete_buy_data
function on_merchant_show()
m.merchant_sell_scan()
incomplete_buy_data = not m.merchant_buy_scan()
merchant_sell_scan()
incomplete_buy_data = not merchant_buy_scan()
end
function on_merchant_closed()
@@ -47,7 +47,7 @@ do
function on_merchant_update()
if incomplete_buy_data then
incomplete_buy_data = not m.merchant_buy_scan()
incomplete_buy_data = not merchant_buy_scan()
end
end
@@ -60,7 +60,7 @@ do
function merchant_on_update()
if sell_scan_countdown == 0 then
sell_scan_countdown = nil
m.merchant_sell_scan()
merchant_sell_scan()
elseif sell_scan_countdown then
sell_scan_countdown = sell_scan_countdown - 1
end
@@ -78,17 +78,17 @@ end
function public.merchant_info(item_id)
local buy_info
if _G.aux_merchant_buy[item_id] then
buy_info = aux.persistence.read(m.merchant_buy_schema, _G.aux_merchant_buy[item_id])
if g.aux_merchant_buy[item_id] then
buy_info = aux.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 = aux.persistence.read(m.items_schema, data_string)
local cached_data = aux.persistence.read(items_schema, data_string)
return {
name = cached_data.name,
itemstring = 'item:'..item_id..':0:0:0',
@@ -104,7 +104,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()
@@ -116,8 +116,8 @@ function merchant_buy_scan()
if link then
local item_id = aux.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(m.merchant_buy_schema, _G.aux_merchant_buy[item_id])
if g.aux_merchant_buy[item_id] then
local buy_info = aux.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(m.merchant_buy_schema, {
g.aux_merchant_buy[item_id] = aux.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(m.merchant_buy_schema, {
g.aux_merchant_buy[item_id] = aux.persistence.write(merchant_buy_schema, {
unit_price = new_unit_price,
limited = new_limited,
})
@@ -150,21 +150,21 @@ function merchant_sell_scan()
for slot in aux.util.inventory() do
local item_info = aux.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
function scan_wdb(item_id)
item_id = item_id or m.MIN_ITEM_ID
item_id = item_id or MIN_ITEM_ID
local processed = 0
while processed <= 100 and item_id <= m.MAX_ITEM_ID do
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] = 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(items_schema, {
name = name,
quality = quality,
level = level,
@@ -176,25 +176,25 @@ function scan_wdb(item_id)
})
local tooltip = aux.info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
if aux.info.auctionable(tooltip, quality) then
tinsert(_G.aux_auctionable_items, strlower(name))
tinsert(g.aux_auctionable_items, strlower(name))
end
processed = processed + 1
end
item_id = item_id + 1
end
if item_id <= m.MAX_ITEM_ID then
if item_id <= MAX_ITEM_ID then
local t0 = GetTime()
aux.control.thread(aux.control.when, function() return GetTime() - t0 > 0.1 end, m.scan_wdb, item_id)
aux.control.thread(aux.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)
sort(g.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
end
end
function public.populate_wdb(item_id)
item_id = item_id or m.MIN_ITEM_ID
item_id = item_id or MIN_ITEM_ID
if item_id > m.MAX_ITEM_ID then
if item_id > MAX_ITEM_ID then
aux.log('Cache populated.')
return
end
@@ -204,5 +204,5 @@ function public.populate_wdb(item_id)
AuxTooltip:SetHyperlink('item:'..item_id)
end
aux.control.thread(m.populate_wdb, item_id + 1)
aux.control.thread(populate_wdb, item_id + 1)
end
+2 -2
View File
@@ -145,7 +145,7 @@ function scan_page(i)
end
local auction_info = aux.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
@@ -216,7 +216,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 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 owner_data_complete('list')) or last_update and GetTime() - last_update > 5
+29 -29
View File
@@ -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
_G.aux_datasets = {}
g.aux_datasets = {}
aux.log 'Datasets cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
_G.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
_G.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
_G.aux_items = {}
_G.aux_item_ids = {}
_G.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
_G.aux_tooltip_value = not _G.aux_tooltip_value
aux.log('Historical value in tooltip '..(_G.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
_G.aux_tooltip_daily = not _G.aux_tooltip_daily
aux.log('Market value in tooltip '..(_G.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
_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')..'.')
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
_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')..'.')
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
_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')..'.')
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
_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')..'.')
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
_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')..'.')
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
_G.aux_ignore_owner = not _G.aux_ignore_owner
aux.log('Ignoring of owner '..(_G.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'
_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 = string.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
aux.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 = string.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
aux.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
+8 -8
View File
@@ -1,6 +1,6 @@
aux.module 'tooltip'
_G.aux_tooltip_value = true
g.aux_tooltip_value = true
game_tooltip_hooks = {}
hooked_setter = nil
@@ -47,7 +47,7 @@ function extend_tooltip(tooltip, link, quantity)
local item_id, suffix_id = aux.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=0.7, g=0.7, b=0.7}
local type, range = aux.disenchant.source(item_id)
@@ -69,7 +69,7 @@ function extend_tooltip(tooltip, link, quantity)
if getn(distribution) > 0 then
if _G.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 extend_tooltip(tooltip, link, quantity)
end
end
if _G.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 extend_tooltip(tooltip, link, quantity)
end
end
if _G.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 extend_tooltip(tooltip, link, quantity)
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..aux.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=0.8, g=0.5, b=0.1}
local price = aux.cache.merchant_info(item_id)
@@ -112,10 +112,10 @@ function extend_tooltip(tooltip, link, quantity)
local value = aux.history.value(item_key)
if auctionable then
if _G.aux_tooltip_value then
if g.aux_tooltip_value then
tooltip:AddLine('Value: '..(value and aux.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 = aux.history.market_value(item_key)
tooltip:AddLine('Today: '..(market_value and aux.money.to_string2(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