diff --git a/aux-addon.lua b/aux-addon.lua index 22f0d08..c2fb16a 100644 --- a/aux-addon.lua +++ b/aux-addon.lua @@ -2,8 +2,6 @@ module 'aux' local T = require 'T' -local info = require 'aux.util.info' - _G.aux_scale = 1 _G.aux = { @@ -93,7 +91,7 @@ do end tab_info = {} -function M.TAB(name) +function M.tab(name) local tab = T.map('name', name) local tab_event = { OPEN = function(f) tab.OPEN = f end, @@ -107,12 +105,12 @@ end do local index - function M.get_active_tab() return tab_info[index] end + function M.get_tab() return tab_info[index] end function on_tab_click(i) CloseDropDownMenus() - do (index and get_active_tab().CLOSE or nop)() end + do (index and get_tab().CLOSE or pass)() end index = i - do (index and get_active_tab().OPEN or nop)() end + do (index and get_tab().OPEN or pass)() end end end @@ -142,7 +140,7 @@ do locked = true local send_signal, signal_received = signal() thread(when, signal_received, function() - do (on_success or nop)() end + do (on_success or pass)() end locked = false end) thread(when, later(5), send_signal) @@ -165,7 +163,7 @@ do CancelAuction(index) local send_signal, signal_received = signal() thread(when, signal_received, function() - do (on_success or nop)() end + do (on_success or pass)() end locked = false end) thread(when, later(5), send_signal) @@ -179,12 +177,12 @@ do end function handle.LOAD2() - AuxFrame:SetScale(aux_scale) + frame:SetScale(aux_scale) end function AUCTION_HOUSE_SHOW() AuctionFrame:Hide() - AuxFrame:Show() + frame:Show() set_tab(1) end @@ -200,7 +198,7 @@ do handler() end set_tab() - AuxFrame:Hide() + frame:Hide() end end diff --git a/color.lua b/color.lua index bdf4e69..cb7e2ce 100644 --- a/color.lua +++ b/color.lua @@ -3,7 +3,7 @@ module 'aux' local T = require 'T' function C(r, g, b, a) - local mt = T.map('__metatable', false, '__newindex', nop, 'color', T.list(r, g, b, a)) + local mt = T.map('__metatable', false, '__newindex', pass, 'color', T.list(r, g, b, a)) function mt:__call(text) local r, g, b, a = unpack(mt.color) if text then @@ -20,7 +20,7 @@ function C(r, g, b, a) end M.color = immutable-{ - none = setmetatable({}, {__metatable=false, __newindex=nop, __call=function(_, v) return v end, __concat=function(_, v) return v end}), + none = setmetatable({}, {__metatable=false, __newindex=pass, __call=function(_, v) return v end, __concat=function(_, v) return v end}), text = immutable-{enabled = C(255, 254, 250, 1), disabled = C(147, 151, 139, 1)}, label = immutable-{enabled = C(216, 225, 211, 1), disabled = C(150, 148, 140, 1)}, link = C(153, 255, 255, 1), diff --git a/core/cache.lua b/core/cache.lua index 31b54b7..ce3ef02 100644 --- a/core/cache.lua +++ b/core/cache.lua @@ -1,9 +1,7 @@ module 'aux.util.info' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local persistence = require 'aux.util.persistence' local MIN_ITEM_ID = 1 @@ -18,17 +16,17 @@ _G.aux_auctionable_items = {} _G.aux_merchant_buy = {} _G.aux_merchant_sell = {} -function handle.LOAD() +function aux.handle.LOAD() scan_wdb() - event_listener('MERCHANT_SHOW', on_merchant_show) - event_listener('MERCHANT_CLOSED', on_merchant_closed) - event_listener('MERCHANT_UPDATE', on_merchant_update) - event_listener('BAG_UPDATE', on_bag_update) + aux.event_listener('MERCHANT_SHOW', on_merchant_show) + aux.event_listener('MERCHANT_CLOSED', on_merchant_closed) + aux.event_listener('MERCHANT_UPDATE', on_merchant_update) + aux.event_listener('BAG_UPDATE', on_bag_update) CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', merchant_on_update) - event_listener('NEW_AUCTION_UPDATE', function() + aux.event_listener('NEW_AUCTION_UPDATE', function() local data = auction_sell_item() if data then local item_id = item_id(data.name) @@ -44,8 +42,8 @@ do function M.is_player(name) return not not characters[name] end - function handle.LOAD2() - characters = realm_data'characters' + function aux.handle.LOAD2() + characters = aux.realm_data'characters' for k, v in characters do if GetTime() > v + 60 * 60 * 24 * 30 then characters[k] = nil @@ -199,7 +197,7 @@ function scan_wdb(item_id) end if item_id <= MAX_ITEM_ID then - thread(when, later(.5), scan_wdb, item_id) + aux.thread(when, aux.later(.5), scan_wdb, item_id) else sort(aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end) end @@ -208,12 +206,12 @@ end function M.populate_wdb(item_id) item_id = item_id or MIN_ITEM_ID if item_id > MAX_ITEM_ID then - print'Cache populated.' + aux.print('Cache populated.') return end if not GetItemInfo('item:' .. item_id) then - print('Fetching item ' .. item_id .. '.') + aux.print('Fetching item ' .. item_id .. '.') AuxTooltip:SetHyperlink('item:' .. item_id) end - thread(populate_wdb, item_id + 1) + aux.thread(populate_wdb, item_id + 1) end \ No newline at end of file diff --git a/core/crafting.lua b/core/crafting.lua index fa86339..00eb22a 100644 --- a/core/crafting.lua +++ b/core/crafting.lua @@ -1,16 +1,14 @@ module 'aux.core.crafting' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local money = require 'aux.util.money' local history = require 'aux.core.history' local search_tab = require 'aux.tabs.search' -function handle.LOAD() - event_listener('ADDON_LOADED', function() +function aux.handle.LOAD() + aux.event_listener('ADDON_LOADED', function() if arg1 == 'Blizzard_CraftUI' then craft_ui_loaded() elseif arg1 == 'Blizzard_TradeSkillUI' then @@ -29,8 +27,8 @@ do local function hook_quest_item(f) f:SetScript('OnMouseUp', function() if arg1 == 'RightButton' then - if get_active_tab() then - set_tab(1) + if aux.get_tab() then + aux.set_tab(1) search_tab.set_filter(_G[this:GetName() .. 'Name']:GetText() .. '/exact') search_tab.execute(nil, false) end @@ -38,8 +36,8 @@ do end) end function craft_ui_loaded() - hook('CraftFrame_SetSelection', T.vararg-function(arg) - local ret = T.temp-T.list(orig.CraftFrame_SetSelection(unpack(arg))) + aux.hook('CraftFrame_SetSelection', T.vararg-function(arg) + local ret = T.temp-T.list(aux.orig.CraftFrame_SetSelection(unpack(arg))) local id = GetCraftSelectionIndex() local total_cost = 0 for i = 1, GetCraftNumReagents(id) do @@ -49,7 +47,7 @@ do break end local item_id, suffix_id = info.parse_link(link) - local count = select(3, GetCraftReagentInfo(id, i)) + local count = aux.select(3, GetCraftReagentInfo(id, i)) local _, price, limited = info.merchant_info(item_id) local value = price and not limited and price or history.value(item_id .. ':' .. suffix_id) if not value then @@ -67,8 +65,8 @@ do end end function trade_skill_ui_loaded() - hook('TradeSkillFrame_SetSelection', T.vararg-function(arg) - local ret = T.temp-T.list(orig.TradeSkillFrame_SetSelection(unpack(arg))) + aux.hook('TradeSkillFrame_SetSelection', T.vararg-function(arg) + local ret = T.temp-T.list(aux.orig.TradeSkillFrame_SetSelection(unpack(arg))) local id = GetTradeSkillSelectionIndex() local total_cost = 0 for i = 1, GetTradeSkillNumReagents(id) do @@ -78,7 +76,7 @@ do break end local item_id, suffix_id = info.parse_link(link) - local count = select(3, GetTradeSkillReagentInfo(id, i)) + local count = aux.select(3, GetTradeSkillReagentInfo(id, i)) local _, price, limited = info.merchant_info(item_id) local value = price and not limited and price or history.value(item_id .. ':' .. suffix_id) if not value then diff --git a/core/disenchant.lua b/core/disenchant.lua index b517242..3d61dab 100644 --- a/core/disenchant.lua +++ b/core/disenchant.lua @@ -1,9 +1,6 @@ module 'aux.core.disenchant' -include 'aux' - local T = require 'T' - local history = require 'aux.core.history' local UNCOMMON, RARE, EPIC = 2, 3, 4 diff --git a/core/history.lua b/core/history.lua index 78c07a8..e7b6649 100644 --- a/core/history.lua +++ b/core/history.lua @@ -1,8 +1,7 @@ module 'aux.core.history' -include 'aux' - local T = require 'T' +local aux = require 'aux' local persistence = require 'aux.util.persistence' @@ -10,8 +9,8 @@ local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='n local value_cache = {} -function handle.LOAD2() - data = faction_data'history' +function aux.handle.LOAD2() + data = aux.faction_data'history' end do @@ -50,7 +49,7 @@ end function M.process_auction(auction_record) local item_record = read_record(auction_record.item_key) local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity) - if unit_buyout_price > 0 and unit_buyout_price < (item_record.daily_min_buyout or huge) then + if unit_buyout_price > 0 and unit_buyout_price < (item_record.daily_min_buyout or aux.huge) then item_record.daily_min_buyout = unit_buyout_price write_record(auction_record.item_key, item_record) end @@ -67,7 +66,7 @@ function M.value(item_key) if getn(item_record.data_points) > 0 then local total_weight, weighted_values = 0, T.temp-T.acquire() for _, data_point in item_record.data_points do - local weight = .99 ^ round((item_record.data_points[1].time - data_point.time) / (60 * 60 * 24)) + local weight = .99 ^ aux.round((item_record.data_points[1].time - data_point.time) / (60 * 60 * 24)) total_weight = total_weight + weight tinsert(weighted_values, T.map('value', data_point.value, 'weight', weight)) end diff --git a/core/post.lua b/core/post.lua index 6a16b37..b34c05b 100644 --- a/core/post.lua +++ b/core/post.lua @@ -1,13 +1,12 @@ module 'aux.core.post' -include 'aux' - +local aux = require 'aux' local info = require 'aux.util.info' local stack = require 'aux.core.stack' local state -function handle.CLOSE() +function aux.handle.CLOSE() stop() end @@ -16,8 +15,8 @@ function process() local stacking_complete - local send_signal, signal_received = signal() - when(signal_received, function() + local send_signal, signal_received = aux.signal() + aux.when(signal_received, function() local slot = signal_received()[1] if slot then return post_auction(slot, process) @@ -43,16 +42,16 @@ function post_auction(slot, k) ClickAuctionSellItemButton() ClearCursor() - StartAuction(max(1, round(state.unit_start_price * item_info.aux_quantity)), round(state.unit_buyout_price * item_info.aux_quantity), state.duration) + StartAuction(max(1, aux.round(state.unit_start_price * item_info.aux_quantity)), aux.round(state.unit_buyout_price * item_info.aux_quantity), state.duration) - local send_signal, signal_received = signal() - when(signal_received, function() + local send_signal, signal_received = aux.signal() + aux.when(signal_received, function() state.posted = state.posted + 1 return k() end) local posted - event_listener('CHAT_MSG_SYSTEM', function(kill) + aux.event_listener('CHAT_MSG_SYSTEM', function(kill) if arg1 == ERR_AUCTION_STARTED then send_signal() kill() @@ -65,7 +64,7 @@ end function M.stop() if state then - kill_thread(state.thread_id) + aux.kill_thread(state.thread_id) local callback = state.callback local posted = state.posted @@ -81,7 +80,7 @@ end function M.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback) stop() state = { - thread_id = thread(process), + thread_id = aux.thread(process), item_key = item_key, stack_size = stack_size, duration = duration, diff --git a/core/scan.lua b/core/scan.lua index b7d5ab3..23c1a6f 100644 --- a/core/scan.lua +++ b/core/scan.lua @@ -1,15 +1,13 @@ module 'aux.core.scan' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local history = require 'aux.core.history' local PAGE_SIZE = 50 -function handle.CLOSE() +function aux.handle.CLOSE() abort() end @@ -21,8 +19,8 @@ do if old_state then abort(old_state.id) end - do (params.on_scan_start or nop)() end - local thread_id = thread(scan) + do (params.on_scan_start or pass)() end + local thread_id = aux.thread(scan) scan_states[params.type] = { id = thread_id, params = params, @@ -34,13 +32,13 @@ do local aborted = T.acquire() for type, state in scan_states do if not scan_id or state.id == scan_id then - kill_thread(state.id) + aux.kill_thread(state.id) scan_states[type] = nil tinsert(aborted, state) end end for _, state in aborted do - do (state.params.on_abort or nop)() end + do (state.params.on_abort or pass)() end end end @@ -51,12 +49,12 @@ do function complete() local on_complete = get_state().params.on_complete scan_states[get_state().params.type] = nil - do (on_complete or nop)() end + do (on_complete or pass)() end end function get_state() for _, state in scan_states do - if state.id == thread_id() then + if state.id == aux.thread_id() then return state end end @@ -80,9 +78,9 @@ end function scan() get_state().query_index = get_state().query_index and get_state().query_index + 1 or 1 if get_query() and not get_state().stopped then - do (get_state().params.on_start_query or nop)(get_state().query_index) end + do (get_state().params.on_start_query or pass)(get_state().query_index) end if get_query().blizzard_query then - if (get_query().blizzard_query.first_page or 0) <= (get_query().blizzard_query.last_page or huge) then + if (get_query().blizzard_query.first_page or 0) <= (get_query().blizzard_query.last_page or aux.huge) then get_state().page = get_query().blizzard_query.first_page or 0 return submit_query() end @@ -122,7 +120,7 @@ do if get_state().params.type ~= 'list' then return submit() else - return when(CanSendAuctionQuery, submit) + return aux.when(CanSendAuctionQuery, submit) end end end @@ -131,7 +129,7 @@ function scan_page(i) i = i or 1 if i > PAGE_SIZE then - do (get_state().params.on_page_scanned or nop)() end + do (get_state().params.on_page_scanned or pass)() end if get_query().blizzard_query and get_state().page < last_page(get_state().total_auctions) then get_state().page = get_state().page + 1 return submit_query() @@ -149,12 +147,12 @@ function scan_page(i) history.process_auction(auction_info) - if (get_state().params.auto_buy_validator or nop)(auction_info) then - local send_signal, signal_received = signal() - when(signal_received, scan_page, i) - return place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, send_signal) + if (get_state().params.auto_buy_validator or pass)(auction_info) then + local send_signal, signal_received = aux.signal() + aux.when(signal_received, scan_page, i) + return aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, send_signal) elseif not get_query().validator or get_query().validator(auction_info) then - do (get_state().params.on_auction or nop)(auction_info) end + do (get_state().params.on_auction or pass)(auction_info) end end end @@ -163,7 +161,7 @@ end function wait_for_results() if get_state().params.type == 'bidder' then - return when(function() return bids_loaded() end, accept_results) + return aux.when(function() return aux.bids_loaded() end, accept_results) elseif get_state().params.type == 'owner' then return wait_for_owner_results() elseif get_state().params.type == 'list' then @@ -174,7 +172,7 @@ end function accept_results() _, get_state().total_auctions = GetNumAuctionItems(get_state().params.type) do - (get_state().params.on_page_loaded or nop)( + (get_state().params.on_page_loaded or pass)( get_state().page - (get_query().blizzard_query.first_page or 0) + 1, last_page(get_state().total_auctions) - (get_query().blizzard_query.first_page or 0) + 1, total_pages(get_state().total_auctions) - 1 @@ -184,24 +182,24 @@ function accept_results() end function wait_for_owner_results() - if get_state().page == current_owner_page() then + if get_state().page == aux.current_owner_page() then return accept_results() else local updated - on_next_event('AUCTION_OWNED_LIST_UPDATE', function() updated = true end) - return when(function() return updated end, accept_results) + aux.on_next_event('AUCTION_OWNED_LIST_UPDATE', function() updated = true end) + return aux.when(function() return updated end, accept_results) end end function wait_for_list_results() local updated, last_update - local listener_id = event_listener('AUCTION_ITEM_LIST_UPDATE', function() + local listener_id = aux.event_listener('AUCTION_ITEM_LIST_UPDATE', function() last_update = GetTime() updated = true end) - local timeout = later(5, get_state().last_list_query) + local timeout = aux.later(5, get_state().last_list_query) local ignore_owner = get_state().params.ignore_owner or aux_ignore_owner - return when(function() + return aux.when(function() if not last_update and timeout() then return true end @@ -214,7 +212,7 @@ function wait_for_list_results() end updated = false end, function() - kill_listener(listener_id) + aux.kill_listener(listener_id) if not last_update and timeout() then return submit_query() else diff --git a/core/shortcut.lua b/core/shortcut.lua index 5fbb4dc..84ac6fa 100644 --- a/core/shortcut.lua +++ b/core/shortcut.lua @@ -1,20 +1,18 @@ module 'aux.core.shortcut' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' do local orig = SetItemRef _G.SetItemRef = T.vararg-function(arg) - if arg[3] ~= 'RightButton' or not index(get_active_tab(), 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then + if arg[3] ~= 'RightButton' or not aux.index(aux.get_tab(), 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then return orig(unpack(arg)) end - local item_info = info.item(tonumber(select(3, strfind(arg[1], '^item:(%d+)')))) + local item_info = info.item(tonumber(aux.select(3, strfind(arg[1], '^item:(%d+)')))) if item_info then - return get_active_tab().CLICK_LINK(item_info) + return aux.get_tab().CLICK_LINK(item_info) end end end @@ -22,12 +20,12 @@ end do local orig = UseContainerItem _G.UseContainerItem = T.vararg-function(arg) - if modified() or not get_active_tab() then + if aux.modified() or not aux.get_tab() then return orig(unpack(arg)) end local item_info = info.container_item(arg[1], arg[2]) - if item_info and get_active_tab().USE_ITEM then - get_active_tab().USE_ITEM(item_info) + if item_info and aux.get_tab().USE_ITEM then + aux.get_tab().USE_ITEM(item_info) end end end \ No newline at end of file diff --git a/core/slash.lua b/core/slash.lua index dcb184b..a5a0e18 100644 --- a/core/slash.lua +++ b/core/slash.lua @@ -1,71 +1,69 @@ module 'aux.core.slash' -include 'aux' +local aux = require 'aux' -local info = require 'aux.util.info' - -function handle.LOAD2() - tooltip_settings = character_data'tooltip' +function aux.handle.LOAD2() + tooltip_settings = aux.character_data'tooltip' end _G.aux_ignore_owner = true function status(enabled) - return (enabled and color.green'on' or color.red'off') + return (enabled and aux.color.green'on' or aux.color.red'off') end _G.SLASH_AUX1 = '/aux' function SlashCmdList.AUX(command) if not command then return end - local arguments = tokenize(command) + local arguments = aux.tokenize(command) if arguments[1] == 'scale' and tonumber(arguments[2]) then local scale = tonumber(arguments[2]) - AuxFrame:SetScale(scale) + aux.frame:SetScale(scale) _G.aux_scale = scale elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then _G.aux_ignore_owner = not aux_ignore_owner - print('ignore owner ' .. status(aux_ignore_owner)) + aux.print('ignore owner ' .. status(aux_ignore_owner)) elseif arguments[1] == 'post' and arguments[2] == 'bid' then _G.aux_post_bid = not aux_post_bid - print('post bid ' .. status(aux_post_bid)) + aux.print('post bid ' .. status(aux_post_bid)) elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then tooltip_settings.value = not tooltip_settings.value - print('tooltip value ' .. status(tooltip_settings.value)) + aux.print('tooltip value ' .. status(tooltip_settings.value)) elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then tooltip_settings.daily = not tooltip_settings.daily - print('tooltip daily ' .. status(tooltip_settings.daily)) + aux.print('tooltip daily ' .. status(tooltip_settings.daily)) elseif arguments[1] == 'tooltip' and arguments[2] == 'merchant' and arguments[3] == 'buy' then tooltip_settings.merchant_buy = not tooltip_settings.merchant_buy - print('tooltip merchant buy ' .. status(tooltip_settings.merchant_buy)) + aux.print('tooltip merchant buy ' .. status(tooltip_settings.merchant_buy)) elseif arguments[1] == 'tooltip' and arguments[2] == 'merchant' and arguments[3] == 'sell' then tooltip_settings.merchant_sell = not tooltip_settings.merchant_sell - print('tooltip merchant sell ' .. status(tooltip_settings.merchant_sell)) + aux.print('tooltip merchant sell ' .. status(tooltip_settings.merchant_sell)) elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then tooltip_settings.disenchant_value = not tooltip_settings.disenchant_value - print('tooltip disenchant value ' .. status(tooltip_settings.disenchant_value)) + aux.print('tooltip disenchant value ' .. status(tooltip_settings.disenchant_value)) elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then tooltip_settings.disenchant_distribution = not tooltip_settings.disenchant_distribution - print('tooltip disenchant distribution ' .. status(tooltip_settings.disenchant_distribution)) + aux.print('tooltip disenchant distribution ' .. status(tooltip_settings.disenchant_distribution)) elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then _G.aux_items = {} _G.aux_item_ids = {} _G.aux_auctionable_items = {} - print('Item cache cleared.') + aux.print('Item cache cleared.') elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then info.populate_wdb() else - print('Usage:') - print('- scale [' .. color.blue(aux_scale) .. ']') - print('- ignore owner [' .. status(aux_ignore_owner) .. ']') - print('- post bid [' .. status(aux_post_bid) .. ']') - print('- tooltip value [' .. status(tooltip_settings.value) .. ']') - print('- tooltip daily [' .. status(tooltip_settings.daily) .. ']') - print('- tooltip merchant buy [' .. status(tooltip_settings.merchant_buy) .. ']') - print('- tooltip merchant sell [' .. status(tooltip_settings.merchant_sell) .. ']') - print('- tooltip disenchant value [' .. status(tooltip_settings.disenchant_value) .. ']') - print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']') - print('- clear item cache') - print('- populate wdb') + aux.print('Usage:') + aux.print('- scale [' .. aux.color.blue(aux_scale) .. ']') + aux.print('- ignore owner [' .. status(aux_ignore_owner) .. ']') + aux.print('- post bid [' .. status(aux_post_bid) .. ']') + aux.print('- tooltip value [' .. status(tooltip_settings.value) .. ']') + aux.print('- tooltip daily [' .. status(tooltip_settings.daily) .. ']') + aux.print('- tooltip merchant buy [' .. status(tooltip_settings.merchant_buy) .. ']') + aux.print('- tooltip merchant sell [' .. status(tooltip_settings.merchant_sell) .. ']') + aux.print('- tooltip disenchant value [' .. status(tooltip_settings.disenchant_value) .. ']') + aux.print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']') + aux.print('- clear item cache') + aux.print('- populate wdb') end end \ No newline at end of file diff --git a/core/stack.lua b/core/stack.lua index d0899b0..c954e38 100644 --- a/core/stack.lua +++ b/core/stack.lua @@ -1,14 +1,12 @@ module 'aux.core.stack' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local state -function handle.CLOSE() +function aux.handle.CLOSE() stop() end @@ -34,7 +32,7 @@ end function find_item_slot(partial) for slot in info.inventory() do - if matching_item(slot, partial) and not eq(slot, state.target_slot) then + if matching_item(slot, partial) and not aux.eq(slot, state.target_slot) then return slot end end @@ -63,7 +61,7 @@ end function move_item(from_slot, to_slot, amount, k) if locked(from_slot) or locked(to_slot) then - return wait(k) + return aux.wait(k) end amount = min(max_stack(from_slot) - stack_size(to_slot), stack_size(from_slot), amount) @@ -73,7 +71,7 @@ function move_item(from_slot, to_slot, amount, k) SplitContainerItem(from_slot[1], from_slot[2], amount) PickupContainerItem(unpack(to_slot)) - return when(function() return stack_size(to_slot) == expected_size end, k) + return aux.when(function() return stack_size(to_slot) == expected_size end, k) end function process() @@ -113,18 +111,18 @@ end function M.stop() if state then - kill_thread(state.thread_id) + aux.kill_thread(state.thread_id) local callback, slot = state.callback, state.target_slot slot = slot and matching_item(slot) and slot or nil state = nil - do (callback or nop)(slot) end + do (callback or pass)(slot) end end end function M.start(item_key, size, callback) stop() state = { - thread_id = thread(process), + thread_id = aux.thread(process), item_key = item_key, target_size = size, callback = callback, diff --git a/core/tooltip.lua b/core/tooltip.lua index d83d4d6..766074f 100644 --- a/core/tooltip.lua +++ b/core/tooltip.lua @@ -1,9 +1,7 @@ module 'aux.core.tooltip' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local money = require 'aux.util.money' local disenchant = require 'aux.core.disenchant' @@ -14,16 +12,16 @@ local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE local game_tooltip_hooks, game_tooltip_money = {}, 0 -function handle.LOAD() - settings = character_data('tooltip', {value=true}) +function aux.handle.LOAD() + settings = aux.character_data('tooltip', {value=true}) do local inside_hook = false for name, f in game_tooltip_hooks do local name, f = name, f - hook(name, GameTooltip, T.vararg-function(arg) + aux.hook(name, GameTooltip, T.vararg-function(arg) game_tooltip_money = 0 inside_hook = true - local tmp = T.list(orig[GameTooltip][name](unpack(arg))) + local tmp = T.list(aux.orig[GameTooltip][name](unpack(arg))) inside_hook = false f(unpack(arg)) return T.unpack(tmp) @@ -43,7 +41,7 @@ function handle.LOAD() local name, _, quality = GetItemInfo(arg[1]) local tmp = T.list(orig(unpack(arg))) if not IsShiftKeyDown() and not IsControlKeyDown() and name then - local color_code = select(4, GetItemQualityColor(quality)) + local color_code = aux.select(4, GetItemQualityColor(quality)) local link = color_code .. '|H' .. arg[1] .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE extend_tooltip(ItemRefTooltip, link, 1) end @@ -59,28 +57,28 @@ function M.extend_tooltip(tooltip, link, quantity) local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level) if getn(distribution) > 0 then if settings.disenchant_distribution then - tooltip:AddLine('Disenchants into:', color.tooltip.disenchant.distribution()) + tooltip:AddLine('Disenchants into:', aux.color.tooltip.disenchant.distribution()) sort(distribution, function(a,b) return a.probability > b.probability end) for _, event in ipairs(distribution) do - 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.tooltip.disenchant.distribution()) + 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), aux.color.tooltip.disenchant.distribution()) end end if settings.disenchant_value then local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level) - tooltip:AddLine('Disenchant: ' .. (disenchant_value and money.to_string2(disenchant_value) or UNKNOWN), color.tooltip.disenchant.value()) + tooltip:AddLine('Disenchant: ' .. (disenchant_value and money.to_string2(disenchant_value) or UNKNOWN), aux.color.tooltip.disenchant.value()) end end end if settings.merchant_buy then local _, price, limited = info.merchant_info(item_id) if price then - tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.tooltip.merchant()) + tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), aux.color.tooltip.merchant()) end end if settings.merchant_sell then local price = info.merchant_info(item_id) if price ~= 0 then - tooltip:AddLine('Vendor: ' .. (price and money.to_string2(price * quantity) or UNKNOWN), color.tooltip.merchant()) + tooltip:AddLine('Vendor: ' .. (price and money.to_string2(price * quantity) or UNKNOWN), aux.color.tooltip.merchant()) end end local auctionable = not item_info or info.auctionable(T.temp-info.tooltip('link', item_info.itemstring), item_info.quality) @@ -88,11 +86,11 @@ function M.extend_tooltip(tooltip, link, quantity) local value = history.value(item_key) if auctionable then if settings.value then - tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or UNKNOWN), color.tooltip.value()) + tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or UNKNOWN), aux.color.tooltip.value()) end if settings.daily then local market_value = history.market_value(item_key) - tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. gui.percentage_historical(round(market_value / value * 100)) .. ')' or UNKNOWN), color.tooltip.value()) + tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. gui.percentage_historical(aux.round(market_value / value * 100)) .. ')' or UNKNOWN), aux.color.tooltip.value()) end end @@ -105,7 +103,7 @@ end function game_tooltip_hooks:SetHyperlink(itemstring) local name, _, quality = GetItemInfo(itemstring) if name then - local hex = select(4, GetItemQualityColor(quality)) + local hex = aux.select(4, GetItemQualityColor(quality)) local link = hex .. '|H' .. itemstring .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE extend_tooltip(GameTooltip, link, 1) end @@ -114,35 +112,35 @@ end function game_tooltip_hooks:SetAuctionItem(type, index) local link = GetAuctionItemLink(type, index) if link then - extend_tooltip(GameTooltip, link, select(3, GetAuctionItemInfo(type, index))) + extend_tooltip(GameTooltip, link, aux.select(3, GetAuctionItemInfo(type, index))) end end function game_tooltip_hooks:SetLootItem(slot) local link = GetLootSlotLink(slot) if link then - extend_tooltip(GameTooltip, link, select(3, GetLootSlotInfo(slot))) + extend_tooltip(GameTooltip, link, aux.select(3, GetLootSlotInfo(slot))) end end function game_tooltip_hooks:SetQuestItem(qtype, slot) local link = GetQuestItemLink(qtype, slot) if link then - extend_tooltip(GameTooltip, link, select(3, GetQuestItemInfo(qtype, slot))) + extend_tooltip(GameTooltip, link, aux.select(3, GetQuestItemInfo(qtype, slot))) end end function game_tooltip_hooks:SetQuestLogItem(qtype, slot) local link = GetQuestLogItemLink(qtype, slot) if link then - extend_tooltip(GameTooltip, link, select(3, GetQuestLogRewardInfo(slot))) + extend_tooltip(GameTooltip, link, aux.select(3, GetQuestLogRewardInfo(slot))) end end function game_tooltip_hooks:SetBagItem(bag, slot) local link = GetContainerItemLink(bag, slot) if link then - extend_tooltip(GameTooltip, link, select(2, GetContainerItemInfo(bag, slot))) + extend_tooltip(GameTooltip, link, aux.select(2, GetContainerItemInfo(bag, slot))) end end @@ -151,7 +149,7 @@ function game_tooltip_hooks:SetInboxItem(index) local id = name and info.item_id(name) if id then local _, itemstring, quality = GetItemInfo(id) - local hex = select(4, GetItemQualityColor(tonumber(quality))) + local hex = aux.select(4, GetItemQualityColor(tonumber(quality))) local link = hex .. '|H' .. itemstring .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE extend_tooltip(GameTooltip, link, quantity) end @@ -167,7 +165,7 @@ end function game_tooltip_hooks:SetMerchantItem(slot) local link = GetMerchantItemLink(slot) if link then - local quantity = select(4, GetMerchantItemInfo(slot)) + local quantity = aux.select(4, GetMerchantItemInfo(slot)) extend_tooltip(GameTooltip, link, quantity) end end @@ -175,7 +173,7 @@ end function game_tooltip_hooks:SetCraftItem(skill, slot) local link, quantity if slot then - link, quantity = GetCraftReagentItemLink(skill, slot), select(3, GetCraftReagentInfo(skill, slot)) + link, quantity = GetCraftReagentItemLink(skill, slot), aux.select(3, GetCraftReagentInfo(skill, slot)) else link, quantity = GetCraftItemLink(skill), 1 end @@ -194,7 +192,7 @@ end function game_tooltip_hooks:SetTradeSkillItem(skill, slot) local link, quantity if slot then - link, quantity = GetTradeSkillReagentItemLink(skill, slot), select(3, GetTradeSkillReagentInfo(skill, slot)) + link, quantity = GetTradeSkillReagentItemLink(skill, slot), aux.select(3, GetTradeSkillReagentInfo(skill, slot)) else link, quantity = GetTradeSkillItemLink(skill), 1 end @@ -209,7 +207,7 @@ function game_tooltip_hooks:SetAuctionSellItem() for slot in info.inventory() do T.temp(slot) local link = GetContainerItemLink(unpack(slot)) - if link and select(5, info.parse_link(link)) == name then + if link and aux.select(5, info.parse_link(link)) == name then extend_tooltip(GameTooltip, link, quantity) return end diff --git a/frame.lua b/frame.lua index d868c25..819912f 100644 --- a/frame.lua +++ b/frame.lua @@ -9,8 +9,8 @@ function handle.LOAD() end do - local frame = CreateFrame('Frame', 'AuxFrame', UIParent) - tinsert(UISpecialFrames, 'AuxFrame') + local frame = CreateFrame('Frame', 'aux_frame', UIParent) + tinsert(UISpecialFrames, 'aux_frame') gui.set_window_style(frame) gui.set_size(frame, 768, 447) frame:SetPoint('LEFT', 100, 0) @@ -25,23 +25,23 @@ do frame.content:SetPoint('TOPLEFT', 4, -80) frame.content:SetPoint('BOTTOMRIGHT', -4, 35) frame:Hide() - M.AuxFrame = frame + M.frame = frame end do - tabs = gui.tabs(AuxFrame, 'DOWN') + tabs = gui.tabs(frame, 'DOWN') tabs._on_select = on_tab_click function M.set_tab(id) tabs:select(id) end end do - local btn = gui.button(AuxFrame) + local btn = gui.button(frame) btn:SetPoint('BOTTOMRIGHT', -5, 5) gui.set_size(btn, 60, 24) btn:SetText('Close') - btn:SetScript('OnClick', function() AuxFrame:Hide() end) + btn:SetScript('OnClick', function() frame:Hide() end) close_button = btn end do - local btn = gui.button(AuxFrame, gui.font_size.small) + local btn = gui.button(frame, gui.font_size.small) btn:SetPoint('RIGHT', close_button, 'LEFT' , -5, 0) gui.set_size(btn, 60, 24) btn:SetText(color.blizzard'Blizzard UI') diff --git a/gui/auction_listing.lua b/gui/auction_listing.lua index 7e90fcf..6b40ccf 100644 --- a/gui/auction_listing.lua +++ b/gui/auction_listing.lua @@ -1,9 +1,7 @@ module 'aux.gui.auction_listing' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local sort_util = require 'aux.util.sort' local money = require 'aux.util.money' @@ -17,10 +15,10 @@ local HEAD_HEIGHT = 27 local HEAD_SPACE = 2 local TIME_LEFT_STRINGS = { - color.red'30m', -- Short - color.orange'2h', -- Medium - color.yellow'8h', -- Long - color.blue'24h', -- Very Long + aux.color.red'30m', -- Short + aux.color.orange'2h', -- Medium + aux.color.yellow'8h', -- Long + aux.color.blue'24h', -- Very Long } function item_column_init(rt, cell) @@ -81,7 +79,7 @@ M.search_columns = { align = 'CENTER', fill = function(cell, record) local display_level = max(record.level, 1) - display_level = UnitLevel'player' < record.level and color.red(display_level) or display_level + display_level = UnitLevel'player' < record.level and aux.color.red(display_level) or display_level cell.text:SetText(display_level) end, cmp = function(record_a, record_b, desc) @@ -93,9 +91,9 @@ M.search_columns = { width = .06, align = 'CENTER', fill = function(cell, record, count, own, expandable) - local numAuctionsText = expandable and color.link(count) or count + local numAuctionsText = expandable and aux.color.link(count) or count if own > 0 then - numAuctionsText = numAuctionsText .. (' ' .. color.yellow('(' .. own .. ')')) + numAuctionsText = numAuctionsText .. (' ' .. aux.color.yellow('(' .. own .. ')')) end cell.text:SetText(numAuctionsText) end, @@ -139,7 +137,7 @@ M.search_columns = { width = .13, align = 'CENTER', fill = function(cell, record) - cell.text:SetText(info.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?')) + cell.text:SetText(info.is_player(record.owner) and (aux.color.yellow(record.owner)) or (record.owner or '?')) end, cmp = function(record_a, record_b, desc) if not record_a.owner and not record_b.owner then @@ -161,9 +159,9 @@ M.search_columns = { fill = function(cell, record) local price_color if record.high_bidder then - price_color = color.green + price_color = aux.color.green elseif record.high_bid ~= 0 then - price_color = color.orange + price_color = aux.color.orange end local price if record.high_bidder then @@ -213,8 +211,8 @@ M.search_columns = { cmp = function(record_a, record_b, desc) local price_a = price_per_unit and record_a.unit_buyout_price or record_a.buyout_price local price_b = 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) + price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge) + price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge) return sort_util.compare(price_a, price_b, desc) end, @@ -228,8 +226,8 @@ M.search_columns = { cell.text:SetText((pct or bidPct) and gui.percentage_historical(pct or bidPct, not pct) or '?') end, cmp = function(record_a, record_b, desc) - local pct_a = record_percentage(record_a) or (desc and -huge or huge) - local pct_b = record_percentage(record_b) or (desc and -huge or huge) + local pct_a = record_percentage(record_a) or (desc and -aux.huge or aux.huge) + local pct_b = record_percentage(record_b) or (desc and -aux.huge or aux.huge) return sort_util.compare(pct_a, pct_b, desc) end, }, @@ -251,7 +249,7 @@ M.auctions_columns = { align = 'CENTER', fill = function(cell, record) local display_level = max(record.level, 1) - display_level = UnitLevel('player') < record.level and color.red(display_level) or display_level + display_level = UnitLevel('player') < record.level and aux.color.red(display_level) or display_level cell.text:SetText(display_level) end, cmp = function(record_a, record_b, desc) @@ -263,7 +261,7 @@ M.auctions_columns = { width = .06, align = 'CENTER', fill = function(cell, record, count, own, expandable) - local numAuctionsText = expandable and color.link(count) or count + local numAuctionsText = expandable and aux.color.link(count) or count cell.text:SetText(numAuctionsText) end, cmp = function(record_a, record_b, desc) @@ -343,8 +341,8 @@ M.auctions_columns = { cmp = function(record_a, record_b, desc) local price_a = price_per_unit and record_a.unit_buyout_price or record_a.buyout_price local price_b = 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) + price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge) + price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge) return sort_util.compare(price_a, price_b, desc) end, @@ -354,7 +352,7 @@ M.auctions_columns = { width = .21, align = 'CENTER', fill = function(cell, record) - cell.text:SetText(record.high_bidder or color.red 'No Bids') + cell.text:SetText(record.high_bidder or aux.color.red 'No Bids') end, cmp = function(record_a, record_b, desc) if not record_a.high_bidder and not record_b.high_bidder then @@ -385,7 +383,7 @@ M.bids_columns = { width = .06, align = 'CENTER', fill = function(cell, record, count, own, expandable) - local numAuctionsText = expandable and color.link(count) or count + local numAuctionsText = expandable and aux.color.link(count) or count cell.text:SetText(numAuctionsText) end, cmp = function(record_a, record_b, desc) @@ -428,7 +426,7 @@ M.bids_columns = { width = .13, align = 'CENTER', fill = function(cell, record) - cell.text:SetText(info.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?')) + cell.text:SetText(info.is_player(record.owner) and (aux.color.yellow(record.owner)) or (record.owner or '?')) end, cmp = function(record_a, record_b, desc) if not record_a.owner and not record_b.owner then @@ -484,8 +482,8 @@ M.bids_columns = { cmp = function(record_a, record_b, desc) local price_a = price_per_unit and record_a.unit_buyout_price or record_a.buyout_price local price_b = 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) + price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge) + price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge) return sort_util.compare(price_a, price_b, desc) end, @@ -497,9 +495,9 @@ M.bids_columns = { fill = function(cell, record) local status if record.high_bidder then - status = color.yellow'High Bidder' + status = aux.color.yellow'High Bidder' else - status = color.red'Outbid' + status = aux.color.red'Outbid' end cell.text:SetText(status) end, @@ -515,9 +513,9 @@ function record_percentage(record) local historical_value = history.value(record.item_key) or 0 if historical_value > 0 then if record.unit_buyout_price > 0 then - return round(100 * record.unit_buyout_price / historical_value) + return aux.round(100 * record.unit_buyout_price / historical_value) end - return nil, round(100 * record.unit_bid_price / historical_value) + return nil, aux.round(100 * record.unit_bid_price / historical_value) end end @@ -612,7 +610,7 @@ local methods = { if not selection or selection.record ~= this.record then this.rt:SetSelectedRecord(this.record) end - do (this.rt.handlers.OnClick or nop)(this, button) end + do (this.rt.handlers.OnClick or pass)(this, button) end end end, @@ -645,7 +643,7 @@ local methods = { local records = self.records - local single_item = all(records, function(record) return record.item_key == records[1].item_key end) + local single_item = aux.all(records, function(record) return record.item_key == records[1].item_key end) sort(records, function(a, b) return a.search_signature < b.search_signature or a.search_signature == b.search_signature and tostring(a) < tostring(b) end) @@ -840,7 +838,7 @@ local methods = { end, RemoveAuctionRecord = function(self, record) - local index = key(self.records, record) + local index = aux.key(self.records, record) if index then tremove(self.records, index) end @@ -848,7 +846,7 @@ local methods = { end, ContainsRecord = function(self, record) - if key(self.records, record) then + if aux.key(self.records, record) then return true end end, @@ -930,7 +928,7 @@ function M.new(parent, rows, columns) scrollBar:SetWidth(10) local thumbTex = scrollBar:GetThumbTexture() thumbTex:SetPoint('CENTER', 0, 0) - thumbTex:SetTexture(color.content.background()) + thumbTex:SetTexture(aux.color.content.background()) thumbTex:SetHeight(150) thumbTex:SetWidth(scrollBar:GetWidth()) _G[scrollBar:GetName() .. 'ScrollUpButton']:Hide() @@ -955,7 +953,7 @@ function M.new(parent, rows, columns) local text = cell:CreateFontString() text:SetJustifyH('CENTER') text:SetFont(gui.font, 12) - text:SetTextColor(color.label.enabled()) + text:SetTextColor(aux.color.label.enabled()) cell:SetFontString(text) if not column.isPrice then cell:SetText(column.title or '') end -- TODO text:SetAllPoints() diff --git a/gui/core.lua b/gui/core.lua index 78dd9c6..fdc0964 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -1,18 +1,17 @@ module 'aux.gui' -include 'aux' - local T = require 'T' +local aux = require 'aux' M.font = [[Fonts\ARIALN.TTF]] -M.font_size = immutable-{ +M.font_size = aux.immutable-{ small = 13, medium = 15, large = 18, } ---function handle.LOAD() +--function aux.handle.LOAD() -- do -- local blizzard_backdrop, aux_background, aux_border -- @@ -22,14 +21,14 @@ M.font_size = immutable-{ -- aux_border:SetPoint('BOTTOMRIGHT', DropDownList1Backdrop, 'BOTTOMRIGHT', 1.5, -1.5) -- aux_border:SetBlendMode('ADD') -- aux_background = DropDownList1:CreateTexture(nil, 'OVERLAY') --- aux_background:SetTexture(color.content.background()) +-- aux_background:SetTexture(aux.color.content.background()) -- aux_background:SetAllPoints(DropDownList1Backdrop) -- blizzard_backdrop = DropDownList1Backdrop:GetBackdrop() --- hook('ToggleDropDownMenu', function(...) +-- aux.hook('ToggleDropDownMenu', function(...) -- T.temp(arg) --- local ret = T.temp-T.list(orig.ToggleDropDownMenu(unpack(arg))) +-- local ret = T.temp-T.list(aux.orig.ToggleDropDownMenu(unpack(arg))) -- local dropdown = _G[arg[4] or ''] or this:GetParent() --- if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then +-- if strfind(dropdown:GetName() or '', '^aux.frame%d+$') then -- set_aux_dropdown_style(dropdown) -- else -- set_blizzard_dropdown_style() @@ -91,7 +90,7 @@ do local id = 1 function M.unique_name() id = id + 1 - return 'AuxFrame' .. id + return 'aux.frame' .. id end end @@ -120,15 +119,15 @@ function M.set_frame_style(frame, backdrop_color, border_color, left, right, top end function M.set_window_style(frame, left, right, top, bottom) - set_frame_style(frame, color.window.background, color.window.border, left, right, top, bottom) + set_frame_style(frame, aux.color.window.background, aux.color.window.border, left, right, top, bottom) end function M.set_panel_style(frame, left, right, top, bottom) - set_frame_style(frame, color.panel.background, color.panel.border, left, right, top, bottom) + set_frame_style(frame, aux.color.panel.background, aux.color.panel.border, left, right, top, bottom) end function M.set_content_style(frame, left, right, top, bottom) - set_frame_style(frame, color.content.background, color.content.border, left, right, top, bottom) + set_frame_style(frame, aux.color.content.background, aux.color.content.border, left, right, top, bottom) end function M.panel(parent) @@ -140,13 +139,13 @@ end function M.checkbutton(parent, text_height) local button = button(parent, text_height) button.state = false - button:SetBackdropColor(color.state.disabled()) + button:SetBackdropColor(aux.color.state.disabled()) function button:SetChecked(state) if state then - self:SetBackdropColor(color.state.enabled()) + self:SetBackdropColor(aux.color.state.enabled()) self.state = true else - self:SetBackdropColor(color.state.disabled()) + self:SetBackdropColor(aux.color.state.disabled()) self.state = false end end @@ -171,19 +170,19 @@ function M.button(parent, text_height) label:SetAllPoints(button) label:SetJustifyH('CENTER') label:SetJustifyV('CENTER') - label:SetTextColor(color.text.enabled()) + label:SetTextColor(aux.color.text.enabled()) button:SetFontString(label) end button.default_Enable = button.Enable function button:Enable() if self:IsEnabled() == 1 then return end - self:GetFontString():SetTextColor(color.text.enabled()) + self:GetFontString():SetTextColor(aux.color.text.enabled()) return self:default_Enable() end button.default_Disable = button.Disable function button:Disable() if self:IsEnabled() == 0 then return end - self:GetFontString():SetTextColor(color.text.disabled()) + self:GetFontString():SetTextColor(aux.color.text.disabled()) return self:default_Disable() end @@ -209,7 +208,7 @@ do dock:SetPoint('TOPLEFT', 1, 1) dock:SetPoint('TOPRIGHT', -1, 1) end - dock:SetTexture(color.panel.background()) + dock:SetTexture(aux.color.panel.background()) tab.dock = dock local highlight = tab:CreateTexture(nil, 'HIGHLIGHT') highlight:SetAllPoints() @@ -253,20 +252,20 @@ do function mt.__index:select(id) self._selected = id self:update() - do (self._on_select or nop)(id) end + do (self._on_select or pass)(id) end end function mt.__index:update() for _, tab in self._tabs do if tab.group._selected == tab.id then - tab.text:SetTextColor(color.label.enabled()) + tab.text:SetTextColor(aux.color.label.enabled()) tab:Disable() - tab:SetBackdropColor(color.panel.background()) + tab:SetBackdropColor(aux.color.panel.background()) tab.dock:Show() tab:SetHeight(29) else - tab.text:SetTextColor(color.text.enabled()) + tab.text:SetTextColor(aux.color.text.enabled()) tab:Enable() - tab:SetBackdropColor(color.content.background()) + tab:SetBackdropColor(aux.color.content.background()) tab.dock:Hide() tab:SetHeight(24) end @@ -292,9 +291,9 @@ function M.editbox(parent) set_content_style(editbox) editbox:SetScript('OnEscapePressed', function() this:ClearFocus() - do (this.escape or nop)() end + do (this.escape or pass)() end end) - editbox:SetScript('OnEnterPressed', function() (this.enter or nop)() end) + editbox:SetScript('OnEnterPressed', function() (this.enter or pass)() end) editbox:SetScript('OnEditFocusGained', function() if this.block_focus then this.block_focus = false @@ -302,10 +301,10 @@ function M.editbox(parent) return end this.overlay:Hide() - this:SetTextColor(color.text.enabled()) + this:SetTextColor(aux.color.text.enabled()) this.focused = true this:HighlightText() - do (this.focus_gain or nop)() end + do (this.focus_gain or pass)() end end) editbox:SetScript('OnEditFocusLost', function() this.overlay:Show() @@ -313,13 +312,13 @@ function M.editbox(parent) this.focused = false this:HighlightText(0, 0) this:SetScript('OnUpdate', nil) - do (this.focus_loss or nop)() end + do (this.focus_loss or pass)() end end) editbox:SetScript('OnTextChanged', function() this.overlay:SetText(this.formatter and this.formatter(this:GetText()) or this:GetText()) - do (this.change or nop)() end + do (this.change or pass)() end end) - editbox:SetScript('OnChar', function() (this.char or nop)() end) + editbox:SetScript('OnChar', function() (this.char or pass)() end) do local last_click = T.map('t', 0) editbox:SetScript('OnMouseDown', function() @@ -332,7 +331,7 @@ function M.editbox(parent) -- local offset = x - editbox:GetLeft()*editbox:GetEffectiveScale() TODO use a fontstring to measure getstringwidth for structural highlighting -- or use an overlay with itemlinks if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then - thread(function() editbox:HighlightText() end) + aux.thread(function() editbox:HighlightText() end) end T.wipe(last_click) last_click.t = GetTime() @@ -352,7 +351,7 @@ function M.editbox(parent) local overlay = label(editbox) overlay:SetPoint('LEFT', 1.5, 0) overlay:SetPoint('RIGHT', -1.5, 0) - overlay:SetTextColor(color.text.enabled()) + overlay:SetTextColor(aux.color.text.enabled()) editbox.overlay = overlay editbox:SetAlignment('LEFT') editbox:SetFontSize(font_size.medium) @@ -398,7 +397,7 @@ do text_frame:SetFrameLevel(level + 4) text_frame:SetAllPoints(self) local text = label(text_frame, font_size.medium) - text:SetTextColor(color.text.enabled()) + text:SetTextColor(aux.color.text.enabled()) text:SetPoint('CENTER', 0, 0) self.text = text end @@ -439,7 +438,7 @@ end function M.label(parent, size) local label = parent:CreateFontString() label:SetFont(font, size or font_size.small) - label:SetTextColor(color.label.enabled()) + label:SetTextColor(aux.color.label.enabled()) return label end @@ -449,9 +448,9 @@ function M.horizontal_line(parent, y_offset, inverted_color) texture:SetPoint('TOPRIGHT', parent, 'TOPRIGHT', -2, y_offset) texture:SetHeight(2) if inverted_color then - texture:SetTexture(color.panel.background()) + texture:SetTexture(aux.color.panel.background()) else - texture:SetTexture(color.content.background()) + texture:SetTexture(aux.color.content.background()) end return texture end @@ -462,9 +461,9 @@ function M.vertical_line(parent, x_offset, top_offset, bottom_offset, inverted_c texture:SetPoint('BOTTOMLEFT', parent, 'BOTTOMLEFT', x_offset, bottom_offset or 2) texture:SetWidth(2) if inverted_color then - texture:SetTexture(color.panel.background()) + texture:SetTexture(aux.color.panel.background()) else - texture:SetTexture(color.content.background()) + texture:SetTexture(aux.color.content.background()) end return texture end @@ -504,7 +503,7 @@ function M.slider(parent) set_panel_style(slider) local thumb_texture = slider:CreateTexture(nil, 'ARTWORK') thumb_texture:SetPoint('CENTER', 0, 0) - thumb_texture:SetTexture(color.content.background()) + thumb_texture:SetTexture(aux.color.content.background()) thumb_texture:SetHeight(18) thumb_texture:SetWidth(8) set_size(thumb_texture, 8, 18) @@ -516,7 +515,7 @@ function M.slider(parent) label:SetJustifyH('LEFT') label:SetHeight(13) label:SetFont(font, font_size.small) - label:SetTextColor(color.label.enabled()) + label:SetTextColor(aux.color.label.enabled()) local editbox = editbox(slider) editbox:SetPoint('LEFT', slider, 'RIGHT', 5, 0) @@ -555,16 +554,16 @@ end function M.percentage_historical(pct, bid) local text = (pct > 10000 and '>10000' or pct) .. '%' if bid then - return color.gray(text) + return aux.color.gray(text) elseif pct < 50 then - return color.blue(text) + return aux.color.blue(text) elseif pct < 80 then - return color.green(text) + return aux.color.green(text) elseif pct < 110 then - return color.yellow(text) + return aux.color.yellow(text) elseif pct < 135 then - return color.orange(text) + return aux.color.orange(text) else - return color.red(text) + return aux.color.red(text) end end \ No newline at end of file diff --git a/gui/item_listing.lua b/gui/item_listing.lua index 0cecf0d..4b22728 100644 --- a/gui/item_listing.lua +++ b/gui/item_listing.lua @@ -1,9 +1,7 @@ module 'aux.gui.item_listing' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local gui = require 'aux.gui' @@ -66,7 +64,7 @@ function M.new(parent, on_click, selected) scroll_bar:SetWidth(10) local thumbTex = scroll_bar:GetThumbTexture() thumbTex:SetPoint('CENTER', 0, 0) - thumbTex:SetTexture(color.content.background()) + thumbTex:SetTexture(aux.color.content.background()) thumbTex:SetHeight(150) thumbTex:SetWidth(scroll_bar:GetWidth()) _G[scroll_bar:GetName() .. 'ScrollUpButton']:Hide() diff --git a/gui/listing.lua b/gui/listing.lua index 5b1a8fd..544b234 100644 --- a/gui/listing.lua +++ b/gui/listing.lua @@ -1,9 +1,7 @@ module 'aux.gui.listing' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local gui = require 'aux.gui' local ROW_HEIGHT = 15 @@ -175,7 +173,7 @@ local methods = { local text = col:CreateFontString() text:SetAllPoints() text:SetFont(gui.font, 12) - text:SetTextColor(color.label.enabled()) + text:SetTextColor(aux.color.label.enabled()) col.text = text local tex = col:CreateTexture() @@ -283,7 +281,7 @@ function M.new(parent) scroll_bar:SetWidth(10) local thumbTex = scroll_bar:GetThumbTexture() thumbTex:SetPoint('CENTER', 0, 0) - thumbTex:SetTexture(color.content.background()) + thumbTex:SetTexture(aux.color.content.background()) thumbTex:SetHeight(150) thumbTex:SetWidth(scroll_bar:GetWidth()) _G[scroll_bar:GetName() .. 'ScrollUpButton']:Hide() diff --git a/libs/T.lua b/libs/T.lua index a3b2721..738b613 100644 --- a/libs/T.lua +++ b/libs/T.lua @@ -55,7 +55,7 @@ do return v end end - M.temp = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f}) + M.temp = setmetatable({}, {__metatable=false, __newindex=pass, __call=f, __sub=f}) end do local function f(_, v) @@ -64,7 +64,7 @@ do return v end end - M.static = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f}) + M.static = setmetatable({}, {__metatable=false, __newindex=pass, __call=f, __sub=f}) end do @@ -78,7 +78,7 @@ do M.unpack = unpack end -M.empty = setmetatable({}, {__metatable=false, __newindex=nop}) +M.empty = setmetatable({}, {__metatable=false, __newindex=pass}) local vararg do diff --git a/libs/module.lua b/libs/package.lua similarity index 59% rename from libs/module.lua rename to libs/package.lua index 1059e27..6664fe5 100644 --- a/libs/module.lua +++ b/libs/package.lua @@ -1,25 +1,23 @@ if module then return end local _G, setfenv, setmetatable = getfenv(0), setfenv, setmetatable -local environments, exports_data, interfaces = {}, {}, {} +local environments, interfaces = {}, {} -local function nop() end +local function pass() end + +local environment_mt = {__index=_G} local function create_module(name) - local environment, exports = setmetatable({_G=_G, nop=nop}, {__index=_G}), {} + local environment = setmetatable({_G=_G, pass=pass}, environment_mt) + local exports = {} environment.M = setmetatable({}, { __metatable=false, __newindex=function(_, k, v) environment[k], exports[k] = v, v end, }) - environment.include = function(name) - for k, v in exports_data[name] or error('No such module.', 2) do - environment[k] = v - end - end environment._M = environment - interfaces[name] = setmetatable({}, {__metatable=false, __index=exports, __newindex=nop}) - environments[name], exports_data[name] = environment, exports + environments[name] = environment + interfaces[name] = setmetatable({}, {__metatable=false, __index=exports, __newindex=pass}) end function module(name) diff --git a/tabs/auctions/core.lua b/tabs/auctions/core.lua index 0b812bb..504ba0f 100644 --- a/tabs/auctions/core.lua +++ b/tabs/auctions/core.lua @@ -1,13 +1,11 @@ module 'aux.tabs.auctions' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local scan_util = require 'aux.util.scan' local scan = require 'aux.core.scan' -local tab = TAB 'Auctions' +local tab = aux.tab 'Auctions' auction_records = T.acquire() @@ -75,7 +73,7 @@ do cancel_button:SetScript('OnClick', function() if scan_util.test(record, index) and listing:ContainsRecord(record) then - cancel_auction(index, function() listing:RemoveAuctionRecord(record) end) + aux.cancel_auction(index, function() listing:RemoveAuctionRecord(record) end) end end) cancel_button:Enable() @@ -97,7 +95,7 @@ do find_auction(selection.record) elseif state == FOUND and not scan_util.test(selection.record, found_index) then cancel_button:Disable() - if not cancel_in_progress() then state = IDLE end + if not aux.cancel_in_progress() then state = IDLE end end end end \ No newline at end of file diff --git a/tabs/auctions/frame.lua b/tabs/auctions/frame.lua index d988a26..689663e 100644 --- a/tabs/auctions/frame.lua +++ b/tabs/auctions/frame.lua @@ -1,19 +1,20 @@ module 'aux.tabs.auctions' +local aux = require 'aux' local info = require 'aux.util.info' local gui = require 'aux.gui' local auction_listing = require 'aux.gui.auction_listing' local search_tab = require 'aux.tabs.search' -frame = CreateFrame('Frame', nil, AuxFrame) +frame = CreateFrame('Frame', nil, aux.frame) frame:SetAllPoints() frame:SetScript('OnUpdate', on_update) frame:Hide() frame.listing = gui.panel(frame) 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) +frame.listing:SetPoint('BOTTOMLEFT', aux.frame.content, 'BOTTOMLEFT', 0, 0) +frame.listing:SetPoint('BOTTOMRIGHT', aux.frame.content, 'BOTTOMRIGHT', 0, 0) listing = auction_listing.new(frame.listing, 20, auction_listing.auctions_columns) listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) @@ -26,7 +27,7 @@ listing:SetHandler('OnClick', function(row, button) end end elseif button == 'RightButton' then - set_tab(1) + aux.set_tab(1) search_tab.set_filter(strlower(info.item(this.record.item_id).name) .. '/exact') search_tab.execute(nil, false) end @@ -40,7 +41,7 @@ do status_bar = gui.status_bar(frame) status_bar:SetWidth(265) status_bar:SetHeight(25) - status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) + status_bar:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6) status_bar:update_status(1, 1) status_bar:set_text('') end diff --git a/tabs/bids/core.lua b/tabs/bids/core.lua index d23f9f9..2e80382 100644 --- a/tabs/bids/core.lua +++ b/tabs/bids/core.lua @@ -1,14 +1,12 @@ module 'aux.tabs.bids' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local scan_util = require 'aux.util.scan' local scan = require 'aux.core.scan' -local tab = TAB 'Bids' +local tab = aux.tab 'Bids' auction_records = {} @@ -80,7 +78,7 @@ do if not record.high_bidder then bid_button:SetScript('OnClick', function() if scan_util.test(record, index) and listing:ContainsRecord(record) then - place_bid('bidder', index, record.bid_price, record.bid_price < record.buyout_price and function() + aux.place_bid('bidder', index, record.bid_price, record.bid_price < record.buyout_price and function() info.bid_update(record) listing:SetDatabase() end or function() listing:RemoveAuctionRecord(record) end) @@ -94,7 +92,7 @@ do if record.buyout_price > 0 then buyout_button:SetScript('OnClick', function() if scan_util.test(record, index) and listing:ContainsRecord(record) then - place_bid('bidder', index, record.buyout_price, function() listing:RemoveAuctionRecord(record) end) + aux.place_bid('bidder', index, record.buyout_price, function() listing:RemoveAuctionRecord(record) end) end end) buyout_button:Enable() @@ -121,7 +119,7 @@ do elseif state == FOUND and not scan_util.test(selection.record, found_index) then buyout_button:Disable() bid_button:Disable() - if not bid_in_progress() then state = IDLE end + if not aux.bid_in_progress() then state = IDLE end end end end \ No newline at end of file diff --git a/tabs/bids/frame.lua b/tabs/bids/frame.lua index 2bd20a9..c7f3b47 100644 --- a/tabs/bids/frame.lua +++ b/tabs/bids/frame.lua @@ -1,19 +1,20 @@ module 'aux.tabs.bids' +local aux = require 'aux' local info = require 'aux.util.info' local gui = require 'aux.gui' local auction_listing = require 'aux.gui.auction_listing' local search_tab = require 'aux.tabs.search' -frame = CreateFrame('Frame', nil, AuxFrame) +frame = CreateFrame('Frame', nil, aux.frame) frame:SetAllPoints() frame:SetScript('OnUpdate', on_update) frame:Hide() frame.listing = gui.panel(frame) 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) +frame.listing:SetPoint('BOTTOMLEFT', aux.frame.content, 'BOTTOMLEFT', 0, 0) +frame.listing:SetPoint('BOTTOMRIGHT', aux.frame.content, 'BOTTOMRIGHT', 0, 0) listing = auction_listing.new(frame.listing, 20, auction_listing.bids_columns) listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) @@ -28,7 +29,7 @@ listing:SetHandler('OnClick', function(row, button) end end elseif button == 'RightButton' then - set_tab(1) + aux.set_tab(1) search_tab.set_filter(strlower(info.item(this.record.item_id).name) .. '/exact') search_tab.execute(nil, false) end @@ -42,7 +43,7 @@ do status_bar = gui.status_bar(frame) status_bar:SetWidth(265) status_bar:SetHeight(25) - status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) + status_bar:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6) status_bar:update_status(1, 0) status_bar:set_text('') end diff --git a/tabs/post/core.lua b/tabs/post/core.lua index f7ac7a7..311ad00 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -1,9 +1,7 @@ module 'aux.tabs.post' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local sort_util = require 'aux.util.sort' local persistence = require 'aux.util.persistence' @@ -16,7 +14,7 @@ local item_listing = require 'aux.gui.item_listing' local al = require 'aux.gui.auction_listing' local gui = require 'aux.gui' -local tab = TAB 'Post' +local tab = aux.tab 'Post' local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440 local settings_schema = {'tuple', '#', {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}} @@ -31,8 +29,8 @@ function get_default_settings() return T.map('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false) end -function handle.LOAD2() - data = faction_data'post' +function aux.handle.LOAD2() + data = aux.faction_data'post' end function read_settings(item_key) @@ -102,7 +100,7 @@ function set_unit_buyout_price(amount) end function update_inventory_listing() - local records = values(filter(copy(inventory_records), function(record) + local records = aux.values(aux.filter(aux.copy(inventory_records), function(record) local settings = read_settings(record.key) return record.aux_quantity > 0 and (not settings.hidden or show_hidden_checkbox:GetChecked()) end)) @@ -116,15 +114,15 @@ function update_auction_listing(listing, records, reference) local historical_value = history.value(selected_item.key) local stack_size = stack_size_slider:GetValue() for _, record in records[selected_item.key] or T.empty do - local price_color = undercut(record, stack_size_slider:GetValue(), listing == 'bid') < reference and color.red + local price_color = undercut(record, stack_size_slider:GetValue(), listing == 'bid') < reference and aux.color.red local price = record.unit_price * (listing == 'bid' and record.stack_size / stack_size_slider:GetValue() or 1) tinsert(rows, T.map( 'cols', T.list( - T.map('value', record.own and color.green(record.count) or record.count), + T.map('value', record.own and aux.color.green(record.count) or record.count), T.map('value', al.time_left(record.duration)), - T.map('value', record.stack_size == stack_size and color.green(record.stack_size) or record.stack_size), + T.map('value', record.stack_size == stack_size and aux.color.green(record.stack_size) or record.stack_size), T.map('value', money.to_string(price, true, nil, price_color)), - T.map('value', historical_value and gui.percentage_historical(round(price / historical_value * 100)) or '---') + T.map('value', historical_value and gui.percentage_historical(aux.round(price / historical_value * 100)) or '---') ), 'record', record )) @@ -135,7 +133,7 @@ function update_auction_listing(listing, records, reference) T.map('value', '---'), T.map('value', '---'), T.map('value', '---'), - T.map('value', money.to_string(historical_value, true, nil, color.green)), + T.map('value', money.to_string(historical_value, true, nil, aux.color.green)), T.map('value', historical_value and gui.percentage_historical(100) or '---') ), 'record', T.map('historical_value', true, 'stack_size', stack_size, 'unit_price', historical_value, 'own', true) @@ -173,7 +171,7 @@ function update_auction_listings() end function M.select_item(item_key) - for _, inventory_record in filter(copy(inventory_records), function(record) return record.aux_quantity > 0 end) do + for _, inventory_record in aux.filter(aux.copy(inventory_records), function(record) return record.aux_quantity > 0 end) do if inventory_record.key == item_key then update_item(inventory_record) return @@ -192,8 +190,8 @@ function price_update() set_unit_buyout_price(undercut(get_buyout_selection(), stack_size_slider:GetValue())) unit_buyout_price_input:SetText(money.to_string(get_unit_buyout_price(), true, nil, nil, true)) end - start_price_percentage:SetText(historical_value and gui.percentage_historical(round(get_unit_start_price() / historical_value * 100)) or '---') - buyout_price_percentage:SetText(historical_value and gui.percentage_historical(round(get_unit_buyout_price() / historical_value * 100)) or '---') + start_price_percentage:SetText(historical_value and gui.percentage_historical(aux.round(get_unit_start_price() / historical_value * 100)) or '---') + buyout_price_percentage:SetText(historical_value and gui.percentage_historical(aux.round(get_unit_buyout_price() / historical_value * 100)) or '---') end end @@ -275,7 +273,7 @@ function update_item_configuration() item.texture:SetTexture(nil) item.count:SetText() - item.name:SetTextColor(color.label.enabled()) + item.name:SetTextColor(aux.color.label.enabled()) item.name:SetText('No item selected') unit_start_price_input:Hide() @@ -314,7 +312,7 @@ function update_item_configuration() local duration_factor = UIDropDownMenu_GetSelectedValue(duration_dropdown) / 120 local stack_size, stack_count = selected_item.max_charges and 1 or stack_size_slider:GetValue(), stack_count_slider:GetValue() local amount = floor(selected_item.unit_vendor_price * deposit_factor * stack_size) * stack_count * duration_factor - deposit:SetText('Deposit: ' .. money.to_string(amount, nil, nil, color.text.enabled)) + deposit:SetText('Deposit: ' .. money.to_string(amount, nil, nil, aux.color.text.enabled)) end refresh_button:Enable() @@ -391,7 +389,7 @@ function update_item(item) else stack_size_slider:SetMinMaxValues(1, min(selected_item.max_stack, selected_item.aux_quantity)) end - stack_size_slider:SetValue(huge) + stack_size_slider:SetValue(aux.huge) quantity_update(true) unit_start_price_input:SetText(money.to_string(settings.start_price, true, nil, nil, true)) @@ -442,7 +440,7 @@ function update_inventory_records() end end T.release(inventory_records) - inventory_records = values(auctionable_map) + inventory_records = aux.values(auctionable_map) refresh = true end diff --git a/tabs/post/frame.lua b/tabs/post/frame.lua index 1d68117..4ef040f 100644 --- a/tabs/post/frame.lua +++ b/tabs/post/frame.lua @@ -1,5 +1,6 @@ module 'aux.tabs.post' +local aux = require 'aux' local info = require 'aux.util.info' local money = require 'aux.util.money' local gui = require 'aux.gui' @@ -7,15 +8,15 @@ local listing = require 'aux.gui.listing' local item_listing = require 'aux.gui.item_listing' local search_tab = require 'aux.tabs.search' -frame = CreateFrame('Frame', nil, AuxFrame) +frame = CreateFrame('Frame', nil, aux.frame) frame:SetAllPoints() frame:SetScript('OnUpdate', on_update) frame:Hide() frame.content = CreateFrame('Frame', nil, frame) frame.content:SetPoint('TOP', frame, 'TOP', 0, -8) -frame.content:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0) -frame.content:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0) +frame.content:SetPoint('BOTTOMLEFT', aux.frame.content, 'BOTTOMLEFT', 0, 0) +frame.content:SetPoint('BOTTOMRIGHT', aux.frame.content, 'BOTTOMRIGHT', 0, 0) frame.inventory = gui.panel(frame.content) frame.inventory:SetWidth(212) @@ -61,7 +62,7 @@ do if arg1 == 'LeftButton' then update_item(this.item_record) elseif arg1 == 'RightButton' then - set_tab(1) + aux.set_tab(1) search_tab.set_filter(strlower(info.item(this.item_record.item_id).name) .. '/exact') search_tab.execute(nil, false) end @@ -124,7 +125,7 @@ do status_bar = gui.status_bar(frame) status_bar:SetWidth(265) status_bar:SetHeight(25) - status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) + status_bar:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6) status_bar:update_status(1, 1) status_bar:set_text('') end @@ -310,7 +311,7 @@ do deposit = label end -function handle.LOAD() +function aux.handle.LOAD() if not aux_post_bid then frame.bid_listing:Hide() frame.buyout_listing:SetPoint('BOTTOMLEFT', frame.inventory, 'BOTTOMRIGHT', 2.5, 0) diff --git a/tabs/search/core.lua b/tabs/search/core.lua index 8010279..70dc7ec 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -1,12 +1,9 @@ module 'aux.tabs.search' -include 'aux' - -local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' -local tab = TAB 'Search' +local tab = aux.tab 'Search' StaticPopupDialogs.AUX_SEARCH_TABLE_FULL = { text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.', @@ -20,7 +17,7 @@ RESULTS = 1 SAVED = 2 FILTER = 3 -function handle.LOAD() +function aux.handle.LOAD() set_subtab(SAVED) end @@ -73,7 +70,7 @@ end function add_filter(filter_string) local old_filter_string = search_box:GetText() - old_filter_string = trim(old_filter_string) + old_filter_string = aux.trim(old_filter_string) if old_filter_string ~= '' then old_filter_string = old_filter_string .. ';' diff --git a/tabs/search/filter.lua b/tabs/search/filter.lua index 68482c4..cfa0bce 100644 --- a/tabs/search/filter.lua +++ b/tabs/search/filter.lua @@ -1,7 +1,7 @@ module 'aux.tabs.search' local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local money = require 'aux.util.money' local filter_util = require 'aux.util.filter' @@ -11,7 +11,7 @@ local post_filter_index = 0 function valid_level(str) local level = tonumber(str) - return level and bounded(1, 60, level) + return level and aux.bounded(1, 60, level) end blizzard_query = setmetatable(T.acquire(), { @@ -99,7 +99,7 @@ function update_form() quality_dropdown.button:Enable() end - if any(T.temp-T.list('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then + if aux.any(T.temp-T.list('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then exact_checkbox:Disable() else exact_checkbox:Enable() @@ -116,7 +116,7 @@ function get_filter_builder_query() end local name = blizzard_query.name - if not index(filter_util.parse_filter_string(name), 'blizzard', 'name') then + if not aux.index(filter_util.parse_filter_string(name), 'blizzard', 'name') then name = filter_util.quote(name) end add((name ~= '' or blizzard_query.exact) and name) @@ -183,8 +183,8 @@ function clear_form() end function import_filter_string() - local filter, error = filter_util.parse_filter_string(select(3, strfind(search_box:GetText(), '^([^;]*)'))) - if filter or print(error) then + local filter, error = filter_util.parse_filter_string(aux.select(3, strfind(search_box:GetText(), '^([^;]*)'))) + if filter or aux.print(error) then set_form(filter) end update_form() @@ -206,11 +206,11 @@ function formatted_post_filter(components) end str = str .. '
' for _ = 1, getn(stack) + 1 do - str = str .. color.content.background'----' + str = str .. aux.color.content.background'----' end no_line_break = component[1] == 'operator' and component[2] == 'not' - local filter_color = (post_filter_index == i and color.gold or color.orange) + local filter_color = (post_filter_index == i and aux.color.gold or aux.color.orange) local component_text = filter_color(component[2]) if component[1] == 'operator' and component[2] ~= 'not' then component_text = component_text .. filter_color(tonumber(component[3]) or '') @@ -283,7 +283,7 @@ function add_form_component() filter_input:HighlightText() filter_input:SetFocus() elseif error then - print(error) + aux.print(error) end end end @@ -318,8 +318,8 @@ function set_filter_display_offset(x_offset, y_offset) local x_upper_bound = 0 local y_lower_bound = 0 local y_upper_bound = max(0, height - scroll_frame:GetHeight()) - scroll_frame:SetHorizontalScroll(bounded(x_lower_bound, x_upper_bound, x_offset)) - scroll_frame:SetVerticalScroll(bounded(y_lower_bound, y_upper_bound, y_offset)) + scroll_frame:SetHorizontalScroll(aux.bounded(x_lower_bound, x_upper_bound, x_offset)) + scroll_frame:SetVerticalScroll(aux.bounded(y_lower_bound, y_upper_bound, y_offset)) end function initialize_filter_dropdown() @@ -329,7 +329,7 @@ function initialize_filter_dropdown() 'value', filter, 'func', function() filter_input:SetText(this.value) - if index(filter_util.filters[this.value], 'input_type') == '' or this.value == 'not' then + if aux.index(filter_util.filters[this.value], 'input_type') == '' or this.value == 'not' then add_form_component() elseif filter_util.filters[this.value] then filter_parameter_input:Show() diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 871912e..2688aa4 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -1,7 +1,7 @@ module 'aux.tabs.search' local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local completion = require 'aux.util.completion' local filter_util = require 'aux.util.filter' @@ -12,19 +12,19 @@ local auction_listing = require 'aux.gui.auction_listing' local FILTER_SPACING = 28.5 -frame = CreateFrame('Frame', nil, AuxFrame) +frame = CreateFrame('Frame', nil, aux.frame) frame:SetAllPoints() frame:SetScript('OnUpdate', on_update) frame:Hide() frame.filter = gui.panel(frame) -frame.filter:SetAllPoints(AuxFrame.content) +frame.filter:SetAllPoints(aux.frame.content) frame.results = gui.panel(frame) -frame.results:SetAllPoints(AuxFrame.content) +frame.results:SetAllPoints(aux.frame.content) frame.saved = CreateFrame('Frame', nil, frame) -frame.saved:SetAllPoints(AuxFrame.content) +frame.saved:SetAllPoints(aux.frame.content) frame.saved.favorite = gui.panel(frame.saved) frame.saved.favorite:SetWidth(393) @@ -57,7 +57,7 @@ do local btn = gui.button(frame, gui.font_size.small) btn:SetHeight(25) btn:SetWidth(60) - btn:SetText(color.label.enabled'Range:') + btn:SetText(aux.color.label.enabled'Range:') btn:SetScript('OnClick', function() update_real_time(true) end) @@ -68,7 +68,7 @@ do btn:SetHeight(25) btn:SetWidth(60) btn:Hide() - btn:SetText(color.label.enabled'Real Time') + btn:SetText(aux.color.label.enabled'Real Time') btn:SetScript('OnClick', function() update_real_time(false) end) @@ -98,7 +98,7 @@ do editbox.change = change local label = gui.label(editbox, gui.font_size.medium) label:SetPoint('LEFT', editbox, 'RIGHT', 0, 0) - label:SetTextColor(color.label.enabled()) + label:SetTextColor(aux.color.label.enabled()) label:SetText('-') first_page_input = editbox end @@ -149,7 +149,7 @@ do local btn = gui.button(frame) btn:SetHeight(25) btn:SetPoint('RIGHT', start_button, 'LEFT', -4, 0) - btn:SetBackdropColor(color.state.enabled()) + btn:SetBackdropColor(aux.color.state.enabled()) btn:SetText('Resume') btn:SetScript('OnClick', function() execute(true) @@ -161,7 +161,7 @@ do editbox:EnableMouse(1) editbox.formatter = function(str) local queries = filter_util.queries(str) - return queries and join(map(copy(queries), function(query) return query.prettified end), ';') or color.red(str) + return queries and aux.join(aux.map(aux.copy(queries), function(query) return query.prettified end), ';') or aux.color.red(str) end editbox.complete = completion.complete_filter editbox.escape = function() this:SetText(get_current_search().filter_string or '') end @@ -184,7 +184,7 @@ do end do local btn = gui.button(frame, gui.font_size.large) - btn:SetPoint('BOTTOMLEFT', AuxFrame.content, 'TOPLEFT', 10, 8) + btn:SetPoint('BOTTOMLEFT', aux.frame.content, 'TOPLEFT', 10, 8) btn:SetWidth(243) btn:SetHeight(22) btn:SetText('Search Results') @@ -213,7 +213,7 @@ do local frame = CreateFrame('Frame', nil, frame) frame:SetWidth(265) frame:SetHeight(25) - frame:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6) + frame:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6) status_bar_frame = frame end do @@ -435,7 +435,7 @@ do input:SetPoint('CENTER', filter_dropdown, 'CENTER', 0, 0) input:SetWidth(150) input:SetScript('OnTabPressed', function() filter_parameter_input:SetFocus() end) - input.complete = completion.complete(function() return T.temp-T.list('and', 'or', 'not', unpack(keys(filter_util.filters))) end) + input.complete = completion.complete(function() return T.temp-T.list('and', 'or', 'not', unpack(aux.keys(filter_util.filters))) end) input.char = function() this:complete() end input.change = function() local text = this:GetText() @@ -478,7 +478,7 @@ do scroll_frame:EnableMouseWheel(true) scroll_frame:SetScript('OnMouseWheel', function() local child = this:GetScrollChild() - child:SetFont('p', [[Fonts\ARIALN.TTF]], bounded(gui.font_size.small, gui.font_size.large, select(2, child:GetFont()) + arg1*2)) + child:SetFont('p', [[Fonts\ARIALN.TTF]], aux.bounded(gui.font_size.small, gui.font_size.large, aux.select(2, child:GetFont()) + arg1*2)) update_filter_display() end) scroll_frame:RegisterForDrag('LeftButton') @@ -504,7 +504,7 @@ do local scroll_child = CreateFrame('SimpleHTML', nil, scroll_frame) scroll_frame:SetScrollChild(scroll_child) scroll_child:SetFont('p', [[Fonts\ARIALN.TTF]], gui.font_size.large) - scroll_child:SetTextColor('p', color.label.enabled()) + scroll_child:SetTextColor('p', aux.color.label.enabled()) scroll_child:SetWidth(1) scroll_child:SetHeight(1) scroll_child:SetScript('OnHyperlinkClick', data_link_click) @@ -531,7 +531,7 @@ for _ = 1, 5 do end end elseif button == 'RightButton' then - set_tab(1) + aux.set_tab(1) set_filter(strlower(info.item(this.record.item_id).name) .. '/exact') execute(nil, false) end diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 1073ee0..33a25a1 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -1,7 +1,7 @@ module 'aux.tabs.search' local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local filter_util = require 'aux.util.filter' local scan_util = require 'aux.util.scan' @@ -9,7 +9,7 @@ local scan = require 'aux.core.scan' search_scan_id = 0 -function handle.LOAD() +function aux.handle.LOAD() new_search() end @@ -175,7 +175,7 @@ function start_real_time_scan(query, search, continuation) map[record.sniping_signature] = record end T.release(new_records) - new_records = values(map) + new_records = aux.values(map) if getn(new_records) > 2000 then StaticPopup_Show('AUX_SEARCH_TABLE_FULL') @@ -303,14 +303,14 @@ function M.execute(resume, real_time) local queries, error = filter_util.queries(filter_string) if not queries then - print('Invalid filter:', error) + aux.print('Invalid filter:', error) return elseif real_time then if getn(queries) > 1 then - print('Error: The real time mode does not support multi-queries') + aux.print('Error: The real time mode does not support multi-queries') return elseif queries[1].blizzard_query.first_page or queries[1].blizzard_query.last_page then - print('Error: The real time mode does not support page ranges') + aux.print('Error: The real time mode does not support page ranges') return end end @@ -324,7 +324,7 @@ function M.execute(resume, real_time) else get_current_search().filter_string = filter_string end - new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';')) + new_recent_search(filter_string, aux.join(aux.map(aux.copy(queries), function(filter) return filter.prettified end), ';')) else local search = get_current_search() search.records = T.acquire() @@ -391,7 +391,7 @@ do if not record.high_bidder then bid_button:SetScript('OnClick', function() if scan_util.test(record, index) and search.table:ContainsRecord(record) then - place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function() + aux.place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function() info.bid_update(record) search.table:SetDatabase() end or function() search.table:RemoveAuctionRecord(record) end) @@ -405,7 +405,7 @@ do if record.buyout_price > 0 then buyout_button:SetScript('OnClick', function() if scan_util.test(record, index) and search.table:ContainsRecord(record) then - place_bid('list', index, record.buyout_price, function() search.table:RemoveAuctionRecord(record) end) + aux.place_bid('list', index, record.buyout_price, function() search.table:RemoveAuctionRecord(record) end) end end) buyout_button:Enable() @@ -432,7 +432,7 @@ do elseif state == FOUND and not scan_util.test(selection.record, found_index) then buyout_button:Disable() bid_button:Disable() - if not bid_in_progress() then + if not aux.bid_in_progress() then state = IDLE end end diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index 7b87e73..2f26f1f 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -1,12 +1,12 @@ module 'aux.tabs.search' local T = require 'T' - +local aux = require 'aux' local filter_util = require 'aux.util.filter' local gui = require 'aux.gui' -function handle.LOAD2() - recent_searches, favorite_searches = realm_data'recent_searches', realm_data'favorite_searches' +function aux.handle.LOAD2() + recent_searches, favorite_searches = aux.realm_data'recent_searches', aux.realm_data'favorite_searches' end function update_search_listings() @@ -15,7 +15,7 @@ function update_search_listings() local search = favorite_searches[i] local name = strsub(search.prettified, 1, 250) tinsert(favorite_search_rows, T.map( - 'cols', T.list(T.map('value', search.auto_buy and color.red'X' or ''), T.map('value', name)), + 'cols', T.list(T.map('value', search.auto_buy and aux.color.red'X' or ''), T.map('value', name)), 'search', search, 'index', i )) @@ -92,12 +92,12 @@ function get_auto_buy_validator() if queries then tinsert(validators, queries[1].validator) else - print('Invalid auto buy filter:', error) + aux.print('Invalid auto buy filter:', error) end end end return function(record) - return any(validators, function(validator) return validator(record) end) + return aux.any(validators, function(validator) return validator(record) end) end end @@ -106,11 +106,11 @@ function add_favorite(filter_string) if queries then tinsert(favorite_searches, 1, T.map( 'filter_string', filter_string, - 'prettified', join(map(queries, function(query) return query.prettified end), ';') + 'prettified', aux.join(aux.map(queries, function(query) return query.prettified end), ';') )) update_search_listings() else - print('Invalid filter:', error) + aux.print('Invalid filter:', error) end end @@ -118,14 +118,14 @@ function enable_auto_buy(search) local queries, error = filter_util.queries(search.filter_string) if queries then if getn(queries) > 1 then - print('Error: Auto Buy does not support multi-queries') - elseif size(queries[1].blizzard_query) > 0 and not filter_util.parse_filter_string(search.filter_string).blizzard.exact then - print('Error: Auto Buy does not support Blizzard filters') + aux.print('Error: Auto Buy does not support multi-queries') + elseif aux.size(queries[1].blizzard_query) > 0 and not filter_util.parse_filter_string(search.filter_string).blizzard.exact then + aux.print('Error: Auto Buy does not support Blizzard filters') else search.auto_buy = true end else - print('Invalid filter:', error) + aux.print('Invalid filter:', error) end end diff --git a/util.lua b/util.lua index 8beabb9..b59c814 100644 --- a/util.lua +++ b/util.lua @@ -4,12 +4,16 @@ local T = require 'T' M.immutable = setmetatable(T.acquire(), { __metatable = false, - __newindex = nop, + __newindex = pass, __sub = function(_, t) - return setmetatable(T.acquire(), T.map('__metatable', false, '__newindex', nop, '__index', t)) + return setmetatable(T.acquire(), T.map('__metatable', false, '__newindex', pass, '__index', t)) end }) +function M.enum(n) + if n > 0 then return immutable-{}, enum(n - 1) end +end + M.select = T.vararg-function(arg) for _ = 1, arg[1] do tremove(arg, 1) @@ -23,15 +27,6 @@ end M.join = table.concat -function M.range(arg1, arg2) - local i, n = arg2 and arg1 or 1, arg2 or arg1 - if i <= n then return first, range(i + 1, n) end -end - -function M.replicate(count, value) - if count > 0 then return value, replicate(count - 1, value) end -end - M.index = T.vararg-function(arg) local t = tremove(arg, 1) for _, v in ipairs(arg) do diff --git a/util/completion.lua b/util/completion.lua index e5b71dc..40b9b78 100644 --- a/util/completion.lua +++ b/util/completion.lua @@ -1,7 +1,6 @@ module 'aux.util.completion' -include 'aux' - +local aux = require 'aux' local filter_util = require 'aux.util.filter' function M:complete_filter() @@ -11,7 +10,7 @@ function M:complete_filter() local filter_string = this:GetText() - local completed_filter_string = select(3, strfind(filter_string, '([^;]*)/[^/;]*$')) + local completed_filter_string = aux.select(3, strfind(filter_string, '([^;]*)/[^/;]*$')) local _, suggestions = filter_util.query(completed_filter_string) local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$') diff --git a/util/filter.lua b/util/filter.lua index 61feca7..99ceee3 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -1,9 +1,7 @@ module 'aux.util.filter' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local money = require 'aux.util.money' local filter_util = require 'aux.util.filter' @@ -15,7 +13,7 @@ function default_filter(str) input_type = '', validator = function() return function(auction_record) - return any(auction_record.tooltip, function(entry) + return aux.any(auction_record.tooltip, function(entry) return strfind(strlower(entry.left_text or ''), str, 1, true) or strfind(strlower(entry.right_text or ''), str, 1, true) end) end @@ -186,7 +184,7 @@ M.filters = { function operator(str) local operator = str == 'not' and T.list('operator', 'not', 1) for name in T.temp-T.set('and', 'or') do - local arity = select(3, strfind(str, '^' .. name .. '(%d*)$')) + local arity = aux.select(3, strfind(str, '^' .. name .. '(%d*)$')) if arity then arity = tonumber(arity) operator = not (arity and arity < 2) and T.list('operator', name, arity) @@ -203,7 +201,7 @@ do return self end if self.exact then return end - local number = tonumber(select(3, strfind(str, '^(%d+)$'))) + local number = tonumber(aux.select(3, strfind(str, '^(%d+)$'))) if number then if number >= 1 and number <= 60 then for _, key in ipairs(T.temp-T.list('min_level', 'max_level')) do @@ -216,20 +214,20 @@ do end for _, parser in T.temp-T.list( T.temp-T.list('class', info.item_class_index), - T.temp-T.list('subclass', T.vararg-function(arg) return info.item_subclass_index(index(self.class, 2) or 0, unpack(arg)) end), - T.temp-T.list('slot', T.vararg-function(arg) return info.item_slot_index(index(self.class, 2) == 2 and 2 or 0, index(self.subclass, 2) or 0, unpack(arg)) end), + T.temp-T.list('subclass', T.vararg-function(arg) return info.item_subclass_index(aux.index(self.class, 2) or 0, unpack(arg)) end), + T.temp-T.list('slot', T.vararg-function(arg) return info.item_slot_index(aux.index(self.class, 2) == 2 and 2 or 0, aux.index(self.subclass, 2) or 0, unpack(arg)) end), T.temp-T.list('quality', info.item_quality_index) ) do if not self[parser[1]] then tinsert(parser, str) - local index, label = parser[2](select(3, unpack(parser))) + local index, label = parser[2](aux.select(3, unpack(parser))) if index then self[parser[1]] = T.list(label, index) return T.list('blizzard', parser[1], label, index) end end end - if not self[str] and (str == 'usable' or str == 'exact' and self.name and size(self) == 1) then + if not self[str] and (str == 'usable' or str == 'exact' and self.name and aux.size(self) == 1) then self[str] = T.list(str, 1) return T.list('blizzard', str, str, 1) elseif i == 1 and strlen(str) <= 63 then @@ -254,7 +252,7 @@ function parse_parameter(input_type, str) elseif input_type == 'string' then return str ~= '' and str or nil elseif type(input_type) == 'table' then - return key(input_type, str) + return aux.key(input_type, str) end end @@ -262,7 +260,7 @@ function M.parse_filter_string(str) local filter, post_filter = T.acquire(), T.acquire() local blizzard_filter_parser = blizzard_filter_parser() - local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or T.acquire() + local parts = str and aux.map(aux.split(str, '/'), function(part) return strlower(aux.trim(part)) end) or T.acquire() local i = 1 while parts[i] do @@ -341,7 +339,7 @@ function M.query(filter_string) end function M.queries(filter_string) - local parts = split(filter_string, ';') + local parts = aux.split(filter_string, ';') local queries = T.acquire() for _, str in ipairs(parts) do local query, _, error = query(str) @@ -357,7 +355,7 @@ end function suggestions(filter) local suggestions = T.acquire() - if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end + if filter.blizzard.name and aux.size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end tinsert(suggestions, 'and'); tinsert(suggestions, 'or'); tinsert(suggestions, 'not'); tinsert(suggestions, 'tooltip') @@ -370,14 +368,14 @@ function suggestions(filter) -- subclasses if not filter.blizzard.subclass then - for _, subclass in ipairs(T.temp-T.list(GetAuctionItemSubClasses(index(filter.blizzard.class, 2) or 0))) do + for _, subclass in ipairs(T.temp-T.list(GetAuctionItemSubClasses(aux.index(filter.blizzard.class, 2) or 0))) do tinsert(suggestions, subclass) end end -- slots if not filter.blizzard.slot then - for _, invtype in ipairs(T.temp-T.list(GetAuctionInvTypes(index(filter.blizzard.class, 2) == 2 and 2 or 0, index(filter.blizzard.subclass, 2) or 0))) do + for _, invtype in ipairs(T.temp-T.list(GetAuctionInvTypes(aux.index(filter.blizzard.class, 2) == 2 and 2 or 0, aux.index(filter.blizzard.subclass, 2) or 0))) do tinsert(suggestions, _G[invtype]) end end @@ -427,35 +425,35 @@ function prettified_filter_string(filter) if component[1] == 'blizzard' then if component[2] == 'name' then if filter.blizzard.exact then - prettified.append(info.display_name(info.item_id(component[3])) or color.orange('[' .. component[3] .. ']')) + prettified.append(info.display_name(info.item_id(component[3])) or aux.color.orange('[' .. component[3] .. ']')) elseif component[3] ~= '' then - prettified.append(color.label.enabled(component[3])) + prettified.append(aux.color.label.enabled(component[3])) end elseif component[2] ~= 'exact' then - prettified.append(color.orange(component[3])) + prettified.append(aux.color.orange(component[3])) end elseif component[1] == 'operator' then - prettified.append(color.orange(component[2] .. (component[2] ~= 'not' and tonumber(component[3]) or ''))) + prettified.append(aux.color.orange(component[2] .. (component[2] ~= 'not' and tonumber(component[3]) or ''))) elseif component[1] == 'filter' then if i == 1 or component[2] ~= 'tooltip' then - prettified.append(color.orange(component[2])) + prettified.append(aux.color.orange(component[2])) end local parameter = component[3] if parameter then if component[2] == 'item' then - prettified.append(info.display_name(info.item_id(parameter)) or color.label.enabled('[' .. parameter .. ']')) + prettified.append(info.display_name(info.item_id(parameter)) or aux.color.label.enabled('[' .. parameter .. ']')) else if filters[component[2]].input_type == 'money' then - prettified.append(money.to_string(money.from_string(parameter), nil, true, color.label.enabled)) + prettified.append(money.to_string(money.from_string(parameter), nil, true, aux.color.label.enabled)) else - prettified.append(color.label.enabled(parameter)) + prettified.append(aux.color.label.enabled(parameter)) end end end end end if prettified.get() == '' then - return color.orange'<>' + return aux.color.orange'<>' else return prettified.get() end @@ -466,7 +464,7 @@ function M.quote(name) end function M.unquote(name) - return select(3, strfind(name, '^<(.*)>$')) or name + return aux.select(3, strfind(name, '^<(.*)>$')) or name end function blizzard_query(filter) @@ -490,7 +488,7 @@ function blizzard_query(filter) query.quality = item_info.quality else for key in T.temp-T.set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do - query[key] = index(filters[key], 2) + query[key] = aux.index(filters[key], 2) end end return query @@ -520,15 +518,15 @@ function validator(filter) if name == 'not' then tinsert(stack, not args[1]) elseif name == 'and' then - tinsert(stack, all(args)) + tinsert(stack, aux.all(args)) elseif name == 'or' then - tinsert(stack, any(args)) + tinsert(stack, aux.any(args)) end elseif type == 'filter' then tinsert(stack, not not validators[i](record)) end end - return all(stack) + return aux.all(stack) end end diff --git a/util/info.lua b/util/info.lua index b5a56af..cd29b46 100644 --- a/util/info.lua +++ b/util/info.lua @@ -1,8 +1,7 @@ module 'aux.util.info' -include 'aux' - local T = require 'T' +local aux = require 'aux' CreateFrame('GameTooltip', 'AuxTooltip', nil, 'GameTooltipTemplate') AuxTooltip:SetScript('OnTooltipAddMoney', function() @@ -125,8 +124,8 @@ function M.auction(index, query_type) 'link', link, 'itemstring', item_info.itemstring, 'item_key', item_id .. ':' .. suffix_id, - 'search_signature', join(T.temp-T.list(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(T.temp-T.list(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'), + 'search_signature', aux.join(T.temp-T.list(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', aux.join(T.temp-T.list(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'), 'name', name, 'texture', texture, @@ -170,7 +169,7 @@ function M.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(T.temp-T.list(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 '?')), ':') + auction_record.search_signature = aux.join(T.temp-T.list(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 M.set_tooltip(itemstring, owner, anchor) @@ -210,7 +209,7 @@ function M.set_shopping_tooltip(slot) end function M.tooltip_match(entry, tooltip) - return any(tooltip, function(line) + return aux.any(tooltip, function(line) local left_match = line.left_text and strupper(line.left_text) == strupper(entry) local right_match = line.right_text and strupper(line.right_text) == strupper(entry) return left_match or right_match @@ -254,7 +253,7 @@ function M.display_name(item_id, no_brackets, no_color) name = '[' .. name .. ']' end if not no_color then - name = select(4, GetItemQualityColor(item_info.quality)) .. name .. FONT_COLOR_CODE_CLOSE + name = aux.select(4, GetItemQualityColor(item_info.quality)) .. name .. FONT_COLOR_CODE_CLOSE end return name end diff --git a/util/money.lua b/util/money.lua index 8c15b19..734c4af 100644 --- a/util/money.lua +++ b/util/money.lua @@ -1,8 +1,7 @@ module 'aux.util.money' -include 'aux' - local T = require 'T' +local aux = require 'aux' M.GOLD_TEXT = '|cffffd70ag|r' M.SILVER_TEXT = '|cffc7c7cfs|r' @@ -35,7 +34,7 @@ function M.to_string2(money, exact, color) local NONE = '|cffa0a0a0' .. TEXT_NONE .. FONT_COLOR_CODE_CLOSE if not exact and money >= COPPER_PER_GOLD then - money = round(money / COPPER_PER_SILVER) * COPPER_PER_SILVER + money = aux.round(money / COPPER_PER_SILVER) * COPPER_PER_SILVER end local g, s, c = to_gsc(money) @@ -83,7 +82,7 @@ function M.to_string(money, pad, trim, color, no_color) if copper > 0 or gold == 0 and silver == 0 then tinsert(parts, format_number(copper, pad, color) .. copper_text) end - text = join(parts, ' ') + text = aux.join(parts, ' ') else if gold > 0 then text = format_number(gold, false, color) .. gold_text .. ' ' .. format_number(silver, pad, color) .. silver_text .. ' ' .. format_number(copper, pad, color) .. copper_text @@ -109,9 +108,9 @@ function M.from_string(value) value = gsub(gsub(strlower(value), '|c%x%x%x%x%x%x%x%x', ''), FONT_COLOR_CODE_CLOSE, '') - local gold = tonumber(select(3, strfind(value, '(%d*%.?%d+)g'))) - local silver = tonumber(select(3, strfind(value, '(%d*%.?%d+)s'))) - local copper = tonumber(select(3, strfind(value, '(%d*%.?%d+)c'))) + local gold = tonumber(aux.select(3, strfind(value, '(%d*%.?%d+)g'))) + local silver = tonumber(aux.select(3, strfind(value, '(%d*%.?%d+)s'))) + local copper = tonumber(aux.select(3, strfind(value, '(%d*%.?%d+)c'))) if not gold and not silver and not copper then return end value = gsub(value, '%d*%.?%d+g', '', 1) diff --git a/util/persistence.lua b/util/persistence.lua index 14d639e..8481547 100644 --- a/util/persistence.lua +++ b/util/persistence.lua @@ -1,8 +1,7 @@ module 'aux.util.persistence' -include 'aux' - local T = require 'T' +local aux = require 'aux' function M.read(schema, str) if schema == 'string' then @@ -40,7 +39,7 @@ function read_list(schema, str) if str == '' then return T.acquire() end local separator = schema[2] local element_type = schema[3] - return map(split(str, separator), function(part) + return aux.map(aux.split(str, separator), function(part) return read(element_type, part) end) end @@ -48,16 +47,16 @@ end function write_list(schema, list) local separator = schema[2] local element_type = schema[3] - local parts = map(T.temp-copy(list), function(element) + local parts = aux.map(T.temp-aux.copy(list), function(element) return write(element_type, element) end) - return join(parts, separator) + return aux.join(parts, separator) end function read_tuple(schema, str) local separator = schema[2] local tuple = T.acquire() - local parts = T.temp-split(str, separator) + local parts = T.temp-aux.split(str, separator) for i = 3, getn(schema) do local key, type = next(schema[i]) tuple[key] = read(type, parts[i - 2]) @@ -72,5 +71,5 @@ function write_tuple(schema, tuple) local key, type = next(schema[i]) tinsert(parts, write(type, tuple[key])) end - return join(parts, separator) + return aux.join(parts, separator) end \ No newline at end of file diff --git a/util/scan.lua b/util/scan.lua index a811f2e..68b3c8e 100644 --- a/util/scan.lua +++ b/util/scan.lua @@ -1,9 +1,7 @@ module 'aux.util.scan' -include 'aux' - local T = require 'T' - +local aux = require 'aux' local info = require 'aux.util.info' local filter_util = require 'aux.util.filter' local scan = require 'aux.core.scan' @@ -18,20 +16,20 @@ function M.find(auction_record, status_bar, on_abort, on_failure, on_success) local queries = T.list(T.acquire()) if auction_record.blizzard_query then - local blizzard_query1 = copy(auction_record.blizzard_query) + local blizzard_query1 = aux.copy(auction_record.blizzard_query) blizzard_query1.first_page = auction_record.page blizzard_query1.last_page = auction_record.page tinsert(queries, T.map('blizzard_query', blizzard_query1)) if auction_record.page > 0 then - local blizzard_query2 = copy(auction_record.blizzard_query) + local blizzard_query2 = aux.copy(auction_record.blizzard_query) blizzard_query2.first_page = auction_record.page - 1 blizzard_query2.last_page = auction_record.page - 1 tinsert(queries, T.map('blizzard_query', blizzard_query2)) end local item_query = item_query(auction_record.item_id, 0, 0) - if not eq(auction_record.blizzard_query, item_query.blizzard_query) then + if not aux.eq(auction_record.blizzard_query, item_query.blizzard_query) then tinsert(queries, item_query) end end diff --git a/util/sort.lua b/util/sort.lua index 35135ff..fd8871c 100644 --- a/util/sort.lua +++ b/util/sort.lua @@ -1,7 +1,5 @@ module 'aux.util.sort' -include 'aux' - local T = require 'T' M.EQ = 0