module refactoring
This commit is contained in:
+51
-47
@@ -1,10 +1,9 @@
|
||||
module 'aux'
|
||||
|
||||
include 'T'
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local cache = require 'aux.core.cache'
|
||||
local history = require 'aux.core.history'
|
||||
local stack = require 'aux.core.stack'
|
||||
local post = require 'aux.core.post'
|
||||
@@ -20,27 +19,30 @@ _G.aux = {
|
||||
account = {},
|
||||
}
|
||||
|
||||
M.print = vararg-function(arg)
|
||||
M.print = T.vararg-function(arg)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '<aux> ' .. join(map(arg, tostring), ' '))
|
||||
end
|
||||
|
||||
local bids_loaded
|
||||
function M.get.bids_loaded() return bids_loaded end
|
||||
function M.bids_loaded() return bids_loaded end
|
||||
|
||||
local current_owner_page
|
||||
function M.get.current_owner_page() return current_owner_page end
|
||||
function M.current_owner_page() return current_owner_page end
|
||||
|
||||
local event_frame = CreateFrame'Frame'
|
||||
for event in pairs(temp-S('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION_HOUSE_SHOW', 'AUCTION_HOUSE_CLOSED', 'AUCTION_BIDDER_LIST_UPDATE', 'AUCTION_OWNED_LIST_UPDATE')) do
|
||||
for event in pairs(T.temp-T.set('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION_HOUSE_SHOW', 'AUCTION_HOUSE_CLOSED', 'AUCTION_BIDDER_LIST_UPDATE', 'AUCTION_OWNED_LIST_UPDATE')) do
|
||||
event_frame:RegisterEvent(event)
|
||||
end
|
||||
|
||||
local set_handler = {}
|
||||
M.handle = setmetatable({}, {__metatable=false, __newindex=function(_, k, v) set_handler[k](v) end})
|
||||
|
||||
do
|
||||
local handlers, handlers2 = {}, {}
|
||||
function M.set.LOAD(f)
|
||||
function set_handler.LOAD(f)
|
||||
tinsert(handlers, f)
|
||||
end
|
||||
function M.set.LOAD2(f)
|
||||
function set_handler.LOAD2(f)
|
||||
tinsert(handlers2, f)
|
||||
end
|
||||
event_frame:SetScript('OnEvent', function()
|
||||
@@ -65,7 +67,7 @@ end
|
||||
|
||||
do
|
||||
local cache = {}
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
cache.account = aux.account
|
||||
do
|
||||
local key = format('%s|%s', GetCVar'realmName', UnitName'player')
|
||||
@@ -78,19 +80,19 @@ do
|
||||
cache.realm = aux.realm[key]
|
||||
end
|
||||
end
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
do
|
||||
local key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player')
|
||||
aux.faction[key] = aux.faction[key] or {}
|
||||
cache.faction = aux.faction[key]
|
||||
end
|
||||
end
|
||||
for scope in pairs(temp-S('character', 'faction', 'realm', 'account')) do
|
||||
for scope in pairs(T.temp-T.set('character', 'faction', 'realm', 'account')) do
|
||||
local scope = scope
|
||||
M[scope .. '_data'] = function(key, init)
|
||||
if not cache[scope] then error('Cache for ' .. scope .. ' data not ready.', 2) end
|
||||
cache[scope][key] = cache[scope][key] or {}
|
||||
for k, v in pairs(init or empty) do
|
||||
for k, v in pairs(init or T.empty) do
|
||||
if cache[scope][key][k] == nil then
|
||||
cache[scope][key][k] = v
|
||||
end
|
||||
@@ -102,48 +104,50 @@ end
|
||||
|
||||
tab_info = {}
|
||||
function M.TAB(name)
|
||||
local tab = O('name', name)
|
||||
local env = getfenv(2)
|
||||
function env.set.OPEN(f) tab.OPEN = f end
|
||||
function env.set.CLOSE(f) tab.CLOSE = f end
|
||||
function env.set.USE_ITEM(f) tab.USE_ITEM = f end
|
||||
function env.set.CLICK_LINK(f) tab.CLICK_LINK = f end
|
||||
local tab = T.map('name', name)
|
||||
local tab_event = {
|
||||
OPEN = function(f) tab.OPEN = f end,
|
||||
CLOSE = function(f) tab.CLOSE = f end,
|
||||
USE_ITEM = function(f) tab.USE_ITEM = f end,
|
||||
CLICK_LINK = function(f) tab.CLICK_LINK = f end,
|
||||
}
|
||||
tinsert(tab_info, tab)
|
||||
return setmetatable({}, {__metatable=false, __newindex=function(_, k, v) tab_event[k](v) end})
|
||||
end
|
||||
|
||||
do
|
||||
local index
|
||||
function get.active_tab() return tab_info[index] end
|
||||
function get_active_tab() return tab_info[index] end
|
||||
function on_tab_click(i)
|
||||
CloseDropDownMenus()
|
||||
do (index and active_tab.CLOSE or nop)() end
|
||||
do (index and get_active_tab().CLOSE or nop)() end
|
||||
index = i
|
||||
do (index and active_tab.OPEN or nop)() end
|
||||
do (index and get_active_tab().OPEN or nop)() end
|
||||
end
|
||||
end
|
||||
|
||||
SetItemRef = vararg-function(arg)
|
||||
if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
|
||||
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
|
||||
return orig.SetItemRef(unpack(arg))
|
||||
end
|
||||
local item_info = info.item(tonumber(select(3, strfind(arg[1], '^item:(%d+)'))))
|
||||
if item_info then
|
||||
return active_tab.CLICK_LINK(item_info)
|
||||
return get_active_tab().CLICK_LINK(item_info)
|
||||
end
|
||||
end
|
||||
|
||||
UseContainerItem = vararg-function(arg)
|
||||
if modified or not active_tab then
|
||||
UseContainerItem = T.vararg-function(arg)
|
||||
if modified() or not get_active_tab() then
|
||||
return orig.UseContainerItem(unpack(arg))
|
||||
end
|
||||
local item_info = info.container_item(arg[1], arg[2])
|
||||
if item_info and active_tab.USE_ITEM then
|
||||
active_tab.USE_ITEM(item_info)
|
||||
if item_info and get_active_tab().USE_ITEM then
|
||||
get_active_tab().USE_ITEM(item_info)
|
||||
end
|
||||
end
|
||||
|
||||
M.orig = setmetatable({[_G]=T}, {__index=function(self, key) return self[_G][key] end})
|
||||
M.hook = vararg-function(arg)
|
||||
M.orig = setmetatable({[_G]=T.acquire()}, {__index=function(self, key) return self[_G][key] end})
|
||||
M.hook = T.vararg-function(arg)
|
||||
local name, object, handler
|
||||
if getn(arg) == 3 then
|
||||
name, object, handler = unpack(arg)
|
||||
@@ -151,7 +155,7 @@ M.hook = vararg-function(arg)
|
||||
object, name, handler = _G, unpack(arg)
|
||||
end
|
||||
handler = handler or getfenv(3)[name]
|
||||
orig[object] = orig[object] or T
|
||||
orig[object] = orig[object] or T.acquire()
|
||||
assert(not orig[object][name], '"' .. name .. '" is already hooked into.')
|
||||
orig[object][name], object[name] = object[name], handler
|
||||
return hook
|
||||
@@ -159,7 +163,7 @@ end
|
||||
|
||||
do
|
||||
local locked
|
||||
function M.get.bid_in_progress() return locked end
|
||||
function M.bid_in_progress() return locked end
|
||||
function M.place_bid(type, index, amount, on_success)
|
||||
if locked then return end
|
||||
local money = GetMoney()
|
||||
@@ -184,7 +188,7 @@ end
|
||||
|
||||
do
|
||||
local locked
|
||||
function M.get.cancel_in_progress() return locked end
|
||||
function M.cancel_in_progress() return locked end
|
||||
function M.cancel_auction(index, on_success)
|
||||
if locked then return end
|
||||
locked = true
|
||||
@@ -204,14 +208,14 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
AuxFrame:SetScale(aux_scale)
|
||||
end
|
||||
|
||||
function AUCTION_HOUSE_SHOW()
|
||||
AuctionFrame:Hide()
|
||||
AuxFrame:Show()
|
||||
tab = 1
|
||||
set_tab(1)
|
||||
end
|
||||
|
||||
function AUCTION_HOUSE_CLOSED()
|
||||
@@ -220,7 +224,7 @@ function AUCTION_HOUSE_CLOSED()
|
||||
post.stop()
|
||||
stack.stop()
|
||||
scan.abort()
|
||||
tab = nil
|
||||
set_tab()
|
||||
AuxFrame:Hide()
|
||||
end
|
||||
|
||||
@@ -243,7 +247,7 @@ end
|
||||
function Blizzard_AuctionUI()
|
||||
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
|
||||
AuctionFrame:SetScript('OnHide', nil)
|
||||
hook('ShowUIPanel', vararg-function(arg)
|
||||
hook('ShowUIPanel', T.vararg-function(arg)
|
||||
if arg[1] == AuctionFrame then return AuctionFrame:Show() end
|
||||
return orig.ShowUIPanel(unpack(arg))
|
||||
end)
|
||||
@@ -260,17 +264,17 @@ do
|
||||
local function hook_quest_item(f)
|
||||
f:SetScript('OnMouseUp', function()
|
||||
if arg1 == 'RightButton' then
|
||||
if active_tab then
|
||||
tab = 1
|
||||
search_tab.filter = _G[this:GetName() .. 'Name']:GetText() .. '/exact'
|
||||
if get_active_tab() then
|
||||
set_tab(1)
|
||||
search_tab.set_filter(_G[this:GetName() .. 'Name']:GetText() .. '/exact')
|
||||
search_tab.execute(nil, false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
function Blizzard_CraftUI()
|
||||
hook('CraftFrame_SetSelection', vararg-function(arg)
|
||||
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
|
||||
hook('CraftFrame_SetSelection', T.vararg-function(arg)
|
||||
local ret = T.temp-T.list(orig.CraftFrame_SetSelection(unpack(arg)))
|
||||
local id = GetCraftSelectionIndex()
|
||||
local total_cost = 0
|
||||
for i = 1, GetCraftNumReagents(id) do
|
||||
@@ -281,7 +285,7 @@ do
|
||||
end
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
local count = select(3, GetCraftReagentInfo(id, i))
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
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
|
||||
total_cost = nil
|
||||
@@ -298,8 +302,8 @@ do
|
||||
end
|
||||
end
|
||||
function Blizzard_TradeSkillUI()
|
||||
hook('TradeSkillFrame_SetSelection', vararg-function(arg)
|
||||
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
||||
hook('TradeSkillFrame_SetSelection', T.vararg-function(arg)
|
||||
local ret = T.temp-T.list(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
||||
local id = GetTradeSkillSelectionIndex()
|
||||
local total_cost = 0
|
||||
for i = 1, GetTradeSkillNumReagents(id) do
|
||||
@@ -310,7 +314,7 @@ do
|
||||
end
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
local count = select(3, GetTradeSkillReagentInfo(id, i))
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
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
|
||||
total_cost = nil
|
||||
@@ -328,7 +332,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
AuctionFrameAuctions_OnEvent = vararg-function(arg)
|
||||
AuctionFrameAuctions_OnEvent = T.vararg-function(arg)
|
||||
if AuctionFrameAuctions:IsVisible() then
|
||||
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
|
||||
end
|
||||
|
||||
+2
-4
@@ -13,20 +13,18 @@ control.lua
|
||||
color.lua
|
||||
gui\core.lua
|
||||
frame.lua
|
||||
|
||||
util\persistence.lua
|
||||
util\sort.lua
|
||||
util\money.lua
|
||||
core\cache.lua
|
||||
util\info.lua
|
||||
util\filter.lua
|
||||
util\scan.lua
|
||||
util\completion.lua
|
||||
|
||||
core\cache.lua
|
||||
core\history.lua
|
||||
core\disenchant.lua
|
||||
core\slash.lua
|
||||
core\scan.lua
|
||||
util\scan.lua
|
||||
core\stack.lua
|
||||
core\post.lua
|
||||
core\tooltip.lua
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
module 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
function C(r, g, b, a)
|
||||
local mt = O('__metatable', false, '__newindex', nop, 'color', A(r, g, b, a))
|
||||
local mt = T.map('__metatable', false, '__newindex', nop, 'color', T.list(r, g, b, a))
|
||||
function mt:__call(text)
|
||||
local r, g, b, a = unpack(mt.color)
|
||||
if text then
|
||||
@@ -14,7 +16,7 @@ function C(r, g, b, a)
|
||||
local r, g, b, a = unpack(mt.color)
|
||||
return format('|c%02X%02X%02X%02X', a, r, g, b) .. text
|
||||
end
|
||||
return setmetatable(T, mt)
|
||||
return setmetatable(T.acquire(), mt)
|
||||
end
|
||||
|
||||
M.color = immutable-{
|
||||
|
||||
+17
-15
@@ -1,13 +1,15 @@
|
||||
module 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local event_frame = CreateFrame'Frame'
|
||||
|
||||
local listeners, threads = T, T
|
||||
local listeners, threads = T.acquire(), T.acquire()
|
||||
|
||||
local thread_id
|
||||
function M.get.thread_id() return thread_id end
|
||||
function M.thread_id() return thread_id end
|
||||
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
event_frame:SetScript('OnUpdate', UPDATE)
|
||||
event_frame:SetScript('OnEvent', EVENT)
|
||||
end
|
||||
@@ -50,7 +52,7 @@ end
|
||||
|
||||
do
|
||||
local id = 0
|
||||
function get.unique_id()
|
||||
function unique_id()
|
||||
id = id + 1
|
||||
return id
|
||||
end
|
||||
@@ -71,11 +73,11 @@ function M.kill_thread(thread_id)
|
||||
end
|
||||
|
||||
function M.event_listener(event, cb)
|
||||
local listener_id = unique_id
|
||||
listeners[listener_id] = O(
|
||||
local listener_id = unique_id()
|
||||
listeners[listener_id] = T.map(
|
||||
'event', event,
|
||||
'cb', cb,
|
||||
'kill', vararg-function(arg) if getn(arg) == 0 or arg[1] then kill_listener(listener_id) end end
|
||||
'kill', T.vararg-function(arg) if getn(arg) == 0 or arg[1] then kill_listener(listener_id) end end
|
||||
)
|
||||
event_frame:RegisterEvent(event)
|
||||
return listener_id
|
||||
@@ -88,27 +90,27 @@ end
|
||||
do
|
||||
local mt = {
|
||||
__call = function(self)
|
||||
temp(self)
|
||||
T.temp(self)
|
||||
return self.f(unpack(self))
|
||||
end,
|
||||
}
|
||||
|
||||
M.thread = vararg-function(arg)
|
||||
static(arg)
|
||||
M.thread = T.vararg-function(arg)
|
||||
T.static(arg)
|
||||
arg.f = tremove(arg, 1)
|
||||
local thread_id = unique_id
|
||||
threads[thread_id] = O('k', setmetatable(arg, mt))
|
||||
local thread_id = unique_id()
|
||||
threads[thread_id] = T.map('k', setmetatable(arg, mt))
|
||||
return thread_id
|
||||
end
|
||||
|
||||
M.wait = vararg-function(arg)
|
||||
static(arg)
|
||||
M.wait = T.vararg-function(arg)
|
||||
T.static(arg)
|
||||
arg.f = tremove(arg, 1)
|
||||
threads[thread_id].k = setmetatable(arg, mt)
|
||||
end
|
||||
end
|
||||
|
||||
M.when = vararg-function(arg)
|
||||
M.when = T.vararg-function(arg)
|
||||
local c = tremove(arg, 1)
|
||||
local k = tremove(arg, 1)
|
||||
if c() then
|
||||
|
||||
+18
-18
@@ -1,9 +1,9 @@
|
||||
module 'aux.core.cache'
|
||||
module 'aux.util.info'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local T = require 'T'
|
||||
|
||||
local persistence = require 'aux.util.persistence'
|
||||
|
||||
local MIN_ITEM_ID = 1
|
||||
@@ -18,7 +18,7 @@ _G.aux_auctionable_items = {}
|
||||
_G.aux_merchant_buy = {}
|
||||
_G.aux_merchant_sell = {}
|
||||
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
scan_wdb()
|
||||
|
||||
event_listener('MERCHANT_SHOW', on_merchant_show)
|
||||
@@ -29,22 +29,22 @@ function LOAD()
|
||||
CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', merchant_on_update)
|
||||
|
||||
event_listener('NEW_AUCTION_UPDATE', function()
|
||||
local data = info.auction_sell_item()
|
||||
local data = auction_sell_item()
|
||||
if data then
|
||||
local item_id = item_id(data.name)
|
||||
if item_id then
|
||||
aux_merchant_sell[item_id] = data.vendor_price / (info.max_item_charges(item_id) or data.count)
|
||||
aux_merchant_sell[item_id] = data.vendor_price / (max_item_charges(item_id) or data.count)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
do
|
||||
local characters = empty
|
||||
local characters = T.empty
|
||||
function M.is_player(name)
|
||||
return characters[name] and true or false
|
||||
end
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
characters = realm_data'characters'
|
||||
for k, v in pairs(characters) do
|
||||
if GetTime() > v + 60 * 60 * 24 * 30 then
|
||||
@@ -104,7 +104,7 @@ function M.item_info(item_id)
|
||||
local data_string = aux_items[item_id]
|
||||
if data_string then
|
||||
local cached_data = persistence.read(items_schema, data_string)
|
||||
return O(
|
||||
return T.map(
|
||||
'name', cached_data.name,
|
||||
'itemstring', 'item:' .. item_id .. ':0:0:0',
|
||||
'quality', cached_data.quality,
|
||||
@@ -128,7 +128,7 @@ function merchant_buy_scan()
|
||||
local _, _, price, count, stock = GetMerchantItemInfo(i)
|
||||
local link = GetMerchantItemLink(i)
|
||||
if link then
|
||||
local item_id = info.parse_link(link)
|
||||
local item_id = parse_link(link)
|
||||
local new_unit_price, new_limited = price / count, stock >= 0
|
||||
if aux_merchant_buy[item_id] then
|
||||
local buy_info = persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
|
||||
@@ -142,12 +142,12 @@ function merchant_buy_scan()
|
||||
unit_price = min(buy_info.unit_price, new_unit_price)
|
||||
end
|
||||
|
||||
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, temp-O(
|
||||
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T.temp-T.map(
|
||||
'unit_price', unit_price,
|
||||
'limited', buy_info.limited and new_limited
|
||||
))
|
||||
else
|
||||
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, temp-O(
|
||||
aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T.temp-T.map(
|
||||
'unit_price', new_unit_price,
|
||||
'limited', new_limited
|
||||
))
|
||||
@@ -161,9 +161,9 @@ function merchant_buy_scan()
|
||||
end
|
||||
|
||||
function merchant_sell_scan()
|
||||
for slot in info.inventory do
|
||||
temp(slot)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
for slot in inventory() do
|
||||
T.temp(slot)
|
||||
local item_info = T.temp-container_item(unpack(slot))
|
||||
if item_info then
|
||||
aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
|
||||
end
|
||||
@@ -179,7 +179,7 @@ function scan_wdb(item_id)
|
||||
local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
if name and not aux_item_ids[strlower(name)] then
|
||||
aux_item_ids[strlower(name)] = item_id
|
||||
aux_items[item_id] = persistence.write(items_schema, temp-O(
|
||||
aux_items[item_id] = persistence.write(items_schema, T.temp-T.map(
|
||||
'name', name,
|
||||
'quality', quality,
|
||||
'level', level,
|
||||
@@ -189,8 +189,8 @@ function scan_wdb(item_id)
|
||||
'max_stack', max_stack,
|
||||
'texture', texture
|
||||
))
|
||||
local tooltip = info.tooltip('link', itemstring)
|
||||
if info.auctionable(tooltip, quality) then
|
||||
local tooltip = tooltip('link', itemstring)
|
||||
if auctionable(tooltip, quality) then
|
||||
tinsert(aux_auctionable_items, strlower(name))
|
||||
end
|
||||
processed = processed + 1
|
||||
|
||||
+63
-62
@@ -1,13 +1,14 @@
|
||||
module 'aux.core.disenchant'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local history = require 'aux.core.history'
|
||||
|
||||
local UNCOMMON, RARE, EPIC = 2, 3, 4
|
||||
|
||||
local ARMOR = S(
|
||||
local ARMOR = T.set(
|
||||
'INVTYPE_HEAD',
|
||||
'INVTYPE_NECK',
|
||||
'INVTYPE_SHOULDER',
|
||||
@@ -25,7 +26,7 @@ local ARMOR = S(
|
||||
'INVTYPE_HOLDABLE'
|
||||
)
|
||||
|
||||
local WEAPON = S(
|
||||
local WEAPON = T.set(
|
||||
'INVTYPE_2HWEAPON',
|
||||
'INVTYPE_WEAPONMAINHAND',
|
||||
'INVTYPE_WEAPON',
|
||||
@@ -50,7 +51,7 @@ end
|
||||
|
||||
function M.distribution(slot, quality, level)
|
||||
if not ARMOR[slot] and not WEAPON[slot] or level == 0 then
|
||||
return T
|
||||
return T.acquire()
|
||||
end
|
||||
|
||||
local function p(probability_armor, probability_weapon)
|
||||
@@ -63,103 +64,103 @@ function M.distribution(slot, quality, level)
|
||||
|
||||
if quality == UNCOMMON then
|
||||
if level <= 10 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 10940, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.8, .2)),
|
||||
temp-O('item_id', 10938, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .8))
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 10940, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.8, .2)),
|
||||
T.temp-T.map('item_id', 10938, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .8))
|
||||
)
|
||||
elseif level <= 15 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 10940, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.75, .2)),
|
||||
temp-O('item_id', 10939, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 10940, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.75, .2)),
|
||||
T.temp-T.map('item_id', 10939, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
)
|
||||
elseif level <= 20 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 10940, 'min_quantity', 4, 'max_quantity', 6, 'probability', p(.75, .15)),
|
||||
temp-O('item_id', 10998, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.15, .75)),
|
||||
temp-O('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .10)
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 10940, 'min_quantity', 4, 'max_quantity', 6, 'probability', p(.75, .15)),
|
||||
T.temp-T.map('item_id', 10998, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.15, .75)),
|
||||
T.temp-T.map('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .10)
|
||||
)
|
||||
elseif level <= 25 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 11083, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)),
|
||||
temp-O('item_id', 11082, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 11083, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)),
|
||||
T.temp-T.map('item_id', 11082, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
)
|
||||
elseif level <= 30 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 11083, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)),
|
||||
temp-O('item_id', 11134, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 11083, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)),
|
||||
T.temp-T.map('item_id', 11134, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
)
|
||||
elseif level <= 35 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 11137, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)),
|
||||
temp-O('item_id', 11135, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 11137, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)),
|
||||
T.temp-T.map('item_id', 11135, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
)
|
||||
elseif level <= 40 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 11137, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)),
|
||||
temp-O('item_id', 11174, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 11137, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)),
|
||||
T.temp-T.map('item_id', 11174, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
)
|
||||
elseif level <= 45 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 11176, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)),
|
||||
temp-O('item_id', 11175, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 11176, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)),
|
||||
T.temp-T.map('item_id', 11175, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05)
|
||||
)
|
||||
elseif level <= 50 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 11176, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)),
|
||||
temp-O('item_id', 16202, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03))
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 11176, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)),
|
||||
T.temp-T.map('item_id', 16202, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03))
|
||||
)
|
||||
elseif level <= 55 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 16204, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .22)),
|
||||
temp-O('item_id', 16203, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03))
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 16204, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .22)),
|
||||
T.temp-T.map('item_id', 16203, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03))
|
||||
)
|
||||
elseif level <= 60 then
|
||||
return temp-A(
|
||||
temp-O('item_id', 16204, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)),
|
||||
temp-O('item_id', 16203, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.2, .75)),
|
||||
temp-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03))
|
||||
return T.temp-T.list(
|
||||
T.temp-T.map('item_id', 16204, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)),
|
||||
T.temp-T.map('item_id', 16203, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.2, .75)),
|
||||
T.temp-T.map('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03))
|
||||
)
|
||||
end
|
||||
elseif quality == RARE then
|
||||
if level <= 20 then
|
||||
return temp-A(temp-O('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 25 then
|
||||
return temp-A(temp-O('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 30 then
|
||||
return temp-A(temp-O('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 35 then
|
||||
return temp-A(temp-O('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 40 then
|
||||
return temp-A(temp-O('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 45 then
|
||||
return temp-A(temp-O('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 50 then
|
||||
return temp-A(temp-O('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 55 then
|
||||
return temp-A(temp-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), temp-O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), T.temp-T.map('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005))
|
||||
elseif level <= 60 then
|
||||
return temp-A(temp-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), temp-O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), T.temp-T.map('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005))
|
||||
end
|
||||
elseif quality == EPIC then
|
||||
if level <= 40 then
|
||||
return temp-A(temp-O('item_id', 11177, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 11177, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1))
|
||||
elseif level <= 45 then
|
||||
return temp-A(temp-O('item_id', 11178, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 11178, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1))
|
||||
elseif level <= 50 then
|
||||
return temp-A(temp-O('item_id', 14343, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 14343, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1))
|
||||
elseif level <= 55 then
|
||||
return temp-A(temp-O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1))
|
||||
elseif level <= 60 then
|
||||
return temp-A(temp-O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 2, 'probability', 1))
|
||||
return T.temp-T.list(T.temp-T.map('item_id', 20725, 'min_quantity', 1, 'max_quantity', 2, 'probability', 1))
|
||||
end
|
||||
end
|
||||
return T
|
||||
return T.acquire()
|
||||
end
|
||||
+14
-13
@@ -1,21 +1,22 @@
|
||||
module 'aux.core.history'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local persistence = require 'aux.util.persistence'
|
||||
|
||||
local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='number'}, {data_points={'list', ';', {'tuple', '@', {value='number'}, {time='number'}}}}}
|
||||
|
||||
local value_cache = {}
|
||||
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
data = faction_data'history'
|
||||
end
|
||||
|
||||
do
|
||||
local next_push = 0
|
||||
function get.next_push()
|
||||
function get_next_push()
|
||||
if time() > next_push then
|
||||
local date = date('*t')
|
||||
date.hour, date.min, date.sec = 24, 0, 0
|
||||
@@ -25,12 +26,12 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function get.new_record()
|
||||
return temp-O('next_push', next_push, 'data_points', T)
|
||||
function new_record()
|
||||
return T.temp-T.map('next_push', get_next_push(), 'data_points', T.acquire())
|
||||
end
|
||||
|
||||
function read_record(item_key)
|
||||
local record = data[item_key] and persistence.read(history_schema, data[item_key]) or new_record
|
||||
local record = data[item_key] and persistence.read(history_schema, data[item_key]) or new_record()
|
||||
if record.next_push <= time() then
|
||||
push_record(record)
|
||||
write_record(item_key, record)
|
||||
@@ -41,7 +42,7 @@ end
|
||||
function write_record(item_key, record)
|
||||
data[item_key] = persistence.write(history_schema, record)
|
||||
if value_cache[item_key] then
|
||||
release(value_cache[item_key])
|
||||
T.release(value_cache[item_key])
|
||||
value_cache[item_key] = nil
|
||||
end
|
||||
end
|
||||
@@ -64,11 +65,11 @@ function M.value(item_key)
|
||||
local item_record, value
|
||||
item_record = read_record(item_key)
|
||||
if getn(item_record.data_points) > 0 then
|
||||
local total_weight, weighted_values = 0, temp-T
|
||||
local total_weight, weighted_values = 0, T.temp-T.acquire()
|
||||
for _, data_point in pairs(item_record.data_points) do
|
||||
local weight = .99 ^ round((item_record.data_points[1].time - data_point.time) / (60 * 60 * 24))
|
||||
total_weight = total_weight + weight
|
||||
tinsert(weighted_values, O('value', data_point.value, 'weight', weight))
|
||||
tinsert(weighted_values, T.map('value', data_point.value, 'weight', weight))
|
||||
end
|
||||
for _, weighted_value in pairs(weighted_values) do
|
||||
weighted_value.weight = weighted_value.weight / total_weight
|
||||
@@ -77,7 +78,7 @@ function M.value(item_key)
|
||||
else
|
||||
value = item_record.daily_min_buyout
|
||||
end
|
||||
value_cache[item_key] = O('value', value, 'next_push', item_record.next_push)
|
||||
value_cache[item_key] = T.map('value', value, 'next_push', item_record.next_push)
|
||||
end
|
||||
return value_cache[item_key].value
|
||||
end
|
||||
@@ -99,11 +100,11 @@ end
|
||||
|
||||
function push_record(item_record)
|
||||
if item_record.daily_min_buyout then
|
||||
tinsert(item_record.data_points, 1, O('value', item_record.daily_min_buyout, 'time', item_record.next_push))
|
||||
tinsert(item_record.data_points, 1, T.map('value', item_record.daily_min_buyout, 'time', item_record.next_push))
|
||||
while getn(item_record.data_points) > 11 do
|
||||
release(item_record.data_points[getn(item_record.data_points)])
|
||||
T.release(item_record.data_points[getn(item_record.data_points)])
|
||||
tremove(item_record.data_points)
|
||||
end
|
||||
end
|
||||
item_record.next_push, item_record.daily_min_buyout = next_push, nil
|
||||
item_record.next_push, item_record.daily_min_buyout = get_next_push(), nil
|
||||
end
|
||||
@@ -1,6 +1,5 @@
|
||||
module 'aux.core.post'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
+50
-49
@@ -1,8 +1,9 @@
|
||||
module 'aux.core.scan'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local history = require 'aux.core.history'
|
||||
|
||||
@@ -26,7 +27,7 @@ do
|
||||
end
|
||||
|
||||
function M.abort(scan_id)
|
||||
local aborted = T
|
||||
local aborted = T.acquire()
|
||||
for type, state in pairs(scan_states) do
|
||||
if not scan_id or state.id == scan_id then
|
||||
kill_thread(state.id)
|
||||
@@ -40,26 +41,26 @@ do
|
||||
end
|
||||
|
||||
function M.stop()
|
||||
state.stopped = true
|
||||
get_state().stopped = true
|
||||
end
|
||||
|
||||
function complete()
|
||||
local on_complete = state.params.on_complete
|
||||
scan_states[state.params.type] = nil
|
||||
local on_complete = get_state().params.on_complete
|
||||
scan_states[get_state().params.type] = nil
|
||||
do (on_complete or nop)() end
|
||||
end
|
||||
|
||||
function get.state()
|
||||
function get_state()
|
||||
for _, state in pairs(scan_states) do
|
||||
if state.id == thread_id then
|
||||
if state.id == thread_id() then
|
||||
return state
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function get.query()
|
||||
return state.params.queries[state.query_index]
|
||||
function get_query()
|
||||
return get_state().params.queries[get_state().query_index]
|
||||
end
|
||||
|
||||
function total_pages(total_auctions)
|
||||
@@ -68,21 +69,21 @@ end
|
||||
|
||||
function last_page(total_auctions)
|
||||
local last_page = max(total_pages(total_auctions) - 1, 0)
|
||||
local last_page_limit = query.blizzard_query.last_page or last_page
|
||||
local last_page_limit = get_query().blizzard_query.last_page or last_page
|
||||
return min(last_page_limit, last_page)
|
||||
end
|
||||
|
||||
function scan()
|
||||
state.query_index = state.query_index and state.query_index + 1 or 1
|
||||
if query and not state.stopped then
|
||||
do (state.params.on_start_query or nop)(state.query_index) end
|
||||
if query.blizzard_query then
|
||||
if (query.blizzard_query.first_page or 0) <= (query.blizzard_query.last_page or huge) then
|
||||
state.page = query.blizzard_query.first_page or 0
|
||||
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
|
||||
if get_query().blizzard_query then
|
||||
if (get_query().blizzard_query.first_page or 0) <= (get_query().blizzard_query.last_page or huge) then
|
||||
get_state().page = get_query().blizzard_query.first_page or 0
|
||||
return submit_query()
|
||||
end
|
||||
else
|
||||
state.page = nil
|
||||
get_state().page = nil
|
||||
return scan_page()
|
||||
end
|
||||
end
|
||||
@@ -91,13 +92,13 @@ end
|
||||
|
||||
do
|
||||
local function submit()
|
||||
if state.params.type == 'bidder' then
|
||||
GetBidderAuctionItems(state.page)
|
||||
elseif state.params.type == 'owner' then
|
||||
GetOwnerAuctionItems(state.page)
|
||||
if get_state().params.type == 'bidder' then
|
||||
GetBidderAuctionItems(get_state().page)
|
||||
elseif get_state().params.type == 'owner' then
|
||||
GetOwnerAuctionItems(get_state().page)
|
||||
else
|
||||
state.last_list_query = GetTime()
|
||||
local blizzard_query = query.blizzard_query or T
|
||||
get_state().last_list_query = GetTime()
|
||||
local blizzard_query = get_query().blizzard_query or T.acquire()
|
||||
QueryAuctionItems(
|
||||
blizzard_query.name,
|
||||
blizzard_query.min_level,
|
||||
@@ -105,7 +106,7 @@ do
|
||||
blizzard_query.slot,
|
||||
blizzard_query.class,
|
||||
blizzard_query.subclass,
|
||||
state.page,
|
||||
get_state().page,
|
||||
blizzard_query.usable,
|
||||
blizzard_query.quality
|
||||
)
|
||||
@@ -113,8 +114,8 @@ do
|
||||
return wait_for_results()
|
||||
end
|
||||
function submit_query()
|
||||
if state.stopped then return end
|
||||
if state.params.type ~= 'list' then
|
||||
if get_state().stopped then return end
|
||||
if get_state().params.type ~= 'list' then
|
||||
return submit()
|
||||
else
|
||||
return when(CanSendAuctionQuery, submit)
|
||||
@@ -126,30 +127,30 @@ function scan_page(i)
|
||||
i = i or 1
|
||||
|
||||
if i > PAGE_SIZE then
|
||||
do (state.params.on_page_scanned or nop)() end
|
||||
if query.blizzard_query and state.page < last_page(state.total_auctions) then
|
||||
state.page = state.page + 1
|
||||
do (get_state().params.on_page_scanned or nop)() 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()
|
||||
else
|
||||
return scan()
|
||||
end
|
||||
end
|
||||
|
||||
local auction_info = info.auction(i, state.params.type)
|
||||
if auction_info and (auction_info.owner or state.params.ignore_owner or aux_ignore_owner) then
|
||||
local auction_info = info.auction(i, get_state().params.type)
|
||||
if auction_info and (auction_info.owner or get_state().params.ignore_owner or aux_ignore_owner) then
|
||||
auction_info.index = i
|
||||
auction_info.page = state.page
|
||||
auction_info.blizzard_query = query.blizzard_query
|
||||
auction_info.query_type = state.params.type
|
||||
auction_info.page = get_state().page
|
||||
auction_info.blizzard_query = get_query().blizzard_query
|
||||
auction_info.query_type = get_state().params.type
|
||||
|
||||
history.process_auction(auction_info)
|
||||
|
||||
if (state.params.auto_buy_validator or nop)(auction_info) then
|
||||
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)
|
||||
elseif not query.validator or query.validator(auction_info) then
|
||||
do (state.params.on_auction or nop)(auction_info) end
|
||||
elseif not get_query().validator or get_query().validator(auction_info) then
|
||||
do (get_state().params.on_auction or nop)(auction_info) end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -157,29 +158,29 @@ function scan_page(i)
|
||||
end
|
||||
|
||||
function wait_for_results()
|
||||
if state.params.type == 'bidder' then
|
||||
return when(function() return bids_loaded end, accept_results)
|
||||
elseif state.params.type == 'owner' then
|
||||
if get_state().params.type == 'bidder' then
|
||||
return when(function() return bids_loaded() end, accept_results)
|
||||
elseif get_state().params.type == 'owner' then
|
||||
return wait_for_owner_results()
|
||||
elseif state.params.type == 'list' then
|
||||
elseif get_state().params.type == 'list' then
|
||||
return wait_for_list_results()
|
||||
end
|
||||
end
|
||||
|
||||
function accept_results()
|
||||
_, state.total_auctions = GetNumAuctionItems(state.params.type)
|
||||
_, get_state().total_auctions = GetNumAuctionItems(get_state().params.type)
|
||||
do
|
||||
(state.params.on_page_loaded or nop)(
|
||||
state.page - (query.blizzard_query.first_page or 0) + 1,
|
||||
last_page(state.total_auctions) - (query.blizzard_query.first_page or 0) + 1,
|
||||
total_pages(state.total_auctions) - 1
|
||||
(get_state().params.on_page_loaded or nop)(
|
||||
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
|
||||
)
|
||||
end
|
||||
return scan_page()
|
||||
end
|
||||
|
||||
function wait_for_owner_results()
|
||||
if state.page == current_owner_page then
|
||||
if get_state().page == current_owner_page() then
|
||||
return accept_results()
|
||||
else
|
||||
local updated
|
||||
@@ -194,8 +195,8 @@ function wait_for_list_results()
|
||||
last_update = GetTime()
|
||||
updated = true
|
||||
end)
|
||||
local timeout = later(5, state.last_list_query)
|
||||
local ignore_owner = state.params.ignore_owner or aux_ignore_owner
|
||||
local timeout = later(5, get_state().last_list_query)
|
||||
local ignore_owner = get_state().params.ignore_owner or aux_ignore_owner
|
||||
return when(function()
|
||||
if not last_update and timeout() then
|
||||
return true
|
||||
|
||||
+3
-3
@@ -2,9 +2,9 @@ module 'aux.core.slash'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local cache = require 'aux.core.cache'
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
tooltip_settings = character_data'tooltip'
|
||||
end
|
||||
|
||||
@@ -53,7 +53,7 @@ function SlashCmdList.AUX(command)
|
||||
_G.aux_auctionable_items = {}
|
||||
print('Item cache cleared.')
|
||||
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
||||
cache.populate_wdb()
|
||||
info.populate_wdb()
|
||||
else
|
||||
print('Usage:')
|
||||
print('- scale [' .. color.blue(aux_scale) .. ']')
|
||||
|
||||
+10
-9
@@ -1,34 +1,35 @@
|
||||
module 'aux.core.stack'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
local state
|
||||
|
||||
function stack_size(slot)
|
||||
local container_item_info = temp-info.container_item(unpack(slot))
|
||||
local container_item_info = T.temp-info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.count or 0
|
||||
end
|
||||
|
||||
function charges(slot)
|
||||
local container_item_info = temp-info.container_item(unpack(slot))
|
||||
local container_item_info = T.temp-info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.charges
|
||||
end
|
||||
|
||||
function max_stack(slot)
|
||||
local container_item_info = temp-info.container_item(unpack(slot))
|
||||
local container_item_info = T.temp-info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.max_stack
|
||||
end
|
||||
|
||||
function locked(slot)
|
||||
local container_item_info = temp-info.container_item(unpack(slot))
|
||||
local container_item_info = T.temp-info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.locked
|
||||
end
|
||||
|
||||
function find_item_slot(partial)
|
||||
for slot in info.inventory do
|
||||
for slot in info.inventory() do
|
||||
if matching_item(slot, partial) and not eq(slot, state.target_slot) then
|
||||
return slot
|
||||
end
|
||||
@@ -36,12 +37,12 @@ function find_item_slot(partial)
|
||||
end
|
||||
|
||||
function matching_item(slot, partial)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
local item_info = T.temp-info.container_item(unpack(slot))
|
||||
return item_info and item_info.item_key == state.item_key and info.auctionable(item_info.tooltip, nil, true) and (not partial or item_info.count < item_info.max_stack)
|
||||
end
|
||||
|
||||
function find_empty_slot()
|
||||
for slot, type in info.inventory do
|
||||
for slot, type in info.inventory() do
|
||||
if type == 1 and not GetContainerItemInfo(unpack(slot)) then
|
||||
return slot
|
||||
end
|
||||
@@ -49,7 +50,7 @@ function find_empty_slot()
|
||||
end
|
||||
|
||||
function find_charge_item_slot()
|
||||
for slot in info.inventory do
|
||||
for slot in info.inventory() do
|
||||
if matching_item(slot) and charges(slot) == state.target_size then
|
||||
return slot
|
||||
end
|
||||
|
||||
+17
-17
@@ -1,11 +1,11 @@
|
||||
module 'aux.core.tooltip'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local cache = require 'aux.core.cache'
|
||||
local disenchant = require 'aux.core.disenchant'
|
||||
local history = require 'aux.core.history'
|
||||
local auction_listing = require 'aux.gui.auction_listing'
|
||||
@@ -14,23 +14,23 @@ local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE
|
||||
|
||||
local game_tooltip_hooks, game_tooltip_money = {}, 0
|
||||
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
settings = character_data('tooltip', {value=true})
|
||||
do
|
||||
local inside_hook = false
|
||||
for name, f in pairs(game_tooltip_hooks) do
|
||||
local name, f = name, f
|
||||
hook(name, GameTooltip, vararg-function(arg)
|
||||
hook(name, GameTooltip, T.vararg-function(arg)
|
||||
inside_hook = true
|
||||
game_tooltip_money = 0
|
||||
local tmp = A(orig[GameTooltip][name](unpack(arg)))
|
||||
local tmp = T.list(orig[GameTooltip][name](unpack(arg)))
|
||||
inside_hook = false
|
||||
f(unpack(arg))
|
||||
return ret(tmp)
|
||||
return T.unpack(tmp)
|
||||
end)
|
||||
end
|
||||
local orig = GameTooltip:GetScript'OnTooltipAddMoney'
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', vararg-function(arg)
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', T.vararg-function(arg)
|
||||
if inside_hook then
|
||||
game_tooltip_money = arg1
|
||||
else
|
||||
@@ -39,22 +39,22 @@ function LOAD()
|
||||
end)
|
||||
end
|
||||
local orig = SetItemRef
|
||||
setglobal('SetItemRef', vararg-function(arg)
|
||||
setglobal('SetItemRef', T.vararg-function(arg)
|
||||
local name, _, quality = GetItemInfo(arg[1])
|
||||
local tmp = A(orig(unpack(arg)))
|
||||
local tmp = T.list(orig(unpack(arg)))
|
||||
if not IsShiftKeyDown() and not IsControlKeyDown() and name then
|
||||
local color_code = select(4, GetItemQualityColor(quality))
|
||||
local link = color_code .. '|H' .. arg[1] .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE
|
||||
extend_tooltip(ItemRefTooltip, link, 1)
|
||||
end
|
||||
return ret(tmp)
|
||||
return T.unpack(tmp)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.extend_tooltip(tooltip, link, quantity)
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
quantity = IsShiftKeyDown() and quantity or 1
|
||||
local item_info = temp-info.item(item_id)
|
||||
local item_info = T.temp-info.item(item_id)
|
||||
if item_info then
|
||||
local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
|
||||
if getn(distribution) > 0 then
|
||||
@@ -72,18 +72,18 @@ function M.extend_tooltip(tooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
if settings.merchant_buy then
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
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())
|
||||
end
|
||||
end
|
||||
if settings.merchant_sell then
|
||||
local price = cache.merchant_info(item_id)
|
||||
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())
|
||||
end
|
||||
end
|
||||
local auctionable = not item_info or info.auctionable(temp-info.tooltip('link', item_info.itemstring), item_info.quality)
|
||||
local auctionable = not item_info or info.auctionable(T.temp-info.tooltip('link', item_info.itemstring), item_info.quality)
|
||||
local item_key = (item_id or 0) .. ':' .. (suffix_id or 0)
|
||||
local value = history.value(item_key)
|
||||
if auctionable then
|
||||
@@ -148,7 +148,7 @@ end
|
||||
|
||||
function game_tooltip_hooks:SetInboxItem(index)
|
||||
local name, _, quantity = GetInboxItem(index)
|
||||
local id = name and cache.item_id(name)
|
||||
local id = name and info.item_id(name)
|
||||
if id then
|
||||
local _, itemstring, quality = GetItemInfo(id)
|
||||
local hex = select(4, GetItemQualityColor(tonumber(quality)))
|
||||
@@ -206,8 +206,8 @@ end
|
||||
function game_tooltip_hooks:SetAuctionSellItem()
|
||||
local name, _, quantity = GetAuctionSellItemInfo()
|
||||
if name then
|
||||
for slot in info.inventory do
|
||||
temp(slot)
|
||||
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
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
|
||||
@@ -2,7 +2,7 @@ module 'aux'
|
||||
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
for _, v in ipairs(tab_info) do
|
||||
tabs:create_tab(v.name)
|
||||
end
|
||||
@@ -32,7 +32,7 @@ end
|
||||
do
|
||||
tabs = gui.tabs(AuxFrame, 'DOWN')
|
||||
tabs._on_select = on_tab_click
|
||||
function M.set.tab(id) tabs:select(id) end
|
||||
function M.set_tab(id) tabs:select(id) end
|
||||
end
|
||||
do
|
||||
local btn = gui.button(AuxFrame)
|
||||
|
||||
+17
-17
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui.auction_listing'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local sort_util = require 'aux.util.sort'
|
||||
local money = require 'aux.util.money'
|
||||
@@ -10,7 +11,6 @@ local history = require 'aux.core.history'
|
||||
local gui = require 'aux.gui'
|
||||
local search_tab = require 'aux.tabs.search'
|
||||
local tooltip = require 'aux.core.tooltip'
|
||||
local cache = require 'aux.core.cache'
|
||||
|
||||
local price_per_unit = false
|
||||
|
||||
@@ -140,7 +140,7 @@ M.search_columns = {
|
||||
width = .13,
|
||||
align = 'CENTER',
|
||||
fill = function(cell, record)
|
||||
cell.text:SetText(cache.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?'))
|
||||
cell.text:SetText(info.is_player(record.owner) and (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
|
||||
@@ -429,7 +429,7 @@ M.bids_columns = {
|
||||
width = .13,
|
||||
align = 'CENTER',
|
||||
fill = function(cell, record)
|
||||
cell.text:SetText(cache.is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '?'))
|
||||
cell.text:SetText(info.is_player(record.owner) and (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
|
||||
@@ -625,9 +625,9 @@ local methods = {
|
||||
DressUpItemLink(this.record.link)
|
||||
elseif IsShiftKeyDown() and ChatFrameEditBox:IsVisible() then
|
||||
ChatFrameEditBox:Insert(this.record.link)
|
||||
elseif not modified and button == 'RightButton' then -- TODO not when alt (how?)
|
||||
tab = 1
|
||||
search_tab.filter = strlower(info.item(this.record.item_id).name) .. '/exact'
|
||||
elseif not modified() and button == 'RightButton' then -- TODO not when alt (how?)
|
||||
set_tab(1)
|
||||
search_tab.set_filter(strlower(info.item(this.record.item_id).name) .. '/exact')
|
||||
search_tab.execute(nil, false)
|
||||
else
|
||||
local selection = this.rt:GetSelection()
|
||||
@@ -655,13 +655,13 @@ local methods = {
|
||||
for _, v in ipairs(self.rowInfo) do
|
||||
if type(v) == 'table' then
|
||||
for _, child in pairs(v.children) do
|
||||
release(child)
|
||||
T.release(child)
|
||||
end
|
||||
release(v.children)
|
||||
release(v)
|
||||
T.release(v.children)
|
||||
T.release(v)
|
||||
end
|
||||
end
|
||||
wipe(self.rowInfo)
|
||||
T.wipe(self.rowInfo)
|
||||
self.rowInfo.numDisplayRows = 0
|
||||
self.isSorted = nil
|
||||
self:SetSelectedRecord(nil, true)
|
||||
@@ -680,13 +680,13 @@ local methods = {
|
||||
self.rowInfo[getn(self.rowInfo)].children[getn(self.rowInfo[getn(self.rowInfo)].children)].count = self.rowInfo[getn(self.rowInfo)].children[getn(self.rowInfo[getn(self.rowInfo)].children)].count + 1
|
||||
elseif not single_item and prevRecord and record.item_key == prevRecord.item_key then
|
||||
-- it's the same base item as the previous row so insert a new auction
|
||||
tinsert(self.rowInfo[getn(self.rowInfo)].children, O('count', 1, 'record', record))
|
||||
tinsert(self.rowInfo[getn(self.rowInfo)].children, T.map('count', 1, 'record', record))
|
||||
if self.expanded[self.rowInfo[getn(self.rowInfo)].expandKey] then
|
||||
self.rowInfo.numDisplayRows = self.rowInfo.numDisplayRows + 1
|
||||
end
|
||||
else
|
||||
-- it's a different base item from the previous row
|
||||
tinsert(self.rowInfo, O('item_key', record.item_key, 'expandKey', record.item_key, 'children', A(O('count', 1, 'record', record))))
|
||||
tinsert(self.rowInfo, T.map('item_key', record.item_key, 'expandKey', record.item_key, 'children', T.list(T.map('count', 1, 'record', record))))
|
||||
self.rowInfo.numDisplayRows = self.rowInfo.numDisplayRows + 1
|
||||
end
|
||||
end
|
||||
@@ -695,7 +695,7 @@ local methods = {
|
||||
local totalAuctions, totalPlayerAuctions = 0, 0
|
||||
for _, childInfo in pairs(v.children) do
|
||||
totalAuctions = totalAuctions + childInfo.count
|
||||
if cache.is_player(childInfo.record.owner) then
|
||||
if info.is_player(childInfo.record.owner) then
|
||||
totalPlayerAuctions = totalPlayerAuctions + childInfo.count
|
||||
end
|
||||
end
|
||||
@@ -823,7 +823,7 @@ local methods = {
|
||||
end,
|
||||
|
||||
Reset = function(self)
|
||||
wipe(self.expanded)
|
||||
T.wipe(self.expanded)
|
||||
self:UpdateRowInfo()
|
||||
self:UpdateRows()
|
||||
self:SetSelectedRecord()
|
||||
@@ -876,7 +876,7 @@ local methods = {
|
||||
end
|
||||
end,
|
||||
|
||||
SetSort = vararg-function(arg)
|
||||
SetSort = T.vararg-function(arg)
|
||||
local self = tremove(arg, 1)
|
||||
for _, v in ipairs(arg) do
|
||||
for i, sort in pairs(self.sorts) do
|
||||
@@ -938,7 +938,7 @@ function M.new(parent, rows, columns)
|
||||
contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
rt.contentFrame = contentFrame
|
||||
|
||||
local scrollFrame = CreateFrame('ScrollFrame', gui.unique_name, rt, 'FauxScrollFrameTemplate')
|
||||
local scrollFrame = CreateFrame('ScrollFrame', gui.unique_name(), rt, 'FauxScrollFrameTemplate')
|
||||
scrollFrame:SetScript('OnVerticalScroll', function()
|
||||
FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end)
|
||||
end)
|
||||
|
||||
+17
-16
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
M.font = [[Fonts\ARIALN.TTF]]
|
||||
|
||||
M.font_size = immutable-{
|
||||
@@ -11,7 +12,7 @@ M.font_size = immutable-{
|
||||
large = 18,
|
||||
}
|
||||
|
||||
--function LOAD()
|
||||
--function handle.LOAD()
|
||||
-- do
|
||||
-- local blizzard_backdrop, aux_background, aux_border
|
||||
--
|
||||
@@ -25,8 +26,8 @@ M.font_size = immutable-{
|
||||
-- aux_background:SetAllPoints(DropDownList1Backdrop)
|
||||
-- blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
|
||||
-- hook('ToggleDropDownMenu', function(...)
|
||||
-- temp(arg)
|
||||
-- local ret = temp-A(orig.ToggleDropDownMenu(unpack(arg)))
|
||||
-- T.temp(arg)
|
||||
-- local ret = T.temp-T.list(orig.ToggleDropDownMenu(unpack(arg)))
|
||||
-- local dropdown = _G[arg[4] or ''] or this:GetParent()
|
||||
-- if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then
|
||||
-- set_aux_dropdown_style(dropdown)
|
||||
@@ -37,7 +38,7 @@ M.font_size = immutable-{
|
||||
-- end)
|
||||
--
|
||||
-- function set_aux_dropdown_style(dropdown)
|
||||
-- DropDownList1Backdrop:SetBackdrop(empty)
|
||||
-- DropDownList1Backdrop:SetBackdrop(T.empty)
|
||||
-- aux_border:Show()
|
||||
-- aux_background:Show()
|
||||
-- DropDownList1:SetWidth(dropdown:GetWidth() * .9)
|
||||
@@ -88,19 +89,19 @@ M.font_size = immutable-{
|
||||
|
||||
do
|
||||
local id = 1
|
||||
function M.get.unique_name()
|
||||
function M.unique_name()
|
||||
id = id + 1
|
||||
return 'AuxFrame' .. id
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local menu = CreateFrame('Frame', unique_name, UIParent, 'UIDropDownMenuTemplate')
|
||||
M.menu = vararg-function(arg)
|
||||
local menu = CreateFrame('Frame', unique_name(), UIParent, 'UIDropDownMenuTemplate')
|
||||
M.menu = T.vararg-function(arg)
|
||||
HideDropDownMenu(1)
|
||||
UIDropDownMenu_Initialize(menu, function()
|
||||
for i = 1, getn(arg), 2 do
|
||||
UIDropDownMenu_AddButton(O('text', arg[i], 'notCheckable', true, 'func', arg[i + 1]))
|
||||
UIDropDownMenu_AddButton(T.map('text', arg[i], 'notCheckable', true, 'func', arg[i + 1]))
|
||||
end
|
||||
end, 'MENU')
|
||||
ToggleDropDownMenu(1, nil, menu, 'cursor')
|
||||
@@ -190,11 +191,11 @@ function M.button(parent, text_height)
|
||||
end
|
||||
|
||||
do
|
||||
local mt = {__index=T}
|
||||
local mt = {__index=T.acquire()}
|
||||
function mt.__index:create_tab(text)
|
||||
local id = getn(self._tabs) + 1
|
||||
|
||||
local tab = CreateFrame('Button', unique_name, self._frame)
|
||||
local tab = CreateFrame('Button', unique_name(), self._frame)
|
||||
tab.id = id
|
||||
tab.group = self
|
||||
tab:SetHeight(24)
|
||||
@@ -275,7 +276,7 @@ do
|
||||
local self = {
|
||||
_frame = parent,
|
||||
_orientation = orientation,
|
||||
_tabs = T,
|
||||
_tabs = T.acquire(),
|
||||
}
|
||||
return setmetatable(self, mt)
|
||||
end
|
||||
@@ -320,7 +321,7 @@ function M.editbox(parent)
|
||||
end)
|
||||
editbox:SetScript('OnChar', function() (this.char or nop)() end)
|
||||
do
|
||||
local last_click = O('t', 0)
|
||||
local last_click = T.map('t', 0)
|
||||
editbox:SetScript('OnMouseDown', function()
|
||||
if arg1 == 'RightButton' then
|
||||
this:SetText('')
|
||||
@@ -333,7 +334,7 @@ function M.editbox(parent)
|
||||
if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then
|
||||
thread(function() editbox:HighlightText() end)
|
||||
end
|
||||
wipe(last_click)
|
||||
T.wipe(last_click)
|
||||
last_click.t = GetTime()
|
||||
last_click.x = x
|
||||
last_click.y = y
|
||||
@@ -419,7 +420,7 @@ end
|
||||
function M.item(parent)
|
||||
local item = CreateFrame('Frame', nil, parent)
|
||||
set_size(item, 260, 40)
|
||||
local btn = CreateFrame('CheckButton', unique_name, item, 'ActionButtonTemplate')
|
||||
local btn = CreateFrame('CheckButton', unique_name(), item, 'ActionButtonTemplate')
|
||||
item.button = btn
|
||||
btn:SetPoint('LEFT', 2, .5)
|
||||
btn:SetHighlightTexture(nil)
|
||||
@@ -469,7 +470,7 @@ function M.vertical_line(parent, x_offset, top_offset, bottom_offset, inverted_c
|
||||
end
|
||||
|
||||
function M.dropdown(parent)
|
||||
local dropdown = CreateFrame('Frame', unique_name, parent, 'UIDropDownMenuTemplate')
|
||||
local dropdown = CreateFrame('Frame', unique_name(), parent, 'UIDropDownMenuTemplate')
|
||||
set_content_style(dropdown, 0, 0, 4, 4)
|
||||
|
||||
_G[dropdown:GetName() .. 'Left']:Hide()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui.item_listing'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
@@ -10,7 +11,7 @@ local ROW_HEIGHT = 39
|
||||
|
||||
function M:render()
|
||||
|
||||
if getn(self.item_records or empty) > getn(self.rows) then
|
||||
if getn(self.item_records or T.empty) > getn(self.rows) then
|
||||
self.content_frame:SetPoint('BOTTOMRIGHT', -15, 0)
|
||||
else
|
||||
self.content_frame:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
@@ -51,7 +52,7 @@ function M.new(parent, on_click, selected)
|
||||
local content_frame = CreateFrame('Frame', nil, parent)
|
||||
content_frame:SetAllPoints()
|
||||
|
||||
local scroll_frame = CreateFrame('ScrollFrame', gui.unique_name, parent, 'FauxScrollFrameTemplate')
|
||||
local scroll_frame = CreateFrame('ScrollFrame', gui.unique_name(), parent, 'FauxScrollFrameTemplate')
|
||||
scroll_frame:SetScript('OnVerticalScroll', function()
|
||||
FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() render(this.item_listing) end)
|
||||
end)
|
||||
@@ -71,7 +72,7 @@ function M.new(parent, on_click, selected)
|
||||
_G[scroll_bar:GetName() .. 'ScrollUpButton']:Hide()
|
||||
_G[scroll_bar:GetName() .. 'ScrollDownButton']:Hide()
|
||||
|
||||
local rows = T
|
||||
local rows = T.acquire()
|
||||
local row_index = 1
|
||||
local max_height = content_frame:GetHeight()
|
||||
local total_height = 0
|
||||
|
||||
+12
-11
@@ -1,8 +1,9 @@
|
||||
module 'aux.gui.listing'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
local ROW_HEIGHT = 15
|
||||
@@ -64,7 +65,7 @@ local methods = {
|
||||
self.headHeight = 0
|
||||
end
|
||||
|
||||
if getn(self.rowData or empty) > self.numRows then
|
||||
if getn(self.rowData or T.empty) > self.numRows then
|
||||
self.contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
|
||||
else
|
||||
self.contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
@@ -150,10 +151,10 @@ local methods = {
|
||||
end,
|
||||
|
||||
SetData = function(self, rowData)
|
||||
for _, row in pairs(self.rowData or empty) do
|
||||
for _, col in pairs(row.cols) do release(col) end
|
||||
release(row.cols)
|
||||
release(row)
|
||||
for _, row in pairs(self.rowData or T.empty) do
|
||||
for _, col in pairs(row.cols) do T.release(col) end
|
||||
T.release(row.cols)
|
||||
T.release(row)
|
||||
end
|
||||
self.rowData = rowData
|
||||
self.updateSort = true
|
||||
@@ -235,7 +236,7 @@ local methods = {
|
||||
row.highlight = highlight
|
||||
row.st = self
|
||||
|
||||
row.cols = T
|
||||
row.cols = T.acquire()
|
||||
self.rows[rowNum] = row
|
||||
for _ = 1, getn(self.colInfo) do
|
||||
self:AddCell(rowNum)
|
||||
@@ -258,7 +259,7 @@ local methods = {
|
||||
}
|
||||
|
||||
function M.new(parent)
|
||||
local st = CreateFrame('Frame', gui.unique_name, parent)
|
||||
local st = CreateFrame('Frame', gui.unique_name(), parent)
|
||||
st:SetAllPoints()
|
||||
|
||||
st.numRows = max(floor((parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / ROW_HEIGHT), 0)
|
||||
@@ -292,9 +293,9 @@ function M.new(parent)
|
||||
st[name] = func
|
||||
end
|
||||
|
||||
st.headCols = T
|
||||
st.rows = T
|
||||
st.handlers = T
|
||||
st.headCols = T.acquire()
|
||||
st.rows = T.acquire()
|
||||
st.handlers = T.acquire()
|
||||
st.colInfo = DEFAULT_COL_INFO
|
||||
|
||||
return st
|
||||
|
||||
+7
-10
@@ -1,5 +1,4 @@
|
||||
if defined 'T' then return end
|
||||
module 'T'
|
||||
if module 'T' then return end
|
||||
|
||||
local next, getn, setn, tremove, setmetatable = next, getn, table.setn, tremove, setmetatable
|
||||
|
||||
@@ -56,17 +55,15 @@ do
|
||||
M.static = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f})
|
||||
end
|
||||
|
||||
M.get.T = acquire
|
||||
|
||||
do
|
||||
local function ret(t)
|
||||
local function unpack(t)
|
||||
if getn(t) > 0 then
|
||||
return tremove(t, 1), ret(t)
|
||||
return tremove(t, 1), unpack(t)
|
||||
else
|
||||
release(t)
|
||||
end
|
||||
end
|
||||
M.ret = ret
|
||||
M.unpack = unpack
|
||||
end
|
||||
|
||||
M.empty = setmetatable({}, {__metatable=false, __newindex=nop})
|
||||
@@ -118,18 +115,18 @@ do
|
||||
})
|
||||
end
|
||||
|
||||
M.A = vararg(function(arg)
|
||||
M.list = vararg(function(arg)
|
||||
auto_release[arg] = nil
|
||||
return arg
|
||||
end)
|
||||
M.S = vararg(function(arg)
|
||||
M.set = vararg(function(arg)
|
||||
local t = acquire()
|
||||
for _, v in pairs(arg) do
|
||||
t[v] = true
|
||||
end
|
||||
return t
|
||||
end)
|
||||
M.O = vararg(function(arg)
|
||||
M.map = vararg(function(arg)
|
||||
local t = acquire()
|
||||
for i = 1, getn(arg), 2 do
|
||||
t[arg[i]] = arg[i + 1]
|
||||
|
||||
+26
-12
@@ -1,26 +1,40 @@
|
||||
if module then return end
|
||||
local _G, setfenv, setmetatable = getfenv(0), setfenv, setmetatable
|
||||
local loaded, defined = {}, {}
|
||||
local loaded = {}
|
||||
|
||||
local function nop() end
|
||||
|
||||
local function create_module(name)
|
||||
local private, public = setmetatable({}, {__index=_G}), {}
|
||||
local modifier = setmetatable({}, {
|
||||
local environment, public_fields = setmetatable({}, {__index=_G}), {}
|
||||
local public_modifier = setmetatable({}, {
|
||||
__metatable=false,
|
||||
__newindex=function(_, k, v) private[k], public[k] = v, v end
|
||||
__newindex=function(_, k, v)
|
||||
environment[k], public_fields[k] = v, v
|
||||
end,
|
||||
})
|
||||
private._G, private.nop, private._M, private.M = _G, nop, private, modifier
|
||||
private.include = function(name)
|
||||
environment._G, environment.nop, environment._M, environment.M = _G, nop, environment, public_modifier
|
||||
environment.include = function(name)
|
||||
local P = loaded[name] or error('No such module.', 2)
|
||||
for k, v in P.public do private[k] = v end
|
||||
for k, v in P.public_fields do
|
||||
environment[k] = v
|
||||
end
|
||||
end
|
||||
local interface = setmetatable({}, {__metatable=false, __index=public, __newindex=nop})
|
||||
local P = {private=private, public=public, interface=interface}
|
||||
local interface = setmetatable({}, {__metatable=false, __index=public_fields, __newindex=nop})
|
||||
local P = {environment=environment, public_fields=public_fields, interface=interface}
|
||||
loaded[name] = P
|
||||
return P
|
||||
end
|
||||
|
||||
function module(name) local P = loaded[name] or create_module(name); defined[name] = true; setfenv(2, P.private) end
|
||||
function require(name) local P = loaded[name] or create_module(name); return P.interface end
|
||||
function _G.defined(name) return defined[name] end
|
||||
function module(name)
|
||||
local defined = loaded[name] and true or false
|
||||
if not defined then
|
||||
create_module(name)
|
||||
end
|
||||
setfenv(2, loaded[name].environment)
|
||||
return defined
|
||||
end
|
||||
|
||||
function require(name)
|
||||
local P = loaded[name]
|
||||
return P and P.interface
|
||||
end
|
||||
+10
-9
@@ -1,21 +1,22 @@
|
||||
module 'aux.tabs.auctions'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local scan_util = require 'aux.util.scan'
|
||||
local scan = require 'aux.core.scan'
|
||||
|
||||
TAB 'Auctions'
|
||||
local tab = TAB 'Auctions'
|
||||
|
||||
auction_records = T
|
||||
auction_records = T.acquire()
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
scan_auctions()
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
function tab.CLOSE()
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
@@ -28,11 +29,11 @@ function M.scan_auctions()
|
||||
status_bar:update_status(0, 0)
|
||||
status_bar:set_text('Scanning auctions...')
|
||||
|
||||
wipe(auction_records)
|
||||
T.wipe(auction_records)
|
||||
update_listing()
|
||||
scan.start{
|
||||
type = 'owner',
|
||||
queries = {{blizzard_query = T}},
|
||||
queries = {{blizzard_query = T.acquire()}},
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status(page / total_pages, 0)
|
||||
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
@@ -54,7 +55,7 @@ end
|
||||
|
||||
do
|
||||
local scan_id = 0
|
||||
local IDLE, SEARCHING, FOUND = T, T, T
|
||||
local IDLE, SEARCHING, FOUND = T.acquire(), T.acquire(), T.acquire()
|
||||
local state = IDLE
|
||||
local found_index
|
||||
|
||||
@@ -96,7 +97,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 cancel_in_progress() then state = IDLE end
|
||||
end
|
||||
end
|
||||
end
|
||||
+8
-7
@@ -1,22 +1,23 @@
|
||||
module 'aux.tabs.bids'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local scan_util = require 'aux.util.scan'
|
||||
local scan = require 'aux.core.scan'
|
||||
|
||||
TAB 'Bids'
|
||||
local tab = TAB 'Bids'
|
||||
|
||||
auction_records = {}
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
scan_bids()
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
function tab.CLOSE()
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
@@ -29,11 +30,11 @@ function M.scan_bids()
|
||||
status_bar:update_status(0, 0)
|
||||
status_bar:set_text('Scanning auctions...')
|
||||
|
||||
wipe(auction_records)
|
||||
T.wipe(auction_records)
|
||||
update_listing()
|
||||
scan.start{
|
||||
type = 'bidder',
|
||||
queries = A(O('blizzard_query', T)),
|
||||
queries = T.list(T.map('blizzard_query', T.acquire())),
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status(page / total_pages, 0)
|
||||
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
@@ -120,7 +121,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 bid_in_progress() then state = IDLE end
|
||||
end
|
||||
end
|
||||
end
|
||||
+75
-82
@@ -1,8 +1,9 @@
|
||||
module 'aux.tabs.post'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local sort_util = require 'aux.util.sort'
|
||||
local persistence = require 'aux.util.persistence'
|
||||
@@ -11,28 +12,31 @@ local scan_util = require 'aux.util.scan'
|
||||
local post = require 'aux.core.post'
|
||||
local scan = require 'aux.core.scan'
|
||||
local history = require 'aux.core.history'
|
||||
local cache = require 'aux.core.cache'
|
||||
local item_listing = require 'aux.gui.item_listing'
|
||||
local al = require 'aux.gui.auction_listing'
|
||||
|
||||
TAB 'Post'
|
||||
local tab = 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'}}
|
||||
|
||||
local scan_id, inventory_records, bid_records, buyout_records = 0, {}, {}, {}
|
||||
|
||||
function get.default_settings()
|
||||
return O('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||
refresh = true
|
||||
|
||||
selected_item = nil
|
||||
|
||||
function get_default_settings()
|
||||
return T.map('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||
end
|
||||
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
data = faction_data'post'
|
||||
end
|
||||
|
||||
function read_settings(item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
return data[item_key] and persistence.read(settings_schema, data[item_key]) or default_settings
|
||||
return data[item_key] and persistence.read(settings_schema, data[item_key]) or get_default_settings()
|
||||
end
|
||||
function write_settings(settings, item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
@@ -41,16 +45,16 @@ end
|
||||
|
||||
do
|
||||
local bid_selections, buyout_selections = {}, {}
|
||||
function get.bid_selection()
|
||||
function get_bid_selection()
|
||||
return bid_selections[selected_item.key]
|
||||
end
|
||||
function set.bid_selection(record)
|
||||
function set_bid_selection(record)
|
||||
bid_selections[selected_item.key] = record
|
||||
end
|
||||
function get.buyout_selection()
|
||||
function get_buyout_selection()
|
||||
return buyout_selections[selected_item.key]
|
||||
end
|
||||
function set.buyout_selection(record)
|
||||
function set_buyout_selection(record)
|
||||
buyout_selections[selected_item.key] = record
|
||||
end
|
||||
end
|
||||
@@ -61,48 +65,36 @@ function refresh_button_click()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
do
|
||||
local item
|
||||
function get.selected_item() return item end
|
||||
function set.selected_item(v) item = v end
|
||||
end
|
||||
|
||||
do
|
||||
local c = 0
|
||||
function get.refresh() return c end
|
||||
function set.refresh(v) c = v end
|
||||
end
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
update_inventory_records()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
function tab.CLOSE()
|
||||
selected_item = nil
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
function USE_ITEM(item_info)
|
||||
function tab.USE_ITEM(item_info)
|
||||
select_item(item_info.item_key)
|
||||
end
|
||||
|
||||
function get.unit_start_price()
|
||||
function get_unit_start_price()
|
||||
return selected_item and read_settings().start_price or 0
|
||||
end
|
||||
|
||||
function set.unit_start_price(amount)
|
||||
function set_unit_start_price(amount)
|
||||
local settings = read_settings()
|
||||
settings.start_price = amount
|
||||
write_settings(settings)
|
||||
end
|
||||
|
||||
function get.unit_buyout_price()
|
||||
function get_unit_buyout_price()
|
||||
return selected_item and read_settings().buyout_price or 0
|
||||
end
|
||||
|
||||
function set.unit_buyout_price(amount)
|
||||
function set_unit_buyout_price(amount)
|
||||
local settings = read_settings()
|
||||
settings.buyout_price = amount
|
||||
write_settings(settings)
|
||||
@@ -118,34 +110,34 @@ function update_inventory_listing()
|
||||
end
|
||||
|
||||
function update_auction_listing(listing, records, reference)
|
||||
local rows = T
|
||||
local rows = T.acquire()
|
||||
if selected_item then
|
||||
local historical_value = history.value(selected_item.key)
|
||||
local stack_size = stack_size_slider:GetValue()
|
||||
for _, record in pairs(records[selected_item.key] or empty) do
|
||||
for _, record in pairs(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 = record.unit_price * (listing == 'bid' and record.stack_size / stack_size_slider:GetValue() or 1)
|
||||
tinsert(rows, O(
|
||||
'cols', A(
|
||||
O('value', record.own and color.green(record.count) or record.count),
|
||||
O('value', al.time_left(record.duration)),
|
||||
O('value', record.stack_size == stack_size and color.green(record.stack_size) or record.stack_size),
|
||||
O('value', money.to_string(price, true, nil, price_color)),
|
||||
O('value', historical_value and al.percentage_historical(round(price / historical_value * 100)) or '---')
|
||||
tinsert(rows, T.map(
|
||||
'cols', T.list(
|
||||
T.map('value', record.own and 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', money.to_string(price, true, nil, price_color)),
|
||||
T.map('value', historical_value and al.percentage_historical(round(price / historical_value * 100)) or '---')
|
||||
),
|
||||
'record', record
|
||||
))
|
||||
end
|
||||
if historical_value then
|
||||
tinsert(rows, O(
|
||||
'cols', A(
|
||||
O('value', '---'),
|
||||
O('value', '---'),
|
||||
O('value', '---'),
|
||||
O('value', money.to_string(historical_value, true, nil, color.green)),
|
||||
O('value', historical_value and al.percentage_historical(100) or '---')
|
||||
tinsert(rows, T.map(
|
||||
'cols', T.list(
|
||||
T.map('value', '---'),
|
||||
T.map('value', '---'),
|
||||
T.map('value', '---'),
|
||||
T.map('value', money.to_string(historical_value, true, nil, color.green)),
|
||||
T.map('value', historical_value and al.percentage_historical(100) or '---')
|
||||
),
|
||||
'record', O('historical_value', true, 'stack_size', stack_size, 'unit_price', historical_value, 'own', true)
|
||||
'record', T.map('historical_value', true, 'stack_size', stack_size, 'unit_price', historical_value, 'own', true)
|
||||
))
|
||||
end
|
||||
sort(rows, function(a, b)
|
||||
@@ -175,8 +167,8 @@ function update_auction_listing(listing, records, reference)
|
||||
end
|
||||
|
||||
function update_auction_listings()
|
||||
update_auction_listing('bid', bid_records, unit_start_price)
|
||||
update_auction_listing('buyout', buyout_records, unit_buyout_price)
|
||||
update_auction_listing('bid', bid_records, get_unit_start_price())
|
||||
update_auction_listing('buyout', buyout_records, get_unit_buyout_price())
|
||||
end
|
||||
|
||||
function M.select_item(item_key)
|
||||
@@ -191,23 +183,23 @@ end
|
||||
function price_update()
|
||||
if selected_item then
|
||||
local historical_value = history.value(selected_item.key)
|
||||
if bid_selection or buyout_selection then
|
||||
unit_start_price = undercut(bid_selection or buyout_selection, stack_size_slider:GetValue(), bid_selection)
|
||||
unit_start_price_input:SetText(money.to_string(unit_start_price, true, nil, nil, true))
|
||||
if get_bid_selection() or get_buyout_selection() then
|
||||
set_unit_start_price(undercut(get_bid_selection() or get_buyout_selection(), stack_size_slider:GetValue(), get_bid_selection()))
|
||||
unit_start_price_input:SetText(money.to_string(get_unit_start_price(), true, nil, nil, true))
|
||||
end
|
||||
if buyout_selection then
|
||||
unit_buyout_price = undercut(buyout_selection, stack_size_slider:GetValue())
|
||||
unit_buyout_price_input:SetText(money.to_string(unit_buyout_price, true, nil, nil, true))
|
||||
if get_buyout_selection() then
|
||||
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 al.percentage_historical(round(unit_start_price / historical_value * 100)) or '---')
|
||||
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_buyout_price / historical_value * 100)) or '---')
|
||||
start_price_percentage:SetText(historical_value and al.percentage_historical(round(get_unit_start_price() / historical_value * 100)) or '---')
|
||||
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(get_unit_buyout_price() / historical_value * 100)) or '---')
|
||||
end
|
||||
end
|
||||
|
||||
function post_auctions()
|
||||
if selected_item then
|
||||
local unit_start_price = unit_start_price
|
||||
local unit_buyout_price = unit_buyout_price
|
||||
local unit_start_price = get_unit_start_price()
|
||||
local unit_buyout_price = get_unit_buyout_price()
|
||||
local stack_size = stack_size_slider:GetValue()
|
||||
local stack_count
|
||||
stack_count = stack_count_slider:GetValue()
|
||||
@@ -258,11 +250,11 @@ function validate_parameters()
|
||||
post_button:Disable()
|
||||
return
|
||||
end
|
||||
if unit_buyout_price > 0 and unit_start_price > unit_buyout_price then
|
||||
if get_unit_buyout_price() > 0 and get_unit_start_price() > get_unit_buyout_price() then
|
||||
post_button:Disable()
|
||||
return
|
||||
end
|
||||
if unit_start_price == 0 then
|
||||
if get_unit_start_price() == 0 then
|
||||
post_button:Disable()
|
||||
return
|
||||
end
|
||||
@@ -345,15 +337,15 @@ function quantity_update(maximize_count)
|
||||
end
|
||||
|
||||
function unit_vendor_price(item_key)
|
||||
for slot in info.inventory do
|
||||
temp(slot)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
for slot in info.inventory() do
|
||||
T.temp(slot)
|
||||
local item_info = T.temp-info.container_item(unpack(slot))
|
||||
if item_info and item_info.item_key == item_key then
|
||||
if info.auctionable(item_info.tooltip, nil, true) and not item_info.lootable then
|
||||
ClearCursor()
|
||||
PickupContainerItem(unpack(slot))
|
||||
ClickAuctionSellItemButton()
|
||||
local auction_sell_item = temp-info.auction_sell_item()
|
||||
local auction_sell_item = T.temp-info.auction_sell_item()
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
@@ -411,20 +403,20 @@ function update_item(item)
|
||||
end
|
||||
|
||||
function update_inventory_records()
|
||||
local auctionable_map = temp-T
|
||||
for slot in info.inventory do
|
||||
temp(slot)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
local auctionable_map = T.temp-T.acquire()
|
||||
for slot in info.inventory() do
|
||||
T.temp(slot)
|
||||
local item_info = T.temp-info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
local charge_class = item_info.charges or 0
|
||||
if info.auctionable(item_info.tooltip, nil, true) and not item_info.lootable then
|
||||
if not auctionable_map[item_info.item_key] then
|
||||
local availability = T
|
||||
local availability = T.acquire()
|
||||
for i = 0, 10 do
|
||||
availability[i] = 0
|
||||
end
|
||||
availability[charge_class] = item_info.count
|
||||
auctionable_map[item_info.item_key] = O(
|
||||
auctionable_map[item_info.item_key] = T.map(
|
||||
'item_id', item_info.item_id,
|
||||
'suffix_id', item_info.suffix_id,
|
||||
'key', item_info.item_key,
|
||||
@@ -445,7 +437,7 @@ function update_inventory_records()
|
||||
end
|
||||
end
|
||||
end
|
||||
release(inventory_records)
|
||||
T.release(inventory_records)
|
||||
inventory_records = values(auctionable_map)
|
||||
refresh = true
|
||||
end
|
||||
@@ -453,7 +445,8 @@ end
|
||||
function refresh_entries()
|
||||
if selected_item then
|
||||
local item_key = selected_item.key
|
||||
bid_selection, buyout_selection = nil, nil
|
||||
set_bid_selection()
|
||||
set_buyout_selection()
|
||||
bid_records[item_key], buyout_records[item_key] = nil, nil
|
||||
local query = scan_util.item_query(selected_item.item_id)
|
||||
status_bar:update_status(0, 0)
|
||||
@@ -462,7 +455,7 @@ function refresh_entries()
|
||||
scan_id = scan.start{
|
||||
type = 'list',
|
||||
ignore_owner = true,
|
||||
queries = A(query),
|
||||
queries = T.list(query),
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status(page / total_pages, 0) -- TODO
|
||||
status_bar:set_text(format('Scanning Page %d / %d', page, total_pages))
|
||||
@@ -485,8 +478,8 @@ function refresh_entries()
|
||||
status_bar:set_text('Scan aborted')
|
||||
end,
|
||||
on_complete = function()
|
||||
bid_records[item_key] = bid_records[item_key] or T
|
||||
buyout_records[item_key] = buyout_records[item_key] or T
|
||||
bid_records[item_key] = bid_records[item_key] or T.acquire()
|
||||
buyout_records[item_key] = buyout_records[item_key] or T.acquire()
|
||||
refresh = true
|
||||
status_bar:update_status(1, 1)
|
||||
status_bar:set_text('Scan complete')
|
||||
@@ -496,31 +489,31 @@ function refresh_entries()
|
||||
end
|
||||
|
||||
function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
|
||||
bid_records[key] = bid_records[key] or T
|
||||
bid_records[key] = bid_records[key] or T.acquire()
|
||||
do
|
||||
local entry
|
||||
for _, record in pairs(bid_records[key]) do
|
||||
if unit_blizzard_bid == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
|
||||
if unit_blizzard_bid == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and info.is_player(owner) == record.own then
|
||||
entry = record
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_blizzard_bid, 'duration', duration, 'own', cache.is_player(owner), 'count', 0)
|
||||
entry = T.map('stack_size', aux_quantity, 'unit_price', unit_blizzard_bid, 'duration', duration, 'own', info.is_player(owner), 'count', 0)
|
||||
tinsert(bid_records[key], entry)
|
||||
end
|
||||
entry.count = entry.count + 1
|
||||
end
|
||||
buyout_records[key] = buyout_records[key] or T
|
||||
buyout_records[key] = buyout_records[key] or T.acquire()
|
||||
if unit_buyout_price == 0 then return end
|
||||
do
|
||||
local entry
|
||||
for _, record in pairs(buyout_records[key]) do
|
||||
if unit_buyout_price == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
|
||||
if unit_buyout_price == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and info.is_player(owner) == record.own then
|
||||
entry = record
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_buyout_price, 'duration', duration, 'own', cache.is_player(owner), 'count', 0)
|
||||
entry = T.map('stack_size', aux_quantity, 'unit_price', unit_buyout_price, 'duration', duration, 'own', info.is_player(owner), 'count', 0)
|
||||
tinsert(buyout_records[key], entry)
|
||||
end
|
||||
entry.count = entry.count + 1
|
||||
|
||||
+17
-17
@@ -61,8 +61,8 @@ do
|
||||
if arg1 == 'LeftButton' then
|
||||
update_item(this.item_record)
|
||||
elseif arg1 == 'RightButton' then
|
||||
tab = 1
|
||||
search_tab.filter = strlower(info.item(this.item_record.item_id).name) .. '/exact'
|
||||
set_tab(1)
|
||||
search_tab.set_filter(strlower(info.item(this.item_record.item_id).name) .. '/exact')
|
||||
search_tab.execute(nil, false)
|
||||
end
|
||||
end,
|
||||
@@ -81,13 +81,13 @@ bid_listing:SetColInfo{
|
||||
{name='% Hist.\nValue', width=.21, align='CENTER'},
|
||||
}
|
||||
bid_listing:SetSelection(function(data)
|
||||
return data.record == bid_selection or data.record.historical_value and bid_selection and bid_selection.historical_value
|
||||
return data.record == get_bid_selection() or data.record.historical_value and get_bid_selection() and get_bid_selection().historical_value
|
||||
end)
|
||||
bid_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||
if row_data.record == bid_selection or row_data.record.historical_value and bid_selection and bid_selection.historical_value then
|
||||
bid_selection = nil
|
||||
if row_data.record == get_bid_selection() or row_data.record.historical_value and get_bid_selection() and get_bid_selection().historical_value then
|
||||
set_bid_selection()
|
||||
else
|
||||
bid_selection = row_data.record
|
||||
set_bid_selection(row_data.record)
|
||||
end
|
||||
refresh = true
|
||||
end)
|
||||
@@ -105,13 +105,13 @@ buyout_listing:SetColInfo{
|
||||
{name='% Hist.\nValue', width=.20, align='CENTER'},
|
||||
}
|
||||
buyout_listing:SetSelection(function(data)
|
||||
return data.record == buyout_selection or data.record.historical_value and buyout_selection and buyout_selection.historical_value
|
||||
return data.record == get_buyout_selection() or data.record.historical_value and get_buyout_selection() and get_buyout_selection().historical_value
|
||||
end)
|
||||
buyout_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||
if row_data.record == buyout_selection or row_data.record.historical_value and buyout_selection and buyout_selection.historical_value then
|
||||
buyout_selection = nil
|
||||
if row_data.record == get_buyout_selection() or row_data.record.historical_value and get_buyout_selection() and get_buyout_selection().historical_value then
|
||||
set_buyout_selection()
|
||||
else
|
||||
buyout_selection = row_data.record
|
||||
set_buyout_selection(row_data.record)
|
||||
end
|
||||
refresh = true
|
||||
end)
|
||||
@@ -248,12 +248,12 @@ do
|
||||
unit_buyout_price_input:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox.formatter = function() return money.to_string(unit_start_price, true) end
|
||||
editbox.char = function() bid_selection, buyout_selection = nil, nil; unit_start_price = money.from_string(this:GetText()) end
|
||||
editbox.formatter = function() return money.to_string(get_unit_start_price(), true) end
|
||||
editbox.char = function() set_bid_selection(); set_buyout_selection(); set_unit_start_price(money.from_string(this:GetText())) end
|
||||
editbox.change = function() refresh = true end
|
||||
editbox.enter = function() this:ClearFocus() end
|
||||
editbox.focus_loss = function()
|
||||
this:SetText(money.to_string(unit_start_price, true, nil, nil, true))
|
||||
this:SetText(money.to_string(get_unit_start_price(), true, nil, nil, true))
|
||||
end
|
||||
do
|
||||
local label = gui.label(editbox, gui.font_size.small)
|
||||
@@ -283,12 +283,12 @@ do
|
||||
stack_size_slider.editbox:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox.formatter = function() return money.to_string(unit_buyout_price, true) end
|
||||
editbox.char = function() buyout_selection = nil; unit_buyout_price = money.from_string(this:GetText()) end
|
||||
editbox.formatter = function() return money.to_string(get_unit_buyout_price(), true) end
|
||||
editbox.char = function() set_buyout_selection(); set_unit_buyout_price(money.from_string(this:GetText())) end
|
||||
editbox.change = function() refresh = true end
|
||||
editbox.enter = function() this:ClearFocus() end
|
||||
editbox.focus_loss = function()
|
||||
this:SetText(money.to_string(unit_buyout_price, true, nil, nil, true))
|
||||
this:SetText(money.to_string(get_unit_buyout_price(), true, nil, nil, true))
|
||||
end
|
||||
do
|
||||
local label = gui.label(editbox, gui.font_size.small)
|
||||
@@ -310,7 +310,7 @@ do
|
||||
deposit = label
|
||||
end
|
||||
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
if not aux_post_bid then
|
||||
frame.bid_listing:Hide()
|
||||
frame.buyout_listing:SetPoint('BOTTOMLEFT', frame.inventory, 'BOTTOMRIGHT', 2.5, 0)
|
||||
|
||||
+15
-14
@@ -1,11 +1,12 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
TAB 'Search'
|
||||
local tab = 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.',
|
||||
@@ -19,32 +20,32 @@ RESULTS = 1
|
||||
SAVED = 2
|
||||
FILTER = 3
|
||||
|
||||
function LOAD()
|
||||
subtab = SAVED
|
||||
function handle.LOAD()
|
||||
set_subtab(SAVED)
|
||||
end
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
update_search_listings()
|
||||
update_filter_display()
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
current_search.table:SetSelectedRecord()
|
||||
function tab.CLOSE()
|
||||
get_current_search().table:SetSelectedRecord()
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
function CLICK_LINK(item_info)
|
||||
filter = strlower(item_info.name) .. '/exact'
|
||||
function tab.CLICK_LINK(item_info)
|
||||
set_filter(strlower(item_info.name) .. '/exact')
|
||||
execute(nil, false)
|
||||
end
|
||||
|
||||
function USE_ITEM(item_info)
|
||||
filter = strlower(info.item(item_info.item_id).name) .. '/exact'
|
||||
function tab.USE_ITEM(item_info)
|
||||
set_filter(strlower(info.item(item_info.item_id).name) .. '/exact')
|
||||
execute(nil, false)
|
||||
end
|
||||
|
||||
function set.subtab(tab)
|
||||
function set_subtab(tab)
|
||||
CloseDropDownMenus()
|
||||
search_results_button:UnlockHighlight()
|
||||
saved_searches_button:UnlockHighlight()
|
||||
@@ -65,7 +66,7 @@ function set.subtab(tab)
|
||||
end
|
||||
end
|
||||
|
||||
function M.set.filter(filter_string)
|
||||
function M.set_filter(filter_string)
|
||||
search_box:SetFocus()
|
||||
search_box:SetText(filter_string)
|
||||
end
|
||||
@@ -78,7 +79,7 @@ function add_filter(filter_string)
|
||||
old_filter_string = old_filter_string .. ';'
|
||||
end
|
||||
|
||||
filter = old_filter_string .. filter_string
|
||||
set_filter(old_filter_string .. filter_string)
|
||||
end
|
||||
|
||||
function blizzard_page_index(str)
|
||||
|
||||
+30
-29
@@ -1,8 +1,9 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local cache = require 'aux.core.cache'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
|
||||
local post_filter = {}
|
||||
@@ -13,7 +14,7 @@ function valid_level(str)
|
||||
return level and bounded(1, 60, level)
|
||||
end
|
||||
|
||||
blizzard_query = setmetatable(T, {
|
||||
blizzard_query = setmetatable(T.acquire(), {
|
||||
__index = function(_, key)
|
||||
if key == 'name' then
|
||||
return name_input:GetText()
|
||||
@@ -81,31 +82,31 @@ function update_form()
|
||||
|
||||
if blizzard_query.exact then
|
||||
usable_checkbox:Disable()
|
||||
for key in pairs(temp-S('min_level', 'max_level')) do
|
||||
for key in pairs(T.temp-T.set('min_level', 'max_level')) do
|
||||
_M[key .. '_input']:EnableMouse(false)
|
||||
_M[key .. '_input']:ClearFocus()
|
||||
end
|
||||
for key in pairs(temp-S('class', 'subclass', 'slot', 'quality')) do
|
||||
for key in pairs(T.temp-T.set('class', 'subclass', 'slot', 'quality')) do
|
||||
_M[key .. '_dropdown'].button:Disable()
|
||||
end
|
||||
CloseDropDownMenus()
|
||||
else
|
||||
usable_checkbox:Enable()
|
||||
for key in pairs(temp-S('min_level', 'max_level')) do
|
||||
for key in pairs(T.temp-T.set('min_level', 'max_level')) do
|
||||
_M[key .. '_input']:EnableMouse(true)
|
||||
end
|
||||
class_dropdown.button:Enable()
|
||||
quality_dropdown.button:Enable()
|
||||
end
|
||||
|
||||
if any(temp-A('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then
|
||||
if 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()
|
||||
end
|
||||
end
|
||||
|
||||
function get.filter_builder_query()
|
||||
function get_filter_builder_query()
|
||||
local filter_string
|
||||
|
||||
local function add(part)
|
||||
@@ -125,17 +126,17 @@ function get.filter_builder_query()
|
||||
add(blizzard_query.max_level)
|
||||
add(blizzard_query.usable and 'usable')
|
||||
|
||||
local classes = temp-A(GetAuctionItemClasses())
|
||||
local classes = T.temp-T.list(GetAuctionItemClasses())
|
||||
if blizzard_query.class and blizzard_query.class > 0 then
|
||||
add(strlower(classes[blizzard_query.class]))
|
||||
end
|
||||
local subclasses = temp-A(GetAuctionItemSubClasses(blizzard_query.class or 0))
|
||||
local subclasses = T.temp-T.list(GetAuctionItemSubClasses(blizzard_query.class or 0))
|
||||
if blizzard_query.subclass and blizzard_query.subclass > 0 then
|
||||
add(strlower(subclasses[blizzard_query.subclass]))
|
||||
end
|
||||
local slot_index = blizzard_query.slot
|
||||
if slot_index then
|
||||
local slots = temp-A(GetAuctionInvTypes(blizzard_query.class or 0, blizzard_query.subclass or 0))
|
||||
local slots = T.temp-T.list(GetAuctionInvTypes(blizzard_query.class or 0, blizzard_query.subclass or 0))
|
||||
add(strlower(_G[slots[slot_index]]))
|
||||
end
|
||||
|
||||
@@ -150,7 +151,7 @@ function get.filter_builder_query()
|
||||
return filter_string or ''
|
||||
end
|
||||
|
||||
function set.form(filter)
|
||||
function set_form(filter)
|
||||
clear_form()
|
||||
for _, component in ipairs(filter.components) do
|
||||
if component[1] == 'blizzard' then
|
||||
@@ -176,7 +177,7 @@ function clear_form()
|
||||
UIDropDownMenu_ClearAll(slot_dropdown)
|
||||
UIDropDownMenu_ClearAll(quality_dropdown)
|
||||
filter_parameter_input:ClearFocus()
|
||||
wipe(post_filter)
|
||||
T.wipe(post_filter)
|
||||
post_filter_index = 0
|
||||
update_filter_display()
|
||||
end
|
||||
@@ -184,18 +185,18 @@ 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
|
||||
set.form(filter)
|
||||
set_form(filter)
|
||||
end
|
||||
update_form()
|
||||
end
|
||||
|
||||
function export_filter_string()
|
||||
filter = filter_builder_query
|
||||
set_filter(get_filter_builder_query())
|
||||
end
|
||||
|
||||
function formatted_post_filter(components)
|
||||
local no_line_break
|
||||
local stack = temp-T
|
||||
local stack = T.temp-T.acquire()
|
||||
local str = ''
|
||||
|
||||
for i, component in ipairs(components) do
|
||||
@@ -218,7 +219,7 @@ function formatted_post_filter(components)
|
||||
local parameter = component[3]
|
||||
if parameter then
|
||||
if component[2] == 'item' then
|
||||
parameter = info.display_name(cache.item_id(parameter)) or '[' .. parameter .. ']'
|
||||
parameter = info.display_name(info.item_id(parameter)) or '[' .. parameter .. ']'
|
||||
elseif filter_util.filters[component[2]].input_type == 'money' then
|
||||
parameter = money.to_string(money.from_string(parameter), nil, true)
|
||||
end
|
||||
@@ -322,8 +323,8 @@ function set_filter_display_offset(x_offset, y_offset)
|
||||
end
|
||||
|
||||
function initialize_filter_dropdown()
|
||||
for _, filter in ipairs(temp-A('and', 'or', 'not', 'price', 'profit', 'vendor-profit', 'disenchant-profit', 'percent', 'bid-price', 'bid-profit', 'bid-vendor-profit', 'bid-disenchant-profit', 'bid-percent', 'item', 'tooltip', 'min-level', 'max-level', 'rarity', 'left', 'utilizable')) do
|
||||
UIDropDownMenu_AddButton(O(
|
||||
for _, filter in ipairs(T.temp-T.list('and', 'or', 'not', 'price', 'profit', 'vendor-profit', 'disenchant-profit', 'percent', 'bid-price', 'bid-profit', 'bid-vendor-profit', 'bid-disenchant-profit', 'bid-percent', 'item', 'tooltip', 'min-level', 'max-level', 'rarity', 'left', 'utilizable')) do
|
||||
UIDropDownMenu_AddButton(T.map(
|
||||
'text', filter,
|
||||
'value', filter,
|
||||
'func', function()
|
||||
@@ -352,9 +353,9 @@ function initialize_class_dropdown()
|
||||
update_form()
|
||||
end
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, class in ipairs(temp-A(GetAuctionItemClasses())) do
|
||||
UIDropDownMenu_AddButton(O('text', class, 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, class in ipairs(T.temp-T.list(GetAuctionItemClasses())) do
|
||||
UIDropDownMenu_AddButton(T.map('text', class, 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -365,9 +366,9 @@ function initialize_subclass_dropdown()
|
||||
update_form()
|
||||
end
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, subclass in ipairs(temp-A(GetAuctionItemSubClasses(blizzard_query.class or 0))) do
|
||||
UIDropDownMenu_AddButton(O('text', subclass, 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, subclass in ipairs(T.temp-T.list(GetAuctionItemSubClasses(blizzard_query.class or 0))) do
|
||||
UIDropDownMenu_AddButton(T.map('text', subclass, 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -376,9 +377,9 @@ function initialize_slot_dropdown()
|
||||
UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value)
|
||||
update_form()
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, slot in ipairs(temp-A(GetAuctionInvTypes(blizzard_query.class == 2 and 2 or 0, blizzard_query.subclass or 0))) do
|
||||
UIDropDownMenu_AddButton(O('text', _G[slot], 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, slot in ipairs(T.temp-T.list(GetAuctionInvTypes(blizzard_query.class == 2 and 2 or 0, blizzard_query.subclass or 0))) do
|
||||
UIDropDownMenu_AddButton(T.map('text', _G[slot], 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -387,8 +388,8 @@ function initialize_quality_dropdown()
|
||||
UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value)
|
||||
update_form()
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', -1, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', -1, 'func', on_click))
|
||||
for i = 0, 4 do
|
||||
UIDropDownMenu_AddButton(O('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
+13
-11
@@ -1,5 +1,7 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local completion = require 'aux.util.completion'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan = require 'aux.core.scan'
|
||||
@@ -126,7 +128,7 @@ do
|
||||
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
|
||||
btn:SetScript('OnClick', function()
|
||||
if arg1 == 'RightButton' then
|
||||
filter = current_search.filter_string
|
||||
set_filter(get_current_search().filter_string)
|
||||
end
|
||||
execute()
|
||||
end)
|
||||
@@ -161,7 +163,7 @@ do
|
||||
return queries and join(map(copy(queries), function(query) return query.prettified end), ';') or color.red(str)
|
||||
end
|
||||
editbox.complete = completion.complete_filter
|
||||
editbox.focus_loss = function() this:SetText(current_search.filter_string or '') end
|
||||
editbox.focus_loss = function() this:SetText(get_current_search().filter_string or '') end
|
||||
editbox:SetHeight(25)
|
||||
editbox.char = function()
|
||||
this:complete()
|
||||
@@ -185,7 +187,7 @@ do
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Search Results')
|
||||
btn:SetScript('OnClick', function() subtab = RESULTS end)
|
||||
btn:SetScript('OnClick', function() set_subtab(RESULTS) end)
|
||||
search_results_button = btn
|
||||
end
|
||||
do
|
||||
@@ -194,7 +196,7 @@ do
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Saved Searches')
|
||||
btn:SetScript('OnClick', function() subtab = SAVED end)
|
||||
btn:SetScript('OnClick', function() set_subtab(SAVED) end)
|
||||
saved_searches_button = btn
|
||||
end
|
||||
do
|
||||
@@ -203,7 +205,7 @@ do
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Filter Builder')
|
||||
btn:SetScript('OnClick', function() subtab = FILTER end)
|
||||
btn:SetScript('OnClick', function() set_subtab(FILTER) end)
|
||||
new_filter_button = btn
|
||||
end
|
||||
do
|
||||
@@ -232,8 +234,8 @@ do
|
||||
btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetText('Clear')
|
||||
btn:SetScript('OnClick', function()
|
||||
while tremove(current_search.records) do end
|
||||
current_search.table:SetDatabase()
|
||||
while tremove(get_current_search().records) do end
|
||||
get_current_search().table:SetDatabase()
|
||||
end)
|
||||
end
|
||||
do
|
||||
@@ -432,14 +434,14 @@ 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 temp-A('and', 'or', 'not', unpack(keys(filter_util.filters))) end)
|
||||
input.complete = completion.complete(function() return T.temp-T.list('and', 'or', 'not', unpack(keys(filter_util.filters))) end)
|
||||
input.char = function() this:complete() end
|
||||
input.change = function()
|
||||
local text = this:GetText()
|
||||
if filter_util.filters[text] and filter_util.filters[text].input_type ~= '' then
|
||||
local _, _, suggestions = filter_util.parse_filter_string(text .. '/')
|
||||
filter_parameter_input:SetNumeric(filter_util.filters[text].input_type == 'number')
|
||||
filter_parameter_input.complete = completion.complete(function() return suggestions or empty end)
|
||||
filter_parameter_input.complete = completion.complete(function() return suggestions or T.empty end)
|
||||
filter_parameter_input:Show()
|
||||
else
|
||||
filter_parameter_input:Hide()
|
||||
@@ -519,7 +521,7 @@ for _ = 1, 5 do
|
||||
|
||||
local table = auction_listing.new(frame.results, 16, auction_listing.search_columns)
|
||||
table:SetHandler('OnClick', function(row, button)
|
||||
if IsAltKeyDown() and current_search.table:GetSelection().record == row.record then
|
||||
if IsAltKeyDown() and get_current_search().table:GetSelection().record == row.record then
|
||||
if button == 'LeftButton' then
|
||||
buyout_button:Click()
|
||||
elseif button == 'RightButton' then
|
||||
@@ -541,7 +543,7 @@ favorite_searches_listing:SetColInfo{{name='Auto Buy', width=.07, align='CENTER'
|
||||
recent_searches_listing = listing.new(frame.saved.recent)
|
||||
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
|
||||
|
||||
for listing in pairs(temp-S(favorite_searches_listing, recent_searches_listing)) do
|
||||
for listing in pairs(T.temp-T.set(favorite_searches_listing, recent_searches_listing)) do
|
||||
for k, v in pairs(handlers) do
|
||||
listing:SetHandler(k, v)
|
||||
end
|
||||
|
||||
+46
-51
@@ -1,25 +1,18 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan_util = require 'aux.util.scan'
|
||||
local scan = require 'aux.core.scan'
|
||||
local cache = require 'aux.core.cache'
|
||||
|
||||
function LOAD()
|
||||
search_scan_id = 0
|
||||
|
||||
function handle.LOAD()
|
||||
new_search()
|
||||
end
|
||||
|
||||
do
|
||||
local id = 0
|
||||
function get.search_scan_id()
|
||||
return id
|
||||
end
|
||||
function set.search_scan_id(v)
|
||||
id = v
|
||||
end
|
||||
end
|
||||
|
||||
function update_real_time(enable)
|
||||
if enable then
|
||||
range_button:Hide()
|
||||
@@ -36,7 +29,7 @@ do
|
||||
local searches = {}
|
||||
local search_index = 1
|
||||
|
||||
function get.current_search()
|
||||
function get_current_search()
|
||||
return searches[search_index]
|
||||
end
|
||||
|
||||
@@ -76,7 +69,7 @@ do
|
||||
while getn(searches) > search_index do
|
||||
tremove(searches)
|
||||
end
|
||||
local search = O('records', T, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time)
|
||||
local search = T.map('records', T.acquire(), 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time)
|
||||
tinsert(searches, search)
|
||||
if getn(searches) > 5 then
|
||||
tremove(searches, 1)
|
||||
@@ -106,18 +99,18 @@ do
|
||||
function previous_search()
|
||||
clear_control_focus()
|
||||
update_search(search_index - 1)
|
||||
subtab = RESULTS
|
||||
set_subtab(RESULTS)
|
||||
end
|
||||
|
||||
function next_search()
|
||||
clear_control_focus()
|
||||
update_search(search_index + 1)
|
||||
subtab = RESULTS
|
||||
set_subtab(RESULTS)
|
||||
end
|
||||
end
|
||||
|
||||
function update_continuation()
|
||||
if current_search.continuation then
|
||||
if get_current_search().continuation then
|
||||
resume_button:Show()
|
||||
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
|
||||
else
|
||||
@@ -128,12 +121,12 @@ end
|
||||
|
||||
function discard_continuation()
|
||||
scan.abort(search_scan_id)
|
||||
current_search.continuation = nil
|
||||
get_current_search().continuation = nil
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
function update_start_stop()
|
||||
if current_search.active then
|
||||
if get_current_search().active then
|
||||
stop_button:Show()
|
||||
start_button:Hide()
|
||||
else
|
||||
@@ -146,14 +139,14 @@ function start_real_time_scan(query, search, continuation)
|
||||
|
||||
local ignore_page
|
||||
if not search then
|
||||
search = current_search
|
||||
search = get_current_search()
|
||||
query.blizzard_query.first_page = tonumber(continuation) or 0
|
||||
query.blizzard_query.last_page = tonumber(continuation) or 0
|
||||
ignore_page = not tonumber(continuation)
|
||||
end
|
||||
|
||||
local next_page
|
||||
local new_records = T
|
||||
local new_records = T.acquire()
|
||||
search_scan_id = scan.start{
|
||||
type = 'list',
|
||||
queries = {query},
|
||||
@@ -174,14 +167,14 @@ function start_real_time_scan(query, search, continuation)
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
local map = temp-T
|
||||
local map = T.temp-T.acquire()
|
||||
for _, record in pairs(search.records) do
|
||||
map[record.sniping_signature] = record
|
||||
end
|
||||
for _, record in pairs(new_records) do
|
||||
map[record.sniping_signature] = record
|
||||
end
|
||||
release(new_records)
|
||||
T.release(new_records)
|
||||
new_records = values(map)
|
||||
|
||||
if getn(new_records) > 2000 then
|
||||
@@ -201,7 +194,7 @@ function start_real_time_scan(query, search, continuation)
|
||||
|
||||
search.continuation = next_page or not ignore_page and query.blizzard_query.first_page or true
|
||||
|
||||
if current_search == search then
|
||||
if get_current_search() == search then
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
@@ -214,7 +207,7 @@ end
|
||||
function start_search(queries, continuation)
|
||||
local current_query, current_page, total_queries, start_query, start_page
|
||||
|
||||
local search = current_search
|
||||
local search = get_current_search()
|
||||
|
||||
total_queries = getn(queries)
|
||||
|
||||
@@ -269,8 +262,8 @@ function start_search(queries, continuation)
|
||||
search.status_bar:update_status(1, 1)
|
||||
search.status_bar:set_text('Scan complete')
|
||||
|
||||
if current_search == search and frame.results:IsVisible() and getn(search.records) == 0 then
|
||||
subtab = SAVED
|
||||
if get_current_search() == search and frame.results:IsVisible() and getn(search.records) == 0 then
|
||||
set_subtab(SAVED)
|
||||
end
|
||||
|
||||
search.active = false
|
||||
@@ -285,7 +278,7 @@ function start_search(queries, continuation)
|
||||
else
|
||||
search.continuation = {start_query, start_page}
|
||||
end
|
||||
if current_search == search then
|
||||
if get_current_search() == search then
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
@@ -298,13 +291,13 @@ end
|
||||
function M.execute(resume, real_time)
|
||||
|
||||
if resume then
|
||||
real_time = current_search.real_time
|
||||
real_time = get_current_search().real_time
|
||||
elseif real_time == nil then
|
||||
real_time = real_time_button:IsShown()
|
||||
end
|
||||
|
||||
if resume then
|
||||
search_box:SetText(current_search.filter_string)
|
||||
search_box:SetText(get_current_search().filter_string)
|
||||
end
|
||||
local filter_string, first_page, last_page = search_box:GetText(), blizzard_page_index(first_page_input:GetText()), blizzard_page_index(last_page_input:GetText())
|
||||
|
||||
@@ -323,38 +316,40 @@ function M.execute(resume, real_time)
|
||||
end
|
||||
|
||||
if resume then
|
||||
current_search.table:SetSelectedRecord()
|
||||
get_current_search().table:SetSelectedRecord()
|
||||
else
|
||||
if filter_string ~= current_search.filter_string then
|
||||
if current_search.filter_string then
|
||||
if filter_string ~= get_current_search().filter_string then
|
||||
if get_current_search().filter_string then
|
||||
new_search(filter_string, first_page, last_page, real_time)
|
||||
else
|
||||
current_search.filter_string = filter_string
|
||||
get_current_search().filter_string = filter_string
|
||||
end
|
||||
new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';'))
|
||||
else
|
||||
current_search.records = T
|
||||
current_search.table:Reset()
|
||||
current_search.table:SetDatabase(current_search.records)
|
||||
local search = get_current_search()
|
||||
search.records = T.acquire()
|
||||
search.table:Reset()
|
||||
search.table:SetDatabase(search.records)
|
||||
end
|
||||
current_search.first_page = first_page
|
||||
current_search.last_page = last_page
|
||||
current_search.real_time = real_time
|
||||
current_search.auto_buy_validator = auto_buy_validator
|
||||
local search = get_current_search()
|
||||
search.first_page = first_page
|
||||
search.last_page = last_page
|
||||
search.real_time = real_time
|
||||
search.auto_buy_validator = get_auto_buy_validator()
|
||||
end
|
||||
|
||||
local continuation = resume and current_search.continuation
|
||||
local continuation = resume and get_current_search().continuation
|
||||
discard_continuation()
|
||||
current_search.active = true
|
||||
get_current_search().active = true
|
||||
update_start_stop()
|
||||
clear_control_focus()
|
||||
subtab = RESULTS
|
||||
set_subtab(RESULTS)
|
||||
if real_time then
|
||||
start_real_time_scan(queries[1], nil, continuation)
|
||||
else
|
||||
for _, query in pairs(queries) do
|
||||
query.blizzard_query.first_page = current_search.first_page
|
||||
query.blizzard_query.last_page = current_search.last_page
|
||||
query.blizzard_query.first_page = get_current_search().first_page
|
||||
query.blizzard_query.last_page = get_current_search().last_page
|
||||
end
|
||||
start_search(queries, continuation)
|
||||
end
|
||||
@@ -367,9 +362,9 @@ do
|
||||
local found_index
|
||||
|
||||
function find_auction(record)
|
||||
local search = current_search
|
||||
local search = get_current_search()
|
||||
|
||||
if not search.table:ContainsRecord(record) or cache.is_player(record.owner) then
|
||||
if not search.table:ContainsRecord(record) or info.is_player(record.owner) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -377,7 +372,7 @@ do
|
||||
state = SEARCHING
|
||||
scan_id = scan_util.find(
|
||||
record,
|
||||
current_search.status_bar,
|
||||
get_current_search().status_bar,
|
||||
function()
|
||||
state = IDLE
|
||||
end,
|
||||
@@ -429,7 +424,7 @@ do
|
||||
|
||||
if state == SEARCHING then return end
|
||||
|
||||
local selection = current_search.table:GetSelection()
|
||||
local selection = get_current_search().table:GetSelection()
|
||||
if not selection then
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
@@ -437,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 bid_in_progress() then
|
||||
state = IDLE
|
||||
end
|
||||
end
|
||||
|
||||
+15
-13
@@ -1,31 +1,33 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
recent_searches, favorite_searches = realm_data'recent_searches', realm_data'favorite_searches'
|
||||
end
|
||||
|
||||
function update_search_listings()
|
||||
local favorite_search_rows = T
|
||||
local favorite_search_rows = T.acquire()
|
||||
for i = 1, getn(favorite_searches) do
|
||||
local search = favorite_searches[i]
|
||||
local name = strsub(search.prettified, 1, 250)
|
||||
tinsert(favorite_search_rows, O(
|
||||
'cols', A(O('value', search.auto_buy and color.red'X' or ''), O('value', name)),
|
||||
tinsert(favorite_search_rows, T.map(
|
||||
'cols', T.list(T.map('value', search.auto_buy and color.red'X' or ''), T.map('value', name)),
|
||||
'search', search,
|
||||
'index', i
|
||||
))
|
||||
end
|
||||
favorite_searches_listing:SetData(favorite_search_rows)
|
||||
|
||||
local recent_search_rows = T
|
||||
local recent_search_rows = T.acquire()
|
||||
for i = 1, getn(recent_searches) do
|
||||
local search = recent_searches[i]
|
||||
local name = strsub(search.prettified, 1, 250)
|
||||
tinsert(recent_search_rows, O(
|
||||
'cols', A(O('value', name)),
|
||||
tinsert(recent_search_rows, T.map(
|
||||
'cols', T.list(T.map('value', name)),
|
||||
'search', search,
|
||||
'index', i
|
||||
))
|
||||
@@ -34,7 +36,7 @@ function update_search_listings()
|
||||
end
|
||||
|
||||
function new_recent_search(filter_string, prettified)
|
||||
tinsert(recent_searches, 1, O(
|
||||
tinsert(recent_searches, 1, T.map(
|
||||
'filter_string', filter_string,
|
||||
'prettified', prettified
|
||||
))
|
||||
@@ -48,11 +50,11 @@ handlers = {
|
||||
OnClick = function(st, data, _, button)
|
||||
if not data then return end
|
||||
if button == 'LeftButton' and IsShiftKeyDown() then
|
||||
filter = data.search.filter_string
|
||||
set_filter(data.search.filter_string)
|
||||
elseif button == 'RightButton' and IsShiftKeyDown() then
|
||||
add_filter(data.search.filter_string)
|
||||
elseif button == 'LeftButton' then
|
||||
filter = data.search.filter_string
|
||||
set_filter(data.search.filter_string)
|
||||
execute()
|
||||
elseif button == 'RightButton' then
|
||||
local u = update_search_listings
|
||||
@@ -82,8 +84,8 @@ handlers = {
|
||||
end
|
||||
}
|
||||
|
||||
function get.auto_buy_validator()
|
||||
local validators = T
|
||||
function get_auto_buy_validator()
|
||||
local validators = T.acquire()
|
||||
for _, search in pairs(favorite_searches) do
|
||||
if search.auto_buy then
|
||||
local queries, error = filter_util.queries(search.filter_string)
|
||||
@@ -102,7 +104,7 @@ end
|
||||
function add_favorite(filter_string)
|
||||
local queries, error = filter_util.queries(filter_string)
|
||||
if queries then
|
||||
tinsert(favorite_searches, 1, O(
|
||||
tinsert(favorite_searches, 1, T.map(
|
||||
'filter_string', filter_string,
|
||||
'prettified', join(map(queries, function(query) return query.prettified end), ';')
|
||||
))
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
module 'aux'
|
||||
|
||||
M.immutable = setmetatable(T, {
|
||||
local T = require 'T'
|
||||
|
||||
M.immutable = setmetatable(T.acquire(), {
|
||||
__metatable = false,
|
||||
__newindex = nop,
|
||||
__sub = function(_, t)
|
||||
return setmetatable(T, O('__metatable', false, '__newindex', nop, '__index', t))
|
||||
return setmetatable(T.acquire(), T.map('__metatable', false, '__newindex', nop, '__index', t))
|
||||
end
|
||||
})
|
||||
|
||||
M.select = vararg-function(arg)
|
||||
M.select = T.vararg-function(arg)
|
||||
for _ = 1, arg[1] do
|
||||
tremove(arg, 1)
|
||||
end
|
||||
@@ -30,7 +32,7 @@ function M.replicate(count, value)
|
||||
if count > 0 then return value, replicate(count - 1, value) end
|
||||
end
|
||||
|
||||
M.index = vararg-function(arg)
|
||||
M.index = T.vararg-function(arg)
|
||||
local t = tremove(arg, 1)
|
||||
for _, v in ipairs(arg) do
|
||||
t = t and t[v]
|
||||
@@ -40,12 +42,12 @@ end
|
||||
|
||||
M.huge = 1.8 * 10 ^ 308
|
||||
|
||||
function M.get.modified()
|
||||
function M.modified()
|
||||
return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown()
|
||||
end
|
||||
|
||||
function M.copy(t)
|
||||
local copy = T
|
||||
local copy = T.acquire()
|
||||
for k, v in pairs(t) do
|
||||
copy[k] = v
|
||||
end
|
||||
@@ -70,7 +72,7 @@ function M.key(t, value)
|
||||
end
|
||||
|
||||
function M.keys(t)
|
||||
local keys = T
|
||||
local keys = T.acquire()
|
||||
for k in pairs(t) do
|
||||
tinsert(keys, k)
|
||||
end
|
||||
@@ -78,7 +80,7 @@ function M.keys(t)
|
||||
end
|
||||
|
||||
function M.values(t)
|
||||
local values = T
|
||||
local values = T.acquire()
|
||||
for _, v in pairs(t) do
|
||||
tinsert(values, v)
|
||||
end
|
||||
@@ -137,7 +139,7 @@ function M.trim(str)
|
||||
end
|
||||
|
||||
function M.split(str, separator)
|
||||
local parts = T
|
||||
local parts = T.acquire()
|
||||
while true do
|
||||
local start_index = strfind(str, separator, 1, true)
|
||||
if start_index then
|
||||
@@ -153,7 +155,7 @@ function M.split(str, separator)
|
||||
end
|
||||
|
||||
function M.tokenize(str)
|
||||
local tokens = T
|
||||
local tokens = T.acquire()
|
||||
for token in string.gfind(str, '%S+') do tinsert(tokens, token) end
|
||||
return tokens
|
||||
end
|
||||
@@ -173,8 +175,8 @@ end
|
||||
|
||||
function M.signal()
|
||||
local params
|
||||
return vararg-function(arg)
|
||||
static(arg)
|
||||
return T.vararg-function(arg)
|
||||
T.static(arg)
|
||||
params = arg
|
||||
end, function()
|
||||
return params
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
module 'aux.util.completion'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local filter_util = require 'aux.util.filter'
|
||||
|
||||
+45
-45
@@ -1,12 +1,12 @@
|
||||
module 'aux.util.filter'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local cache = require 'aux.core.cache'
|
||||
local history = require 'aux.core.history'
|
||||
local disenchant = require 'aux.core.disenchant'
|
||||
|
||||
@@ -51,7 +51,7 @@ M.filters = {
|
||||
},
|
||||
|
||||
['left'] = {
|
||||
input_type = A('30m', '2h', '8h', '24h'),
|
||||
input_type = T.list('30m', '2h', '8h', '24h'),
|
||||
validator = function(index)
|
||||
return function(auction_record)
|
||||
return auction_record.duration == index
|
||||
@@ -60,7 +60,7 @@ M.filters = {
|
||||
},
|
||||
|
||||
['rarity'] = {
|
||||
input_type = A('poor', 'common', 'uncommon', 'rare', 'epic'),
|
||||
input_type = T.list('poor', 'common', 'uncommon', 'rare', 'epic'),
|
||||
validator = function(index)
|
||||
return function(auction_record)
|
||||
return auction_record.quality == index - 1
|
||||
@@ -166,7 +166,7 @@ M.filters = {
|
||||
input_type = 'money',
|
||||
validator = function(amount)
|
||||
return function(auction_record)
|
||||
local vendor_price = cache.merchant_info(auction_record.item_id)
|
||||
local vendor_price = info.merchant_info(auction_record.item_id)
|
||||
return vendor_price and vendor_price * auction_record.aux_quantity - auction_record.bid_price >= amount
|
||||
end
|
||||
end
|
||||
@@ -176,7 +176,7 @@ M.filters = {
|
||||
input_type = 'money',
|
||||
validator = function(amount)
|
||||
return function(auction_record)
|
||||
local vendor_price = cache.merchant_info(auction_record.item_id)
|
||||
local vendor_price = info.merchant_info(auction_record.item_id)
|
||||
return auction_record.buyout_price > 0 and vendor_price and vendor_price * auction_record.aux_quantity - auction_record.buyout_price >= amount
|
||||
end
|
||||
end
|
||||
@@ -184,12 +184,12 @@ M.filters = {
|
||||
}
|
||||
|
||||
function operator(str)
|
||||
local operator = str == 'not' and A('operator', 'not', 1)
|
||||
for name in pairs(temp-S('and', 'or')) do
|
||||
local operator = str == 'not' and T.list('operator', 'not', 1)
|
||||
for name in pairs(T.temp-T.set('and', 'or')) do
|
||||
local arity = select(3, strfind(str, '^' .. name .. '(%d*)$'))
|
||||
if arity then
|
||||
arity = tonumber(arity)
|
||||
operator = not (arity and arity < 2) and A('operator', name, arity)
|
||||
operator = not (arity and arity < 2) and T.list('operator', name, arity)
|
||||
end
|
||||
end
|
||||
return operator or nil
|
||||
@@ -206,41 +206,41 @@ do
|
||||
local number = tonumber(select(3, strfind(str, '^(%d+)$')))
|
||||
if number then
|
||||
if number >= 1 and number <= 60 then
|
||||
for _, key in ipairs(temp-A('min_level', 'max_level')) do
|
||||
for _, key in ipairs(T.temp-T.list('min_level', 'max_level')) do
|
||||
if not self[key] then
|
||||
self[key] = A(str, number)
|
||||
return A('blizzard', key, str, number)
|
||||
self[key] = T.list(str, number)
|
||||
return T.list('blizzard', key, str, number)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, parser in pairs(temp-A(
|
||||
temp-A('class', info.item_class_index),
|
||||
temp-A('subclass', vararg-function(arg) return info.item_subclass_index(index(self.class, 2) or 0, unpack(arg)) end),
|
||||
temp-A('slot', 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),
|
||||
temp-A('quality', info.item_quality_index)
|
||||
for _, parser in pairs(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('quality', info.item_quality_index)
|
||||
)) do
|
||||
if not self[parser[1]] then
|
||||
tinsert(parser, str)
|
||||
local index, label = parser[2](select(3, unpack(parser)))
|
||||
if index then
|
||||
self[parser[1]] = A(label, index)
|
||||
return A('blizzard', parser[1], label, index)
|
||||
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
|
||||
self[str] = A(str, 1)
|
||||
return A('blizzard', str, str, 1)
|
||||
self[str] = T.list(str, 1)
|
||||
return T.list('blizzard', str, str, 1)
|
||||
elseif i == 1 and strlen(str) <= 63 then
|
||||
self.name = unquote(str)
|
||||
return A('blizzard', 'name', unquote(str), str)
|
||||
return T.list('blizzard', 'name', unquote(str), str)
|
||||
-- return nil, 'The name filter must not be longer than 63 characters' TODO
|
||||
end
|
||||
end,
|
||||
}
|
||||
function blizzard_filter_parser()
|
||||
return setmetatable(T, mt)
|
||||
return setmetatable(T.acquire(), mt)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -259,10 +259,10 @@ function parse_parameter(input_type, str)
|
||||
end
|
||||
|
||||
function M.parse_filter_string(str)
|
||||
local filter, post_filter = T, T
|
||||
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
|
||||
local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or T.acquire()
|
||||
|
||||
local i = 1
|
||||
while parts[i] do
|
||||
@@ -282,10 +282,10 @@ function M.parse_filter_string(str)
|
||||
return nil, 'Invalid input for ' .. parts[i] .. '. Expecting: ' .. input_type
|
||||
end
|
||||
end
|
||||
tinsert(post_filter, A('filter', parts[i], parts[i + 1]))
|
||||
tinsert(post_filter, T.list('filter', parts[i], parts[i + 1]))
|
||||
i = i + 1
|
||||
else
|
||||
tinsert(post_filter, A('filter', parts[i]))
|
||||
tinsert(post_filter, T.list('filter', parts[i]))
|
||||
end
|
||||
tinsert(filter, post_filter[getn(post_filter)])
|
||||
else
|
||||
@@ -293,7 +293,7 @@ function M.parse_filter_string(str)
|
||||
if part then
|
||||
tinsert(filter, part)
|
||||
elseif parts[i] ~= '' then
|
||||
tinsert(post_filter, A('filter', 'tooltip', parts[i]))
|
||||
tinsert(post_filter, T.list('filter', 'tooltip', parts[i]))
|
||||
tinsert(filter, post_filter[getn(post_filter)])
|
||||
else
|
||||
return nil, 'Empty modifier'
|
||||
@@ -302,14 +302,14 @@ function M.parse_filter_string(str)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return O('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
return T.map('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
end
|
||||
|
||||
function M.query(filter_string)
|
||||
local filter, error, suggestions = parse_filter_string(filter_string)
|
||||
|
||||
if not filter then
|
||||
return nil, suggestions or T, error
|
||||
return nil, suggestions or T.acquire(), error
|
||||
end
|
||||
|
||||
local polish_notation_counter = 0
|
||||
@@ -323,7 +323,7 @@ function M.query(filter_string)
|
||||
end
|
||||
|
||||
if polish_notation_counter > 0 then
|
||||
local suggestions = T
|
||||
local suggestions = T.acquire()
|
||||
for key in pairs(filters) do
|
||||
tinsert(suggestions, strlower(key))
|
||||
end
|
||||
@@ -342,7 +342,7 @@ end
|
||||
|
||||
function M.queries(filter_string)
|
||||
local parts = split(filter_string, ';')
|
||||
local queries = T
|
||||
local queries = T.acquire()
|
||||
for _, str in ipairs(parts) do
|
||||
local query, _, error = query(str)
|
||||
if not query then
|
||||
@@ -355,7 +355,7 @@ function M.queries(filter_string)
|
||||
end
|
||||
|
||||
function suggestions(filter)
|
||||
local suggestions = T
|
||||
local suggestions = T.acquire()
|
||||
|
||||
if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end
|
||||
|
||||
@@ -365,19 +365,19 @@ function suggestions(filter)
|
||||
|
||||
-- classes
|
||||
if not filter.blizzard.class then
|
||||
for _, class in ipairs(temp-A(GetAuctionItemClasses())) do tinsert(suggestions, class) end
|
||||
for _, class in ipairs(T.temp-T.list(GetAuctionItemClasses())) do tinsert(suggestions, class) end
|
||||
end
|
||||
|
||||
-- subclasses
|
||||
if not filter.blizzard.subclass then
|
||||
for _, subclass in ipairs(temp-A(GetAuctionItemSubClasses(index(filter.blizzard.class, 2) or 0))) do
|
||||
for _, subclass in ipairs(T.temp-T.list(GetAuctionItemSubClasses(index(filter.blizzard.class, 2) or 0))) do
|
||||
tinsert(suggestions, subclass)
|
||||
end
|
||||
end
|
||||
|
||||
-- slots
|
||||
if not filter.blizzard.slot then
|
||||
for _, invtype in ipairs(temp-A(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(index(filter.blizzard.class, 2) == 2 and 2 or 0, index(filter.blizzard.subclass, 2) or 0))) do
|
||||
tinsert(suggestions, _G[invtype])
|
||||
end
|
||||
end
|
||||
@@ -427,7 +427,7 @@ 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(cache.item_id(component[3])) or color.orange('[' .. component[3] .. ']'))
|
||||
prettified.append(info.display_name(info.item_id(component[3])) or color.orange('[' .. component[3] .. ']'))
|
||||
elseif component[3] ~= '' then
|
||||
prettified.append(color.label.enabled(component[3]))
|
||||
end
|
||||
@@ -443,7 +443,7 @@ function prettified_filter_string(filter)
|
||||
local parameter = component[3]
|
||||
if parameter then
|
||||
if component[2] == 'item' then
|
||||
prettified.append(info.display_name(cache.item_id(parameter)) or color.label.enabled('[' .. parameter .. ']'))
|
||||
prettified.append(info.display_name(info.item_id(parameter)) or 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))
|
||||
@@ -471,9 +471,9 @@ end
|
||||
|
||||
function blizzard_query(filter)
|
||||
local filters = filter.blizzard
|
||||
local query = O('name', filters.name)
|
||||
local query = T.map('name', filters.name)
|
||||
local item_info, class_index, subclass_index, slot_index
|
||||
local item_id = filters.name and cache.item_id(filters.name)
|
||||
local item_id = filters.name and info.item_id(filters.name)
|
||||
item_info = item_id and info.item(item_id)
|
||||
if filters.exact and item_info then
|
||||
class_index = info.item_class_index(item_info.class)
|
||||
@@ -489,7 +489,7 @@ function blizzard_query(filter)
|
||||
query.slot = slot_index
|
||||
query.quality = item_info.quality
|
||||
else
|
||||
for key in pairs(temp-S('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality')) do
|
||||
for key in pairs(T.temp-T.set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality')) do
|
||||
query[key] = index(filters[key], 2)
|
||||
end
|
||||
end
|
||||
@@ -497,7 +497,7 @@ function blizzard_query(filter)
|
||||
end
|
||||
|
||||
function validator(filter)
|
||||
local validators = T
|
||||
local validators = T.acquire()
|
||||
for i, component in pairs(filter.post) do
|
||||
local type, name, param = unpack(component)
|
||||
if type == 'filter' then
|
||||
@@ -508,11 +508,11 @@ function validator(filter)
|
||||
if filter.blizzard.exact and strlower(info.item(record.item_id).name) ~= filter.blizzard.name then
|
||||
return false
|
||||
end
|
||||
local stack = temp-T
|
||||
local stack = T.temp-T.acquire()
|
||||
for i = getn(filter.post), 1, -1 do
|
||||
local type, name, param = unpack(filter.post[i])
|
||||
if type == 'operator' then
|
||||
local args = temp-T
|
||||
local args = T.temp-T.acquire()
|
||||
while (not param or param > 0) and getn(stack) > 0 do
|
||||
tinsert(args, tremove(stack))
|
||||
param = param and param - 1
|
||||
@@ -534,7 +534,7 @@ end
|
||||
|
||||
function M.query_builder()
|
||||
local filter
|
||||
return O(
|
||||
return T.map(
|
||||
'append', function(part)
|
||||
filter = not filter and part or filter .. '/' .. part
|
||||
end,
|
||||
|
||||
+24
-25
@@ -1,9 +1,8 @@
|
||||
module 'aux.util.info'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local cache = require 'aux.core.cache'
|
||||
local T = require 'T'
|
||||
|
||||
CreateFrame('GameTooltip', 'AuxTooltip', nil, 'GameTooltipTemplate')
|
||||
AuxTooltip:SetScript('OnTooltipAddMoney', function()
|
||||
@@ -38,7 +37,7 @@ do
|
||||
INVTYPE_TABARD = {19},
|
||||
}
|
||||
function M.inventory_index(slot)
|
||||
return unpack(inventory_index_map[slot] or temp-T)
|
||||
return unpack(inventory_index_map[slot] or T.temp-T.acquire())
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,14 +45,14 @@ function M.container_item(bag, slot)
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = T.temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working?
|
||||
local tooltip, tooltip_money = tooltip('bag', bag, slot)
|
||||
local max_charges = max_item_charges(item_id)
|
||||
local charges = max_charges and item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
return O(
|
||||
return T.map(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -88,7 +87,7 @@ end
|
||||
|
||||
function M.auction_sell_item()
|
||||
for name, texture, count, quality, usable, vendor_price in GetAuctionSellItemInfo do
|
||||
return O(
|
||||
return T.map(
|
||||
'name', name,
|
||||
'texture', texture,
|
||||
'quality', quality,
|
||||
@@ -105,7 +104,7 @@ function M.auction(index, query_type)
|
||||
local link = GetAuctionItemLink(query_type, index)
|
||||
if link then
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = T.temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local name, texture, count, quality, usable, level, start_price, min_increment, buyout_price, high_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(query_type, index)
|
||||
|
||||
@@ -117,7 +116,7 @@ function M.auction(index, query_type)
|
||||
local blizzard_bid = high_bid > 0 and high_bid or start_price
|
||||
local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price
|
||||
|
||||
return O(
|
||||
return T.map(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -126,8 +125,8 @@ function M.auction(index, query_type)
|
||||
'link', link,
|
||||
'itemstring', item_info.itemstring,
|
||||
'item_key', item_id .. ':' .. suffix_id,
|
||||
'search_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'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 '?')), ':'),
|
||||
|
||||
'name', name,
|
||||
'texture', texture,
|
||||
@@ -171,7 +170,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(temp-A(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (cache.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
|
||||
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 '?')), ':')
|
||||
end
|
||||
|
||||
function M.set_tooltip(itemstring, owner, anchor)
|
||||
@@ -181,7 +180,7 @@ end
|
||||
|
||||
function M.set_shopping_tooltip(slot)
|
||||
local index1, index2 = inventory_index(slot)
|
||||
local tooltips = temp-T
|
||||
local tooltips = T.temp-T.acquire()
|
||||
if index1 then
|
||||
local tooltip = tooltip('inventory', 'player', index1)
|
||||
if getn(tooltip) > 0 then
|
||||
@@ -196,14 +195,14 @@ function M.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[1] then
|
||||
tinsert(tooltips[1], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[1], 1, T.temp-T.map('left_text', 'Currently Equipped', 'left_color', T.temp-T.list(.5, .5, .5)))
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_NONE')
|
||||
ShoppingTooltip1:SetPoint('TOPLEFT', GameTooltip, 'TOPRIGHT', 0, -10)
|
||||
load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
end
|
||||
|
||||
if tooltips[2] then
|
||||
tinsert(tooltips[2], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[2], 1, T.temp-T.map('left_text', 'Currently Equipped', 'left_color', T.temp-T.list(.5, .5, .5)))
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_NONE')
|
||||
ShoppingTooltip2:SetPoint('TOPLEFT', ShoppingTooltip1, 'TOPRIGHT')
|
||||
load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
@@ -284,13 +283,13 @@ function M.tooltip(setter, arg1, arg2)
|
||||
elseif setter == 'link' then
|
||||
AuxTooltip:SetHyperlink(arg1)
|
||||
end
|
||||
local tooltip = T
|
||||
local tooltip = T.acquire()
|
||||
for i = 1, AuxTooltip:NumLines() do
|
||||
tinsert(tooltip, O(
|
||||
tinsert(tooltip, T.map(
|
||||
'left_text', _G['AuxTooltipTextLeft' .. i]:GetText(),
|
||||
'left_color', A(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'left_color', T.list(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'right_text', _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(),
|
||||
'right_color', A(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
'right_color', T.list(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
))
|
||||
end
|
||||
return tooltip, AuxTooltip.money
|
||||
@@ -372,7 +371,7 @@ end
|
||||
function M.item(item_id, suffix_id)
|
||||
local itemstring = 'item:' .. (item_id or 0) .. ':0:' .. (suffix_id or 0) .. ':0'
|
||||
local name, itemstring, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
return name and O(
|
||||
return name and T.map(
|
||||
'name', name,
|
||||
'itemstring', itemstring,
|
||||
'quality', quality,
|
||||
@@ -382,11 +381,11 @@ function M.item(item_id, suffix_id)
|
||||
'slot', slot,
|
||||
'max_stack', max_stack,
|
||||
'texture', texture
|
||||
) or cache.item_info(item_id)
|
||||
) or item_info(item_id)
|
||||
end
|
||||
|
||||
function M.item_class_index(item_class)
|
||||
for i, class in pairs(temp-A(GetAuctionItemClasses())) do
|
||||
for i, class in pairs(T.temp-T.list(GetAuctionItemClasses())) do
|
||||
if strupper(class) == strupper(item_class) then
|
||||
return i, class
|
||||
end
|
||||
@@ -394,7 +393,7 @@ function M.item_class_index(item_class)
|
||||
end
|
||||
|
||||
function M.item_subclass_index(class_index, item_subclass)
|
||||
for i, subclass in pairs(temp-A(GetAuctionItemSubClasses(class_index))) do
|
||||
for i, subclass in pairs(T.temp-T.list(GetAuctionItemSubClasses(class_index))) do
|
||||
if strupper(subclass) == strupper(item_subclass) then
|
||||
return i, subclass
|
||||
end
|
||||
@@ -402,7 +401,7 @@ function M.item_subclass_index(class_index, item_subclass)
|
||||
end
|
||||
|
||||
function M.item_slot_index(class_index, subclass_index, slot_name)
|
||||
for i, slot in pairs(temp-A(GetAuctionInvTypes(class_index, subclass_index))) do
|
||||
for i, slot in pairs(T.temp-T.list(GetAuctionInvTypes(class_index, subclass_index))) do
|
||||
if strupper(_G[slot]) == strupper(slot_name) then
|
||||
return i, _G[slot]
|
||||
end
|
||||
@@ -418,7 +417,7 @@ function M.item_quality_index(item_quality)
|
||||
end
|
||||
end
|
||||
|
||||
function M.get.inventory()
|
||||
function M.inventory()
|
||||
local bag, slot = 0, 0
|
||||
return function()
|
||||
if not GetBagName(bag) or slot >= GetContainerNumSlots(bag) then
|
||||
@@ -427,7 +426,7 @@ function M.get.inventory()
|
||||
else
|
||||
slot = slot + 1
|
||||
end
|
||||
if bag <= 4 then return A(bag, slot), bag_type(bag) end
|
||||
if bag <= 4 then return T.list(bag, slot), bag_type(bag) end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
module 'aux.util.money'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
M.GOLD_TEXT = '|cffffd70ag|r'
|
||||
M.SILVER_TEXT = '|cffc7c7cfs|r'
|
||||
M.COPPER_TEXT = '|cffeda55fc|r'
|
||||
@@ -72,7 +73,7 @@ function M.to_string(money, pad, trim, color, no_color)
|
||||
|
||||
local text
|
||||
if trim then
|
||||
local parts = temp-T
|
||||
local parts = T.temp-T.acquire()
|
||||
if gold > 0 then
|
||||
tinsert(parts, format_number(gold, false, color) .. gold_text)
|
||||
end
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
module 'aux.util.persistence'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
function M.read(schema, str)
|
||||
if schema == 'string' then
|
||||
return str
|
||||
@@ -11,9 +12,9 @@ function M.read(schema, str)
|
||||
elseif schema == 'number' then
|
||||
return tonumber(str)
|
||||
elseif type(schema) == 'table' and schema[1] == 'list' then
|
||||
return temp-read_list(schema, str)
|
||||
return T.temp-read_list(schema, str)
|
||||
elseif type(schema) == 'table' and schema[1] == 'tuple' then
|
||||
return temp-read_tuple(schema, str)
|
||||
return T.temp-read_tuple(schema, str)
|
||||
else
|
||||
error('Invalid schema.', 2)
|
||||
end
|
||||
@@ -36,7 +37,7 @@ function M.write(schema, obj)
|
||||
end
|
||||
|
||||
function read_list(schema, str)
|
||||
if str == '' then return T end
|
||||
if str == '' then return T.acquire() end
|
||||
local separator = schema[2]
|
||||
local element_type = schema[3]
|
||||
return map(split(str, separator), function(part)
|
||||
@@ -47,7 +48,7 @@ end
|
||||
function write_list(schema, list)
|
||||
local separator = schema[2]
|
||||
local element_type = schema[3]
|
||||
local parts = map(temp-copy(list), function(element)
|
||||
local parts = map(T.temp-copy(list), function(element)
|
||||
return write(element_type, element)
|
||||
end)
|
||||
return join(parts, separator)
|
||||
@@ -55,8 +56,8 @@ end
|
||||
|
||||
function read_tuple(schema, str)
|
||||
local separator = schema[2]
|
||||
local tuple = T
|
||||
local parts = temp-split(str, separator)
|
||||
local tuple = T.acquire()
|
||||
local parts = T.temp-split(str, separator)
|
||||
for i = 3, getn(schema) do
|
||||
local key, type = next(schema[i])
|
||||
tuple[key] = read(type, parts[i - 2])
|
||||
@@ -66,7 +67,7 @@ end
|
||||
|
||||
function write_tuple(schema, tuple)
|
||||
local separator = schema[2]
|
||||
local parts = temp-T
|
||||
local parts = T.temp-T.acquire()
|
||||
for i = 3, getn(schema) do
|
||||
local key, type = next(schema[i])
|
||||
tinsert(parts, write(type, tuple[key]))
|
||||
|
||||
+7
-6
@@ -1,32 +1,33 @@
|
||||
module 'aux.util.scan'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan = require 'aux.core.scan'
|
||||
|
||||
function M.test(record, index)
|
||||
local auction_record = temp-info.auction(index, record.query_type)
|
||||
local auction_record = T.temp-info.auction(index, record.query_type)
|
||||
return auction_record and auction_record.search_signature == record.search_signature
|
||||
end
|
||||
|
||||
function M.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
|
||||
local queries = A(T)
|
||||
local queries = T.list(T.acquire())
|
||||
|
||||
if auction_record.blizzard_query then
|
||||
local blizzard_query1 = copy(auction_record.blizzard_query)
|
||||
blizzard_query1.first_page = auction_record.page
|
||||
blizzard_query1.last_page = auction_record.page
|
||||
tinsert(queries, O('blizzard_query', blizzard_query1))
|
||||
tinsert(queries, T.map('blizzard_query', blizzard_query1))
|
||||
|
||||
if auction_record.page > 0 then
|
||||
local blizzard_query2 = copy(auction_record.blizzard_query)
|
||||
blizzard_query2.first_page = auction_record.page - 1
|
||||
blizzard_query2.last_page = auction_record.page - 1
|
||||
tinsert(queries, O('blizzard_query', blizzard_query2))
|
||||
tinsert(queries, T.map('blizzard_query', blizzard_query2))
|
||||
end
|
||||
|
||||
local item_query = item_query(auction_record.item_id, 0, 0)
|
||||
@@ -78,6 +79,6 @@ function M.item_query(item_id, first_page, last_page)
|
||||
local query = filter_util.query(item_info.name .. '/exact')
|
||||
query.blizzard_query.first_page = first_page
|
||||
query.blizzard_query.last_page = last_page
|
||||
return O('validator', query.validator, 'blizzard_query', query.blizzard_query)
|
||||
return T.map('validator', query.validator, 'blizzard_query', query.blizzard_query)
|
||||
end
|
||||
end
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
module 'aux.util.sort'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
M.EQ = 0
|
||||
M.LT = 1
|
||||
M.GT = 2
|
||||
@@ -17,7 +18,7 @@ function M.compare(a, b, desc)
|
||||
end
|
||||
end
|
||||
|
||||
M.multi_lt = vararg-function(arg)
|
||||
M.multi_lt = T.vararg-function(arg)
|
||||
for i = 1, getn(arg), 2 do
|
||||
if arg[i] and arg[i + 1] and arg[i] ~= arg[i + 1] then
|
||||
return arg[i] < arg[i + 1]
|
||||
|
||||
Reference in New Issue
Block a user