module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-09-22 18:56:00 +02:00
parent 1344ae0d23
commit 240589eef1
32 changed files with 525 additions and 499 deletions
+21 -16
View File
@@ -1,7 +1,8 @@
--aux_account_settings = {} -- TODO clean up the mess of savedvariables
--aux_character_settings = {}
do local modules = {}
do
local modules = {}
local mt = {__metatable=false, __index=function(_, key) return modules[key]._I end, __newindex=error}
aux = function(name)
if not modules[name] then
@@ -37,11 +38,15 @@ for event in temp-S('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION
event_frame:RegisterEvent(event)
end
ADDON_LOADED = t
private.ADDON_LOADED = t
do
local handlers, handlers2 = t, t
function public.LOAD.set(f) tinsert(handlers, f) end
function public.LOAD2.set(f) tinsert(handlers2, f) end
function public.LOAD.set(f)
tinsert(handlers, f)
end
function public.LOAD2.set(f)
tinsert(handlers2, f)
end
event_frame:SetScript('OnEvent', function()
if event == 'ADDON_LOADED' then
(ADDON_LOADED[arg1] or nop)()
@@ -56,7 +61,7 @@ do
end)
end
tab_info = t
private.tab_info = t
do
for _, info in temp-A(temp-A('search_tab', 'Search'), temp-A('post_tab', 'Post'), temp-A('auctions_tab', 'Auctions'), temp-A('bids_tab', 'Bids')) do
local tab = T('name', info[2])
@@ -74,13 +79,13 @@ do
local index
function private.active_tab.get() return tab_info[index] end
function on_tab_click(i)
(index and active_tab.CLOSE or nop)()
do (index and active_tab.CLOSE or nop)() end
index = i
;(index and active_tab.OPEN or nop)()
do (index and active_tab.OPEN or nop)() end
end
end
function SetItemRef(...) auto[arg] = true
function private.SetItemRef(...) auto[arg] = true
if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
return orig.SetItemRef(unpack(arg))
end
@@ -89,7 +94,7 @@ function SetItemRef(...) auto[arg] = true
end
end
function UseContainerItem(...) auto[arg] = true
function private.UseContainerItem(...) auto[arg] = true
if modified or not index(active_tab, 'USE_ITEM') then
return orig.UseContainerItem(unpack(arg))
end
@@ -152,7 +157,7 @@ end
function public.is_player(name, current)
local realm = GetCVar('realmName')
return not current and index(_G.aux_characters, realm, name) or UnitName('player') == name
return not current and index(aux_characters, realm, name) or UnitName('player') == name
end
function public.neutral_faction()
@@ -163,13 +168,13 @@ function public.min_bid_increment(current_bid)
return max(1, floor(current_bid / 100) * 5)
end
function AUCTION_HOUSE_SHOW()
function private.AUCTION_HOUSE_SHOW()
AuctionFrame:Hide()
aux_frame:Show()
tab = 1
end
function AUCTION_HOUSE_CLOSED()
function private.AUCTION_HOUSE_CLOSED()
bids_loaded = false
current_owner_page = nil
aux.post.stop()
@@ -179,18 +184,18 @@ function AUCTION_HOUSE_CLOSED()
aux_frame:Hide()
end
function AUCTION_BIDDER_LIST_UPDATE()
function private.AUCTION_BIDDER_LIST_UPDATE()
bids_loaded = true
end
do
local last_owner_page_requested
function GetOwnerAuctionItems(...) auto[arg] = true
function private.GetOwnerAuctionItems(...) auto[arg] = true
local page = arg[1]
last_owner_page_requested = page
return orig.GetOwnerAuctionItems(unpack(arg))
end
function AUCTION_OWNED_LIST_UPDATE()
function private.AUCTION_OWNED_LIST_UPDATE()
current_owner_page = last_owner_page_requested or 0
end
end
@@ -268,7 +273,7 @@ do
end
end
function AuctionFrameAuctions_OnEvent(...) auto[arg] = true
function private.AuctionFrameAuctions_OnEvent(...) auto[arg] = true
if AuctionFrameAuctions:IsVisible() then
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
end
+27 -11
View File
@@ -12,7 +12,7 @@ function LOAD()
event_frame:SetScript('OnEvent', EVENT)
end
function EVENT()
function private.EVENT()
for id, listener in listeners do
if listener.killed then
listeners[id] = nil
@@ -23,11 +23,15 @@ function EVENT()
end
do
function UPDATE()
function private.UPDATE()
for _, listener in listeners do
local event, needed = listener.event, false
for _, listener in listeners do needed = needed or listener.event == event and not listener.killed end
if not needed then event_frame:UnregisterEvent(event) end
for _, listener in listeners do
needed = needed or listener.event == event and not listener.killed
end
if not needed then
event_frame:UnregisterEvent(event)
end
end
for id, thread in threads do
@@ -44,21 +48,33 @@ do
end
end
do local id = 0
function private.unique_id.get() id = id + 1; return id end
do
local id = 0
function private.unique_id.get()
id = id + 1
return id
end
end
function public.kill_listener(listener_id)
for listener in present(listeners[listener_id]) do listener.killed = true end
for listener in present(listeners[listener_id]) do
listener.killed = true
end
end
function public.kill_thread(thread_id)
for thread in present(threads[thread_id]) do thread.killed = true end
for thread in present(threads[thread_id]) do
thread.killed = true
end
end
function public.event_listener(event, cb)
local listener_id = unique_id
listeners[listener_id] = { event=event, cb=cb, kill=vararg-function(arg) if getn(arg) == 0 or arg[1] then kill_listener(listener_id) end end }
listeners[listener_id] = T(
'event', event,
'cb', cb,
'kill', vararg-function(arg) if getn(arg) == 0 or arg[1] then kill_listener(listener_id) end end
)
event_frame:RegisterEvent(event)
return listener_id
end
@@ -70,7 +86,7 @@ end
function public.vararg.thread(arg)
local k = tremove(arg, 1)
local thread_id = unique_id
threads[thread_id] = T('k', partial(k, unpack(arg)))
threads[thread_id] = T('k', papply(k, unpack(arg)))
return thread_id
end
@@ -79,7 +95,7 @@ function public.vararg.wait(arg)
if type(k) == 'number' then
when(function() k = k - 1 return k <= 1 end, unpack(arg))
else
threads[thread_id].k = partial(k, unpack(arg))
threads[thread_id].k = papply(k, unpack(arg))
end
end
+35 -35
View File
@@ -1,19 +1,19 @@
aux 'cache' local info, persistence = aux.info, aux.persistence
MIN_ITEM_ID = 1
MAX_ITEM_ID = 30000
local MIN_ITEM_ID = 1
local MAX_ITEM_ID = 30000
--items_schema = record '#' {name='string'} {quality='number'} {level='number'} {class='string'} {subclass='string'} {slot='string'} {max_stack='number'} {texture='string'} -- TODO
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'}}
local items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
local merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'}}
_G.aux_items = t
_G.aux_item_ids = t
_G.aux_auctionable_items = t
_G.aux_merchant_buy = t
_G.aux_merchant_sell = t
_G.aux_characters = t
aux_items = t
aux_item_ids = t
aux_auctionable_items = t
aux_merchant_buy = t
aux_merchant_sell = t
aux_characters = t
function LOAD()
scan_wdb()
@@ -28,7 +28,7 @@ function LOAD()
event_listener('NEW_AUCTION_UPDATE', function()
for info in present(info.auction_sell_item()) do
for item_id in present(item_id(info.name)) do
_G.aux_merchant_sell[_E.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count)
aux_merchant_sell[_E.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count)
end
end
end)
@@ -36,25 +36,25 @@ end
do
local sell_scan_countdown, incomplete_buy_data
function on_merchant_show()
function private.on_merchant_show()
merchant_sell_scan()
incomplete_buy_data = not merchant_buy_scan()
end
function on_merchant_closed()
function private.on_merchant_closed()
sell_scan_countdown = nil
incomplete_buy_data = false
end
function on_merchant_update()
function private.on_merchant_update()
if incomplete_buy_data then
incomplete_buy_data = not merchant_buy_scan()
end
end
function on_bag_update()
function private.on_bag_update()
if MerchantFrame:IsVisible() then
sell_scan_countdown = 10
end
end
function merchant_on_update()
function private.merchant_on_update()
if sell_scan_countdown == 0 then
sell_scan_countdown = nil
merchant_sell_scan()
@@ -64,7 +64,7 @@ do
end
end
function merchant_loaded()
function private.merchant_loaded()
for i = 1, GetMerchantNumItems() do
if not GetMerchantItemLink(i) then
return false
@@ -75,15 +75,15 @@ end
function public.merchant_info(item_id)
local buy_info
if _G.aux_merchant_buy[item_id] then
buy_info = persistence.read(merchant_buy_schema, _G.aux_merchant_buy[item_id])
if aux_merchant_buy[item_id] then
buy_info = persistence.read(merchant_buy_schema, 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 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 = aux_items[item_id]
if data_string then
local cached_data = persistence.read(items_schema, data_string)
return T(
@@ -101,10 +101,10 @@ function public.item_info(item_id)
end
function public.item_id(item_name)
return _G.aux_item_ids[strlower(item_name)]
return aux_item_ids[strlower(item_name)]
end
function merchant_buy_scan()
function private.merchant_buy_scan()
local incomplete_data
for i = 1, GetMerchantNumItems() do
@@ -113,8 +113,8 @@ function merchant_buy_scan()
if link then
local item_id = info.parse_link(link)
local new_unit_price, new_limited = price / count, stock >= 0
if _G.aux_merchant_buy[item_id] then
local buy_info = persistence.read(merchant_buy_schema, _G.aux_merchant_buy[item_id])
if aux_merchant_buy[item_id] then
local buy_info = persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
local unit_price
if buy_info.limited and not new_limited then
@@ -125,12 +125,12 @@ function merchant_buy_scan()
unit_price = min(buy_info.unit_price, new_unit_price)
end
_G.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T(
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T(
'unit_price', unit_price,
'limited', buy_info.limited and new_limited
))
else
_G.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T(
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T(
'unit_price', new_unit_price,
'limited', new_limited
))
@@ -143,25 +143,25 @@ function merchant_buy_scan()
return not incomplete_data
end
function merchant_sell_scan()
function private.merchant_sell_scan()
for slot in info.inventory do auto[slot] = true
local item_info = temp-info.container_item(unpack(slot))
if item_info then
_G.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
end
end
end
function scan_wdb(item_id)
function private.scan_wdb(item_id)
item_id = item_id or MIN_ITEM_ID
local processed = 0
while processed <= 100 and item_id <= MAX_ITEM_ID do
local itemstring = 'item:' .. item_id
local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
if name and not _G.aux_item_ids[strlower(name)] then
_G.aux_item_ids[strlower(name)] = item_id
_G.aux_items[item_id] = persistence.write(items_schema, T(
if name and not aux_item_ids[strlower(name)] then
aux_item_ids[strlower(name)] = item_id
aux_items[item_id] = persistence.write(items_schema, T(
'name', name,
'quality', quality,
'level', level,
@@ -173,7 +173,7 @@ function scan_wdb(item_id)
))
local tooltip = info.tooltip(function(tooltip) tooltip:SetHyperlink(itemstring) end)
if info.auctionable(tooltip, quality) then
tinsert(_G.aux_auctionable_items, strlower(name))
tinsert(aux_auctionable_items, strlower(name))
end
processed = processed + 1
end
@@ -183,7 +183,7 @@ function scan_wdb(item_id)
if item_id <= MAX_ITEM_ID then
thread(wait, 10, 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(aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
end
end
+56 -57
View File
@@ -1,71 +1,70 @@
aux 'disenchant'
UNCOMMON, RARE, EPIC = 2, 3, 4
local UNCOMMON, RARE, EPIC = 2, 3, 4
do
local data = {
[10940] = A('DUST', '1-20'),
[11083] = A('DUST', '21-30'),
[11137] = A('DUST', '31-40'),
[11176] = A('DUST', '41-50'),
[16204] = A('DUST', '51-60'),
local data = T(
10940, A('DUST', '1-20'),
11083, A('DUST', '21-30'),
11137, A('DUST', '31-40'),
11176, A('DUST', '41-50'),
16204, A('DUST', '51-60'),
[10938] = A('ESSENCE', '1-10'),
[10939] = A('ESSENCE', '11-15'),
[10998] = A('ESSENCE', '16-20'),
[11082] = A('ESSENCE', '21-25'),
[11134] = A('ESSENCE', '26-30'),
[11135] = A('ESSENCE', '31-35'),
[11174] = A('ESSENCE', '36-40'),
[11175] = A('ESSENCE', '41-45'),
[16202] = A('ESSENCE', '46-50'),
[16203] = A('ESSENCE', '51-60'),
10938, A('ESSENCE', '1-10'),
10939, A('ESSENCE', '11-15'),
10998, A('ESSENCE', '16-20'),
11082, A('ESSENCE', '21-25'),
11134, A('ESSENCE', '26-30'),
11135, A('ESSENCE', '31-35'),
11174, A('ESSENCE', '36-40'),
11175, A('ESSENCE', '41-45'),
16202, A('ESSENCE', '46-50'),
16203, A('ESSENCE', '51-60'),
[10978] = A('SHARD', '1-20'),
[11084] = A('SHARD', '21-25'),
[11138] = A('SHARD', '26-30'),
[11139] = A('SHARD', '31-35'),
[11177] = A('SHARD', '36-40'),
[11178] = A('SHARD', '41-45'),
[14343] = A('SHARD', '46-50'),
[14344] = A('SHARD', '51-60'),
10978, A('SHARD', '1-20'),
11084, A('SHARD', '21-25'),
11138, A('SHARD', '26-30'),
11139, A('SHARD', '31-35'),
11177, A('SHARD', '36-40'),
11178, A('SHARD', '41-45'),
14343, A('SHARD', '46-50'),
14344, A('SHARD', '51-60'),
[20725] = A('CRYSTAL', '51+'),
}
20725, A('CRYSTAL', '51+')
)
function public.source(item_id)
return unpack(data[item_id] or tt)
return unpack(data[item_id] or empty)
end
end
function LOAD()
ARMOR = S(
'INVTYPE_HEAD',
'INVTYPE_NECK',
'INVTYPE_SHOULDER',
'INVTYPE_BODY',
'INVTYPE_CHEST',
'INVTYPE_ROBE',
'INVTYPE_WAIST',
'INVTYPE_LEGS',
'INVTYPE_FEET',
'INVTYPE_WRIST',
'INVTYPE_HAND',
'INVTYPE_FINGER',
'INVTYPE_TRINKET',
'INVTYPE_CLOAK',
'INVTYPE_HOLDABLE'
)
WEAPON = S(
'INVTYPE_2HWEAPON',
'INVTYPE_WEAPONMAINHAND',
'INVTYPE_WEAPON',
'INVTYPE_WEAPONOFFHAND',
'INVTYPE_SHIELD',
'INVTYPE_RANGED',
'INVTYPE_RANGEDRIGHT'
)
end
local ARMOR = S(
'INVTYPE_HEAD',
'INVTYPE_NECK',
'INVTYPE_SHOULDER',
'INVTYPE_BODY',
'INVTYPE_CHEST',
'INVTYPE_ROBE',
'INVTYPE_WAIST',
'INVTYPE_LEGS',
'INVTYPE_FEET',
'INVTYPE_WRIST',
'INVTYPE_HAND',
'INVTYPE_FINGER',
'INVTYPE_TRINKET',
'INVTYPE_CLOAK',
'INVTYPE_HOLDABLE'
)
local WEAPON = S(
'INVTYPE_2HWEAPON',
'INVTYPE_WEAPONMAINHAND',
'INVTYPE_WEAPON',
'INVTYPE_WEAPONOFFHAND',
'INVTYPE_SHIELD',
'INVTYPE_RANGED',
'INVTYPE_RANGEDRIGHT'
)
function public.value(slot, quality, level)
local expectation
@@ -81,7 +80,7 @@ function public.value(slot, quality, level)
end
function public.distribution(slot, quality, level)
if not (ARMOR[slot] or WEAPON[slot]) or level == 0 then
if not ARMOR[slot] and not WEAPON[slot] or level == 0 then
return t
end
+5 -5
View File
@@ -2,7 +2,7 @@ aux 'history' local persistence = aux.persistence
local history_schema = {'record', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'record', '@', {market_value='number'}, {time='number'}}}} }
value_cache = t
local value_cache = t
do
local cache
@@ -32,7 +32,7 @@ function private.new_record.get()
return T('next_push', next_push, 'data_points', t)
end
function read_record(item_key)
function private.read_record(item_key)
local record = data[item_key] and persistence.read(history_schema, data[item_key]) or new_record
if record.next_push <= time() then
push_record(record)
@@ -41,7 +41,7 @@ function read_record(item_key)
return record
end
function write_record(item_key, record)
function private.write_record(item_key, record)
value_cache[item_key] = nil
data[item_key] = persistence.write(history_schema, record)
end
@@ -100,7 +100,7 @@ function calculate_market_value(item_record)
return item_record.daily_min_buyout and min(ceil(item_record.daily_min_buyout * 1.15), item_record.daily_max_price)
end
function weighted_median(list)
function private.weighted_median(list)
sort(list, function(a,b) return a.value < b.value end)
local weight = 0
for _, element in list do
@@ -111,7 +111,7 @@ function weighted_median(list)
end
end
function push_record(item_record)
function private.push_record(item_record)
for market_value in present(calculate_market_value(item_record)) do
tinsert(item_record.data_points, 1, T('market_value', market_value, 'time', item_record.next_push))
while getn(item_record.data_points) > 11 do
+4 -7
View File
@@ -1,8 +1,8 @@
aux 'post'
local state = nil
local state
function process()
function private.process()
if state.posted < state.count then
local stacking_complete
@@ -23,7 +23,7 @@ function process()
return stop()
end
function post_auction(slot, k)
function private.post_auction(slot, k)
local item_info = aux.info.container_item(unpack(slot))
if item_info.item_key == state.item_key and aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
@@ -71,11 +71,8 @@ end
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
stop()
local thread_id = thread(process)
state = {
thread_id = thread_id,
thread_id = thread(process),
item_key = item_key,
stack_size = stack_size,
duration = duration,
+37 -24
View File
@@ -27,22 +27,29 @@ do
end
end
for _, state in aborted do
(state.params.on_abort or nop)()
do (state.params.on_abort or nop)() end
end
end
function complete()
function private.complete()
local on_complete = state.params.on_complete
scan_states[state.params.type] = nil
(on_complete or nop)()
-- for _ in on_complete or nop do end TODO test performance
do (on_complete or nop)() end
end
function private.state.get()
for _, state in scan_states do if state.id == thread_id then return state end end
for _, state in scan_states do
if state.id == thread_id then
return state
end
end
end
end
function private.query.get() return state.params.queries[state.query_index] end
function private.query.get()
return state.params.queries[state.query_index]
end
function private.vararg.wait_for_callback(arg)
local send_signal, signal_received = signal()
@@ -52,10 +59,14 @@ function private.vararg.wait_for_callback(arg)
local k = tremove(arg)
if f then
tinsert(arg, {
suspend = function() suspended = true end,
resume = send_signal,
})
tinsert(arg, T(
'suspend', function() suspended = true end,
'resume', send_signal
))
-- tinsert(arg, -pairs TODO
-- :suspend (function() suspended = true end)
-- :resume (send_signal)
-- )
f(unpack(arg))
end
if not suspended then send_signal() end
@@ -63,17 +74,17 @@ function private.vararg.wait_for_callback(arg)
return when(signal_received, function() return k(unpack(signal_received())) end)
end
function total_pages(total_auctions)
function private.total_pages(total_auctions)
return ceil(total_auctions / PAGE_SIZE)
end
function last_page(total_auctions)
function private.last_page(total_auctions)
local last_page = max(total_pages(total_auctions) - 1, 0)
local last_page_limit = query.blizzard_query and query.blizzard_query.last_page or last_page
return min(last_page_limit, last_page)
end
function scan()
function private.scan()
state.query_index = state.query_index and state.query_index + 1 or 1
if query and (index(query.blizzard_query, 'first_page') or 0) <= (index(query.blizzard_query, 'last_page') or huge) then
if query.blizzard_query then
@@ -87,13 +98,13 @@ function scan()
end
end
function process_query()
function private.process_query()
return (query.blizzard_query and submit_query or scan_page)()
end
function submit_query()
function private.submit_query()
when(function() return state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
(state.params.on_submit_query or nop)()
do (state.params.on_submit_query or nop)() end
state.last_query_time = GetTime()
if state.params.type == 'bidder' then
GetBidderAuctionItems(state.page)
@@ -117,7 +128,7 @@ function submit_query()
end)
end
function scan_page(i)
function private.scan_page(i)
i = i or 1
local recurse = function(retry)
if i >= PAGE_SIZE then
@@ -135,7 +146,7 @@ function scan_page(i)
end
local auction_info = info.auction(i, state.params.type)
if auction_info and (auction_info.owner or state.params.ignore_owner or _G.aux_ignore_owner) then
if auction_info and (auction_info.owner or state.params.ignore_owner or aux_ignore_owner) then
auction_info.index = i
auction_info.page = state.page
auction_info.blizzard_query = query.blizzard_query
@@ -146,7 +157,7 @@ function scan_page(i)
if (state.params.auto_buy_validator or nop)(auction_info) then
local send_signal, signal_received = signal()
when(signal_received, recurse)
place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, partial(send_signal, true))
place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, papply(send_signal, true))
return thread(when, later(GetTime(), 10), send_signal, false)
elseif not query.validator or query.validator(auction_info) then
return wait_for_callback(state.params.on_auction, auction_info, function(removed)
@@ -162,7 +173,7 @@ function scan_page(i)
return recurse()
end
function wait_for_results()
function private.wait_for_results()
local timeout = later(state.last_query_time, 10)
local send_signal, signal_received = signal()
when(signal_received, function()
@@ -191,7 +202,7 @@ function wait_for_results()
end
end
function wait_for_owner_results(send_signal)
function private.wait_for_owner_results(send_signal)
if state.page == current_owner_page then
return send_signal()
else
@@ -199,14 +210,14 @@ function wait_for_owner_results(send_signal)
end
end
function wait_for_list_results(send_signal, signal_received)
function private.wait_for_list_results(send_signal, signal_received)
local updated, last_update
event_listener('AUCTION_ITEM_LIST_UPDATE', function(kill)
kill(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 aux_ignore_owner
return thread(when, function()
-- short circuiting order important, owner_data_complete must be called iif an update has happened.
local ok = updated and (ignore_owner or owner_data_complete('list')) or last_update and GetTime() - last_update > 5
@@ -215,10 +226,12 @@ function wait_for_list_results(send_signal, signal_received)
end, send_signal)
end
function owner_data_complete(type)
function private.owner_data_complete(type)
for i = 1, PAGE_SIZE do
local auction_info = info.auction(i, type)
if auction_info and not auction_info.owner then return false end
if auction_info and not auction_info.owner then
return false
end
end
return true
end
+33 -33
View File
@@ -1,9 +1,9 @@
aux 'slash' local persistence = aux.persistence
_G.aux_ignore_owner = true
aux_ignore_owner = true
_G.SLASH_AUX1 = '/aux'
function _G.SlashCmdList.AUX(command)
SLASH_AUX1 = '/aux'
function SlashCmdList.AUX(command)
if not command then return end
local arguments = tokenize(command)
if arguments[1] == 'clear' and arguments[2] == 'history' then
@@ -13,77 +13,77 @@ function _G.SlashCmdList.AUX(command)
persistence.dataset.post = nil
print 'Post settings cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
_G.aux_datasets = t
aux_datasets = t
print 'Datasets cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
_G.aux_merchant_buy = t
aux_merchant_buy = t
print 'Merchant buy prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
_G.aux_merchant_sell = t
aux_merchant_sell = t
print 'Merchant sell prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
_G.aux_items = t
_G.aux_item_ids = t
_G.aux_auctionable_items = t
aux_items = t
aux_item_ids = t
aux_auctionable_items = t
print '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
print('Historical value in tooltip ' .. (_G.aux_tooltip_value and 'enabled' or 'disabled') .. '.')
aux_tooltip_value = not aux_tooltip_value
print('Historical value in tooltip ' .. (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
print('Market value in tooltip ' .. (_G.aux_tooltip_daily and 'enabled' or 'disabled') .. '.')
aux_tooltip_daily = not aux_tooltip_daily
print('Market value in tooltip ' .. (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
print('Vendor buy price in tooltip ' .. (_G.aux_tooltip_vendor_buy and 'enabled' or 'disabled') .. '.')
aux_tooltip_vendor_buy = not aux_tooltip_vendor_buy
print('Vendor buy price in tooltip ' .. (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
print('Vendor sell price in tooltip ' .. (_G.aux_tooltip_vendor_sell and 'enabled' or 'disabled') .. '.')
aux_tooltip_vendor_sell = not aux_tooltip_vendor_sell
print('Vendor sell price in tooltip ' .. (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
print('Disenchant value in tooltip ' .. (_G.aux_tooltip_disenchant_value and 'enabled' or 'disabled') .. '.')
aux_tooltip_disenchant_value = not aux_tooltip_disenchant_value
print('Disenchant value in tooltip ' .. (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
print('Disenchant distribution in tooltip ' .. (_G.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled') .. '.')
aux_tooltip_disenchant_distribution = not aux_tooltip_disenchant_distribution
print('Disenchant distribution in tooltip ' .. (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
print('Disenchant source in tooltip ' .. (_G.aux_tooltip_disenchant_source and 'enabled' or 'disabled') .. '.')
aux_tooltip_disenchant_source = not aux_tooltip_disenchant_source
print('Disenchant source in tooltip ' .. (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
print('Ignoring of owner ' .. (_G.aux_ignore_owner and 'enabled' or 'disabled') .. '.')
aux_ignore_owner = not aux_ignore_owner
print('Ignoring of owner ' .. (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 t
aux_characters[realm] = aux_characters[realm] or t
for i = 3, getn(arguments) do
local name = gsub(strlower(arguments[i]), '^%l', strupper)
if not _G.aux_characters[realm][name] then
_G.aux_characters[realm][name] = true
if not aux_characters[realm][name] then
aux_characters[realm][name] = true
print('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 aux_characters[realm] then
return
end
for i = 3, getn(arguments) do
local name = gsub(strlower(arguments[i]), '^%l', strupper)
if _G.aux_characters[realm][name] then
_G.aux_characters[realm][name] = nil
if aux_characters[realm][name] then
aux_characters[realm][name] = nil
print('Character "' .. name .. '" removed.')
end
end
elseif arguments[1] == 'chars' then
local realm = GetCVar('realmName')
local chars = t
for name in _G.aux_characters[realm] or t do
for name in aux_characters[realm] or t do
tinsert(chars, name)
end
if getn(chars) > 0 then
print('Your characters: "' .. join(chars, ', ') .. '".')
else
print 'You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".'
print('You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".')
end
else
print('Unknown command: "' .. command .. '"')
+14 -18
View File
@@ -2,40 +2,40 @@ aux 'stack' local info = aux.info
local state
function stack_size(slot)
function private.stack_size(slot)
local container_item_info = info.container_item(unpack(slot))
return container_item_info and container_item_info.count or 0
end
function charges(slot)
function private.charges(slot)
local container_item_info = info.container_item(unpack(slot))
return container_item_info and container_item_info.charges
end
function max_stack(slot)
function private.max_stack(slot)
local container_item_info = info.container_item(unpack(slot))
return container_item_info and container_item_info.max_stack
end
function locked(slot)
function private.locked(slot)
local container_item_info = info.container_item(unpack(slot))
return container_item_info and container_item_info.locked
end
function find_item_slot(partial)
function private.find_item_slot(papply)
for slot in info.inventory do
if matching_item(slot, partial) and not eq(slot, state.target_slot) then
if matching_item(slot, papply) and not eq(slot, state.target_slot) then
return slot
end
end
end
function matching_item(slot, partial)
function private.matching_item(slot, papply)
local item_info = info.container_item(unpack(slot))
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)
return item_info and item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and (not papply or item_info.count < item_info.max_stack)
end
function find_empty_slot()
function private.find_empty_slot()
for slot, type in info.inventory do
if type == 1 and not GetContainerItemInfo(unpack(slot)) then
return slot
@@ -43,7 +43,7 @@ function find_empty_slot()
end
end
function find_charge_item_slot()
function private.find_charge_item_slot()
for slot in info.inventory do
if matching_item(slot) and charges(slot) == state.target_size then
return slot
@@ -51,7 +51,7 @@ function find_charge_item_slot()
end
end
function move_item(from_slot, to_slot, amount, k)
function private.move_item(from_slot, to_slot, amount, k)
if locked(from_slot) or locked(to_slot) then
return wait(k)
end
@@ -66,15 +66,13 @@ function move_item(from_slot, to_slot, amount, k)
return when(function() return stack_size(to_slot) == expected_size end, k)
end
function process()
function private.process()
if not state.target_slot or not matching_item(state.target_slot) then
state.target_slot = find_item_slot()
if not state.target_slot then
return stop()
end
end
if charges(state.target_slot) then
state.target_slot = find_charge_item_slot()
return stop()
@@ -109,16 +107,14 @@ function public.stop()
local callback, slot = state.callback, state.target_slot
slot = slot and matching_item(slot) and slot or nil
state = nil
(callback or nop)(slot)
do (callback or nop)(slot) end
end
end
function public.start(item_key, size, callback)
stop()
local thread_id = thread(process)
state = {
thread_id = thread_id,
thread_id = thread(process),
item_key = item_key,
target_size = size,
callback = callback,
+14 -14
View File
@@ -1,6 +1,6 @@
aux 'tooltip' local info, disenchant, cache, money, history = aux.info, aux.disenchant, aux.cache, aux.money, aux.history
_G.aux_tooltip_value = true
aux_tooltip_value = true
local game_tooltip_hooks, game_tooltip_money = t, 0
@@ -43,8 +43,8 @@ end
function extend_tooltip(tooltip, link, quantity)
local item_id, suffix_id = info.parse_link(link)
quantity = IsShiftKeyDown() and quantity or 1
if _G.aux_tooltip_disenchant_source then
local color = {r=.7, g=.7, b=.7}
if aux_tooltip_disenchant_source then
local color = { r=.7, g=.7, b=.7 }
local type, range = disenchant.source(item_id)
if type == 'CRYSTAL' then
tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), color.r, color.g, color.b, true)
@@ -60,8 +60,8 @@ function extend_tooltip(tooltip, link, quantity)
if item_info then
local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
if getn(distribution) > 0 then
if _G.aux_tooltip_disenchant_distribution then
local color = {r=.8, g=.8, b=.2}
if aux_tooltip_disenchant_distribution then
local color = { r=.8, g=.8, b=.2 }
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
sort(distribution, function(a,b) return a.probability > b.probability end)
@@ -69,37 +69,37 @@ function extend_tooltip(tooltip, link, quantity)
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), color.r, color.g, color.b)
end
end
if _G.aux_tooltip_disenchant_value then
local color = {r=.1, g=.6, b=.6}
if aux_tooltip_disenchant_value then
local color = { r=.1, g=.6, b=.6 }
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
tooltip:AddLine('Disenchant Value: ' .. (disenchant_value and money.to_string2(disenchant_value) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
end
end
end
if _G.aux_tooltip_vendor_buy then
local color = {r=.8, g=.5, b=.1}
if aux_tooltip_vendor_buy then
local color = { r=.8, g=.5, b=.1 }
local _, price, limited = cache.merchant_info(item_id)
if price then
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.r, color.g, color.b)
end
end
if _G.aux_tooltip_vendor_sell then
local color = {r=.8, g=.5, b=.1}
if aux_tooltip_vendor_sell then
local color = { r=.8, g=.5, b=.1 }
local price = cache.merchant_info(item_id)
if price ~= 0 then
tooltip:AddLine('Vendor Sell: ' .. (price and money.to_string2(price * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
end
end
local color = {r=1, g=1, b=.6}
local color = { r=1, g=1, b=.6 }
local auctionable = not item_info or info.auctionable(info.tooltip(function(tooltip) tooltip:SetHyperlink(item_info.itemstring) end), item_info.quality)
local item_key = (item_id or 0) .. ':' .. (suffix_id or 0)
local value = history.value(item_key)
if auctionable then
if _G.aux_tooltip_value then
if aux_tooltip_value then
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
end
if _G.aux_tooltip_daily then
if aux_tooltip_daily then
local market_value = history.market_value(item_key)
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. aux.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
+2 -2
View File
@@ -26,7 +26,7 @@ do
public.aux_frame = frame
end
do
tabs = gui.tabs(aux_frame, 'DOWN')
private.tabs = gui.tabs(aux_frame, 'DOWN')
tabs._on_select = on_tab_click
function public.tab.set(id) tabs:select(id) end
end
@@ -35,7 +35,7 @@ do
btn:SetPoint('BOTTOMRIGHT', -5, 5)
gui.set_size(btn, 60, 24)
btn:SetText('Close')
btn:SetScript('OnClick', partial(aux_frame.Hide, aux_frame))
btn:SetScript('OnClick', papply(aux_frame.Hide, aux_frame))
public.close_button = btn
end
do
+47 -49
View File
@@ -1,29 +1,27 @@
aux 'auction_listing' local gui, sorting, money, info = aux.gui, aux.sorting, aux.money, aux.info
_G.aux_price_per_unit = false
aux_price_per_unit = false
local RT_COUNT = 1
local HEAD_HEIGHT = 27
local HEAD_SPACE = 2
function LOAD()
AUCTION_PCT_COLORS = {
{ color=inline_color.blue, value=50 },
{ color=inline_color.green, value=80 },
{ color=inline_color.yellow, value=110 },
{ color=inline_color.orange, value=135 },
{ color=inline_color.red, value=huge },
}
local AUCTION_PCT_COLORS = {
{ color=inline_color.blue, value=50 },
{ color=inline_color.green, value=80 },
{ color=inline_color.yellow, value=110 },
{ color=inline_color.orange, value=135 },
{ color=inline_color.red, value=huge },
}
TIME_LEFT_STRINGS = {
color.red '30m', -- Short
color.orange '2h', -- Medium
color.yellow '8h', -- Long
color.blue '24h', -- Very Long
}
end
local TIME_LEFT_STRINGS = {
color.red '30m', -- Short
color.orange '2h', -- Medium
color.yellow '8h', -- Long
color.blue '24h', -- Very Long
}
function item_column_init(rt, cell)
function private.item_column_init(rt, cell)
local spacer = CreateFrame('Frame', nil, cell)
spacer:SetPoint('TOPLEFT', 0, 0)
spacer:SetHeight(rt.ROW_HEIGHT)
@@ -166,24 +164,24 @@ public.search_config = {
end
local price
if record.high_bidder then
price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = _G.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
price = aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell:SetText(money.to_string(price, true, false, nil, color))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = _G.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
price_a = aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
end
local price_b
if record_b.high_bidder then
price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = _G.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
price_b = aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
end
return sorting.compare(price_a, price_b, desc)
end,
@@ -194,12 +192,12 @@ public.search_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
price_a = price_a > 0 and price_a or (desc and -huge or huge)
price_b = price_b > 0 and price_b or (desc and -huge or huge)
@@ -308,24 +306,24 @@ public.auctions_config = {
fill = function(cell, record)
local price
if record.high_bidder then
price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = _G.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
price = aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
end
cell:SetText(money.to_string(price, true, false))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = _G.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price
price_a = aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price
end
local price_b
if record_b.high_bidder then
price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = _G.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
price_b = aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
end
return sorting.compare(price_a, price_b, desc)
end,
@@ -336,12 +334,12 @@ public.auctions_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
price_a = price_a > 0 and price_a or (desc and -huge or huge)
price_b = price_b > 0 and price_b or (desc and -huge or huge)
@@ -461,24 +459,24 @@ public.bids_config = {
fill = function(cell, record)
local price
if record.high_bidder then
price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = _G.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
price = aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell:SetText(money.to_string(price))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = _G.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
price_a = aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
end
local price_b
if record_b.high_bidder then
price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = _G.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
price_b = aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
end
return sorting.compare(price_a, price_b, desc)
end,
@@ -489,12 +487,12 @@ public.bids_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
price_a = price_a > 0 and price_a or (desc and -huge or huge)
price_b = price_b > 0 and price_b or (desc and -huge or huge)
@@ -520,7 +518,7 @@ public.bids_config = {
},
}
function record_percentage(record)
function private.record_percentage(record)
if not record then return end
local historical_value = aux.history.value(record.item_key) or 0
@@ -532,7 +530,7 @@ function record_percentage(record)
end
end
function percentage_color(pct)
function private.percentage_color(pct)
for i = 1, getn(AUCTION_PCT_COLORS) do
if pct < AUCTION_PCT_COLORS[i].value then
return AUCTION_PCT_COLORS[i].color
@@ -567,10 +565,10 @@ local methods = {
if rt.disabled then return end
if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then
_G.aux_price_per_unit = not _G.aux_price_per_unit
aux_price_per_unit = not aux_price_per_unit
for _, cell in rt.headCells do
if cell.info.isPrice then
cell:SetText(cell.info.title[_G.aux_price_per_unit and 1 or 2])
cell:SetText(cell.info.title[aux_price_per_unit and 1 or 2])
end
end
rt:SetSort()
@@ -997,7 +995,7 @@ function public.CreateAuctionResultsTable(parent, config)
rt:SetScript('OnShow', function()
for _, cell in this.headCells do
if cell.info.isPrice then
cell:SetText(cell.info.title[_G.aux_price_per_unit and 1 or 2])
cell:SetText(cell.info.title[aux_price_per_unit and 1 or 2])
end
end
end)
+7 -7
View File
@@ -33,7 +33,7 @@ function LOAD()
return unpack(ret)
end)
function set_aux_dropdown_style(dropdown)
function private.set_aux_dropdown_style(dropdown)
DropDownList1Backdrop:SetBackdrop{}
aux_border:Show()
aux_background:Show()
@@ -62,7 +62,7 @@ function LOAD()
end
end
function set_blizzard_dropdown_style()
function private.set_blizzard_dropdown_style()
DropDownList1Backdrop:SetBackdrop(blizzard_backdrop)
aux_border:Hide()
aux_background:Hide()
@@ -201,7 +201,7 @@ function public.resize_tab(tab, width, padding)
end
do
local mt = {__index=t}
local mt = { __index=t }
function mt.__index:create_tab(text)
local id = getn(self._tabs) + 1
@@ -265,7 +265,7 @@ do
function mt.__index:select(id)
self._selected = id
self:update()
;(self._on_select or nop)(id)
do (self._on_select or nop)(id) end
end
function mt.__index:update()
for _, tab in self._tabs do
@@ -312,7 +312,7 @@ function public.editbox(parent)
this:SetTextColor(color.text.enabled())
this.focused = true
this:HighlightText()
;(this.focus_gain or nop)()
do (this.focus_gain or nop)() end
end)
editbox:SetScript('OnEditFocusLost', function()
this.overlay:Show()
@@ -320,11 +320,11 @@ function public.editbox(parent)
this.focused = false
this:HighlightText(0, 0)
this:SetScript('OnUpdate', nil)
;(this.focus_loss or nop)()
do (this.focus_loss or nop)() end
end)
editbox:SetScript('OnTextChanged', function()
this.overlay:SetText((this.formatter or id)(this:GetText()))
;(this.change or nop)()
do (this.change or nop)() end
end)
editbox:SetScript('OnChar', function() (this.char or nop)() end)
do
+1 -1
View File
@@ -6,7 +6,7 @@ local ST_ROW_HEIGHT = 15
local ST_ROW_TEXT_SIZE = 14
local ST_HEAD_HEIGHT = 26.3
local ST_HEAD_SPACE = 2
local DEFAULT_COL_INFO = {{width=1}}
local DEFAULT_COL_INFO = {{ width=1 }}
local function GetTableIndex(tbl, value)
+4 -4
View File
@@ -27,9 +27,9 @@ function definition_helper_mt:__index(k)
return self
end
function definition_helper_mt:__newindex(k, v) local module, modifiers = _module[self], _modifiers[self]
local access = ACCESS[tremove(modifiers, 1)] or error'Invalid definition.'
local name = META[k] and (tremove(modifiers) or error'Invalid definition.') or k
if type(name) ~= 'string' or not strfind(name, '^[_%a][_%w]*') then error'Invalid definition.' end
local access = ACCESS[tremove(modifiers, 1)] or error'Definition missing access modifier.'
local name = META[k] and (tremove(modifiers) or error'Definition missing identifier.') or k
if type(name) ~= 'string' or not strfind(name, '^[_%a][_%w]*') then error('"%s" is not a valid identifier.', name) end
local type = META[k] or FIELD
module.defined[name .. OPERATION[type]] = module.defined[name .. OPERATION[type]] and error('"%s" already exists.', name) or true
for i = getn(modifiers), 1, -1 do v = module[FIELD][modifiers[i]](v) end
@@ -56,7 +56,7 @@ function global_mt:__index(key)
local module, environment, interface, definition_helper, accessors, mutators, fields, public_accessors, public_mutators, public_fields
environment, interface, definition_helper = {}, {}, setmetatable({}, definition_helper_mt)
accessors = { private=function() return definition_helper.private end, public=function() return definition_helper.public end }
mutators = setmetatable({ _=nop }, { __index=function(_, k) return function(v) if v == interface and (_G[k] == nil or _G.error(nil)) then _G[k] = v else definition_helper.private[k] = v end end end })
mutators = setmetatable({ _=nop }, { __index=function(_, k) return function(v) _G[k] = v == interface and _G[k] ~= nil and _G.error(nil) or v end end })
fields = setmetatable(
{ _E=environment, _I=interface, _G=_G, import=function(interface) import(module, interface) end, error=error, nop=nop, id=id },
{ __index=function(_, key) local accessor = accessors[key]; if accessor then return accessor() else return _G[key] end end }
+7 -7
View File
@@ -1,6 +1,6 @@
aux 'auctions_tab' local scan = aux.scan
auction_records = t
private.auction_records = t
function LOAD()
create_frames()
@@ -15,7 +15,7 @@ function CLOSE()
frame:Hide()
end
function update_listing()
function private.update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -29,7 +29,7 @@ function public.scan_auctions()
update_listing()
scan.start{
type = 'owner',
queries = {{blizzard_query = t}},
queries = {{ blizzard_query = t }},
on_page_loaded = function(page, total_pages)
status_bar:update_status(100 * (page - 1) / total_pages, 0)
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
@@ -49,7 +49,7 @@ function public.scan_auctions()
}
end
function test(record)
function private.test(record)
return function(index)
local auction_info = aux.info.auction(index, 'owner')
return auction_info and auction_info.search_signature == record.search_signature
@@ -62,7 +62,7 @@ do
local state = IDLE
local found_index
function find_auction(record)
function private.find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -78,7 +78,7 @@ do
cancel_button:SetScript('OnClick', function()
if test(record)(index) and listing:ContainsRecord(record) then
cancel_auction(index, partial(listing.RemoveAuctionRecord, listing, record))
cancel_auction(index, papply(listing.RemoveAuctionRecord, listing, record))
end
end)
cancel_button:Enable()
@@ -86,7 +86,7 @@ do
)
end
function on_update()
function private.on_update()
if state == IDLE or state == SEARCHING then
cancel_button:Disable()
end
+5 -5
View File
@@ -1,7 +1,7 @@
aux 'auctions_tab' local gui, auction_listing = aux.gui, aux.auction_listing
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -11,7 +11,7 @@ function create_frames()
frame.listing:SetPoint('BOTTOMLEFT', aux_frame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', aux_frame.content, 'BOTTOMRIGHT', 0, 0)
listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config)
listing:SetSort(1,2,3,4,5,6,7,8)
listing:Reset()
listing:SetHandler('OnCellClick', function(cell, button)
@@ -25,7 +25,7 @@ function create_frames()
end)
do
status_bar = gui.status_bar(frame)
private.status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
@@ -37,7 +37,7 @@ function create_frames()
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Cancel')
btn:Disable()
cancel_button = btn
private.cancel_button = btn
end
do
local btn = gui.button(frame)
+8 -8
View File
@@ -1,6 +1,6 @@
aux 'bids_tab' local scan = aux.scan
auction_records = t
private.auction_records = t
function LOAD()
create_frames()
@@ -15,7 +15,7 @@ function CLOSE()
frame:Hide()
end
function update_listing()
function private.update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -29,7 +29,7 @@ function public.scan_bids()
update_listing()
scan.start{
type = 'bidder',
queries = {{blizzard_query=t}},
queries = {{ blizzard_query=t }},
on_page_loaded = function(page, total_pages)
status_bar:update_status(100 * (page - 1) / total_pages, 0)
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
@@ -49,7 +49,7 @@ function public.scan_bids()
}
end
function test(record)
function private.test(record)
return function(index)
local auction_info = aux.info.auction(index, 'bidder')
return auction_info and auction_info.search_signature == record.search_signature
@@ -62,7 +62,7 @@ do
local state = IDLE
local found_index
function find_auction(record)
function private.find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -85,7 +85,7 @@ do
place_bid('bidder', index, record.bid_price, record.bid_price < record.buyout_price and function()
aux.info.bid_update(record)
listing:SetDatabase()
end or partial(listing.RemoveAuctionRecord, listing, record))
end or papply(listing.RemoveAuctionRecord, listing, record))
end
end)
bid_button:Enable()
@@ -94,7 +94,7 @@ do
if record.buyout_price > 0 then
buyout_button:SetScript('OnClick', function()
if test(record)(index) and listing:ContainsRecord(record) then
place_bid('bidder', index, record.buyout_price, partial(listing.RemoveAuctionRecord, listing, record))
place_bid('bidder', index, record.buyout_price, papply(listing.RemoveAuctionRecord, listing, record))
end
end)
buyout_button:Enable()
@@ -103,7 +103,7 @@ do
)
end
function on_update()
function private.on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+6 -6
View File
@@ -1,7 +1,7 @@
aux 'bids_tab' local gui, auction_listing = aux.gui, aux.auction_listing
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -11,7 +11,7 @@ function create_frames()
frame.listing:SetPoint('BOTTOMLEFT', aux_frame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', aux_frame.content, 'BOTTOMRIGHT', 0, 0)
listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config)
listing:SetSort(1,2,3,4,5,6,7,8)
listing:Reset()
listing:SetHandler('OnCellClick', function(cell, button)
@@ -29,7 +29,7 @@ function create_frames()
end)
do
status_bar = gui.status_bar(frame)
private.status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
@@ -41,14 +41,14 @@ function create_frames()
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Bid')
btn:Disable()
bid_button = btn
private.bid_button = btn
end
do
local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText('Buyout')
btn:Disable()
buyout_button = btn
private.buyout_button = btn
end
do
local btn = gui.button(frame)
+23 -23
View File
@@ -20,19 +20,19 @@ do
end
end
function read_settings(item_key)
function private.read_settings(item_key)
item_key = item_key or selected_item.key
return data[item_key] and persistence.read(settings_schema, data[item_key]) or default_settings
end
function write_settings(settings, item_key)
function private.write_settings(settings, item_key)
item_key = item_key or selected_item.key
data[item_key] = persistence.write(settings_schema, settings)
end
local scan_id, inventory_records, existing_auctions = 0, t, t
function refresh_button_click()
function private.refresh_button_click()
aux.scan.abort(scan_id)
refresh_entries()
refresh = true
@@ -69,25 +69,25 @@ function USE_ITEM(item_info)
select_item(item_info.item_key)
end
function get_unit_start_price()
function private.get_unit_start_price()
local money_text = unit_start_price:GetText()
return aux.money.from_string(money_text) or 0
end
function set_unit_start_price(amount)
function private.set_unit_start_price(amount)
unit_start_price:SetText(aux.money.to_string(amount, true, nil, 3, nil, true))
end
function get_unit_buyout_price()
function private.get_unit_buyout_price()
local money_text = unit_buyout_price:GetText()
return aux.money.from_string(money_text) or 0
end
function set_unit_buyout_price(amount)
function private.set_unit_buyout_price(amount)
unit_buyout_price:SetText(aux.money.to_string(amount, true, nil, 3, nil, true))
end
function update_inventory_listing()
function private.update_inventory_listing()
if not ACTIVE then return end
item_listing.populate(inventory_listing, values(filter(copy(inventory_records), function(record)
local settings = read_settings(record.key)
@@ -95,7 +95,7 @@ function update_inventory_listing()
end)))
end
function update_auction_listing()
function private.update_auction_listing()
if not ACTIVE then return end
local auction_rows = t
if selected_item then
@@ -177,7 +177,7 @@ function public.select_item(item_key)
end
end
function price_update()
function private.price_update()
if selected_item then
local settings = read_settings()
@@ -195,7 +195,7 @@ function price_update()
end
end
function post_auctions()
function private.post_auctions()
if selected_item then
local unit_start_price = get_unit_start_price()
local unit_buyout_price = get_unit_buyout_price()
@@ -239,7 +239,7 @@ function post_auctions()
end
end
function validate_parameters()
function private.validate_parameters()
if not selected_item then
post_button:Disable()
return
@@ -259,7 +259,7 @@ function validate_parameters()
post_button:Enable()
end
function update_item_configuration()
function private.update_item_configuration()
if not selected_item then
refresh_button:Disable()
@@ -314,7 +314,7 @@ function update_item_configuration()
end
end
function undercut(record, stack_size, stack)
function private.undercut(record, stack_size, stack)
local start_price = round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
local buyout_price = round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
if not record.own then
@@ -324,7 +324,7 @@ function undercut(record, stack_size, stack)
return start_price / stack_size, buyout_price / stack_size
end
function quantity_update(max_count)
function private.quantity_update(max_count)
if selected_item then
local max_stack_count = selected_item.max_charges and selected_item.availability[stack_size_slider:GetValue()] or floor(selected_item.availability[0] / stack_size_slider:GetValue())
stack_count_slider:SetMinMaxValues(1, max_stack_count)
@@ -335,7 +335,7 @@ function quantity_update(max_count)
refresh = true
end
function unit_vendor_price(item_key)
function private.unit_vendor_price(item_key)
for slot in info.inventory do auto[slot] = true
local item_info = info.container_item(unpack(slot))
if item_info and item_info.item_key == item_key then
@@ -355,7 +355,7 @@ function unit_vendor_price(item_key)
end
end
function update_historical_value_button()
function private.update_historical_value_button()
if selected_item then
local historical_value = history.value(selected_item.key)
historical_value_button.amount = historical_value
@@ -363,7 +363,7 @@ function update_historical_value_button()
end
end
function set_item(item)
function private.set_item(item)
local settings = read_settings(item.key)
item.unit_vendor_price = unit_vendor_price(item.key)
@@ -398,7 +398,7 @@ function set_item(item)
refresh = true
end
function update_inventory_records()
function private.update_inventory_records()
local auctionable_map = tt
for slot in info.inventory do auto[slot] = true
for item_info in present(info.container_item(unpack(slot))) do
@@ -436,7 +436,7 @@ function update_inventory_records()
refresh = true
end
function refresh_entries()
function private.refresh_entries()
if selected_item then
local item_id, suffix_id = selected_item.item_id, selected_item.suffix_id
local item_key = item_id .. ':' .. suffix_id
@@ -481,7 +481,7 @@ function refresh_entries()
end
end
function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
existing_auctions[key] = existing_auctions[key] or t
local entry
for _, record in existing_auctions[key] do
@@ -497,7 +497,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
return entry
end
function on_update()
function private.on_update()
if refresh then
refresh = false
price_update()
@@ -509,7 +509,7 @@ function on_update()
validate_parameters()
end
function initialize_duration_dropdown()
function private.initialize_duration_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(duration_dropdown, this.value)
local settings = read_settings()
+26 -26
View File
@@ -1,7 +1,7 @@
aux 'post_tab' local gui, listing, item_listing, money, search_tab = aux.gui, aux.listing, aux.item_listing, aux.money, aux.search_tab
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -35,12 +35,12 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Show hidden items')
show_hidden_checkbox = checkbox
private.show_hidden_checkbox = checkbox
end
gui.horizontal_line(frame.inventory, -48)
inventory_listing = item_listing.create(
private.inventory_listing = item_listing.create(
frame.inventory,
function()
if arg1 == 'LeftButton' then
@@ -56,15 +56,15 @@ function create_frames()
end
)
auction_listing = listing.CreateScrollingTable(frame.auctions)
private.auction_listing = listing.CreateScrollingTable(frame.auctions)
auction_listing:SetColInfo{
{name='Auctions', width=.12, align='CENTER'},
{name='Left', width=.1, align='CENTER'},
{name='Qty', width=.08, align='CENTER'},
{name='Bid/ea', width=.22, align='RIGHT'},
{name='Bid Pct', width=.13, align='CENTER'},
{name='Buy/ea', width=.22, align='RIGHT'},
{name='Buy Pct', width=.13, align='CENTER'}
{ name='Auctions', width=.12, align='CENTER' },
{ name='Left', width=.1, align='CENTER' },
{ name='Qty', width=.08, align='CENTER' },
{ name='Bid/ea', width=.22, align='RIGHT' },
{ name='Bid Pct', width=.13, align='CENTER' },
{ name='Buy/ea', width=.22, align='RIGHT' },
{ name='Buy Pct', width=.13, align='CENTER' },
}
auction_listing:EnableSorting(false)
auction_listing:DisableSelection(true)
@@ -81,7 +81,7 @@ function create_frames()
end)
do
status_bar = gui.status_bar(frame)
private.status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
@@ -93,17 +93,17 @@ function create_frames()
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Post')
btn:SetScript('OnClick', post_auctions)
post_button = btn
private.post_button = btn
end
do
local btn = gui.button(frame.parameters)
btn:SetPoint('TOPLEFT', post_button, 'TOPRIGHT', 5, 0)
btn:SetText('Refresh')
btn:SetScript('OnClick', refresh_button_click)
refresh_button = btn
private.refresh_button = btn
end
do
item = gui.item(frame.parameters)
private.item = gui.item(frame.parameters)
item:SetPoint('TOPLEFT', 10, -6)
item.button:SetScript('OnEnter', function()
if selected_item then
@@ -143,7 +143,7 @@ function create_frames()
slider.editbox:SetNumeric(true)
slider.editbox:SetMaxLetters(3)
slider.label:SetText('Stack Size')
stack_size_slider = slider
private.stack_size_slider = slider
end
do
local slider = gui.slider(frame.parameters)
@@ -166,7 +166,7 @@ function create_frames()
end)
slider.editbox:SetNumeric(true)
slider.label:SetText('Stack Count')
stack_count_slider = slider
private.stack_count_slider = slider
end
do
local dropdown = gui.dropdown(frame.parameters)
@@ -179,12 +179,12 @@ function create_frames()
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, initialize_duration_dropdown)
end)
duration_dropdown = dropdown
private.duration_dropdown = dropdown
end
do
local label = gui.label(frame.parameters, gui.font_size.medium)
label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0)
deposit = label
private.deposit = label
end
do
local checkbox = gui.checkbox(frame.parameters)
@@ -198,7 +198,7 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Hide this item')
hide_checkbox = checkbox
private.hide_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -231,9 +231,9 @@ function create_frames()
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
start_price_percentage = label
private.start_price_percentage = label
end
unit_start_price = editbox
private.unit_start_price = editbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -266,9 +266,9 @@ function create_frames()
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
buyout_price_percentage = label
private.buyout_price_percentage = label
end
unit_buyout_price = editbox
private.unit_buyout_price = editbox
end
do
local btn = gui.button(frame.parameters, 14)
@@ -285,6 +285,6 @@ function create_frames()
local label = gui.label(btn, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
label:SetText('Historical Value')
historical_value_button = btn
private.historical_value_button = btn
end
end
+5 -3
View File
@@ -19,7 +19,7 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
}
do
local function action()
_G.aux_auto_buy_filter = _G[this:GetParent():GetName() .. 'EditBox']:GetText()
aux_auto_buy_filter = _G[this:GetParent():GetName() .. 'EditBox']:GetText()
update_auto_buy_filter()
end
@@ -47,7 +47,9 @@ do
}
end
RESULTS, SAVED, FILTER = 1, 2, 3
private.RESULTS = 1
private.SAVED = 2
private.FILTER = 3
function LOAD()
create_frames()
@@ -113,7 +115,7 @@ function public.add_filter(filter_string)
search_box:SetText(old_filter_string .. filter_string)
end
function blizzard_page_index(str)
function private.blizzard_page_index(str)
if tonumber(str) then
return max(0, tonumber(str) - 1)
end
+23 -23
View File
@@ -1,11 +1,11 @@
aux 'search_tab' local filter_util = aux.filter_util
function valid_level(str)
function private.valid_level(str)
local level = tonumber(str)
return level and bounded(1, 60, level)
end
blizzard_query = setmetatable(t, {
private.blizzard_query = setmetatable(t, {
__index = function(_, key)
if key == 'name' then
return name_input:GetText()
@@ -58,7 +58,7 @@ blizzard_query = setmetatable(t, {
end,
})
function update_form()
function private.update_form()
if blizzard_query.class and GetAuctionItemSubClasses(blizzard_query.class) then
subclass_dropdown.button:Enable()
else
@@ -99,7 +99,7 @@ function update_form()
end
end
function get_filter_builder_query()
function private.get_filter_builder_query()
local filter_string
local function add(part)
@@ -143,7 +143,7 @@ function get_filter_builder_query()
return filter_string or ''
end
function set_form(filter)
function private.set_form(filter)
clear_form()
for _, component in filter.components do
if component[1] == 'blizzard' then
@@ -155,7 +155,7 @@ function set_form(filter)
update_filter_display()
end
function clear_form()
function private.clear_form()
blizzard_query.name = ''
name_input:ClearFocus()
blizzard_query.exact = false
@@ -174,14 +174,14 @@ function clear_form()
update_filter_display()
end
function import_filter_string()
function private.import_filter_string()
local filter, error = filter_util.parse_filter_string(select(3, strfind(search_box:GetText(), '^([^;]*)')))
if filter or print(error) then
set_form(filter)
end
end
function export_filter_string()
function private.export_filter_string()
search_box:SetText(get_filter_builder_query())
filter_parameter_input:ClearFocus()
end
@@ -230,14 +230,14 @@ function public.formatted_post_filter(components)
return '<html><body><p>' .. str .. '</p></body></html>'
end
function data_link(id, str)
function private.data_link(id, str)
return '|H' .. id .. '|h' .. str .. '|h'
end
post_filter = t
filter_builder_state = T('selected', 0)
private.post_filter = t
private.filter_builder_state = T('selected', 0)
function data_link_click()
function private.data_link_click()
local button = arg3
local index = tonumber(arg1)
if button == 'LeftButton' then
@@ -248,7 +248,7 @@ function data_link_click()
update_filter_display()
end
function remove_component(index)
function private.remove_component(index)
index = index or filter_builder_state.selected
if filter_builder_state.selected >= index then
filter_builder_state.selected = max(filter_builder_state.selected - 1, min(1, getn(post_filter)))
@@ -257,12 +257,12 @@ function remove_component(index)
tremove(post_filter, index)
end
function add_component(component)
function private.add_component(component)
filter_builder_state.selected = filter_builder_state.selected + 1
tinsert(post_filter, filter_builder_state.selected, component)
end
function add_post_filter()
function private.add_post_filter()
for str in present(filter_input:GetText()) do
for filter in present(filter_util.filters[str]) do
if filter.input_type ~= '' then
@@ -284,13 +284,13 @@ end
do
local text = ''
function update_filter_display()
function private.update_filter_display()
text = formatted_post_filter(post_filter)
filter_display:SetWidth(filter_display_size())
set_filter_display_offset()
filter_display:SetText(text)
end
function filter_display_size()
function private.filter_display_size()
local font, font_size = filter_display:GetFont()
filter_display.measure:SetFont(font, font_size)
local lines = 0
@@ -304,7 +304,7 @@ do
end
end
function set_filter_display_offset(x_offset, y_offset)
function private.set_filter_display_offset(x_offset, y_offset)
local scroll_frame = filter_display:GetParent()
x_offset, y_offset = x_offset or scroll_frame:GetHorizontalScroll(), y_offset or scroll_frame:GetVerticalScroll()
local width, height = filter_display_size()
@@ -316,7 +316,7 @@ function set_filter_display_offset(x_offset, y_offset)
scroll_frame:SetVerticalScroll(bounded(y_lower_bound, y_upper_bound, y_offset))
end
function initialize_filter_dropdown()
function private.initialize_filter_dropdown()
for filter in temp-S('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity', 'left', 'utilizable', 'discard') do
UIDropDownMenu_AddButton(T(
'text', filter,
@@ -336,7 +336,7 @@ function initialize_filter_dropdown()
end
end
function initialize_class_dropdown()
function private.initialize_class_dropdown()
local function on_click()
if this.value ~= blizzard_query.class then
UIDropDownMenu_SetSelectedValue(class_dropdown, this.value)
@@ -353,7 +353,7 @@ function initialize_class_dropdown()
end
end
function initialize_subclass_dropdown()
function private.initialize_subclass_dropdown()
local function on_click()
if this.value ~= blizzard_query.subclass then
UIDropDownMenu_SetSelectedValue(subclass_dropdown, this.value)
@@ -371,7 +371,7 @@ function initialize_subclass_dropdown()
end
end
function initialize_slot_dropdown()
function private.initialize_slot_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value)
update_form()
@@ -386,7 +386,7 @@ function initialize_slot_dropdown()
end
end
function initialize_quality_dropdown()
function private.initialize_quality_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value)
update_form()
+58 -58
View File
@@ -2,8 +2,8 @@ aux 'search_tab' local gui, completion, listing, auction_listing, filter_util =
FILTER_SPACING = 28.5
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -49,7 +49,7 @@ function create_frames()
fake_icon_part:SetText('_')
end
settings_button = btn
private.settings_button = btn
end
do
local panel = CreateFrame('Frame', nil, frame)
@@ -59,14 +59,14 @@ function create_frames()
panel:SetPoint('RIGHT', 0, 0)
panel:SetHeight(42)
panel:Hide()
settings = panel
private.settings = panel
end
do
local panel = CreateFrame('Frame', nil, frame)
panel:SetPoint('LEFT', settings_button, 'RIGHT', 0, 0)
panel:SetPoint('RIGHT', 0, 1)
panel:SetHeight(40)
controls = panel
private.controls = panel
end
do
local function change()
@@ -93,7 +93,7 @@ function create_frames()
label:SetPoint('RIGHT', editbox, 'LEFT', -6, 0)
label:SetText('Pages')
label:SetTextColor(color.text.enabled())
first_page_input = editbox
private.first_page_input = editbox
end
do
local editbox = gui.editbox(settings)
@@ -107,7 +107,7 @@ function create_frames()
label:SetPoint('RIGHT', editbox, 'LEFT', -3.5, 0)
label:SetText('-')
label:SetTextColor(color.text.enabled())
last_page_input = editbox
private.last_page_input = editbox
end
end
do
@@ -118,9 +118,9 @@ function create_frames()
btn:SetText('Real Time Mode')
btn:SetScript('OnClick', function()
this:SetChecked(not this:GetChecked())
_G.this = first_page_input
this = first_page_input
first_page_input:GetScript('OnTextChanged')()
_G.this = last_page_input
this = last_page_input
last_page_input:GetScript('OnTextChanged')()
end)
public.real_time_button = btn
@@ -138,7 +138,7 @@ function create_frames()
StaticPopup_Show('AUX_SEARCH_AUTO_BUY')
end
end)
auto_buy_button = btn
private.auto_buy_button = btn
end
do
local btn = gui.checkbutton(settings)
@@ -149,7 +149,7 @@ function create_frames()
btn:SetScript('OnClick', function()
if this:GetChecked() then
this:SetChecked(false)
_G.aux_auto_buy_filter = nil
aux_auto_buy_filter = nil
this.prettified = nil
auto_buy_validator = nil
else
@@ -166,7 +166,7 @@ function create_frames()
btn:SetScript('OnLeave', function()
GameTooltip:Hide()
end)
auto_buy_filter_button = btn
private.auto_buy_filter_button = btn
end
do
local btn = gui.button(controls, 25)
@@ -175,7 +175,7 @@ function create_frames()
btn:SetHeight(25)
btn:SetText('<')
btn:SetScript('OnClick', previous_search)
previous_button = btn
private.previous_button = btn
end
do
local btn = gui.button(controls, 25)
@@ -184,7 +184,7 @@ function create_frames()
btn:SetHeight(25)
btn:SetText('>')
btn:SetScript('OnClick', next_search)
next_button = btn
private.next_button = btn
end
do
local btn = gui.button(controls, gui.font_size.huge)
@@ -199,7 +199,7 @@ function create_frames()
end
execute()
end)
start_button = btn
private.start_button = btn
end
do
local btn = gui.button(controls, gui.font_size.huge)
@@ -210,7 +210,7 @@ function create_frames()
btn:SetScript('OnClick', function()
aux.scan.abort(search_scan_id)
end)
stop_button = btn
private.stop_button = btn
end
do
local btn = gui.button(controls, gui.font_size.huge)
@@ -221,7 +221,7 @@ function create_frames()
btn:SetScript('OnClick', function()
execute(true)
end)
resume_button = btn
private.resume_button = btn
end
do
local editbox = gui.editbox(controls)
@@ -240,7 +240,7 @@ function create_frames()
this:HighlightText(0, 0)
end)
editbox.enter = execute
search_box = editbox
private.search_box = editbox
end
do
gui.horizontal_line(frame, -40)
@@ -252,7 +252,7 @@ function create_frames()
btn:SetHeight(22)
btn:SetText('Search Results')
btn:SetScript('OnClick', function() subtab = RESULTS end)
search_results_button = btn
private.search_results_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -261,7 +261,7 @@ function create_frames()
btn:SetHeight(22)
btn:SetText('Saved Searches')
btn:SetScript('OnClick', function() subtab = SAVED end)
saved_searches_button = btn
private.saved_searches_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -270,28 +270,28 @@ function create_frames()
btn:SetHeight(22)
btn:SetText('Filter Builder')
btn:SetScript('OnClick', function() subtab = FILTER end)
new_filter_button = btn
private.new_filter_button = btn
end
do
local frame = CreateFrame('Frame', nil, frame)
frame:SetWidth(265)
frame:SetHeight(25)
frame:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
status_bar_frame = frame
private.status_bar_frame = frame
end
do
local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0)
btn:SetText('Bid')
btn:Disable()
bid_button = btn
private.bid_button = btn
end
do
local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText('Buyout')
btn:Disable()
buyout_button = btn
private.buyout_button = btn
end
do
local btn = gui.button(frame.results)
@@ -340,7 +340,7 @@ function create_frames()
end
do
local editbox = gui.editbox(frame.filter)
editbox.complete_item = completion.complete(function() return _G.aux_auctionable_items end)
editbox.complete_item = completion.complete(function() return aux_auctionable_items end)
editbox:SetPoint('TOPLEFT', 14, -FILTER_SPACING)
editbox:SetWidth(260)
editbox.char = function()
@@ -359,11 +359,11 @@ function create_frames()
end
end)
editbox.change = update_form
editbox.enter = partial(editbox.ClearFocus, editbox)
editbox.enter = papply(editbox.ClearFocus, editbox)
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Name')
name_input = editbox
private.name_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -372,7 +372,7 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText('Exact')
exact_checkbox = checkbox
private.exact_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -386,7 +386,7 @@ function create_frames()
max_level_input:SetFocus()
end
end)
editbox.enter = partial(editbox.ClearFocus, editbox)
editbox.enter = papply(editbox.ClearFocus, editbox)
editbox.change = function()
local valid_level = valid_level(this:GetText())
if tostring(valid_level) ~= this:GetText() then
@@ -397,7 +397,7 @@ function create_frames()
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Level Range')
min_level_input = editbox
private.min_level_input = editbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -411,7 +411,7 @@ function create_frames()
name_input:SetFocus()
end
end)
editbox.enter = partial(editbox.ClearFocus, editbox)
editbox.enter = papply(editbox.ClearFocus, editbox)
editbox.change = function()
local valid_level = valid_level(this:GetText())
if tostring(valid_level) ~= this:GetText() then
@@ -422,7 +422,7 @@ function create_frames()
local label = gui.label(editbox, gui.font_size.medium)
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
label:SetText('-')
max_level_input = editbox
private.max_level_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -431,11 +431,11 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText('Usable')
usable_checkbox = checkbox
private.usable_checkbox = checkbox
end
do
local dropdown = gui.dropdown(frame.filter)
class_dropdown = dropdown
private.class_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', min_level_input, 'BOTTOMLEFT', 0, 5 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -448,7 +448,7 @@ function create_frames()
end
do
local dropdown = gui.dropdown(frame.filter)
subclass_dropdown = dropdown
private.subclass_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', class_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -461,7 +461,7 @@ function create_frames()
end
do
local dropdown = gui.dropdown(frame.filter)
slot_dropdown = dropdown
private.slot_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', subclass_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -474,7 +474,7 @@ function create_frames()
end
do
local dropdown = gui.dropdown(frame.filter)
quality_dropdown = dropdown
private.quality_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', slot_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -498,7 +498,7 @@ function create_frames()
local label = gui.label(dropdown, gui.font_size.medium)
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
label:SetText('Post Filter')
filter_dropdown = dropdown
private.filter_dropdown = dropdown
end
do
local input = gui.editbox(frame.filter)
@@ -525,7 +525,7 @@ function create_frames()
add_post_filter()
end
end
filter_input = input
private.filter_input = input
end
do
local input = gui.editbox(frame.filter)
@@ -537,7 +537,7 @@ function create_frames()
input.char = function() this:complete() end
input.enter = add_post_filter
input:Hide()
filter_parameter_input = input
private.filter_parameter_input = input
end
do
local scroll_frame = CreateFrame('ScrollFrame', nil, frame.filter)
@@ -578,14 +578,14 @@ function create_frames()
scroll_child:SetWidth(1)
scroll_child:SetHeight(1)
scroll_child:SetScript('OnHyperlinkClick', data_link_click)
-- scroll_child:SetHyperlinkFormat("format")
-- scroll_child:SetHyperlinkFormat("format") TODO
scroll_child.measure = scroll_child:CreateFontString()
filter_display = scroll_child
private.filter_display = scroll_child
end
status_bars = t
tables = t
for _=1,5 do
private.status_bars = t
private.tables = t
for _ = 1, 5 do
local status_bar = gui.status_bar(frame)
status_bar:SetAllPoints(status_bar_frame)
status_bar:Hide()
@@ -618,16 +618,16 @@ function create_frames()
add_filter(data.search.filter_string)
elseif button == 'LeftButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index > 1 then
local temp = _G.aux_favorite_searches[data.index - 1]
_G.aux_favorite_searches[data.index - 1] = data.search
_G.aux_favorite_searches[data.index] = temp
local temp = aux_favorite_searches[data.index - 1]
aux_favorite_searches[data.index - 1] = data.search
aux_favorite_searches[data.index] = temp
update_search_listings()
end
elseif button == 'RightButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index < getn(_G.aux_favorite_searches) then
local temp = _G.aux_favorite_searches[data.index + 1]
_G.aux_favorite_searches[data.index + 1] = data.search
_G.aux_favorite_searches[data.index] = temp
if st == favorite_searches_listing and data.index < getn(aux_favorite_searches) then
local temp = aux_favorite_searches[data.index + 1]
aux_favorite_searches[data.index + 1] = data.search
aux_favorite_searches[data.index] = temp
update_search_listings()
end
elseif button == 'LeftButton' then
@@ -635,9 +635,9 @@ function create_frames()
execute()
elseif button == 'RightButton' then
if st == recent_searches_listing then
tinsert(_G.aux_favorite_searches, 1, data.search)
tinsert(aux_favorite_searches, 1, data.search)
elseif st == favorite_searches_listing then
tremove(_G.aux_favorite_searches, data.index)
tremove(aux_favorite_searches, data.index)
end
update_search_listings()
end
@@ -654,16 +654,16 @@ function create_frames()
end
}
recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
private.recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing:SetColInfo{{ name='Recent Searches', width=1 }}
recent_searches_listing:EnableSorting(false)
recent_searches_listing:DisableSelection(true)
recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite)
favorite_searches_listing:SetColInfo{{name='Favorite Searches', width=1}}
private.favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite)
favorite_searches_listing:SetColInfo{{ name='Favorite Searches', width=1 }}
favorite_searches_listing:EnableSorting(false)
favorite_searches_listing:DisableSelection(true)
favorite_searches_listing:SetHandler('OnClick', handlers.OnClick)
+21 -21
View File
@@ -1,6 +1,6 @@
aux 'search_tab' local info, scan = aux.info, aux.scan
_G.aux_auto_buy_filter = ''
aux_auto_buy_filter = ''
do
local id = 0
@@ -19,7 +19,7 @@ do
function private.current_search.get() return searches[search_index] end
function update_search(index)
function private.update_search(index)
searches[search_index].status_bar:Hide()
searches[search_index].table:Hide()
searches[search_index].table:SetSelectedRecord()
@@ -46,7 +46,7 @@ do
update_continuation()
end
function new_search(filter_string)
function private.new_search(filter_string)
while getn(searches) > search_index do
tremove(searches)
end
@@ -71,26 +71,26 @@ do
update_search(getn(searches))
end
function previous_search()
function private.previous_search()
search_box:ClearFocus()
update_search(search_index - 1)
subtab = RESULTS
end
function next_search()
function private.next_search()
search_box:ClearFocus()
update_search(search_index + 1)
subtab = RESULTS
end
end
function close_settings()
function private.close_settings()
if settings_button.open then
settings_button:Click()
end
end
function update_continuation()
function private.update_continuation()
if current_search.continuation then
resume_button:Show()
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
@@ -100,7 +100,7 @@ function update_continuation()
end
end
function discard_continuation()
function private.discard_continuation()
scan.abort(search_scan_id)
current_search.continuation = nil
update_continuation()
@@ -116,9 +116,9 @@ function update_start_stop()
end
end
function update_auto_buy_filter()
if _G.aux_auto_buy_filter ~= '' then
local queries, error = aux.filter_util.queries(_G.aux_auto_buy_filter)
function private.update_auto_buy_filter()
if aux_auto_buy_filter ~= '' then
local queries, error = aux.filter_util.queries(aux_auto_buy_filter)
if queries then
if getn(queries) > 1 then
print 'Error: The automatic buyout filter does not support multi-queries'
@@ -134,10 +134,10 @@ function update_auto_buy_filter()
print('Invalid auto buy filter:', error)
end
end
_G.aux_auto_buy_filter = ''
aux_auto_buy_filter = ''
end
function start_real_time_scan(query, search, continuation)
function private.start_real_time_scan(query, search, continuation)
local ignore_page
if not search then
@@ -167,7 +167,7 @@ function start_real_time_scan(query, search, continuation)
if not ignore_page then
if search.auto_buy then
ctrl.suspend()
place_bid('list', auction_record.index, auction_record.buyout_price, partial(ctrl.resume, true))
place_bid('list', auction_record.index, auction_record.buyout_price, papply(ctrl.resume, true))
thread(when, later(GetTime(), 10), ctrl.resume, false)
else
tinsert(new_records, auction_record)
@@ -211,7 +211,7 @@ function start_real_time_scan(query, search, continuation)
}
end
function start_search(queries, continuation)
function private.start_search(queries, continuation)
local current_query, current_page, total_queries, start_query, start_page
local search = current_search
@@ -260,7 +260,7 @@ function start_search(queries, continuation)
on_auction = function(auction_record, ctrl)
if search.auto_buy then
ctrl.suspend()
place_bid('list', auction_record.index, auction_record.buyout_price, partial(ctrl.resume, true))
place_bid('list', auction_record.index, auction_record.buyout_price, papply(ctrl.resume, true))
thread(when, later(GetTime(), 10), ctrl.resume, false)
elseif getn(search.records) < 1000 then
tinsert(search.records, auction_record)
@@ -368,7 +368,7 @@ function public.execute(resume, real_time)
end
end
function test(record)
function private.test(record)
return function(index)
local auction_info = info.auction(index)
return auction_info and auction_info.search_signature == record.search_signature
@@ -381,7 +381,7 @@ do
local state = IDLE
local found_index
function find_auction(record)
function private.find_auction(record)
local search = current_search
if not search.table:ContainsRecord(record) or is_player(record.owner) then
@@ -414,7 +414,7 @@ do
place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function()
info.bid_update(record)
search.table:SetDatabase()
end or partial(search.table.RemoveAuctionRecord, search.table, record))
end or papply(search.table.RemoveAuctionRecord, search.table, record))
end
end)
bid_button:Enable()
@@ -423,7 +423,7 @@ do
if record.buyout_price > 0 then
buyout_button:SetScript('OnClick', function()
if test(record)(index) and search.table:ContainsRecord(record) then
place_bid('list', index, record.buyout_price, partial(search.table.RemoveAuctionRecord, search.table, record))
place_bid('list', index, record.buyout_price, papply(search.table.RemoveAuctionRecord, search.table, record))
end
end)
buyout_button:Enable()
@@ -432,7 +432,7 @@ do
)
end
function on_update()
function private.on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+10 -10
View File
@@ -1,14 +1,14 @@
aux 'search_tab'
_G.aux_favorite_searches = t
_G.aux_recent_searches = t
aux_favorite_searches = t
aux_recent_searches = t
function update_search_listings()
function private.update_search_listings()
local favorite_search_rows = t
for i, favorite_search in _G.aux_favorite_searches do
for i, favorite_search in aux_favorite_searches do
local name = strsub(favorite_search.prettified, 1, 250)
tinsert(favorite_search_rows, {
cols = {{value=name}},
cols = {{ value=name }},
search = favorite_search,
index = i,
})
@@ -16,7 +16,7 @@ function update_search_listings()
favorite_searches_listing:SetData(favorite_search_rows)
local recent_search_rows = t
for i, recent_search in _G.aux_recent_searches do
for i, recent_search in aux_recent_searches do
local name = strsub(recent_search.prettified, 1, 250)
tinsert(recent_search_rows, {
cols = {{ value=name }},
@@ -27,13 +27,13 @@ function update_search_listings()
recent_searches_listing:SetData(recent_search_rows)
end
function new_recent_search(filter_string, prettified)
tinsert(_G.aux_recent_searches, 1, {
function private.new_recent_search(filter_string, prettified)
tinsert(aux_recent_searches, 1, {
filter_string = filter_string,
prettified = prettified,
})
while getn(_G.aux_recent_searches) > 50 do
tremove(_G.aux_recent_searches)
while getn(aux_recent_searches) > 50 do
tremove(aux_recent_searches)
end
update_search_listings()
end
+3 -3
View File
@@ -1,6 +1,6 @@
aux 'core'
COLORS = {
local COLORS = {
text = {enabled = {255, 254, 250, 1}, disabled = {147, 151, 139, 1}},
label = {enabled = {216, 225, 211, 1}, disabled = {150, 148, 140, 1}},
link = {153, 255, 255, 1},
@@ -31,9 +31,9 @@ do
return self.private.callback(color)
end
end
function color_accessor(callback)
function private.color_accessor(callback)
return function()
return index_function({callback=callback, table=COLORS}, index_handler)
return index_function({ callback=callback, table=COLORS }, index_handler)
end
end
end
+2 -2
View File
@@ -67,7 +67,7 @@ function public.vararg.select(arg)
end
end
public.join = _G.table.concat
public.join = table.concat
function public.range(arg1, arg2)
local i, n = arg2 and arg1 or 1, arg2 or arg1
@@ -91,7 +91,7 @@ do
end
end
function public.vararg.partial(arg)
function public.vararg.papply(arg)
local f, arg1 = tremove(arg, 1), perm-arg
return vararg(function(arg)
for i = 1, getn(arg) do
+12 -12
View File
@@ -1,6 +1,6 @@
aux 'filter_util' local info = aux.info
function default_filter(str)
function private.default_filter(str)
return {
input_type = '',
validator = function()
@@ -200,7 +200,7 @@ public.filters = {
},
}
function operator(str)
function private.operator(str)
local operator = str == 'not' and A('operator', 'not', 1)
for name in temp-S('and', 'or') do
for arity in present(select(3, strfind(str, '^' .. name .. '(%d*)$'))) do
@@ -231,8 +231,8 @@ do
end
for _, parser in temp-A(
temp-A('class', info.item_class_index),
temp-A('subclass', partial(info.item_subclass_index, index(self.class, 2) or 0)),
temp-A('slot', partial(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0)),
temp-A('subclass', papply(info.item_subclass_index, index(self.class, 2) or 0)),
temp-A('slot', papply(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0)),
temp-A('quality', info.item_quality_index)
) do
if not self[parser[1]] then
@@ -254,12 +254,12 @@ do
end
end,
}
function blizzard_filter_parser()
function private.blizzard_filter_parser()
return setmetatable(t, mt)
end
end
function parse_parameter(input_type, str)
function private.parse_parameter(input_type, str)
if input_type == 'money' then
local money = aux.money.from_string(str)
return money and money > 0 and money or nil
@@ -290,7 +290,7 @@ function public.parse_filter_string(str)
if input_type ~= '' then
if not parts[i + 1] or not parse_parameter(input_type, parts[i + 1]) then
if parts[i] == 'item' then
return nil, 'Invalid item name', _G.aux_auctionable_items
return nil, 'Invalid item name', aux_auctionable_items
elseif type(input_type) == 'table' then
return nil, 'Invalid choice for ' .. parts[i], input_type
else
@@ -370,7 +370,7 @@ function public.queries(filter_string)
return queries
end
function suggestions(filter)
function private.suggestions(filter)
local suggestions = t
if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end
@@ -408,7 +408,7 @@ function suggestions(filter)
-- item names
if getn(filter.components) == 0 then
for _, name in _G.aux_auctionable_items do
for _, name in aux_auctionable_items do
tinsert(suggestions, name .. '/exact')
end
end
@@ -438,7 +438,7 @@ function public.filter_string(components)
return query_builder.get()
end
function prettified_filter_string(filter)
function private.prettified_filter_string(filter)
local prettified = query_builder()
for _, component in filter.components do
@@ -486,7 +486,7 @@ function public.unquote(name)
return select(3, strfind(name, '^<(.*)>$')) or name
end
function blizzard_query(filter)
function private.blizzard_query(filter)
local filters = filter.blizzard
local query = T('name', filters.name and filters.name[2])
local item_info, class_index, subclass_index, slot_index
@@ -514,7 +514,7 @@ function blizzard_query(filter)
return query
end
function validator(filter)
function private.validator(filter)
local validators = t
for i, component in filter.post do
+4 -4
View File
@@ -120,8 +120,8 @@ function public.auction(index, query_type)
'link', link,
'itemstring', item_info.itemstring,
'item_key', item_id .. ':' .. suffix_id,
'search_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), _G.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _G.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')), ':'),
'search_signature', join(temp-A(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), aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')), ':'),
'name', name,
'texture', texture,
@@ -165,7 +165,7 @@ function public.bid_update(auction_record)
auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity
auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity
auction_record.high_bidder = 1
auction_record.search_signature = join(temp-A(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, _G.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
auction_record.search_signature = join(temp-A(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, aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
end
function public.set_tooltip(itemstring, owner, anchor)
@@ -283,7 +283,7 @@ function public.tooltip(setter)
return tooltip, AuxTooltip.money
end
function item_charges(tooltip)
function private.item_charges(tooltip)
for _, line in tooltip do
local pattern = '^' .. gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
+2 -2
View File
@@ -4,8 +4,8 @@ public.GOLD_TEXT = '|cffffd70ag|r'
public.SILVER_TEXT = '|cffc7c7cfs|r'
public.COPPER_TEXT = '|cffeda55fc|r'
COPPER_PER_GOLD = 10000
COPPER_PER_SILVER = 100
local COPPER_PER_GOLD = 10000
local COPPER_PER_SILVER = 100
function public.to_gsc(money)
local gold = floor(money / COPPER_PER_GOLD)
+3 -3
View File
@@ -1,14 +1,14 @@
aux 'persistence'
_G.aux_datasets = t
aux_datasets = t
do
local dataset
function public.dataset.get()
if not dataset then
local dataset_key = format('%s|%s', GetCVar 'realmName', UnitFactionGroup 'player')
dataset = _G.aux_datasets[dataset_key] or t
_G.aux_datasets[dataset_key] = dataset
dataset = aux_datasets[dataset_key] or t
aux_datasets[dataset_key] = dataset
end
return dataset
end