big refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-21 14:29:01 +02:00
parent 2b9a63fe8c
commit 590347a1e5
23 changed files with 236 additions and 263 deletions
+22 -22
View File
@@ -6,12 +6,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'}} 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'} } merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'} }
g.aux_items = {} _g.aux_items = {}
g.aux_item_ids = {} _g.aux_item_ids = {}
g.aux_auctionable_items = {} _g.aux_auctionable_items = {}
g.aux_merchant_buy = {} _g.aux_merchant_buy = {}
g.aux_merchant_sell = {} _g.aux_merchant_sell = {}
g.aux_characters = {} _g.aux_characters = {}
function LOAD() function LOAD()
scan_wdb() scan_wdb()
@@ -26,7 +26,7 @@ function LOAD()
control.event_listener('NEW_AUCTION_UPDATE', function() control.event_listener('NEW_AUCTION_UPDATE', function()
for _, info in {info.auction_sell_item()} do for _, info in {info.auction_sell_item()} do
for _, item_id in {cache.item_id(info.name)} 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) _g.aux_merchant_sell[cache.item_id(info.name)] = info.vendor_price / (info.max_item_charges(item_id) or info.count)
end end
end end
end) end)
@@ -78,15 +78,15 @@ end
function public.merchant_info(item_id) function public.merchant_info(item_id)
local buy_info local buy_info
if g.aux_merchant_buy[item_id] then if _g.aux_merchant_buy[item_id] then
buy_info = 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 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 end
function public.item_info(item_id) 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 if data_string then
local cached_data = persistence.read(items_schema, data_string) local cached_data = persistence.read(items_schema, data_string)
return { return {
@@ -104,7 +104,7 @@ function public.item_info(item_id)
end end
function public.item_id(item_name) function public.item_id(item_name)
return g.aux_item_ids[strlower(item_name)] return _g.aux_item_ids[strlower(item_name)]
end end
function merchant_buy_scan() function merchant_buy_scan()
@@ -116,8 +116,8 @@ function merchant_buy_scan()
if link then if link then
local item_id = info.parse_link(link) local item_id = info.parse_link(link)
local new_unit_price, new_limited = price / count, stock >= 0 local new_unit_price, new_limited = price / count, stock >= 0
if g.aux_merchant_buy[item_id] then if _g.aux_merchant_buy[item_id] then
local buy_info = 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 local unit_price
if buy_info.limited and not new_limited then 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) unit_price = min(buy_info.unit_price, new_unit_price)
end end
g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, { _g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
unit_price = unit_price, unit_price = unit_price,
limited = buy_info.limited and new_limited, limited = buy_info.limited and new_limited,
}) })
else else
g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, { _g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
unit_price = new_unit_price, unit_price = new_unit_price,
limited = new_limited, limited = new_limited,
}) })
@@ -150,7 +150,7 @@ function merchant_sell_scan()
for slot in inventory do for slot in inventory do
local item_info = info.container_item(unpack(slot)) local item_info = info.container_item(unpack(slot))
if item_info then 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 end
end end
@@ -162,9 +162,9 @@ function scan_wdb(item_id)
while processed <= 100 and item_id <= MAX_ITEM_ID do while processed <= 100 and item_id <= MAX_ITEM_ID do
local itemstring = 'item:'..item_id local itemstring = 'item:'..item_id
local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring) local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
if name and not g.aux_item_ids[strlower(name)] then if name and not _g.aux_item_ids[strlower(name)] then
g.aux_item_ids[strlower(name)] = item_id _g.aux_item_ids[strlower(name)] = item_id
g.aux_items[item_id] = persistence.write(items_schema, { _g.aux_items[item_id] = persistence.write(items_schema, {
name = name, name = name,
quality = quality, quality = quality,
level = level, level = level,
@@ -176,7 +176,7 @@ function scan_wdb(item_id)
}) })
local tooltip = info.tooltip(function(tt) tt:SetHyperlink(itemstring) end) local tooltip = info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
if info.auctionable(tooltip, quality) then if info.auctionable(tooltip, quality) then
tinsert(g.aux_auctionable_items, strlower(name)) tinsert(_g.aux_auctionable_items, strlower(name))
end end
processed = processed + 1 processed = processed + 1
end end
@@ -187,7 +187,7 @@ function scan_wdb(item_id)
local t0 = GetTime() local t0 = GetTime()
control.thread(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 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
end end
+8 -8
View File
@@ -40,7 +40,7 @@ do
end end
end end
function m.LOAD() function LOAD()
armor = set( armor = set(
'INVTYPE_HEAD', 'INVTYPE_HEAD',
'INVTYPE_NECK', 'INVTYPE_NECK',
@@ -72,7 +72,7 @@ end
function public.value(slot, quality, level) function public.value(slot, quality, level)
local expectation local expectation
for _, event in m.distribution(slot, quality, level) do for _, event in distribution(slot, quality, level) do
local value = history.value(event.item_id..':'..0) local value = history.value(event.item_id..':'..0)
if not value then if not value then
return return
@@ -84,19 +84,19 @@ function public.value(slot, quality, level)
end end
function public.distribution(slot, quality, level) function public.distribution(slot, quality, level)
if not (m.armor(slot) or m.weapon(slot)) or level == 0 then if not (armor(slot) or weapon(slot)) or level == 0 then
return {} return {}
end end
local function p(probability_armor, probability_weapon) local function p(probability_armor, probability_weapon)
if m.armor(slot) then if armor(slot) then
return probability_armor return probability_armor
elseif m.weapon(slot) then elseif weapon(slot) then
return probability_weapon return probability_weapon
end end
end end
if quality == m.UNCOMMON then if quality == UNCOMMON then
if level <= 10 then if level <= 10 then
return { return {
{item_id=10940, min_quantity=1, max_quantity=2, probability=p(0.8, 0.2)}, {item_id=10940, min_quantity=1, max_quantity=2, probability=p(0.8, 0.2)},
@@ -163,7 +163,7 @@ function public.distribution(slot, quality, level)
{item_id=14344, min_quantity=1, max_quantity=1, probability=p(0.05, 0.03)}, {item_id=14344, min_quantity=1, max_quantity=1, probability=p(0.05, 0.03)},
} }
end end
elseif quality == m.RARE then elseif quality == RARE then
if level <= 20 then if level <= 20 then
return {{item_id=10978, min_quantity=1, max_quantity=1, probability=1}} return {{item_id=10978, min_quantity=1, max_quantity=1, probability=1}}
elseif level <= 25 then elseif level <= 25 then
@@ -183,7 +183,7 @@ function public.distribution(slot, quality, level)
elseif level <= 60 then elseif level <= 60 then
return {{item_id=14344, min_quantity=1, max_quantity=1, probability=0.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=0.005}} return {{item_id=14344, min_quantity=1, max_quantity=1, probability=0.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=0.005}}
end end
elseif quality == m.EPIC then elseif quality == EPIC then
if level <= 40 then if level <= 40 then
return {{item_id=11177, min_quantity=2, max_quantity=4, probability=1}} return {{item_id=11177, min_quantity=2, max_quantity=4, probability=1}}
elseif level <= 45 then elseif level <= 45 then
+20 -20
View File
@@ -10,7 +10,7 @@ function next_push()
end end
function new_record() function new_record()
return { next_push = m.next_push(), data_points = {} } return { next_push = next_push(), data_points = {} }
end end
function load_data() function load_data()
@@ -20,31 +20,31 @@ function load_data()
end end
function read_record(item_key) function read_record(item_key)
local data = m.load_data() local data = load_data()
local record local record
if data[item_key] then if data[item_key] then
record = persistence.read(history_schema, data[item_key]) record = persistence.read(history_schema, data[item_key])
else else
record = m.new_record() record = new_record()
end end
if record.next_push <= time() then if record.next_push <= time() then
m.push_record(record) push_record(record)
m.write_record(item_key, record) write_record(item_key, record)
end end
return record return record
end end
function write_record(item_key, record) function write_record(item_key, record)
m.value_cache[item_key] = nil value_cache[item_key] = nil
local data = m.load_data() local data = load_data()
data[item_key] = persistence.write(history_schema, record) data[item_key] = persistence.write(history_schema, record)
end end
function public.process_auction(auction_record) function public.process_auction(auction_record)
local item_record = m.read_record(auction_record.item_key) local item_record = read_record(auction_record.item_key)
local unit_bid_price = ceil(auction_record.bid_price / auction_record.aux_quantity) local unit_bid_price = ceil(auction_record.bid_price / auction_record.aux_quantity)
local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity) local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity)
@@ -55,17 +55,17 @@ function public.process_auction(auction_record)
item_record.daily_max_price = max(item_record.daily_max_price or 0, unit_buyout_price, unit_bid_price) item_record.daily_max_price = max(item_record.daily_max_price or 0, unit_buyout_price, unit_bid_price)
m.write_record(auction_record.item_key, item_record) write_record(auction_record.item_key, item_record)
end end
function public.price_data(item_key) function public.price_data(item_key)
local item_record = m.read_record(item_key) local item_record = read_record(item_key)
return item_record.daily_min_buyout, item_record.daily_max_price, item_record.data_points return item_record.daily_min_buyout, item_record.daily_max_price, item_record.data_points
end end
function public.value(item_key) function public.value(item_key)
if not m.value_cache[item_key] or m.value_cache[item_key].next_push <= time() then if not value_cache[item_key] or value_cache[item_key].next_push <= time() then
local item_record = m.read_record(item_key) local item_record = read_record(item_key)
local value local value
if getn(item_record.data_points) > 0 then if getn(item_record.data_points) > 0 then
@@ -80,20 +80,20 @@ function public.value(item_key)
weighted_value.weight = weighted_value.weight / total_weight weighted_value.weight = weighted_value.weight / total_weight
end end
value = m.weighted_median(weighted_values) value = weighted_median(weighted_values)
else else
value = m.calculate_market_value(item_record) value = calculate_market_value(item_record)
end end
m.value_cache[item_key] = {value=value, next_push=item_record.next_push} value_cache[item_key] = {value=value, next_push=item_record.next_push}
end end
return m.value_cache[item_key].value return value_cache[item_key].value
end end
function public.market_value(item_key) function public.market_value(item_key)
local item_record = m.read_record(item_key) local item_record = read_record(item_key)
return m.calculate_market_value(item_record) return calculate_market_value(item_record)
end end
function calculate_market_value(item_record) function calculate_market_value(item_record)
@@ -118,7 +118,7 @@ end
function push_record(item_record) function push_record(item_record)
local market_value = m.calculate_market_value(item_record) local market_value = calculate_market_value(item_record)
if market_value then if market_value then
tinsert(item_record.data_points, 1, { market_value = market_value, time = item_record.next_push }) tinsert(item_record.data_points, 1, { market_value = market_value, time = item_record.next_push })
while getn(item_record.data_points) > 11 do while getn(item_record.data_points) > 11 do
@@ -128,5 +128,5 @@ function push_record(item_record)
item_record.daily_min_buyout = nil item_record.daily_min_buyout = nil
item_record.daily_max_price = nil item_record.daily_max_price = nil
item_record.next_push = m.next_push() item_record.next_push = next_push()
end end
+17 -17
View File
@@ -3,7 +3,7 @@ aux.module 'post'
state = nil state = nil
function process() function process()
if m.state.posted < m.state.count then if state.posted < state.count then
local stacking_complete local stacking_complete
@@ -11,21 +11,21 @@ function process()
control.when(signal_received, function() control.when(signal_received, function()
local slot = signal_received()[1] local slot = signal_received()[1]
if slot then if slot then
return m.post_auction(slot, m.process) return post_auction(slot, process)
else else
return m.stop() return stop()
end end
end) end)
return stack.start(m.state.item_key, m.state.stack_size, send_signal) return stack.start(state.item_key, state.stack_size, send_signal)
end end
return m.stop() return stop()
end end
function post_auction(slot, k) function post_auction(slot, k)
local item_info = info.container_item(unpack(slot)) local item_info = info.container_item(unpack(slot))
if item_info.item_key == m.state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
ClearCursor() ClearCursor()
ClickAuctionSellItemButton() ClickAuctionSellItemButton()
@@ -34,11 +34,11 @@ function post_auction(slot, k)
ClickAuctionSellItemButton() ClickAuctionSellItemButton()
ClearCursor() ClearCursor()
StartAuction(max(1, round(m.state.unit_start_price * item_info.aux_quantity)), round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration) StartAuction(max(1, round(state.unit_start_price * item_info.aux_quantity)), round(state.unit_buyout_price * item_info.aux_quantity), state.duration)
local send_signal, signal_received = signal() local send_signal, signal_received = signal()
control.when(signal_received, function() control.when(signal_received, function()
m.state.posted = m.state.posted + 1 state.posted = state.posted + 1
return k() return k()
end) end)
@@ -50,18 +50,18 @@ function post_auction(slot, k)
end end
end) end)
else else
return m.stop() return stop()
end end
end end
function public.stop() function public.stop()
if m.state then if state then
control.kill_thread(m.state.thread_id) control.kill_thread(state.thread_id)
local callback = m.state.callback local callback = state.callback
local posted = m.state.posted local posted = state.posted
m.state = nil state = nil
if callback then if callback then
callback(posted) callback(posted)
@@ -70,11 +70,11 @@ function public.stop()
end end
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback) function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
m.stop() stop()
local thread_id = control.thread(m.process) local thread_id = control.thread(process)
m.state = { state = {
thread_id = thread_id, thread_id = thread_id,
item_key = item_key, item_key = item_key,
stack_size = stack_size, stack_size = stack_size,
+2 -2
View File
@@ -145,7 +145,7 @@ function scan_page(i)
end end
local auction_info = info.auction(i, state.params.type) 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.index = i
auction_info.page = state.page auction_info.page = state.page
auction_info.blizzard_query = query.blizzard_query auction_info.blizzard_query = query.blizzard_query
@@ -216,7 +216,7 @@ function wait_for_list_results(send_signal, signal_received)
last_update = GetTime() last_update = GetTime()
updated = true updated = true
end) 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 control.thread(control.when, function() return control.thread(control.when, function()
-- short circuiting order important, owner_data_complete must be called iif an update has happened. -- 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 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)
persistence.load_dataset().post = nil persistence.load_dataset().post = nil
log 'Post settings cleared.' log 'Post settings cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
g.aux_datasets = {} _g.aux_datasets = {}
log 'Datasets cleared.' log 'Datasets cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then 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.' log 'Merchant buy prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then 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.' log 'Merchant sell prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
g.aux_items = {} _g.aux_items = {}
g.aux_item_ids = {} _g.aux_item_ids = {}
g.aux_auctionable_items = {} _g.aux_auctionable_items = {}
log 'Item cache cleared.' log 'Item cache cleared.'
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
cache.populate_wdb() cache.populate_wdb()
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
g.aux_tooltip_value = not g.aux_tooltip_value _g.aux_tooltip_value = not _g.aux_tooltip_value
log('Historical value in tooltip '..(g.aux_tooltip_value and 'enabled' or 'disabled')..'.') log('Historical value in tooltip '..(_g.aux_tooltip_value and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
g.aux_tooltip_daily = not g.aux_tooltip_daily _g.aux_tooltip_daily = not _g.aux_tooltip_daily
log('Market value in tooltip '..(g.aux_tooltip_daily and 'enabled' or 'disabled')..'.') 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 elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then
g.aux_tooltip_vendor_buy = not g.aux_tooltip_vendor_buy _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')..'.') 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 elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then
g.aux_tooltip_vendor_sell = not g.aux_tooltip_vendor_sell _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')..'.') 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 elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
g.aux_tooltip_disenchant_value = not g.aux_tooltip_disenchant_value _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')..'.') 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 elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then
g.aux_tooltip_disenchant_distribution = not g.aux_tooltip_disenchant_distribution _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')..'.') 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 elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then
g.aux_tooltip_disenchant_source = not g.aux_tooltip_disenchant_source _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')..'.') log('Disenchant source in tooltip '..(_g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
g.aux_ignore_owner = not g.aux_ignore_owner _g.aux_ignore_owner = not _g.aux_ignore_owner
log('Ignoring of owner '..(g.aux_ignore_owner and 'enabled' or 'disabled')..'.') log('Ignoring of owner '..(_g.aux_ignore_owner and 'enabled' or 'disabled')..'.')
elseif arguments[1] == 'chars' and arguments[2] == 'add' then elseif arguments[1] == 'chars' and arguments[2] == 'add' then
local realm = GetCVar 'realmName' 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 for i=3,getn(arguments) do
local name = string.gsub(strlower(arguments[i]), '^%l', strupper) local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
if not g.aux_characters[realm][name] then if not _g.aux_characters[realm][name] then
g.aux_characters[realm][name] = true _g.aux_characters[realm][name] = true
log('Character "'..name..'" added.') log('Character "'..name..'" added.')
end end
end end
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
local realm = GetCVar 'realmName' local realm = GetCVar 'realmName'
if not g.aux_characters[realm] then if not _g.aux_characters[realm] then
return return
end end
for i=3,getn(arguments) do for i=3,getn(arguments) do
local name = string.gsub(strlower(arguments[i]), '^%l', strupper) local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
if g.aux_characters[realm][name] then if _g.aux_characters[realm][name] then
g.aux_characters[realm][name] = nil _g.aux_characters[realm][name] = nil
log('Character "'..name..'" removed.') log('Character "'..name..'" removed.')
end end
end end
elseif arguments[1] == 'chars' then elseif arguments[1] == 'chars' then
local realm = GetCVar 'realmName' local realm = GetCVar 'realmName'
local chars = {} local chars = {}
for name in g.aux_characters[realm] or {} do for name in _g.aux_characters[realm] or {} do
tinsert(chars, name) tinsert(chars, name)
end end
if getn(chars) > 0 then if getn(chars) > 0 then
+35 -35
View File
@@ -24,7 +24,7 @@ end
function find_item_slot(partial) function find_item_slot(partial)
for slot in inventory do for slot in inventory do
if m.matching_item(slot, partial) and not eq(slot, m.state.target_slot) then if matching_item(slot, partial) and not eq(slot, state.target_slot) then
return slot return slot
end end
end end
@@ -32,7 +32,7 @@ end
function matching_item(slot, partial) function matching_item(slot, partial)
local item_info = info.container_item(unpack(slot)) local item_info = info.container_item(unpack(slot))
return item_info and item_info.item_key == m.state.item_key and info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack) return item_info and item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
end end
function find_empty_slot() function find_empty_slot()
@@ -45,81 +45,81 @@ end
function find_charge_item_slot() function find_charge_item_slot()
for slot in inventory do for slot in inventory do
if m.matching_item(slot) and m.charges(slot) == m.state.target_size then if matching_item(slot) and charges(slot) == state.target_size then
return slot return slot
end end
end end
end end
function move_item(from_slot, to_slot, amount, k) function move_item(from_slot, to_slot, amount, k)
if m.locked(from_slot) or m.locked(to_slot) then if locked(from_slot) or locked(to_slot) then
return control.wait(k) return control.wait(k)
end end
amount = min(m.max_stack(from_slot) - m.stack_size(to_slot), m.stack_size(from_slot), amount) amount = min(max_stack(from_slot) - stack_size(to_slot), stack_size(from_slot), amount)
local expected_size = m.stack_size(to_slot) + amount local expected_size = stack_size(to_slot) + amount
ClearCursor() ClearCursor()
SplitContainerItem(from_slot[1], from_slot[2], amount) SplitContainerItem(from_slot[1], from_slot[2], amount)
PickupContainerItem(unpack(to_slot)) PickupContainerItem(unpack(to_slot))
return control.when(function() return m.stack_size(to_slot) == expected_size end, k) return control.when(function() return stack_size(to_slot) == expected_size end, k)
end end
function process() function process()
if not m.state.target_slot or not m.matching_item(m.state.target_slot) then if not state.target_slot or not matching_item(state.target_slot) then
m.state.target_slot = m.find_item_slot() state.target_slot = find_item_slot()
if not m.state.target_slot then if not state.target_slot then
return m.stop() return stop()
end end
end end
if m.charges(m.state.target_slot) then if charges(state.target_slot) then
m.state.target_slot = m.find_charge_item_slot() state.target_slot = find_charge_item_slot()
return m.stop() return stop()
end end
if m.stack_size(m.state.target_slot) > m.state.target_size then if stack_size(state.target_slot) > state.target_size then
local slot = m.find_item_slot(true) or m.find_empty_slot() local slot = find_item_slot(true) or find_empty_slot()
if slot then if slot then
return m.move_item( return move_item(
m.state.target_slot, state.target_slot,
slot, slot,
m.stack_size(m.state.target_slot) - m.state.target_size, stack_size(state.target_slot) - state.target_size,
m.process process
) )
end end
elseif m.stack_size(m.state.target_slot) < m.state.target_size then elseif stack_size(state.target_slot) < state.target_size then
local slot = m.find_item_slot() local slot = find_item_slot()
if slot then if slot then
return m.move_item( return move_item(
slot, slot,
m.state.target_slot, state.target_slot,
m.state.target_size - m.stack_size(m.state.target_slot), state.target_size - stack_size(state.target_slot),
m.process process
) )
end end
end end
return m.stop() return stop()
end end
function public.stop() function public.stop()
if m.state then if state then
control.kill_thread(m.state.thread_id) control.kill_thread(state.thread_id)
local callback, slot = m.state.callback, m.state.target_slot local callback, slot = state.callback, state.target_slot
if slot and not m.matching_item(slot) then if slot and not matching_item(slot) then
slot = nil slot = nil
end end
m.state = nil state = nil
call(callback, slot) call(callback, slot)
end end
end end
function public.start(item_key, size, callback) function public.start(item_key, size, callback)
m.stop() stop()
local thread_id = control.thread(m.process) local thread_id = control.thread(process)
m.state = { state = {
thread_id = thread_id, thread_id = thread_id,
item_key = item_key, item_key = item_key,
target_size = size, target_size = size,
+8 -8
View File
@@ -1,6 +1,6 @@
aux.module 'tooltip' aux.module 'tooltip'
g.aux_tooltip_value = true _g.aux_tooltip_value = true
game_tooltip_hooks = {} game_tooltip_hooks = {}
hooked_setter = nil hooked_setter = nil
@@ -47,7 +47,7 @@ function extend_tooltip(tooltip, link, quantity)
local item_id, suffix_id = info.parse_link(link) local item_id, suffix_id = info.parse_link(link)
quantity = IsShiftKeyDown() and quantity or 1 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 color = {r=0.7, g=0.7, b=0.7}
local type, range = disenchant.source(item_id) local type, range = disenchant.source(item_id)
@@ -69,7 +69,7 @@ function extend_tooltip(tooltip, link, quantity)
if getn(distribution) > 0 then 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} local color = {r=0.8, g=0.8, b=0.2}
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b) tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
@@ -79,7 +79,7 @@ function extend_tooltip(tooltip, link, quantity)
end end
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 color = {r=0.1, g=0.6, b=0.6}
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level) local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
@@ -88,7 +88,7 @@ function extend_tooltip(tooltip, link, quantity)
end end
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 color = {r=0.8, g=0.5, b=0.1}
local _, price, limited = cache.merchant_info(item_id) local _, price, limited = cache.merchant_info(item_id)
@@ -96,7 +96,7 @@ function extend_tooltip(tooltip, link, quantity)
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..money.to_string2(price * quantity), color.r, color.g, color.b) tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..money.to_string2(price * quantity), color.r, color.g, color.b)
end end
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 color = {r=0.8, g=0.5, b=0.1}
local price = cache.merchant_info(item_id) local price = cache.merchant_info(item_id)
@@ -112,10 +112,10 @@ function extend_tooltip(tooltip, link, quantity)
local value = history.value(item_key) local value = history.value(item_key)
if auctionable then 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) 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 end
if g.aux_tooltip_daily then if _g.aux_tooltip_daily then
local market_value = history.market_value(item_key) 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) 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 end
+3 -3
View File
@@ -77,10 +77,10 @@ do
end end
end end
public.orig = setmetatable({}, {__index=function(self, key) return self[g][key] end}) public.orig = setmetatable({}, {__index=function(self, key) return self[_g][key] end})
function public.hook(name, handler, object) function public.hook(name, handler, object)
handler = handler or getfenv(2)[name] handler = handler or getfenv(2)[name]
object = object or g object = object or _g
orig[object] = orig[object] or {} orig[object] = orig[object] or {}
assert(not orig[object][name] '"'..name..'" is already hooked into.') assert(not orig[object][name] '"'..name..'" is already hooked into.')
orig[object][name], object[name] = object[name], handler orig[object][name], object[name] = object[name], handler
@@ -129,7 +129,7 @@ end
function public.is_player(name, current) function public.is_player(name, current)
local realm = GetCVar 'realmName' 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 end
function public.neutral_faction() function public.neutral_faction()
+6 -6
View File
@@ -1,10 +1,10 @@
local type, setmetatable, setfenv, unpack, mask, g = type, setmetatable, setfenv, unpack, bit.band, getfenv(0) local type, setmetatable, setfenv, unpack, mask, _g = type, setmetatable, setfenv, unpack, bit.band, getfenv(0)
local PRIVATE, PUBLIC, MUTABLE, PROPERTY = 0, 1, 2, 4 local PRIVATE, PUBLIC, MUTABLE, PROPERTY = 0, 1, 2, 4
local MODIFIER = {private=PRIVATE, public=PUBLIC, mutable=MUTABLE, property=PROPERTY} local MODIFIER = {private=PRIVATE, public=PUBLIC, mutable=MUTABLE, property=PROPERTY}
local MODIFIER_MASK, PROPERTY_MASK = {private=MUTABLE+PROPERTY, public=MUTABLE+PROPERTY, mutable=PRIVATE+PUBLIC}, PRIVATE+PUBLIC local MODIFIER_MASK, PROPERTY_MASK = {private=MUTABLE+PROPERTY, public=MUTABLE+PROPERTY, mutable=PRIVATE+PUBLIC}, PRIVATE+PUBLIC
local error, import, define_property, lock_mt, env_mt, interface_mt, declarator_mt local error, import, define_property, lock_mt, env_mt, interface_mt, declarator_mt
local _state, _modules = {}, {} local _state, _modules = {}, {}
function error(message, level, ...) g.error(format(message, unpack(arg))..'\n'..debugstack(3, 5, 0), (level or 1) + 1) end function error(message, level, ...) _g.error(format(message, unpack(arg))..'\n'..debugstack(3, 5, 0), (level or 1) + 1) end
function import(imports, t) for k, v in t do imports[type(k) == 'number' and v or k] = v end end function import(imports, t) for k, v in t do imports[type(k) == 'number' and v or k] = v end end
declarator_mt = {__metatable=false} declarator_mt = {__metatable=false}
function define_property(self, key, t) function define_property(self, key, t)
@@ -44,7 +44,7 @@ do
end end
end end
end end
env_mt = {__metatable=false, __index=index(PRIVATE, g)} env_mt = {__metatable=false, __index=index(PRIVATE, _g)}
function env_mt.__newindex(self, key, value) function env_mt.__newindex(self, key, value)
local state = _state[self] local state = _state[self]
if not state.metadata[key] then if not state.metadata[key] then
@@ -66,14 +66,14 @@ do
end end
end end
end end
function g.aux_module(name) function _g.aux_module(name)
if not _state[name] then if not _state[name] then
local state, declarator, env, interface, imports local state, declarator, env, interface, imports
env, interface, declarator, imports = setmetatable({}, env_mt), setmetatable({}, interface_mt), setmetatable({}, declarator_mt), {} env, interface, declarator, imports = setmetatable({}, env_mt), setmetatable({}, interface_mt), setmetatable({}, declarator_mt), {}
state = { state = {
name = name, env = env, interface = interface, declarator = declarator, imports = {}, declarator_state = PRIVATE, name = name, env = env, interface = interface, declarator = declarator, imports = {}, declarator_state = PRIVATE,
metadata={_g=PRIVATE, _m=PRIVATE, _i=PRIVATE, import=PRIVATE, private=PROPERTY, public=PROPERTY, getter=PROPERTY, setter=PROPERTY, mutable=PROPERTY}, metadata={_g=PRIVATE, _m=PRIVATE, _i=PRIVATE, import=PRIVATE, private=PROPERTY, public=PROPERTY, getter=PROPERTY, setter=PROPERTY, mutable=PROPERTY},
data = {_g=g, _m=env, _i=interface, import=function(t) import(imports, t) end}, data = {_g=_g, _m=env, _i=interface, import=function(t) import(imports, t) end},
getters = {private=function() state.modifiers = PRIVATE return declarator end, public=function() state.modifiers = PUBLIC return declarator end, mutable=function() state.modifiers = MUTABLE return declarator end}, getters = {private=function() state.modifiers = PRIVATE return declarator end, public=function() state.modifiers = PUBLIC return declarator end, mutable=function() state.modifiers = MUTABLE return declarator end},
setters = {}, setters = {},
} }
@@ -107,5 +107,5 @@ frame:SetScript('OnEvent', function()
end end
end end
end end
g.aux.log('imported: '..count..' in '..(GetTime()-t0)) _g.aux.log('imported: '..count..' in '..(GetTime()-t0))
end) end)
+31 -31
View File
@@ -1,6 +1,6 @@
aux.module 'auction_listing' aux.module 'auction_listing'
g.aux_price_per_unit = false _g.aux_price_per_unit = false
local RT_COUNT = 1 local RT_COUNT = 1
local HEAD_HEIGHT = 27 local HEAD_HEIGHT = 27
@@ -166,24 +166,24 @@ public.search_config = {
end end
local price local price
if record.high_bidder then 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 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 end
cell:SetText(money.to_string(price, true, false, nil, color)) cell:SetText(money.to_string(price, true, false, nil, color))
end, end,
cmp = function(record_a, record_b, desc) cmp = function(record_a, record_b, desc)
local price_a local price_a
if record_a.high_bidder then 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 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 end
local price_b local price_b
if record_b.high_bidder then 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 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 end
return sorting.compare(price_a, price_b, desc) return sorting.compare(price_a, price_b, desc)
end, end,
@@ -194,12 +194,12 @@ public.search_config = {
align = 'RIGHT', align = 'RIGHT',
isPrice = true, isPrice = true,
fill = function(cell, record) 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 '---') cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end, end,
cmp = function(record_a, record_b, desc) 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_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_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_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) 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) fill = function(cell, record)
local price local price
if record.high_bidder then 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 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 end
cell:SetText(money.to_string(price, true, false)) cell:SetText(money.to_string(price, true, false))
end, end,
cmp = function(record_a, record_b, desc) cmp = function(record_a, record_b, desc)
local price_a local price_a
if record_a.high_bidder then 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 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 end
local price_b local price_b
if record_b.high_bidder then 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 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 end
return sorting.compare(price_a, price_b, desc) return sorting.compare(price_a, price_b, desc)
end, end,
@@ -336,12 +336,12 @@ public.auctions_config = {
align = 'RIGHT', align = 'RIGHT',
isPrice = true, isPrice = true,
fill = function(cell, record) 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 '---') cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end, end,
cmp = function(record_a, record_b, desc) 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_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_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_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) 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) fill = function(cell, record)
local price local price
if record.high_bidder then 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 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 end
cell:SetText(money.to_string(price)) cell:SetText(money.to_string(price))
end, end,
cmp = function(record_a, record_b, desc) cmp = function(record_a, record_b, desc)
local price_a local price_a
if record_a.high_bidder then 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 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 end
local price_b local price_b
if record_b.high_bidder then 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 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 end
return sorting.compare(price_a, price_b, desc) return sorting.compare(price_a, price_b, desc)
end, end,
@@ -489,12 +489,12 @@ public.bids_config = {
align = 'RIGHT', align = 'RIGHT',
isPrice = true, isPrice = true,
fill = function(cell, record) 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 '---') cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end, end,
cmp = function(record_a, record_b, desc) 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_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_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_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) 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 rt.disabled then return end
if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then 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 for _, cell in rt.headCells do
if cell.info.isPrice then 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 end
rt:SetSort() rt:SetSort()
@@ -1009,7 +1009,7 @@ function public.CreateAuctionResultsTable(parent, config)
rt:SetScript('OnShow', function() rt:SetScript('OnShow', function()
for _, cell in this.headCells do for _, cell in this.headCells do
if cell.info.isPrice then 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 end
end) end)
+5 -15
View File
@@ -37,21 +37,13 @@ function public.render(item_listing)
end end
function public.create(parent, on_click, selected) function public.create(parent, on_click, selected)
local name = 'g.aux_item_list'
local id = 1
while getglobal(name..id) do
id = id + 1
end
name = name..id
local content = CreateFrame('Frame', nil, parent) local content = CreateFrame('Frame', nil, parent)
content:SetPoint('TOPLEFT', 0, -51) content:SetPoint('TOPLEFT', 0, -51)
content:SetPoint('BOTTOMRIGHT', -15, 0) content:SetPoint('BOTTOMRIGHT', -15, 0)
local scroll_frame = CreateFrame('ScrollFrame', name..'ScrollFrame', parent, 'FauxScrollFrameTemplate') local scroll_frame = CreateFrame('ScrollFrame', gui.name..'ScrollFrame', parent, 'FauxScrollFrameTemplate')
scroll_frame:SetScript('OnVerticalScroll', function(self, offset) scroll_frame:SetScript('OnVerticalScroll', function(self, offset)
FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() m.render(this.item_listing) end) FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() render(this.item_listing) end)
end) end)
scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15) scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15)
scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15) scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15)
@@ -60,7 +52,7 @@ function public.create(parent, on_click, selected)
scrollBar:SetWidth(12) scrollBar:SetWidth(12)
local thumbTex = scrollBar:GetThumbTexture() local thumbTex = scrollBar:GetThumbTexture()
thumbTex:SetPoint('CENTER', 0, 0) thumbTex:SetPoint('CENTER', 0, 0)
thumbTex:SetTexture(unpack(gui.color.content.background)) thumbTex:SetTexture(gui.color.content.background())
thumbTex:SetHeight(50) thumbTex:SetHeight(50)
thumbTex:SetWidth(12) thumbTex:SetWidth(12)
getglobal(scrollBar:GetName()..'ScrollUpButton'):Hide() getglobal(scrollBar:GetName()..'ScrollUpButton'):Hide()
@@ -93,9 +85,7 @@ function public.create(parent, on_click, selected)
row.item.button:SetScript('OnEnter', function() row.item.button:SetScript('OnEnter', function()
info.set_tooltip(row.item_record.itemstring, this, 'ANCHOR_RIGHT') info.set_tooltip(row.item_record.itemstring, this, 'ANCHOR_RIGHT')
end) end)
row.item.button:SetScript('OnLeave', function() row.item.button:SetScript('OnLeave', function() GameTooltip:Hide() end)
GameTooltip:Hide()
end)
local highlight = row:CreateTexture() local highlight = row:CreateTexture()
highlight:SetAllPoints(row) highlight:SetAllPoints(row)
@@ -120,5 +110,5 @@ end
function public.populate(item_listing, item_records) function public.populate(item_listing, item_records)
item_listing.item_records = item_records item_listing.item_records = item_records
m.render(item_listing) render(item_listing)
end end
+1 -1
View File
@@ -1,5 +1,5 @@
aux.module 'auctions_tab' aux.module 'auctions_tab'
g.aux.tab(3, 'Auctions') aux.tab(3, 'Auctions')
auction_records = nil auction_records = nil
+1 -1
View File
@@ -1,5 +1,5 @@
aux.module 'bids_tab' aux.module 'bids_tab'
g.aux.tab(4, 'Bids') aux.tab(4, 'Bids')
auction_records = nil auction_records = nil
+1 -1
View File
@@ -1,5 +1,5 @@
aux.module 'post_tab' aux.module 'post_tab'
g.aux.tab(2, 'Post') aux.tab(2, 'Post')
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440 local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}} local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
+2 -2
View File
@@ -1,5 +1,5 @@
aux.module 'search_tab' aux.module 'search_tab'
g.aux.tab(1, 'Search') aux.tab(1, 'Search')
StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = { StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = {
text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.', text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.',
@@ -20,7 +20,7 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
} }
do do
local function action() local function action()
g.aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText() _g.aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText()
update_auto_buy_filter() update_auto_buy_filter()
end end
+14 -14
View File
@@ -118,9 +118,9 @@ function create_frames()
btn:SetText('Real Time Mode') btn:SetText('Real Time Mode')
btn:SetScript('OnClick', function() btn:SetScript('OnClick', function()
this:SetChecked(not this:GetChecked()) this:SetChecked(not this:GetChecked())
g.this = first_page_input _g.this = first_page_input
first_page_input:GetScript('OnTextChanged')() first_page_input:GetScript('OnTextChanged')()
g.this = last_page_input _g.this = last_page_input
last_page_input:GetScript('OnTextChanged')() last_page_input:GetScript('OnTextChanged')()
end) end)
public.real_time_button = btn public.real_time_button = btn
@@ -149,7 +149,7 @@ function create_frames()
btn:SetScript('OnClick', function() btn:SetScript('OnClick', function()
if this:GetChecked() then if this:GetChecked() then
this:SetChecked(false) this:SetChecked(false)
g.aux_auto_buy_filter = nil _g.aux_auto_buy_filter = nil
this.prettified = nil this.prettified = nil
auto_buy_validator = nil auto_buy_validator = nil
else else
@@ -313,7 +313,7 @@ function create_frames()
btn:SetScript('OnClick', function() btn:SetScript('OnClick', function()
local filters = filter.queries(search_box:GetText()) local filters = filter.queries(search_box:GetText())
if filters then if filters then
tinsert(g.aux_favorite_searches, 1, { tinsert(_g.aux_favorite_searches, 1, {
filter_string = search_box:GetText(), filter_string = search_box:GetText(),
prettified = table.concat(map(filters, function(filter) return filter.prettified end), ';'), prettified = table.concat(map(filters, function(filter) return filter.prettified end), ';'),
}) })
@@ -345,7 +345,7 @@ function create_frames()
end end
do do
local editbox = gui.editbox(frame.filter) 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:SetPoint('TOPLEFT', 14, -FILTER_SPACING)
editbox:SetWidth(260) editbox:SetWidth(260)
editbox.char = function() editbox.char = function()
@@ -623,16 +623,16 @@ function create_frames()
add_filter(data.search.filter_string) add_filter(data.search.filter_string)
elseif button == 'LeftButton' and IsControlKeyDown() then elseif button == 'LeftButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index > 1 then if st == favorite_searches_listing and data.index > 1 then
local temp = g.aux_favorite_searches[data.index - 1] local temp = _g.aux_favorite_searches[data.index - 1]
g.aux_favorite_searches[data.index - 1] = data.search _g.aux_favorite_searches[data.index - 1] = data.search
g.aux_favorite_searches[data.index] = temp _g.aux_favorite_searches[data.index] = temp
update_search_listings() update_search_listings()
end end
elseif button == 'RightButton' and IsControlKeyDown() then elseif button == 'RightButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index < getn(g.aux_favorite_searches) then if st == favorite_searches_listing and data.index < getn(_g.aux_favorite_searches) then
local temp = g.aux_favorite_searches[data.index + 1] local temp = _g.aux_favorite_searches[data.index + 1]
g.aux_favorite_searches[data.index + 1] = data.search _g.aux_favorite_searches[data.index + 1] = data.search
g.aux_favorite_searches[data.index] = temp _g.aux_favorite_searches[data.index] = temp
update_search_listings() update_search_listings()
end end
elseif button == 'LeftButton' then elseif button == 'LeftButton' then
@@ -640,9 +640,9 @@ function create_frames()
execute() execute()
elseif button == 'RightButton' then elseif button == 'RightButton' then
if st == recent_searches_listing 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 elseif st == favorite_searches_listing then
tremove(g.aux_favorite_searches, data.index) tremove(_g.aux_favorite_searches, data.index)
end end
update_search_listings() update_search_listings()
end end
+4 -4
View File
@@ -1,6 +1,6 @@
aux.module 'search_tab' aux.module 'search_tab'
g.aux_auto_buy_filter = '' _g.aux_auto_buy_filter = ''
search_scan_id = 0 search_scan_id = 0
auto_buy_validator = nil auto_buy_validator = nil
@@ -114,8 +114,8 @@ function update_start_stop()
end end
function update_auto_buy_filter() function update_auto_buy_filter()
if g.aux_auto_buy_filter ~= '' then if _g.aux_auto_buy_filter ~= '' then
local queries = filter.queries(g.aux_auto_buy_filter) local queries = filter.queries(_g.aux_auto_buy_filter)
if queries then if queries then
if getn(queries) > 1 then if getn(queries) > 1 then
log('Error: The automatic buyout filter may contain only one query') log('Error: The automatic buyout filter may contain only one query')
@@ -129,7 +129,7 @@ function update_auto_buy_filter()
end end
end end
end end
g.aux_auto_buy_filter = '' _g.aux_auto_buy_filter = ''
end end
function start_real_time_scan(query, search, continuation) function start_real_time_scan(query, search, continuation)
+10 -10
View File
@@ -1,11 +1,11 @@
aux.module 'search_tab' aux.module 'search_tab'
g.aux_favorite_searches = {} _g.aux_favorite_searches = {}
g.aux_recent_searches = {} _g.aux_recent_searches = {}
function update_search_listings() function update_search_listings()
local favorite_search_rows = {} 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) local name = strsub(favorite_search.prettified, 1, 250)
tinsert(favorite_search_rows, { tinsert(favorite_search_rows, {
cols = {{value=name}}, cols = {{value=name}},
@@ -13,10 +13,10 @@ function update_search_listings()
index = i, index = i,
}) })
end end
m.favorite_searches_listing:SetData(favorite_search_rows) favorite_searches_listing:SetData(favorite_search_rows)
local recent_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) local name = strsub(recent_search.prettified, 1, 250)
tinsert(recent_search_rows, { tinsert(recent_search_rows, {
cols = {{value=name}}, cols = {{value=name}},
@@ -24,16 +24,16 @@ function update_search_listings()
index = i, index = i,
}) })
end end
m.recent_searches_listing:SetData(recent_search_rows) recent_searches_listing:SetData(recent_search_rows)
end end
function new_recent_search(filter_string, prettified) function new_recent_search(filter_string, prettified)
tinsert(g.aux_recent_searches, 1, { tinsert(_g.aux_recent_searches, 1, {
filter_string = filter_string, filter_string = filter_string,
prettified = prettified, prettified = prettified,
}) })
while getn(g.aux_recent_searches) > 50 do while getn(_g.aux_recent_searches) > 50 do
tremove(g.aux_recent_searches) tremove(_g.aux_recent_searches)
end end
m.update_search_listings() update_search_listings()
end end
+2 -2
View File
@@ -1,6 +1,6 @@
aux.module 'util' aux.module 'util'
local temp, recycle, getn = g.temp, g.recycle, g.getn local temp, recycle, getn = temp, recycle, _g.getn
function public.copy(t) function public.copy(t)
local copy = {} local copy = {}
@@ -9,7 +9,7 @@ function public.copy(t)
return copy return copy
end end
public.join = g.table.concat public.join = _g.table.concat
function public.replicate(count, value) function public.replicate(count, value)
if count > 0 then return value, replicate(count - 1, value) end if count > 0 then return value, replicate(count - 1, value) end
+9 -26
View File
@@ -292,7 +292,7 @@ function public.parse_query_string(str)
if input_type ~= '' then if input_type ~= '' then
if not parts[i + 1] or not parse_parameter(input_type, parts[i + 1]) then if not parts[i + 1] or not parse_parameter(input_type, parts[i + 1]) then
if parts[i] == 'item' 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 elseif type(input_type) == 'table' then
return nil, 'Invalid choice for '..parts[i], input_type return nil, 'Invalid choice for '..parts[i], input_type
else else
@@ -349,18 +349,15 @@ function public.query(query_string)
blizzard_query = blizzard_query(components), blizzard_query = blizzard_query(components),
validator = validator(components), validator = validator(components),
prettified = prettified_query_string(components), prettified = prettified_query_string(components),
}, m.suggestions(components) }, _m.suggestions(components)
end end
function public.queries(query_string) function public.queries(query_string)
local parts = split(query_string, ';') local parts = split(query_string, ';')
local queries = {} local queries = {}
for _, str in parts do for _, str in parts do
str = trim(str) str = trim(str)
local query, _, error = query(str) local query, _, error = query(str)
if not query then if not query then
log('Invalid filter:', error) log('Invalid filter:', error)
return return
@@ -368,31 +365,21 @@ function public.queries(query_string)
tinsert(queries, query) tinsert(queries, query)
end end
end end
return queries return queries
end end
function suggestions(components) function suggestions(components)
local suggestions = {} local suggestions = {}
if components.blizzard.name and size(components.blizzard) == 1 then if components.blizzard.name and size(components.blizzard) == 1 then tinsert(suggestions, 'exact') end
tinsert(suggestions, 'exact')
end
tinsert(suggestions, 'and') tinsert(suggestions, 'and'); tinsert(suggestions, 'or'); tinsert(suggestions, 'not'); tinsert(suggestions, 'tt')
tinsert(suggestions, 'or')
tinsert(suggestions, 'not')
tinsert(suggestions, 'tt')
for key in filters do for key in filters do tinsert(suggestions, key) end
tinsert(suggestions, key)
end
-- classes -- classes
if not components.blizzard.class then if not components.blizzard.class then
for _, class in {GetAuctionItemClasses()} do for _, class in {GetAuctionItemClasses()} do tinsert(suggestions, class) end
tinsert(suggestions, class)
end
end end
-- subclasses -- subclasses
@@ -410,20 +397,16 @@ function suggestions(components)
end end
-- usable -- usable
if not components.blizzard.usable then if not components.blizzard.usable then tinsert(suggestions, 'usable') end
tinsert(suggestions, 'usable')
end
-- rarities -- rarities
if not components.blizzard.quality then if not components.blizzard.quality then
for i=0,4 do for i=0,4 do tinsert(suggestions, getglobal('ITEM_QUALITY'..i..'_DESC')) end
tinsert(suggestions, getglobal('ITEM_QUALITY'..i..'_DESC'))
end
end end
-- item names -- item names
if size(components.blizzard) + getn(components.post) == 1 and components.blizzard.name == '' then 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') tinsert(suggestions, name..'/exact')
end end
end end
+3 -3
View File
@@ -121,8 +121,8 @@ function public.auction(index, query_type)
link = link, link = link,
itemstring = item_info.itemstring, itemstring = item_info.itemstring,
item_key = item_id..':'..suffix_id, item_key = item_id..':'..suffix_id,
search_signature = join({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 '?')}, ':'), search_signature = join({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({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 '?')}, ':'), sniping_signature = join({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, name = name,
texture = texture, texture = texture,
@@ -166,7 +166,7 @@ function public.bid_update(auction_record)
auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity 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.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity
auction_record.high_bidder = 1 auction_record.high_bidder = 1
auction_record.search_signature = table.concat({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 = table.concat({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 end
function public.set_tooltip(itemstring, owner, anchor) function public.set_tooltip(itemstring, owner, anchor)
+3 -3
View File
@@ -1,6 +1,6 @@
aux.module 'persistence' aux.module 'persistence'
g.aux_datasets = {} _g.aux_datasets = {}
do do
local realm, faction local realm, faction
@@ -17,8 +17,8 @@ end
function public.load_dataset() function public.load_dataset()
local dataset_key = dataset_key local dataset_key = dataset_key
g.aux_datasets[dataset_key] = g.aux_datasets[dataset_key] or {} _g.aux_datasets[dataset_key] = _g.aux_datasets[dataset_key] or {}
return g.aux_datasets[dataset_key] return _g.aux_datasets[dataset_key]
end end
function public.read(schema, str) function public.read(schema, str)