performance improvements
This commit is contained in:
+19
-12
@@ -83,19 +83,26 @@ function M.on_next_event(event, callback)
|
||||
event_listener(event, function(kill) callback(); kill() end)
|
||||
end
|
||||
|
||||
M.thread = vararg-function(arg)
|
||||
local k = tremove(arg, 1)
|
||||
local thread_id = unique_id
|
||||
threads[thread_id] = T('k', papply(k, unpack(arg)))
|
||||
return thread_id
|
||||
end
|
||||
do
|
||||
local mt = {
|
||||
__call = function(self)
|
||||
auto_release(self, true)
|
||||
return self.f(unpack(self))
|
||||
end,
|
||||
}
|
||||
|
||||
M.wait = vararg-function(arg)
|
||||
local k = tremove(arg, 1)
|
||||
if type(k) == 'number' then
|
||||
when(function() k = k - 1 return k <= 1 end, unpack(arg))
|
||||
else
|
||||
threads[thread_id].k = papply(k, unpack(arg))
|
||||
M.thread = vararg-function(arg)
|
||||
auto_release(arg, false)
|
||||
arg.f = tremove(arg, 1)
|
||||
local thread_id = unique_id
|
||||
threads[thread_id] = T('k', setmetatable(arg, mt))
|
||||
return thread_id
|
||||
end
|
||||
|
||||
M.wait = vararg-function(arg)
|
||||
auto_release(arg, false)
|
||||
arg.f = tremove(arg, 1)
|
||||
threads[thread_id].k = setmetatable(arg, mt)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+2
-2
@@ -171,7 +171,7 @@ function scan_wdb(item_id)
|
||||
'max_stack', max_stack,
|
||||
'texture', texture
|
||||
))
|
||||
local tooltip = info.tooltip(function(tooltip) tooltip:SetHyperlink(itemstring) end)
|
||||
local tooltip = info.tooltip('link', itemstring)
|
||||
if info.auctionable(tooltip, quality) then
|
||||
tinsert(aux_auctionable_items, strlower(name))
|
||||
end
|
||||
@@ -181,7 +181,7 @@ function scan_wdb(item_id)
|
||||
end
|
||||
|
||||
if item_id <= MAX_ITEM_ID then
|
||||
thread(wait, 10, scan_wdb, item_id)
|
||||
thread(when, later(.5), scan_wdb, item_id)
|
||||
else
|
||||
sort(aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
|
||||
end
|
||||
|
||||
+9
-9
@@ -8,36 +8,36 @@ local info = require 'aux.util.info'
|
||||
local state
|
||||
|
||||
function stack_size(slot)
|
||||
local container_item_info = info.container_item(unpack(slot))
|
||||
local container_item_info = 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 = info.container_item(unpack(slot))
|
||||
local container_item_info = temp-info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.charges
|
||||
end
|
||||
|
||||
function max_stack(slot)
|
||||
local container_item_info = info.container_item(unpack(slot))
|
||||
local container_item_info = temp-info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.max_stack
|
||||
end
|
||||
|
||||
function locked(slot)
|
||||
local container_item_info = info.container_item(unpack(slot))
|
||||
local container_item_info = temp-info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.locked
|
||||
end
|
||||
|
||||
function find_item_slot(papply)
|
||||
function find_item_slot(partial)
|
||||
for slot in info.inventory do
|
||||
if matching_item(slot, papply) and not eq(slot, state.target_slot) then
|
||||
if matching_item(slot, partial) and not eq(slot, state.target_slot) then
|
||||
return slot
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function matching_item(slot, papply)
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
return item_info and item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and (not papply or item_info.count < item_info.max_stack)
|
||||
function matching_item(slot, partial)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
return item_info and item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
|
||||
end
|
||||
|
||||
function find_empty_slot()
|
||||
|
||||
+25
-24
@@ -10,6 +10,14 @@ local disenchant = require 'aux.core.disenchant'
|
||||
local history = require 'aux.core.history'
|
||||
local auction_listing = require 'aux.gui.auction_listing'
|
||||
|
||||
local color = {
|
||||
value = {1, 1, .6},
|
||||
merchant = {.8, .5, .1},
|
||||
disenchant_source = {.7, .7, .7},
|
||||
disenchant_distribution = {.8, .8, .2},
|
||||
disenchant_value = {.1, .6, .6},
|
||||
}
|
||||
|
||||
_G.aux_tooltip_value = true
|
||||
|
||||
local game_tooltip_hooks, game_tooltip_money = t, 0
|
||||
@@ -19,7 +27,7 @@ function LOAD()
|
||||
local inside_hook = false
|
||||
for name, f in game_tooltip_hooks do
|
||||
local name, f = name, f
|
||||
hook(name, GameTooltip, function(...) auto_release(arg, true)
|
||||
hook(name, GameTooltip, vararg-function(arg)
|
||||
inside_hook = true
|
||||
game_tooltip_money = 0
|
||||
local ret = temp-A(orig[GameTooltip][name](unpack(arg)))
|
||||
@@ -29,7 +37,7 @@ function LOAD()
|
||||
end)
|
||||
end
|
||||
local orig = GameTooltip:GetScript('OnTooltipAddMoney')
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', function(...) auto_release(arg, true)
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', vararg-function(arg)
|
||||
if inside_hook then
|
||||
game_tooltip_money = arg1
|
||||
else
|
||||
@@ -38,7 +46,7 @@ function LOAD()
|
||||
end)
|
||||
end
|
||||
local orig = SetItemRef
|
||||
setglobal('SetItemRef', function(...) auto_release(arg, true)
|
||||
setglobal('SetItemRef', vararg-function(arg)
|
||||
local name, _, quality = GetItemInfo(arg[1])
|
||||
local ret = A(orig(unpack(arg)))
|
||||
if not IsShiftKeyDown() and not IsControlKeyDown() and name then
|
||||
@@ -54,64 +62,57 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
quantity = IsShiftKeyDown() and quantity or 1
|
||||
if aux_tooltip_disenchant_source then
|
||||
local color = {r=.7, g=.7, b=.7}
|
||||
local color = color.disenchant_source
|
||||
local type, range = disenchant.source(item_id)
|
||||
if type == 'CRYSTAL' then
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), color.r, color.g, color.b, true)
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), color[1], color[2], color[3], true)
|
||||
elseif type == 'SHARD' then
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cff0070ddRare|r and |cff1eff00Uncommon|r items.', range), color.r, color.g, color.b, true)
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cff0070ddRare|r and |cff1eff00Uncommon|r items.', range), color[1], color[2], color[3], true)
|
||||
elseif type == 'ESSENCE' then
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), color.r, color.g, color.b, true)
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), color[1], color[2], color[3], true)
|
||||
elseif type == 'DUST' then
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), color.r, color.g, color.b, true)
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), color[1], color[2], color[3], true)
|
||||
end
|
||||
end
|
||||
local item_info = info.item(item_id)
|
||||
local item_info = 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
|
||||
if aux_tooltip_disenchant_distribution then
|
||||
local color = {r=.8, g=.8, b=.2}
|
||||
|
||||
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
|
||||
tooltip:AddLine('Disenchants into:', unpack(color.disenchant_distribution))
|
||||
sort(distribution, function(a,b) return a.probability > b.probability end)
|
||||
for _, event in distribution do
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), color.r, color.g, color.b)
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), unpack(color.disenchant_distribution))
|
||||
end
|
||||
end
|
||||
if aux_tooltip_disenchant_value then
|
||||
local color = {r=.1, g=.6, b=.6}
|
||||
|
||||
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
|
||||
tooltip:AddLine('Disenchant Value: ' .. (disenchant_value and money.to_string2(disenchant_value) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Disenchant Value: ' .. (disenchant_value and money.to_string2(disenchant_value) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.disenchant_value))
|
||||
end
|
||||
end
|
||||
end
|
||||
if aux_tooltip_vendor_buy then
|
||||
local color = {r=.8, g=.5, b=.1}
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
if price then
|
||||
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), unpack(color.merchant))
|
||||
end
|
||||
end
|
||||
if aux_tooltip_vendor_sell then
|
||||
local color = {r=.8, g=.5, b=.1}
|
||||
local price = cache.merchant_info(item_id)
|
||||
if price ~= 0 then
|
||||
tooltip:AddLine('Vendor Sell: ' .. (price and money.to_string2(price * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Vendor Sell: ' .. (price and money.to_string2(price * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.merchant))
|
||||
end
|
||||
end
|
||||
local color = {r=1, g=1, b=.6}
|
||||
local auctionable = not item_info or info.auctionable(info.tooltip(function(tooltip) tooltip:SetHyperlink(item_info.itemstring) end), item_info.quality)
|
||||
local auctionable = not item_info or info.auctionable(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
|
||||
if aux_tooltip_value then
|
||||
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.value))
|
||||
end
|
||||
if aux_tooltip_daily then
|
||||
local market_value = history.market_value(item_key)
|
||||
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. auction_listing.percentage_historical(round(market_value / value * 100)) .. ')' or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. auction_listing.percentage_historical(round(market_value / value * 100)) .. ')' or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.value))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ do
|
||||
btn:SetPoint('BOTTOMRIGHT', -5, 5)
|
||||
gui.set_size(btn, 60, 24)
|
||||
btn:SetText('Close')
|
||||
btn:SetScript('OnClick', papply(AuxFrame.Hide, AuxFrame))
|
||||
btn:SetScript('OnClick', function() AuxFrame:Hide() end)
|
||||
close_button = btn
|
||||
end
|
||||
do
|
||||
|
||||
+5
-2
@@ -36,7 +36,7 @@ function LOAD()
|
||||
end)
|
||||
|
||||
function set_aux_dropdown_style(dropdown)
|
||||
DropDownList1Backdrop:SetBackdrop{}
|
||||
DropDownList1Backdrop:SetBackdrop(empty)
|
||||
aux_border:Show()
|
||||
aux_background:Show()
|
||||
DropDownList1:SetWidth(dropdown:GetWidth() * .9)
|
||||
@@ -109,7 +109,8 @@ do
|
||||
return orig()
|
||||
end)
|
||||
M.menu = vararg-function(arg)
|
||||
structure = static-arg
|
||||
auto_release(arg, false)
|
||||
structure = arg
|
||||
local x, y = GetCursorPosition()
|
||||
menu:ClearAllPoints()
|
||||
menu:SetPoint('BOTTOMLEFT', x + 75, y)
|
||||
@@ -187,11 +188,13 @@ function M.button(parent, text_height)
|
||||
end
|
||||
button.default_Enable = button.Enable
|
||||
function button:Enable()
|
||||
if self:IsEnabled() == 1 then return end
|
||||
self:GetFontString():SetTextColor(color.text.enabled())
|
||||
return self:default_Enable()
|
||||
end
|
||||
button.default_Disable = button.Disable
|
||||
function button:Disable()
|
||||
if self:IsEnabled() == 0 then return end
|
||||
self:GetFontString():SetTextColor(color.text.disabled())
|
||||
return self:default_Disable()
|
||||
end
|
||||
|
||||
@@ -143,6 +143,11 @@ local methods = {
|
||||
end,
|
||||
|
||||
SetData = function(st, rowData)
|
||||
for _, row in st.rowData or empty do
|
||||
for _, col in row.cols do release(col) end
|
||||
release(row.cols)
|
||||
release(row)
|
||||
end
|
||||
st.rowData = rowData
|
||||
st.updateSort = true
|
||||
st:RefreshRows()
|
||||
|
||||
+22
-9
@@ -2,23 +2,27 @@ library 'green_t'
|
||||
|
||||
local next, getn, setn, tremove, type, setmetatable = next, getn, table.setn, tremove, type, setmetatable
|
||||
|
||||
local wipe, acquire, release, auto_release
|
||||
local wipe, acquire, release, auto_release, dep_release
|
||||
do
|
||||
local pool, pool_size, overflow_pool, auto_release_queue = {}, 0, setmetatable({}, {__mode='k'}), {}
|
||||
local pool, pool_size, overflow_pool, is_auto_release, is_dep_release = {}, 0, setmetatable({}, {__mode='k'}), {}, setmetatable({}, {__mode='k'})
|
||||
|
||||
function wipe(t)
|
||||
setmetatable(t, nil)
|
||||
for k in t do t[k] = nil end
|
||||
for k, v in t do
|
||||
if is_dep_release[v] then release(v) end
|
||||
t[k] = nil
|
||||
end
|
||||
t.reset, t.reset = nil, 1
|
||||
setn(t, 0)
|
||||
end
|
||||
M.wipe = wipe
|
||||
|
||||
CreateFrame'Frame':SetScript('OnUpdate', function()
|
||||
for t in auto_release_queue do release(t) end
|
||||
wipe(auto_release_queue)
|
||||
for t in is_auto_release do release(t) end
|
||||
wipe(is_auto_release)
|
||||
end)
|
||||
|
||||
local kek = 0
|
||||
function acquire()
|
||||
if pool_size > 0 then
|
||||
pool_size = pool_size - 1
|
||||
@@ -29,13 +33,16 @@ do
|
||||
overflow_pool[t] = nil
|
||||
return t
|
||||
end
|
||||
kek = kek + 1
|
||||
if mod(kek, 100) == 0 then p(kek, debugstack()) end
|
||||
return {}
|
||||
end
|
||||
M.acquire = acquire
|
||||
|
||||
function release(t)
|
||||
wipe(t)
|
||||
auto_release_queue[t] = nil
|
||||
is_auto_release[t] = nil
|
||||
is_dep_release[t] = nil
|
||||
if pool_size < 50 then
|
||||
pool_size = pool_size + 1
|
||||
pool[pool_size] = t
|
||||
@@ -47,9 +54,15 @@ do
|
||||
|
||||
function auto_release(v, enable)
|
||||
if type(v) ~= 'table' then return end
|
||||
auto_release_queue[v] = enable and true or nil
|
||||
is_auto_release[v] = enable and true or nil
|
||||
end
|
||||
M.auto_release = auto_release
|
||||
|
||||
function dep_release(v, enable)
|
||||
if type(v) ~= 'table' then return end
|
||||
is_dep_release[v] = enable and true or nil
|
||||
end
|
||||
M.dep_release = dep_release
|
||||
end
|
||||
|
||||
M.get_t = acquire
|
||||
@@ -65,10 +78,10 @@ M.temp = setmetatable({}, {
|
||||
__newindex = nop,
|
||||
__sub = function(_, v) auto_release(v, true); return v end,
|
||||
})
|
||||
M.static = setmetatable({}, {
|
||||
M.weak = setmetatable({}, {
|
||||
__metatable = false,
|
||||
__newindex = nop,
|
||||
__sub = function(_, v) auto_release(v, false); return v end,
|
||||
__sub = function(_, v) dep_release(v, true); return v end,
|
||||
})
|
||||
|
||||
do
|
||||
|
||||
+3
-10
@@ -54,13 +54,6 @@ function M.scan_auctions()
|
||||
}
|
||||
end
|
||||
|
||||
function test(record)
|
||||
return function(index)
|
||||
local auction_info = info.auction(index, 'owner')
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local scan_id = 0
|
||||
local IDLE, SEARCHING, FOUND = t, t, t
|
||||
@@ -82,8 +75,8 @@ do
|
||||
found_index = index
|
||||
|
||||
cancel_button:SetScript('OnClick', function()
|
||||
if test(record)(index) and listing:ContainsRecord(record) then
|
||||
cancel_auction(index, papply(listing.RemoveAuctionRecord, listing, record))
|
||||
if scan_util.test(record, index) and listing:ContainsRecord(record) then
|
||||
cancel_auction(index, function() listing:RemoveAuctionRecord(record) end)
|
||||
end
|
||||
end)
|
||||
cancel_button:Enable()
|
||||
@@ -103,7 +96,7 @@ do
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
find_auction(selection.record)
|
||||
elseif state == FOUND and not test(selection.record)(found_index) then
|
||||
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
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listi
|
||||
listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
|
||||
listing:Reset()
|
||||
listing:SetHandler('OnCellClick', function(cell, button)
|
||||
if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record and cancel_button:IsEnabled() then
|
||||
if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record then
|
||||
cancel_button:Click()
|
||||
end
|
||||
end)
|
||||
|
||||
+6
-13
@@ -34,7 +34,7 @@ function M.scan_bids()
|
||||
update_listing()
|
||||
scan.start{
|
||||
type = 'bidder',
|
||||
queries = {{blizzard_query=t}},
|
||||
queries = A(T('blizzard_query', t)),
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status((page - 1) / total_pages, 0)
|
||||
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
@@ -54,13 +54,6 @@ function M.scan_bids()
|
||||
}
|
||||
end
|
||||
|
||||
function test(record)
|
||||
return function(index)
|
||||
local auction_info = info.auction(index, 'bidder')
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local scan_id = 0
|
||||
local IDLE, SEARCHING, FOUND = 1, 2, 3
|
||||
@@ -86,11 +79,11 @@ do
|
||||
|
||||
if not record.high_bidder then
|
||||
bid_button:SetScript('OnClick', function()
|
||||
if test(record)(index) and listing:ContainsRecord(record) then
|
||||
if scan_util.test(record, index) and listing:ContainsRecord(record) then
|
||||
place_bid('bidder', index, record.bid_price, record.bid_price < record.buyout_price and function()
|
||||
info.bid_update(record)
|
||||
listing:SetDatabase()
|
||||
end or papply(listing.RemoveAuctionRecord, listing, record))
|
||||
end or function() listing:RemoveAuctionRecord(record) end)
|
||||
end
|
||||
end)
|
||||
bid_button:Enable()
|
||||
@@ -100,8 +93,8 @@ do
|
||||
|
||||
if record.buyout_price > 0 then
|
||||
buyout_button:SetScript('OnClick', function()
|
||||
if test(record)(index) and listing:ContainsRecord(record) then
|
||||
place_bid('bidder', index, record.buyout_price, papply(listing.RemoveAuctionRecord, listing, record))
|
||||
if scan_util.test(record, index) and listing:ContainsRecord(record) then
|
||||
place_bid('bidder', index, record.buyout_price, function() listing:RemoveAuctionRecord(record) end)
|
||||
end
|
||||
end)
|
||||
buyout_button:Enable()
|
||||
@@ -125,7 +118,7 @@ do
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
find_auction(selection.record)
|
||||
elseif state == FOUND and not test(selection.record)(found_index) then
|
||||
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
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
|
||||
listing:Reset()
|
||||
listing:SetHandler('OnCellClick', function(cell, button)
|
||||
if IsAltKeyDown() and listing:GetSelection().record == cell.row.data.record then
|
||||
if button == 'LeftButton' and buyout_button:IsEnabled() then
|
||||
if button == 'LeftButton' then
|
||||
buyout_button:Click()
|
||||
elseif button == 'RightButton' and bid_button:IsEnabled() then
|
||||
elseif button == 'RightButton' then
|
||||
bid_button:Click()
|
||||
end
|
||||
end
|
||||
|
||||
+12
-11
@@ -146,13 +146,13 @@ function update_auction_listing()
|
||||
|
||||
tinsert(auction_rows, T(
|
||||
'cols', A(
|
||||
{value=auction_record.own and color.yellow(auction_record.count) or auction_record.count},
|
||||
{value=al.time_left(auction_record.duration)},
|
||||
{value=auction_record.stack_size == stack_size and color.yellow(auction_record.stack_size) or auction_record.stack_size},
|
||||
{value=money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color)},
|
||||
{value=historical_value and al.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'},
|
||||
{value=auction_record.unit_buyout_price > 0 and money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'},
|
||||
{value=auction_record.unit_buyout_price > 0 and historical_value and al.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---'}
|
||||
T('value', auction_record.own and color.yellow(auction_record.count) or auction_record.count),
|
||||
T('value', al.time_left(auction_record.duration)),
|
||||
T('value', auction_record.stack_size == stack_size and color.yellow(auction_record.stack_size) or auction_record.stack_size),
|
||||
T('value', money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color)),
|
||||
T('value', historical_value and al.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'),
|
||||
T('value', auction_record.unit_buyout_price > 0 and money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'),
|
||||
T('value', auction_record.unit_buyout_price > 0 and historical_value and al.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---')
|
||||
),
|
||||
'record', auction_record
|
||||
))
|
||||
@@ -343,14 +343,15 @@ function quantity_update(max_count)
|
||||
end
|
||||
|
||||
function unit_vendor_price(item_key)
|
||||
for slot in info.inventory do auto_release(slot, true)
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
for slot in info.inventory do
|
||||
auto_release(slot, true)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
if item_info and item_info.item_key == item_key then
|
||||
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||
ClearCursor()
|
||||
PickupContainerItem(unpack(slot))
|
||||
ClickAuctionSellItemButton()
|
||||
local auction_sell_item = info.auction_sell_item()
|
||||
local auction_sell_item = temp-info.auction_sell_item()
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
@@ -408,7 +409,7 @@ end
|
||||
function update_inventory_records()
|
||||
local auctionable_map = tt
|
||||
for slot in info.inventory do auto_release(slot, true)
|
||||
for item_info in present(info.container_item(unpack(slot))) do
|
||||
for item_info in present(temp-info.container_item(unpack(slot))) do
|
||||
local charge_class = item_info.charges or 0
|
||||
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||
if not auctionable_map[item_info.item_key] then
|
||||
|
||||
@@ -294,7 +294,7 @@ do
|
||||
end
|
||||
end)
|
||||
editbox.change = update_form
|
||||
editbox.enter = papply(editbox.ClearFocus, editbox)
|
||||
editbox.enter = function() editbox:ClearFocus() end
|
||||
local label = gui.label(editbox, gui.font_size.small)
|
||||
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
|
||||
label:SetText('Name')
|
||||
@@ -322,7 +322,7 @@ do
|
||||
max_level_input:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox.enter = papply(editbox.ClearFocus, editbox)
|
||||
editbox.enter = function() editbox:ClearFocus() end
|
||||
editbox.change = function()
|
||||
local valid_level = valid_level(this:GetText())
|
||||
if tostring(valid_level) ~= this:GetText() then
|
||||
@@ -348,7 +348,7 @@ do
|
||||
name_input:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox.enter = papply(editbox.ClearFocus, editbox)
|
||||
editbox.enter = function() editbox:ClearFocus() end
|
||||
editbox.change = function()
|
||||
local valid_level = valid_level(this:GetText())
|
||||
if tostring(valid_level) ~= this:GetText() then
|
||||
@@ -531,9 +531,9 @@ for _ = 1, 5 do
|
||||
local table = auction_listing.CreateAuctionResultsTable(frame.results, auction_listing.search_config)
|
||||
table:SetHandler('OnCellClick', function(cell, button)
|
||||
if IsAltKeyDown() and current_search.table:GetSelection().record == cell.row.data.record then
|
||||
if button == 'LeftButton' and buyout_button:IsEnabled() then
|
||||
if button == 'LeftButton' then
|
||||
buyout_button:Click()
|
||||
elseif button == 'RightButton' and bid_button:IsEnabled() then
|
||||
elseif button == 'RightButton' then
|
||||
bid_button:Click()
|
||||
end
|
||||
end
|
||||
|
||||
+5
-12
@@ -360,13 +360,6 @@ function M.execute(resume, real_time)
|
||||
end
|
||||
end
|
||||
|
||||
function test(record)
|
||||
return function(index)
|
||||
local auction_info = info.auction(index)
|
||||
return auction_info and auction_info.search_signature == record.search_signature
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local scan_id = 0
|
||||
local IDLE, SEARCHING, FOUND = t, t, t
|
||||
@@ -402,11 +395,11 @@ do
|
||||
|
||||
if not record.high_bidder then
|
||||
bid_button:SetScript('OnClick', function()
|
||||
if test(record)(index) and search.table:ContainsRecord(record) then
|
||||
if scan_util.test(record, index) and search.table:ContainsRecord(record) then
|
||||
place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function()
|
||||
info.bid_update(record)
|
||||
search.table:SetDatabase()
|
||||
end or papply(search.table.RemoveAuctionRecord, search.table, record))
|
||||
end or function() search.table:RemoveAuctionRecord(record) end)
|
||||
end
|
||||
end)
|
||||
bid_button:Enable()
|
||||
@@ -416,8 +409,8 @@ do
|
||||
|
||||
if record.buyout_price > 0 then
|
||||
buyout_button:SetScript('OnClick', function()
|
||||
if test(record)(index) and search.table:ContainsRecord(record) then
|
||||
place_bid('list', index, record.buyout_price, papply(search.table.RemoveAuctionRecord, search.table, record))
|
||||
if scan_util.test(record, index) and search.table:ContainsRecord(record) then
|
||||
place_bid('list', index, record.buyout_price, function() search.table:RemoveAuctionRecord(record) end)
|
||||
end
|
||||
end)
|
||||
buyout_button:Enable()
|
||||
@@ -441,7 +434,7 @@ do
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
find_auction(selection.record)
|
||||
elseif state == FOUND and not test(selection.record)(found_index) then
|
||||
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
|
||||
|
||||
@@ -80,16 +80,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
M.papply = vararg-function(arg)
|
||||
local f, arg1 = tremove(arg, 1), static-arg
|
||||
return vararg-function(arg)
|
||||
for i = 1, getn(arg) do
|
||||
tinsert(arg1, arg[i])
|
||||
end
|
||||
return f(unpack(arg1))
|
||||
end
|
||||
end
|
||||
|
||||
M.index = vararg-function(arg)
|
||||
local t = tremove(arg, 1)
|
||||
for i = 1, getn(arg) do t = t and t[arg[i]] end return t
|
||||
@@ -216,5 +206,10 @@ end
|
||||
|
||||
function M.signal()
|
||||
local params
|
||||
return vararg-function(arg) params = static-arg end, function() return params end
|
||||
return vararg-function(arg)
|
||||
auto_release(arg, false)
|
||||
params = arg
|
||||
end, function()
|
||||
return params
|
||||
end
|
||||
end
|
||||
+2
-2
@@ -241,8 +241,8 @@ do
|
||||
end
|
||||
for _, parser in temp-A(
|
||||
temp-A('class', info.item_class_index),
|
||||
temp-A('subclass', papply(info.item_subclass_index, index(self.class, 2) or 0)),
|
||||
temp-A('slot', papply(info.item_slot_index, index(self.class, 2) == 2 and 2 or 0, index(self.subclass, 2) or 0)),
|
||||
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)
|
||||
) do
|
||||
if not self[parser[1]] then
|
||||
|
||||
+21
-14
@@ -46,10 +46,10 @@ function M.container_item(bag, slot)
|
||||
for link in present(GetContainerItemLink(bag, slot)) do
|
||||
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = 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(function(tooltip) tooltip:SetBagItem(bag, slot) end)
|
||||
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
|
||||
@@ -77,7 +77,7 @@ function M.container_item(bag, slot)
|
||||
'readable', readable,
|
||||
'lootable', lootable,
|
||||
|
||||
'tooltip', tooltip,
|
||||
'tooltip', weak-tooltip,
|
||||
'tooltip_money', tooltip_money,
|
||||
'max_charges', max_charges,
|
||||
'charges', charges,
|
||||
@@ -104,12 +104,12 @@ function M.auction(index, query_type)
|
||||
|
||||
for link in present(GetAuctionItemLink(query_type, index)) do
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = 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)
|
||||
|
||||
local duration = GetAuctionItemTimeLeft(query_type, index)
|
||||
local tooltip, tooltip_money = tooltip(function(tooltip) tooltip:SetAuctionItem(query_type, index) end)
|
||||
local tooltip, tooltip_money = tooltip('auction', query_type, index)
|
||||
local max_charges = max_item_charges(item_id)
|
||||
local charges = max_charges and item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
@@ -153,7 +153,7 @@ function M.auction(index, query_type)
|
||||
'duration', duration,
|
||||
'usable', usable,
|
||||
|
||||
'tooltip', tooltip,
|
||||
'tooltip', weak-tooltip,
|
||||
'tooltip_money', tooltip_money,
|
||||
'max_charges', max_charges,
|
||||
'charges', charges,
|
||||
@@ -182,13 +182,13 @@ function M.set_shopping_tooltip(slot)
|
||||
local index1, index2 = inventory_index(slot)
|
||||
local tooltips = tt
|
||||
if index1 then
|
||||
local tooltip = tooltip(function(tooltip) tooltip:SetInventoryItem('player', index1) end)
|
||||
local tooltip = tooltip('inventory', 'player', index1)
|
||||
if getn(tooltip) > 0 then
|
||||
tinsert(tooltips, tooltip)
|
||||
end
|
||||
end
|
||||
if index2 then
|
||||
local tooltip = tooltip(function(tooltip) tooltip:SetInventoryItem('player', index2) end)
|
||||
local tooltip = tooltip('inventory', 'player', index2)
|
||||
if getn(tooltip) > 0 then
|
||||
tinsert(tooltips, tooltip)
|
||||
end
|
||||
@@ -271,20 +271,27 @@ function M.auctionable(tooltip, quality, lootable)
|
||||
and not (durability and durability < max_durability)
|
||||
end
|
||||
|
||||
function M.tooltip(setter)
|
||||
function M.tooltip(setter, arg1, arg2)
|
||||
AuxTooltip:SetOwner(UIParent, 'ANCHOR_NONE')
|
||||
AuxTooltip.money = 0
|
||||
setter(AuxTooltip)
|
||||
if setter == 'auction' then
|
||||
AuxTooltip:SetAuctionItem(arg1, arg2)
|
||||
elseif setter == 'bag' then
|
||||
AuxTooltip:SetBagItem(arg1, arg2)
|
||||
elseif setter == 'inventory' then
|
||||
AuxTooltip:SetInventoryItem(arg1, arg2)
|
||||
elseif setter == 'link' then
|
||||
AuxTooltip:SetHyperlink(arg1)
|
||||
end
|
||||
local tooltip = t
|
||||
for i = 1, AuxTooltip:NumLines() do
|
||||
tinsert(tooltip, T(
|
||||
tinsert(tooltip, weak-T(
|
||||
'left_text', _G['AuxTooltipTextLeft' .. i]:GetText(),
|
||||
'left_color', A(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'left_color', weak-A(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'right_text', _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(),
|
||||
'right_color', A(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
'right_color', weak-A(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
))
|
||||
end
|
||||
|
||||
return tooltip, AuxTooltip.money
|
||||
end
|
||||
|
||||
|
||||
+9
-11
@@ -7,18 +7,16 @@ 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)
|
||||
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 function test(index)
|
||||
local auction_info = info.auction(index, auction_record.query_type)
|
||||
return auction_info and auction_info.search_signature == auction_record.search_signature
|
||||
end
|
||||
|
||||
local queries = t
|
||||
tinsert(queries, t)
|
||||
local queries = A(t)
|
||||
|
||||
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
|
||||
@@ -48,13 +46,13 @@ function M.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
on_start_query = function(query_index)
|
||||
status_bar:update_status((query_index - 1) / getn(queries), 0)
|
||||
end,
|
||||
on_auction = function(auction_record)
|
||||
if test(auction_record.index) then
|
||||
on_auction = function(record)
|
||||
if test(auction_record, record.index) then
|
||||
found = true
|
||||
scan.stop()
|
||||
status_bar:update_status(1, 1)
|
||||
status_bar:set_text('Auction found')
|
||||
return on_success(auction_record.index)
|
||||
return on_success(record.index)
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
|
||||
Reference in New Issue
Block a user