module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-10-14 01:55:38 +02:00
parent 2660b44861
commit cc7139c0e2
30 changed files with 326 additions and 343 deletions
+24 -24
View File
@@ -15,7 +15,7 @@ local scan = require 'aux.core.scan'
public.version = '5.0.0'
function public.p.set(v)
function public.set_p(v)
inspect(nil, v)
end
@@ -24,10 +24,10 @@ function public.print(...) auto[arg] = true
end
local bids_loaded
function public.bids_loaded.get() return bids_loaded end
function public.get_bids_loaded() return bids_loaded end
local current_owner_page
function public.current_owner_page.get() return current_owner_page end
function public.get_current_owner_page() return current_owner_page end
local event_frame = CreateFrame'Frame'
@@ -35,13 +35,13 @@ for event in temp-S('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION
event_frame:RegisterEvent(event)
end
private.ADDON_LOADED = t
ADDON_LOADED = t
do
local handlers, handlers2 = t, t
function public.LOAD.set(f)
function public.set_LOAD(f)
tinsert(handlers, f)
end
function public.LOAD2.set(f)
function public.set_LOAD2(f)
tinsert(handlers2, f)
end
event_frame:SetScript('OnEvent', function()
@@ -58,29 +58,29 @@ do
end)
end
private.tab_info = t
tab_info = t
function public.TAB(name)
local tab = T('name', name)
local env = getfenv(2)
function env.private.OPEN.set(f) tab.OPEN = f end
function env.private.CLOSE.set(f) tab.CLOSE = f end
function env.private.USE_ITEM.set(f) tab.USE_ITEM = f end
function env.private.CLICK_LINK.set(f) tab.CLICK_LINK = f end
function env.public.ACTIVE.get() return tab == active_tab end
function env.set_OPEN(f) tab.OPEN = f end
function env.set_CLOSE(f) tab.CLOSE = f end
function env.set_USE_ITEM(f) tab.USE_ITEM = f end
function env.set_CLICK_LINK(f) tab.CLICK_LINK = f end
function env.public.get_ACTIVE() return tab == active_tab end
tinsert(tab_info, tab)
end
do
local index
function private.active_tab.get() return tab_info[index] end
function private.on_tab_click(i)
function get_active_tab() return tab_info[index] end
function on_tab_click(i)
do (index and active_tab.CLOSE or nop)() end
index = i
do (index and active_tab.OPEN or nop)() end
end
end
function private.SetItemRef(...) auto[arg] = true
function 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 +89,7 @@ function private.SetItemRef(...) auto[arg] = true
end
end
function private.UseContainerItem(...) auto[arg] = true
function UseContainerItem(...) auto[arg] = true
if modified or not index(active_tab, 'USE_ITEM') then
return orig.UseContainerItem(unpack(arg))
end
@@ -115,7 +115,7 @@ end
do
local locked
function public.bid_in_progress.get() return locked end
function public.get_bid_in_progress() return locked end
function public.place_bid(type, index, amount, on_success)
if locked then return end
local money = GetMoney()
@@ -135,7 +135,7 @@ end
do
local locked
function public.cancel_in_progress.get() return locked end
function public.get_cancel_in_progress() return locked end
function public.cancel_auction(index, on_success)
if locked then return end
locked = true
@@ -163,13 +163,13 @@ function public.min_bid_increment(current_bid)
return max(1, floor(current_bid / 100) * 5)
end
function private.AUCTION_HOUSE_SHOW()
function AUCTION_HOUSE_SHOW()
AuctionFrame:Hide()
AuxFrame:Show()
tab = 1
end
function private.AUCTION_HOUSE_CLOSED()
function AUCTION_HOUSE_CLOSED()
bids_loaded = false
current_owner_page = nil
post.stop()
@@ -179,18 +179,18 @@ function private.AUCTION_HOUSE_CLOSED()
AuxFrame:Hide()
end
function private.AUCTION_BIDDER_LIST_UPDATE()
function AUCTION_BIDDER_LIST_UPDATE()
bids_loaded = true
end
do
local last_owner_page_requested
function private.GetOwnerAuctionItems(...) auto[arg] = true
function GetOwnerAuctionItems(...) auto[arg] = true
local page = arg[1]
last_owner_page_requested = page
return orig.GetOwnerAuctionItems(unpack(arg))
end
function private.AUCTION_OWNED_LIST_UPDATE()
function AUCTION_OWNED_LIST_UPDATE()
current_owner_page = last_owner_page_requested or 0
end
end
@@ -268,7 +268,7 @@ do
end
end
function private.AuctionFrameAuctions_OnEvent(...) auto[arg] = true
function AuctionFrameAuctions_OnEvent(...) auto[arg] = true
if AuctionFrameAuctions:IsVisible() then
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
end
+3 -3
View File
@@ -31,7 +31,7 @@ do
return self.private.callback(color)
end
end
function private.color_accessor(callback)
function color_accessor(callback)
return function()
return index_function({ callback=callback, table=COLORS }, index_handler)
end
@@ -49,13 +49,13 @@ do
end
end
}
public.color.get = color_accessor(function(color)
public.get_color = color_accessor(function(color)
local r, g, b, a = unpack(color)
return setmetatable(A(r/255, g/255, b/255, a), mt)
end)
end
public.inline_color.get = color_accessor(function(color)
public.get_inline_color = color_accessor(function(color)
local r, g, b, a = unpack(color)
return format('|c%02X%02X%02X%02X', a, r, g, b)
end)
+4 -4
View File
@@ -5,14 +5,14 @@ local event_frame = CreateFrame'Frame'
local listeners, threads = t, t
local thread_id
function public.thread_id.get() return thread_id end
function public.get_thread_id() return thread_id end
function LOAD()
event_frame:SetScript('OnUpdate', UPDATE)
event_frame:SetScript('OnEvent', EVENT)
end
function private.EVENT()
function EVENT()
for id, listener in listeners do
if listener.killed then
listeners[id] = nil
@@ -23,7 +23,7 @@ function private.EVENT()
end
do
function private.UPDATE()
function UPDATE()
for _, listener in listeners do
local event, needed = listener.event, false
for _, listener in listeners do
@@ -50,7 +50,7 @@ end
do
local id = 0
function private.unique_id.get()
function get_unique_id()
id = id + 1
return id
end
+15 -15
View File
@@ -14,12 +14,12 @@ local MAX_ITEM_ID = 30000
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'}}
aux_items = t
aux_item_ids = t
aux_auctionable_items = t
aux_merchant_buy = t
aux_merchant_sell = t
aux_characters = t
_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
function LOAD()
scan_wdb()
@@ -42,25 +42,25 @@ end
do
local sell_scan_countdown, incomplete_buy_data
function private.on_merchant_show()
function on_merchant_show()
merchant_sell_scan()
incomplete_buy_data = not merchant_buy_scan()
end
function private.on_merchant_closed()
function on_merchant_closed()
sell_scan_countdown = nil
incomplete_buy_data = false
end
function private.on_merchant_update()
function on_merchant_update()
if incomplete_buy_data then
incomplete_buy_data = not merchant_buy_scan()
end
end
function private.on_bag_update()
function on_bag_update()
if MerchantFrame:IsVisible() then
sell_scan_countdown = 10
end
end
function private.merchant_on_update()
function merchant_on_update()
if sell_scan_countdown == 0 then
sell_scan_countdown = nil
merchant_sell_scan()
@@ -70,7 +70,7 @@ do
end
end
function private.merchant_loaded()
function merchant_loaded()
for i = 1, GetMerchantNumItems() do
if not GetMerchantItemLink(i) then
return false
@@ -110,7 +110,7 @@ function public.item_id(item_name)
return aux_item_ids[strlower(item_name)]
end
function private.merchant_buy_scan()
function merchant_buy_scan()
local incomplete_data
for i = 1, GetMerchantNumItems() do
@@ -149,7 +149,7 @@ function private.merchant_buy_scan()
return not incomplete_data
end
function private.merchant_sell_scan()
function 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
@@ -158,7 +158,7 @@ function private.merchant_sell_scan()
end
end
function private.scan_wdb(item_id)
function scan_wdb(item_id)
item_id = item_id or MIN_ITEM_ID
local processed = 0
+7 -7
View File
@@ -11,7 +11,7 @@ local value_cache = t
do
local cache
function private.data.get()
function get_data()
if not cache then
local dataset = persistence.dataset
cache = dataset.history or t
@@ -23,7 +23,7 @@ end
do
local cache = 0
function private.next_push.get()
function get_next_push()
if time() > cache then
local date = date('*t')
date.hour, date.min, date.sec = 24, 0, 0
@@ -33,11 +33,11 @@ do
end
end
function private.new_record.get()
function get_new_record()
return T('next_push', next_push, 'data_points', t)
end
function private.read_record(item_key)
function 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)
@@ -46,7 +46,7 @@ function private.read_record(item_key)
return record
end
function private.write_record(item_key, record)
function write_record(item_key, record)
value_cache[item_key] = nil
data[item_key] = persistence.write(history_schema, record)
end
@@ -105,7 +105,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 private.weighted_median(list)
function weighted_median(list)
sort(list, function(a,b) return a.value < b.value end)
local weight = 0
for _, element in list do
@@ -116,7 +116,7 @@ function private.weighted_median(list)
end
end
function private.push_record(item_record)
function 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
+2 -2
View File
@@ -8,7 +8,7 @@ local stack = require 'aux.core.stack'
local state
function private.process()
function process()
if state.posted < state.count then
local stacking_complete
@@ -29,7 +29,7 @@ function private.process()
return stop()
end
function private.post_auction(slot, k)
function post_auction(slot, k)
local item_info = info.container_item(unpack(slot))
if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
+14 -14
View File
@@ -37,14 +37,14 @@ do
end
end
function private.complete()
function complete()
local on_complete = state.params.on_complete
scan_states[state.params.type] = nil
-- for _ in on_complete or nop do end TODO test performance
do (on_complete or nop)() end
end
function private.state.get()
function get_state()
for _, state in scan_states do
if state.id == thread_id then
return state
@@ -53,11 +53,11 @@ do
end
end
function private.query.get()
function get_query()
return state.params.queries[state.query_index]
end
private.wait_for_callback = vararg-function(arg)
wait_for_callback = vararg-function(arg)
local send_signal, signal_received = signal()
local suspended, ret
@@ -76,17 +76,17 @@ private.wait_for_callback = vararg-function(arg)
return when(signal_received, function() return k(unpack(signal_received())) end)
end
function private.total_pages(total_auctions)
function total_pages(total_auctions)
return ceil(total_auctions / PAGE_SIZE)
end
function private.last_page(total_auctions)
function 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 private.scan()
function 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
@@ -100,11 +100,11 @@ function private.scan()
end
end
function private.process_query()
function process_query()
return (query.blizzard_query and submit_query or scan_page)()
end
function private.submit_query()
function submit_query()
when(function() return state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
do (state.params.on_submit_query or nop)() end
state.last_query_time = GetTime()
@@ -130,7 +130,7 @@ function private.submit_query()
end)
end
function private.scan_page(i)
function scan_page(i)
i = i or 1
local recurse = function(retry)
if i >= PAGE_SIZE then
@@ -175,7 +175,7 @@ function private.scan_page(i)
return recurse()
end
function private.wait_for_results()
function wait_for_results()
local timeout = later(state.last_query_time, 10)
local send_signal, signal_received = signal()
when(signal_received, function()
@@ -204,7 +204,7 @@ function private.wait_for_results()
end
end
function private.wait_for_owner_results(send_signal)
function wait_for_owner_results(send_signal)
if state.page == current_owner_page then
return send_signal()
else
@@ -212,7 +212,7 @@ function private.wait_for_owner_results(send_signal)
end
end
function private.wait_for_list_results(send_signal, signal_received)
function wait_for_list_results(send_signal, signal_received)
local updated, last_update
event_listener('AUCTION_ITEM_LIST_UPDATE', function(kill)
kill(signal_received())
@@ -228,7 +228,7 @@ function private.wait_for_list_results(send_signal, signal_received)
end, send_signal)
end
function private.owner_data_complete(type)
function 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
+15 -15
View File
@@ -6,7 +6,7 @@ include 'aux'
local persistence = require 'aux.util.persistence'
local cache = require 'aux.core.cache'
aux_ignore_owner = true
_G.aux_ignore_owner = true
SLASH_AUX1 = '/aux'
function SlashCmdList.AUX(command)
@@ -19,44 +19,44 @@ function SlashCmdList.AUX(command)
persistence.dataset.post = nil
print 'Post settings cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
aux_datasets = t
_G.aux_datasets = t
print 'Datasets cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
aux_merchant_buy = t
_G.aux_merchant_buy = t
print 'Merchant buy prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
aux_merchant_sell = t
_G.aux_merchant_sell = t
print 'Merchant sell prices cleared.'
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
aux_items = t
aux_item_ids = t
aux_auctionable_items = t
_G.aux_items = t
_G.aux_item_ids = t
_G.aux_auctionable_items = t
print 'Item cache cleared.'
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
cache.populate_wdb()
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
aux_tooltip_value = not aux_tooltip_value
_G.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
aux_tooltip_daily = not aux_tooltip_daily
_G.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
aux_tooltip_vendor_buy = not aux_tooltip_vendor_buy
_G.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
aux_tooltip_vendor_sell = not aux_tooltip_vendor_sell
_G.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
aux_tooltip_disenchant_value = not aux_tooltip_disenchant_value
_G.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
aux_tooltip_disenchant_distribution = not aux_tooltip_disenchant_distribution
_G.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
aux_tooltip_disenchant_source = not aux_tooltip_disenchant_source
_G.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
aux_ignore_owner = not aux_ignore_owner
_G.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')
+10 -10
View File
@@ -7,27 +7,27 @@ local info = require 'aux.util.info'
local state
function private.stack_size(slot)
function 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 private.charges(slot)
function charges(slot)
local container_item_info = info.container_item(unpack(slot))
return container_item_info and container_item_info.charges
end
function private.max_stack(slot)
function max_stack(slot)
local container_item_info = info.container_item(unpack(slot))
return container_item_info and container_item_info.max_stack
end
function private.locked(slot)
function locked(slot)
local container_item_info = info.container_item(unpack(slot))
return container_item_info and container_item_info.locked
end
function private.find_item_slot(papply)
function find_item_slot(papply)
for slot in info.inventory do
if matching_item(slot, papply) and not eq(slot, state.target_slot) then
return slot
@@ -35,12 +35,12 @@ function private.find_item_slot(papply)
end
end
function private.matching_item(slot, papply)
function 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 papply or item_info.count < item_info.max_stack)
end
function private.find_empty_slot()
function find_empty_slot()
for slot, type in info.inventory do
if type == 1 and not GetContainerItemInfo(unpack(slot)) then
return slot
@@ -48,7 +48,7 @@ function private.find_empty_slot()
end
end
function private.find_charge_item_slot()
function find_charge_item_slot()
for slot in info.inventory do
if matching_item(slot) and charges(slot) == state.target_size then
return slot
@@ -56,7 +56,7 @@ function private.find_charge_item_slot()
end
end
function private.move_item(from_slot, to_slot, amount, k)
function move_item(from_slot, to_slot, amount, k)
if locked(from_slot) or locked(to_slot) then
return wait(k)
end
@@ -71,7 +71,7 @@ function private.move_item(from_slot, to_slot, amount, k)
return when(function() return stack_size(to_slot) == expected_size end, k)
end
function private.process()
function 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
+1 -1
View File
@@ -10,7 +10,7 @@ local disenchant = require 'aux.core.disenchant'
local history = require 'aux.core.history'
local auction_listing = require 'aux.gui.auction_listing'
aux_tooltip_value = true
_G.aux_tooltip_value = true
local game_tooltip_hooks, game_tooltip_money = t, 0
+3 -3
View File
@@ -30,9 +30,9 @@ do
public.AuxFrame = frame
end
do
private.tabs = gui.tabs(AuxFrame, 'DOWN')
tabs = gui.tabs(AuxFrame, 'DOWN')
tabs._on_select = on_tab_click
function public.tab.set(id) tabs:select(id) end
function public.set_tab(id) tabs:select(id) end
end
do
local btn = gui.button(AuxFrame)
@@ -40,7 +40,7 @@ do
gui.set_size(btn, 60, 24)
btn:SetText'Close'
btn:SetScript('OnClick', papply(AuxFrame.Hide, AuxFrame))
private.close_button = btn
close_button = btn
end
do
local btn = gui.button(AuxFrame, gui.font_size.small)
+5 -5
View File
@@ -10,7 +10,7 @@ local history = require 'aux.core.history'
local gui = require 'aux.gui'
local search_tab = require 'aux.tabs.search'
aux_price_per_unit = false
_G.aux_price_per_unit = false
local RT_COUNT = 1
local HEAD_HEIGHT = 27
@@ -31,7 +31,7 @@ local TIME_LEFT_STRINGS = {
color.blue '24h', -- Very Long
}
function private.item_column_init(rt, cell)
function item_column_init(rt, cell)
local spacer = CreateFrame('Frame', nil, cell)
spacer:SetPoint('TOPLEFT', 0, 0)
spacer:SetHeight(rt.ROW_HEIGHT)
@@ -528,7 +528,7 @@ public.bids_config = {
},
}
function private.record_percentage(record)
function record_percentage(record)
if not record then return end
local historical_value = history.value(record.item_key) or 0
@@ -540,7 +540,7 @@ function private.record_percentage(record)
end
end
function private.percentage_color(pct)
function 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
@@ -575,7 +575,7 @@ local methods = {
if rt.disabled then return end
if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then
aux_price_per_unit = not aux_price_per_unit
_G.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[aux_price_per_unit and 1 or 2])
+3 -3
View File
@@ -35,7 +35,7 @@ function LOAD()
return unpack(ret)
end)
function private.set_aux_dropdown_style(dropdown)
function set_aux_dropdown_style(dropdown)
DropDownList1Backdrop:SetBackdrop{}
aux_border:Show()
aux_background:Show()
@@ -64,7 +64,7 @@ function LOAD()
end
end
function private.set_blizzard_dropdown_style()
function set_blizzard_dropdown_style()
DropDownList1Backdrop:SetBackdrop(blizzard_backdrop)
aux_border:Hide()
aux_background:Hide()
@@ -87,7 +87,7 @@ end
do
local id = 1
function public.unique_name.get()
function public.get_unique_name()
id = id + 1
return 'AuxFrame' .. id
end
+2 -2
View File
@@ -54,8 +54,8 @@ do
public.set_auto_release = set_auto_release
end
public.t.get = acquire
function public.tt.get()
public.get_t = acquire
function public.get_tt()
local t = acquire()
set_auto_release(t, true)
return t
+38 -55
View File
@@ -1,61 +1,48 @@
if module then return end
local strfind, type, setmetatable, setfenv, _G = strfind, type, setmetatable, setfenv, getfenv(0)
local error, nop, id, define, include, require, create_module, nop_default_mt, public_modifier_mt, proxy_mt
local loaded, interfaces, environments = {}, {}, {}
local PRIVATE, PUBLIC, FIELD, ACCESSOR, MUTATOR = 0, 1, 2, 4, 6
local MODES = {FIELD, ACCESSOR, MUTATOR}
local READ, WRITE = '', '='
local OPERATION = {[FIELD]=READ, [ACCESSOR]=READ, [MUTATOR]=WRITE}
local META = {get=ACCESSOR, set=MUTATOR}
function error(msg, ...) return _G.error(format(msg or '', unpack(arg)) .. '\n' .. debugstack(), 0) end
local function error(msg, ...) return _G.error(format(msg or '', unpack(arg))..'\n'..debugstack(), 0) end
nop, id = function() end, function(v) return v end
local nop, id = function() end, function(v) return v end
local function proxy_mt(fields, mutators)
return {__metatable=false, __index=fields, __newindex=function(_, k, v) return mutators[k](v) end}
function define(self, k, v, private)
if type(k) ~= 'string' or not strfind(k, '^[_%a][_%w]*') then error('Invalid identifier "%s".', k) end
local _, _, prefix, suffix = strfind(k, '^(.?.?.?.?)([_%a][_%w]*)')
local module = loaded[self]
module.defined[k] = module.defined[k] and error('Duplicate identifier "%s".', k) or true
module.fields[k] = v
if prefix == 'get_' then module.accessors[suffix] = v elseif prefix == 'set_' then module.mutators[suffix] = v end
if not private then
module.public_fields[k] = v
if prefix == 'get_' then module.public_accessors[suffix] = v elseif prefix == 'set_' then module.public_mutators[suffix] = v end
end
end
local nop_default_mt, definition_helper_mt, require, include, create_module
local loaded, _interface, _environment, _access, _name = {}, {}, {}, {}, {}
nop_default_mt = {__index=function() return nop end}
definition_helper_mt = {__metatable=false}
function definition_helper_mt:__index(k)
_name[self] = _name[self] and error('Invalid modifier "%s".', k) or k
return self
end
function definition_helper_mt:__newindex(k, v)
local module, name, mode
module, name = loaded[self], _name[self]
if name then mode = META[k] or error('Invalid modifier "%s"', k) else name, mode = k, FIELD end
if type(name) ~= 'string' or not strfind(name, '^[_%a][_%w]*') then error('Invalid identifier "%s".', name) end
module.defined[name..OPERATION[mode]] = module.defined[name..OPERATION[mode]] and error('Duplicate identifier "%s".', name) or true
module[mode][name], module[_access[self] + mode][name] = v, v
_access[self], _name[self] = nil, nil
end
function require(name) if not loaded[name] then create_module(name) end return _interface[name] end
function include(self, name)
local module = name and loaded[name] or error('No module "%s".', name)
for _, mode in MODES do
for k, v in module[PUBLIC + mode] do
if not self.defined[k..OPERATION[mode]] or error('Import conflict for "%s".', k) then
self.defined[k..OPERATION[mode]], self[mode][k] = true, v
end
end
end
for k, v in module.public_fields do define(self, k, v, true) end
end
function require(name) if not loaded[name] then create_module(name) end return interfaces[name] end
public_modifier_mt = {__metatable=false, __newindex=define}
nop_default_mt = {__index=function() return nop end}
function proxy_mt(fields, mutators)
return {__metatable=false, __index=fields, __newindex=function(_, k, v) return mutators[k](v) end}
end
function create_module(name)
if type(name) ~= 'string' then error('Invalid module name "%s".', name) end
local P, environment, interface, definition_helper, modifiers, accessors, mutators, fields, public_accessors, public_mutators, public_fields
environment, interface, definition_helper = {}, {}, setmetatable({}, definition_helper_mt)
accessors = {private=function() _access[definition_helper] = PRIVATE; return definition_helper end, public=function() _access[definition_helper] = PUBLIC; return definition_helper end}
mutators = setmetatable({_=nop}, {__index=function(_, k) return function(v) _G[k] = v end end})
local P, environment, interface, public_modifier, accessors, mutators, fields, public_accessors, public_mutators, public_fields
environment, interface, public_modifier = {}, {}, setmetatable({}, public_modifier_mt)
accessors = {public=function() return public_modifier end}
mutators = setmetatable({_=nop}, {__index=function(_, k) return function(v) define(name, k, v, true) end end})
fields = setmetatable(
{_M=environment, _G=_G, require=require, include=function(interface) include(P, interface) end, error=error, nop=nop, id=id},
{_M=environment, _G=_G, require=require, include=function(interface) include(name, interface) end, error=error, nop=nop, id=id},
{__index=function(_, k) local accessor = accessors[k]; if accessor then return accessor() else return _G[k] end end}
)
public_accessors = setmetatable({}, nop_default_mt)
@@ -64,17 +51,13 @@ function create_module(name)
setmetatable(environment, proxy_mt(fields, mutators))
setmetatable(interface, proxy_mt(public_fields, public_mutators))
P = {
defined = {_M=true, _G=true, require=true, include=true, error=true, nop=true, id=true, public=true, private=true, ['_=']=true},
[ACCESSOR] = accessors,
[MUTATOR] = mutators,
[FIELD] = fields,
[PUBLIC + ACCESSOR] = public_accessors,
[PUBLIC + MUTATOR] = public_mutators,
[PUBLIC + FIELD] = public_fields,
defined = {_M=true, _G=true, require=true, include=true, error=true, nop=true, id=true, public=true, get_public=true, set__=true},
fields = fields, accessors = accessors, mutators = mutators,
public_fields = public_fields, public_accessors = public_accessors, public_mutators = public_mutators,
}
_environment[name], _interface[name] = environment, interface
loaded[name], loaded[definition_helper] = P, P
environments[name], interfaces[name] = environment, interface
loaded[name], loaded[public_modifier] = P, P
end
function module(name) if not loaded[name] then create_module(name) end setfenv(2, _environment[name]) end
function library(name) if loaded[name] then _G.error(nil) end create_module(name) setfenv(2, _environment[name]) end
function module(name) if not loaded[name] then create_module(name) end setfenv(2, environments[name]) end
function library(name) if loaded[name] then _G.error(nil) end create_module(name) setfenv(2, environments[name]) end
+5 -5
View File
@@ -9,7 +9,7 @@ local scan = require 'aux.core.scan'
TAB 'Auctions'
private.auction_records = t
auction_records = t
function OPEN()
frame:Show()
@@ -20,7 +20,7 @@ function CLOSE()
frame:Hide()
end
function private.update_listing()
function update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -54,7 +54,7 @@ function public.scan_auctions()
}
end
function private.test(record)
function test(record)
return function(index)
local auction_info = info.auction(index, 'owner')
return auction_info and auction_info.search_signature == record.search_signature
@@ -67,7 +67,7 @@ do
local state = IDLE
local found_index
function private.find_auction(record)
function find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -91,7 +91,7 @@ do
)
end
function private.on_update()
function on_update()
if state == IDLE or state == SEARCHING then
cancel_button:Disable()
end
+4 -4
View File
@@ -3,7 +3,7 @@ module 'aux.tabs.auctions'
local gui = require 'aux.gui'
local auction_listing = require 'aux.gui.auction_listing'
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config)
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)
@@ -27,7 +27,7 @@ listing:SetHandler('OnSelectionChanged', function(rt, datum)
end)
do
private.status_bar = gui.status_bar(frame)
status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
@@ -39,7 +39,7 @@ do
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText'Cancel'
btn:Disable()
private.cancel_button = btn
cancel_button = btn
end
do
local btn = gui.button(frame)
+5 -5
View File
@@ -9,7 +9,7 @@ local scan = require 'aux.core.scan'
TAB 'Bids'
private.auction_records = t
auction_records = t
function OPEN()
frame:Show()
@@ -20,7 +20,7 @@ function CLOSE()
frame:Hide()
end
function private.update_listing()
function update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -54,7 +54,7 @@ function public.scan_bids()
}
end
function private.test(record)
function test(record)
return function(index)
local auction_info = info.auction(index, 'bidder')
return auction_info and auction_info.search_signature == record.search_signature
@@ -67,7 +67,7 @@ do
local state = IDLE
local found_index
function private.find_auction(record)
function find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -108,7 +108,7 @@ do
)
end
function private.on_update()
function on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+5 -5
View File
@@ -3,7 +3,7 @@ module 'aux.tabs.bids'
local gui = require 'aux.gui'
local auction_listing = require 'aux.gui.auction_listing'
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config)
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)
@@ -31,7 +31,7 @@ listing:SetHandler('OnSelectionChanged', function(rt, datum)
end)
do
private.status_bar = gui.status_bar(frame)
status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
@@ -43,14 +43,14 @@ do
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText'Bid'
btn:Disable()
private.bid_button = btn
bid_button = btn
end
do
local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText'Buyout'
btn:Disable()
private.buyout_button = btn
buyout_button = btn
end
do
local btn = gui.button(frame)
+29 -29
View File
@@ -19,13 +19,13 @@ TAB 'Post'
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
function private.default_settings.get()
function get_default_settings()
return T('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
end
do
local data
function private.data.get()
function get_data()
if not data then
local dataset = persistence.dataset
data = dataset.post or t
@@ -35,19 +35,19 @@ do
end
end
function private.read_settings(item_key)
function 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 private.write_settings(settings, item_key)
function 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 private.refresh_button_click()
function refresh_button_click()
scan.abort(scan_id)
refresh_entries()
refresh = true
@@ -55,14 +55,14 @@ end
do
local item
function private.selected_item.get() return item end
function private.selected_item.set(v) item = v end
function get_selected_item() return item end
function set_selected_item(v) item = v end
end
do
local c = 0
function private.refresh.get() return c end
function private.refresh.set(v) c = v end
function get_refresh() return c end
function set_refresh(v) c = v end
end
function OPEN()
@@ -80,25 +80,25 @@ function USE_ITEM(item_info)
select_item(item_info.item_key)
end
function private.get_unit_start_price()
function get_unit_start_price()
local money_text = unit_start_price:GetText()
return money.from_string(money_text) or 0
end
function private.set_unit_start_price(amount)
function set_unit_start_price(amount)
unit_start_price:SetText(money.to_string(amount, true, nil, 3, nil, true))
end
function private.get_unit_buyout_price()
function get_unit_buyout_price()
local money_text = unit_buyout_price:GetText()
return money.from_string(money_text) or 0
end
function private.set_unit_buyout_price(amount)
function set_unit_buyout_price(amount)
unit_buyout_price:SetText(money.to_string(amount, true, nil, 3, nil, true))
end
function private.update_inventory_listing()
function 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)
@@ -106,7 +106,7 @@ function private.update_inventory_listing()
end)))
end
function private.update_auction_listing()
function update_auction_listing()
if not ACTIVE then return end
local auction_rows = t
if selected_item then
@@ -188,7 +188,7 @@ function public.select_item(item_key)
end
end
function private.price_update()
function price_update()
if selected_item then
local settings = read_settings()
@@ -206,7 +206,7 @@ function private.price_update()
end
end
function private.post_auctions()
function post_auctions()
if selected_item then
local unit_start_price = get_unit_start_price()
local unit_buyout_price = get_unit_buyout_price()
@@ -250,7 +250,7 @@ function private.post_auctions()
end
end
function private.validate_parameters()
function validate_parameters()
if not selected_item then
post_button:Disable()
return
@@ -270,7 +270,7 @@ function private.validate_parameters()
post_button:Enable()
end
function private.update_item_configuration()
function update_item_configuration()
if not selected_item then
refresh_button:Disable()
@@ -325,7 +325,7 @@ function private.update_item_configuration()
end
end
function private.undercut(record, stack_size, stack)
function 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
@@ -335,7 +335,7 @@ function private.undercut(record, stack_size, stack)
return start_price / stack_size, buyout_price / stack_size
end
function private.quantity_update(max_count)
function 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)
@@ -346,7 +346,7 @@ function private.quantity_update(max_count)
refresh = true
end
function private.unit_vendor_price(item_key)
function 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
@@ -366,7 +366,7 @@ function private.unit_vendor_price(item_key)
end
end
function private.update_historical_value_button()
function update_historical_value_button()
if selected_item then
local historical_value = history.value(selected_item.key)
historical_value_button.amount = historical_value
@@ -374,7 +374,7 @@ function private.update_historical_value_button()
end
end
function private.set_item(item)
function set_item(item)
local settings = read_settings(item.key)
item.unit_vendor_price = unit_vendor_price(item.key)
@@ -409,7 +409,7 @@ function private.set_item(item)
refresh = true
end
function private.update_inventory_records()
function 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
@@ -447,7 +447,7 @@ function private.update_inventory_records()
refresh = true
end
function private.refresh_entries()
function 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
@@ -492,7 +492,7 @@ function private.refresh_entries()
end
end
function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
function 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
@@ -508,7 +508,7 @@ function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyou
return entry
end
function private.on_update()
function on_update()
if refresh then
refresh = false
price_update()
@@ -520,7 +520,7 @@ function private.on_update()
validate_parameters()
end
function private.initialize_duration_dropdown()
function initialize_duration_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(duration_dropdown, this.value)
local settings = read_settings()
+18 -18
View File
@@ -7,7 +7,7 @@ local listing = require 'aux.gui.listing'
local item_listing = require 'aux.gui.item_listing'
local search_tab = require 'aux.tabs.search'
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -41,12 +41,12 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Show hidden items')
private.show_hidden_checkbox = checkbox
show_hidden_checkbox = checkbox
end
gui.horizontal_line(frame.inventory, -48)
private.inventory_listing = item_listing.create(
inventory_listing = item_listing.create(
frame.inventory,
function()
if arg1 == 'LeftButton' then
@@ -62,7 +62,7 @@ private.inventory_listing = item_listing.create(
end
)
private.auction_listing = listing.CreateScrollingTable(frame.auctions)
auction_listing = listing.CreateScrollingTable(frame.auctions)
auction_listing:SetColInfo{
{ name='Auctions', width=.12, align='CENTER' },
{ name='Left', width=.1, align='CENTER' },
@@ -87,7 +87,7 @@ auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
end)
do
private.status_bar = gui.status_bar(frame)
status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
@@ -99,17 +99,17 @@ do
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Post')
btn:SetScript('OnClick', post_auctions)
private.post_button = btn
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)
private.refresh_button = btn
refresh_button = btn
end
do
private.item = gui.item(frame.parameters)
item = gui.item(frame.parameters)
item:SetPoint('TOPLEFT', 10, -6)
item.button:SetScript('OnEnter', function()
if selected_item then
@@ -149,7 +149,7 @@ do
slider.editbox:SetNumeric(true)
slider.editbox:SetMaxLetters(3)
slider.label:SetText('Stack Size')
private.stack_size_slider = slider
stack_size_slider = slider
end
do
local slider = gui.slider(frame.parameters)
@@ -172,7 +172,7 @@ do
end)
slider.editbox:SetNumeric(true)
slider.label:SetText('Stack Count')
private.stack_count_slider = slider
stack_count_slider = slider
end
do
local dropdown = gui.dropdown(frame.parameters)
@@ -185,12 +185,12 @@ do
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, initialize_duration_dropdown)
end)
private.duration_dropdown = dropdown
duration_dropdown = dropdown
end
do
local label = gui.label(frame.parameters, gui.font_size.medium)
label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0)
private.deposit = label
deposit = label
end
do
local checkbox = gui.checkbox(frame.parameters)
@@ -204,7 +204,7 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Hide this item')
private.hide_checkbox = checkbox
hide_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -237,9 +237,9 @@ do
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
private.start_price_percentage = label
start_price_percentage = label
end
private.unit_start_price = editbox
unit_start_price = editbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -272,9 +272,9 @@ do
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
private.buyout_price_percentage = label
buyout_price_percentage = label
end
private.unit_buyout_price = editbox
unit_buyout_price = editbox
end
do
local btn = gui.button(frame.parameters, 14)
@@ -291,5 +291,5 @@ do
local label = gui.label(btn, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
label:SetText('Historical Value')
private.historical_value_button = btn
historical_value_button = btn
end
+6 -16
View File
@@ -12,20 +12,10 @@ StaticPopupDialogs.AUX_SEARCH_TABLE_FULL = {
timeout = 0,
hideOnEscape = 1,
}
--StaticPopupDialogs.AUX_SEARCH_AUTO_BUY = {
-- text = 'Are you sure you want to activate automatic buyout?',
-- button1 = 'Yes',
-- button2 = 'No',
-- OnAccept = function()
-- auto_buy_button:SetChecked(true)
-- end,
-- timeout = 0,
-- hideOnEscape = 1,
--}
private.RESULTS = 1
private.SAVED = 2
private.FILTER = 3
RESULTS = 1
SAVED = 2
FILTER = 3
function LOAD()
-- aux_search_tab_frame.create()
@@ -52,7 +42,7 @@ function USE_ITEM(item_info)
execute(nil, false)
end
function private.subtab.set(tab)
function set_subtab(tab)
search_results_button:UnlockHighlight()
saved_searches_button:UnlockHighlight()
new_filter_button:UnlockHighlight()
@@ -76,7 +66,7 @@ function public.set_filter(filter_string)
search_box:SetText(filter_string)
end
function private.add_filter(filter_string)
function add_filter(filter_string)
local old_filter_string = search_box:GetText()
old_filter_string = trim(old_filter_string)
@@ -87,7 +77,7 @@ function private.add_filter(filter_string)
search_box:SetText(old_filter_string .. filter_string)
end
function private.blizzard_page_index(str)
function blizzard_page_index(str)
if tonumber(str) then
return max(0, tonumber(str) - 1)
end
+24 -24
View File
@@ -5,12 +5,12 @@ local money = require 'aux.util.money'
local cache = require 'aux.core.cache'
local filter_util = require 'aux.util.filter'
function private.valid_level(str)
function valid_level(str)
local level = tonumber(str)
return level and bounded(1, 60, level)
end
private.blizzard_query = setmetatable(t, {
blizzard_query = setmetatable(t, {
__index = function(_, key)
if key == 'name' then
return name_input:GetText()
@@ -63,7 +63,7 @@ private.blizzard_query = setmetatable(t, {
end,
})
function private.update_form()
function update_form()
if blizzard_query.class and GetAuctionItemSubClasses(blizzard_query.class) then
subclass_dropdown.button:Enable()
else
@@ -105,7 +105,7 @@ function private.update_form()
end
end
function private.get_filter_builder_query()
function get_filter_builder_query()
local filter_string
local function add(part)
@@ -149,7 +149,7 @@ function private.get_filter_builder_query()
return filter_string or ''
end
function private.set_form(filter)
function set_form(filter)
clear_form()
for _, component in filter.components do
if component[1] == 'blizzard' then
@@ -161,7 +161,7 @@ function private.set_form(filter)
update_filter_display()
end
function private.clear_form()
function clear_form()
blizzard_query.name = ''
name_input:ClearFocus()
blizzard_query.exact = false
@@ -180,19 +180,19 @@ function private.clear_form()
update_filter_display()
end
function private.import_filter_string()
function 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 private.export_filter_string()
function export_filter_string()
search_box:SetText(get_filter_builder_query())
filter_parameter_input:ClearFocus()
end
function private.formatted_post_filter(components)
function formatted_post_filter(components)
local no_line_break
local stack = tt
local str = ''
@@ -236,14 +236,14 @@ function private.formatted_post_filter(components)
return '<html><body><p>' .. str .. '</p></body></html>'
end
function private.data_link(id, str)
function data_link(id, str)
return '|H' .. id .. '|h' .. str .. '|h'
end
private.post_filter = t
private.filter_builder_state = T('selected', 0)
post_filter = t
filter_builder_state = T('selected', 0)
function private.data_link_click()
function data_link_click()
local button = arg3
local index = tonumber(arg1)
if button == 'LeftButton' then
@@ -254,7 +254,7 @@ function private.data_link_click()
update_filter_display()
end
function private.remove_component(index)
function 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)))
@@ -263,12 +263,12 @@ function private.remove_component(index)
tremove(post_filter, index)
end
function private.add_component(component)
function add_component(component)
filter_builder_state.selected = filter_builder_state.selected + 1
tinsert(post_filter, filter_builder_state.selected, component)
end
function private.add_post_filter()
function 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
@@ -290,13 +290,13 @@ end
do
local text = ''
function private.update_filter_display()
function 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 private.filter_display_size()
function filter_display_size()
local font, font_size = filter_display:GetFont()
filter_display.measure:SetFont(font, font_size)
local lines = 0
@@ -310,7 +310,7 @@ do
end
end
function private.set_filter_display_offset(x_offset, y_offset)
function 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()
@@ -322,7 +322,7 @@ function private.set_filter_display_offset(x_offset, y_offset)
scroll_frame:SetVerticalScroll(bounded(y_lower_bound, y_upper_bound, y_offset))
end
function private.initialize_filter_dropdown()
function 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,
@@ -342,7 +342,7 @@ function private.initialize_filter_dropdown()
end
end
function private.initialize_class_dropdown()
function initialize_class_dropdown()
local function on_click()
if this.value ~= blizzard_query.class then
UIDropDownMenu_SetSelectedValue(class_dropdown, this.value)
@@ -359,7 +359,7 @@ function private.initialize_class_dropdown()
end
end
function private.initialize_subclass_dropdown()
function initialize_subclass_dropdown()
local function on_click()
if this.value ~= blizzard_query.subclass then
UIDropDownMenu_SetSelectedValue(subclass_dropdown, this.value)
@@ -377,7 +377,7 @@ function private.initialize_subclass_dropdown()
end
end
function private.initialize_slot_dropdown()
function initialize_slot_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value)
update_form()
@@ -392,7 +392,7 @@ function private.initialize_slot_dropdown()
end
end
function private.initialize_quality_dropdown()
function initialize_quality_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value)
update_form()
+35 -35
View File
@@ -9,7 +9,7 @@ local auction_listing = require 'aux.gui.auction_listing'
local FILTER_SPACING = 28.5
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -42,7 +42,7 @@ do
btn:SetHeight(25)
btn:SetText'<'
btn:SetScript('OnClick', previous_search)
private.previous_button = btn
previous_button = btn
end
do
local btn = gui.button(frame, 25)
@@ -51,7 +51,7 @@ do
btn:SetHeight(25)
btn:SetText'>'
btn:SetScript('OnClick', next_search)
private.next_button = btn
next_button = btn
end
do
local btn = gui.button(frame, gui.font_size.small)
@@ -61,7 +61,7 @@ do
btn:SetScript('OnClick', function()
update_real_time(true)
end)
private.range_button = btn
range_button = btn
end
do
local btn = gui.button(frame, gui.font_size.small)
@@ -72,7 +72,7 @@ do
btn:SetScript('OnClick', function()
update_real_time(false)
end)
private.real_time_button = btn
real_time_button = btn
end
do
local function change()
@@ -96,7 +96,7 @@ do
label:SetPoint('LEFT', editbox, 'RIGHT', 0, 0)
label:SetTextColor(color.label.enabled())
label:SetText'-'
private.first_page_input = editbox
first_page_input = editbox
end
do
local editbox = gui.editbox(range_button)
@@ -108,7 +108,7 @@ do
editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end)
editbox.enter = execute
editbox.change = change
private.last_page_input = editbox
last_page_input = editbox
end
end
do
@@ -122,7 +122,7 @@ do
end
execute()
end)
private.start_button = btn
start_button = btn
end
do
local btn = gui.button(frame)
@@ -131,7 +131,7 @@ do
btn:SetScript('OnClick', function()
scan.abort(search_scan_id)
end)
private.stop_button = btn
stop_button = btn
end
do
local btn = gui.button(frame)
@@ -141,7 +141,7 @@ do
btn:SetScript('OnClick', function()
execute(true)
end)
private.resume_button = btn
resume_button = btn
end
do
local editbox = gui.editbox(frame)
@@ -159,7 +159,7 @@ do
this:HighlightText(0, 0)
end)
editbox.enter = execute
private.search_box = editbox
search_box = editbox
end
do
gui.horizontal_line(frame, -40)
@@ -171,7 +171,7 @@ do
btn:SetHeight(22)
btn:SetText'Search Results'
btn:SetScript('OnClick', function() subtab = RESULTS end)
private.search_results_button = btn
search_results_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -180,7 +180,7 @@ do
btn:SetHeight(22)
btn:SetText'Saved Searches'
btn:SetScript('OnClick', function() subtab = SAVED end)
private.saved_searches_button = btn
saved_searches_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -189,28 +189,28 @@ do
btn:SetHeight(22)
btn:SetText'Filter Builder'
btn:SetScript('OnClick', function() subtab = FILTER end)
private.new_filter_button = btn
new_filter_button = btn
end
do
local frame = CreateFrame('Frame', nil, frame)
frame:SetWidth(265)
frame:SetHeight(25)
frame:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
private.status_bar_frame = frame
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()
private.bid_button = btn
bid_button = btn
end
do
local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText'Buyout'
btn:Disable()
private.buyout_button = btn
buyout_button = btn
end
do
local btn = gui.button(frame.results)
@@ -281,7 +281,7 @@ do
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText'Name'
private.name_input = editbox
name_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -290,7 +290,7 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText'Exact'
private.exact_checkbox = checkbox
exact_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -316,7 +316,7 @@ do
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText'Level Range'
private.min_level_input = editbox
min_level_input = editbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -342,7 +342,7 @@ do
local label = gui.label(editbox, gui.font_size.medium)
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
label:SetText'-'
private.max_level_input = editbox
max_level_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -351,11 +351,11 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText'Usable'
private.usable_checkbox = checkbox
usable_checkbox = checkbox
end
do
local dropdown = gui.dropdown(frame.filter)
private.class_dropdown = dropdown
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)
@@ -368,7 +368,7 @@ do
end
do
local dropdown = gui.dropdown(frame.filter)
private.subclass_dropdown = dropdown
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)
@@ -381,7 +381,7 @@ do
end
do
local dropdown = gui.dropdown(frame.filter)
private.slot_dropdown = dropdown
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)
@@ -394,7 +394,7 @@ do
end
do
local dropdown = gui.dropdown(frame.filter)
private.quality_dropdown = dropdown
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)
@@ -418,7 +418,7 @@ do
local label = gui.label(dropdown, gui.font_size.medium)
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
label:SetText'Post Filter'
private.filter_dropdown = dropdown
filter_dropdown = dropdown
end
do
local input = gui.editbox(frame.filter)
@@ -445,7 +445,7 @@ do
add_post_filter()
end
end
private.filter_input = input
filter_input = input
end
do
local input = gui.editbox(frame.filter)
@@ -457,7 +457,7 @@ do
input.char = function() this:complete() end
input.enter = add_post_filter
input:Hide()
private.filter_parameter_input = input
filter_parameter_input = input
end
do
local scroll_frame = CreateFrame('ScrollFrame', nil, frame.filter)
@@ -500,11 +500,11 @@ do
scroll_child:SetScript('OnHyperlinkClick', data_link_click)
-- scroll_child:SetHyperlinkFormat("format") TODO
scroll_child.measure = scroll_child:CreateFontString()
private.filter_display = scroll_child
filter_display = scroll_child
end
private.status_bars = t
private.tables = t
status_bars = t
tables = t
for _ = 1, 5 do
local status_bar = gui.status_bar(frame)
status_bar:SetAllPoints(status_bar_frame)
@@ -529,7 +529,7 @@ for _ = 1, 5 do
tinsert(tables, table)
end
private.auto_buy_listing = listing.CreateScrollingTable(frame.saved.autobuy)
auto_buy_listing = listing.CreateScrollingTable(frame.saved.autobuy)
auto_buy_listing:SetColInfo{{name='Auto Buy Filters', width=1}}
auto_buy_listing:EnableSorting(false)
auto_buy_listing:DisableSelection(true)
@@ -537,7 +537,7 @@ auto_buy_listing:SetHandler('OnClick', handlers.OnClick)
auto_buy_listing:SetHandler('OnEnter', handlers.OnEnter)
auto_buy_listing:SetHandler('OnLeave', handlers.OnLeave)
private.recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
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)
@@ -545,7 +545,7 @@ recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
private.favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite)
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)
+25 -15
View File
@@ -9,7 +9,17 @@ function LOAD()
new_search()
end
function private.update_real_time(enable)
do
local id = 0
function get_search_scan_id()
return id
end
function set_search_scan_id(v)
id = v
end
end
function update_real_time(enable)
if enable then
range_button:Hide()
real_time_button:Show()
@@ -25,11 +35,11 @@ do
local searches = t
local search_index = 1
function private.current_search.get()
function get_current_search()
return searches[search_index]
end
function private.update_search(index)
function update_search(index)
searches[search_index].status_bar:Hide()
searches[search_index].table:Hide()
searches[search_index].table:SetSelectedRecord()
@@ -61,7 +71,7 @@ do
update_continuation()
end
function private.new_search(filter_string, first_page, last_page, real_time)
function new_search(filter_string, first_page, last_page, real_time)
while getn(searches) > search_index do
tremove(searches)
end
@@ -86,26 +96,26 @@ do
update_search(getn(searches))
end
function private.clear_control_focus()
function clear_control_focus()
search_box:ClearFocus()
first_page_input:ClearFocus()
last_page_input:ClearFocus()
end
function private.previous_search()
function previous_search()
clear_control_focus()
update_search(search_index - 1)
subtab = RESULTS
end
function private.next_search()
function next_search()
clear_control_focus()
update_search(search_index + 1)
subtab = RESULTS
end
end
function private.update_continuation()
function update_continuation()
if current_search.continuation then
resume_button:Show()
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
@@ -115,13 +125,13 @@ function private.update_continuation()
end
end
function private.discard_continuation()
function discard_continuation()
scan.abort(search_scan_id)
current_search.continuation = nil
update_continuation()
end
function private.update_start_stop()
function update_start_stop()
if current_search.active then
stop_button:Show()
start_button:Hide()
@@ -131,7 +141,7 @@ function private.update_start_stop()
end
end
function private.start_real_time_scan(query, search, continuation)
function start_real_time_scan(query, search, continuation)
local ignore_page
if not search then
@@ -199,7 +209,7 @@ function private.start_real_time_scan(query, search, continuation)
}
end
function private.start_search(queries, continuation)
function start_search(queries, continuation)
local current_query, current_page, total_queries, start_query, start_page
local search = current_search
@@ -349,7 +359,7 @@ function public.execute(resume, real_time)
end
end
function private.test(record)
function test(record)
return function(index)
local auction_info = info.auction(index)
return auction_info and auction_info.search_signature == record.search_signature
@@ -362,7 +372,7 @@ do
local state = IDLE
local found_index
function private.find_auction(record)
function find_auction(record)
local search = current_search
if not search.table:ContainsRecord(record) or is_player(record.owner) then
@@ -413,7 +423,7 @@ do
)
end
function private.on_update()
function on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+11 -11
View File
@@ -2,11 +2,11 @@ module 'aux.tabs.search'
local filter_util = require 'aux.util.filter'
aux_auto_buy_filters = t
aux_favorite_searches = t
aux_recent_searches = t
_G.aux_auto_buy_filters = t
_G.aux_favorite_searches = t
_G.aux_recent_searches = t
function private.update_search_listings()
function update_search_listings()
local autobuy_filter_rows = t
for i, autobuy_filter in aux_auto_buy_filters do
local name = strsub(autobuy_filter.prettified, 1, 250)
@@ -41,7 +41,7 @@ function private.update_search_listings()
recent_searches_listing:SetData(recent_search_rows)
end
function private.new_recent_search(filter_string, prettified)
function new_recent_search(filter_string, prettified)
tinsert(aux_recent_searches, 1, {
filter_string = filter_string,
prettified = prettified,
@@ -52,7 +52,7 @@ function private.new_recent_search(filter_string, prettified)
update_search_listings()
end
private.handlers = {
handlers = {
OnClick = function(st, data, _, button)
if not data then return end
if button == 'LeftButton' and IsShiftKeyDown() then
@@ -104,7 +104,7 @@ private.handlers = {
end
}
function private.auto_buy_validator.get()
function get_auto_buy_validator()
local validators = t
for _, filter in aux_auto_buy_filters do
local queries, error = filter_util.queries(filter.filter_string)
@@ -119,7 +119,7 @@ function private.auto_buy_validator.get()
end
end
function private.add_favorite(filter_string)
function add_favorite(filter_string)
local queries, error = filter_util.queries(filter_string)
if queries then
tinsert(aux_favorite_searches, 1, T(
@@ -132,7 +132,7 @@ function private.add_favorite(filter_string)
end
end
function private.add_auto_buy(filter_string)
function add_auto_buy(filter_string)
local queries, error = filter_util.queries(filter_string)
if queries then
if getn(queries) > 1 then
@@ -150,13 +150,13 @@ function private.add_auto_buy(filter_string)
end
end
function private.move_up(list, index)
function move_up(list, index)
if list[index - 1] then
list[index], list[index - 1] = list[index - 1], list[index]
end
end
function private.move_down(list, index)
function move_down(list, index)
if list[index + 1] then
list[index], list[index + 1] = list[index + 1], list[index]
end
+1 -1
View File
@@ -92,7 +92,7 @@ end
public.huge = 1.8 * 10 ^ 308
function public.modified.get()
function public.get_modified()
return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown()
end
+8 -8
View File
@@ -10,7 +10,7 @@ local cache = require 'aux.core.cache'
local history = require 'aux.core.history'
local disenchant = require 'aux.core.disenchant'
function private.default_filter(str)
function default_filter(str)
return {
input_type = '',
validator = function()
@@ -210,7 +210,7 @@ public.filters = {
},
}
function private.operator(str)
function 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
@@ -264,12 +264,12 @@ do
end
end,
}
function private.blizzard_filter_parser()
function blizzard_filter_parser()
return setmetatable(t, mt)
end
end
function private.parse_parameter(input_type, str)
function parse_parameter(input_type, str)
if input_type == 'money' then
local money = money.from_string(str)
return money and money > 0 and money or nil
@@ -380,7 +380,7 @@ function public.queries(filter_string)
return queries
end
function private.suggestions(filter)
function suggestions(filter)
local suggestions = t
if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end
@@ -448,7 +448,7 @@ function public.filter_string(components)
return query_builder.get()
end
function private.prettified_filter_string(filter)
function prettified_filter_string(filter)
local prettified = query_builder()
for _, component in filter.components do
@@ -496,7 +496,7 @@ function public.unquote(name)
return select(3, strfind(name, '^<(.*)>$')) or name
end
function private.blizzard_query(filter)
function 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
@@ -524,7 +524,7 @@ function private.blizzard_query(filter)
return query
end
function private.validator(filter)
function validator(filter)
local validators = t
for i, component in filter.post do
+2 -2
View File
@@ -288,7 +288,7 @@ function public.tooltip(setter)
return tooltip, AuxTooltip.money
end
function private.item_charges(tooltip)
function item_charges(tooltip)
for _, line in tooltip do
local pattern = '^' .. gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
@@ -406,7 +406,7 @@ function public.item_quality_index(item_quality)
end
end
function public.inventory.get()
function public.get_inventory()
local bag, slot = 0, 0
return function()
if not GetBagName(bag) or slot >= GetContainerNumSlots(bag) then
+2 -2
View File
@@ -3,11 +3,11 @@ module 'aux.util.persistence'
include 'green_t'
include 'aux'
aux_datasets = t
_G.aux_datasets = t
do
local dataset
function public.dataset.get()
function public.get_dataset()
if not dataset then
local dataset_key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player')
dataset = aux_datasets[dataset_key] or t