refactoring complete
This commit is contained in:
@@ -4,10 +4,16 @@
|
||||
## SavedVariablesPerCharacter: AUX_ENABLE_ALT, AUX_OPEN_FIRST, AUX_INSTANT_BUYOUT, AUX_AUCTION_DURATION
|
||||
## SavedVariables: auxSellEntries
|
||||
core.xml
|
||||
|
||||
sell.xml
|
||||
buy.xml
|
||||
|
||||
scan.xml
|
||||
stack.xml
|
||||
post.xml
|
||||
info.xml
|
||||
util.lua
|
||||
|
||||
options.xml
|
||||
about.xml
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
local processScanResults, createOrder, updateOrder
|
||||
Aux.buy = {}
|
||||
|
||||
local record_auction, createOrder, updateOrder
|
||||
local entries
|
||||
local selectedEntries = {}
|
||||
local searchQuery
|
||||
@@ -18,14 +20,22 @@ function AuxBuySearchButton_OnClick()
|
||||
entries = nil
|
||||
selectedEntries = {}
|
||||
Aux_Buy_ScrollbarUpdate()
|
||||
searchQuery = Aux_Scan_CreateQuery{
|
||||
searchQuery = Aux.scan.create_query{
|
||||
name = AuxBuySearchBox:GetText(),
|
||||
exactMatch = true
|
||||
}
|
||||
Aux_Scan_Start{
|
||||
Aux.buy.set_message('Scanning auctions ...')
|
||||
Aux.scan.start{
|
||||
query = searchQuery,
|
||||
onComplete = function(data)
|
||||
processScanResults(data)
|
||||
on_start_page = function(i)
|
||||
Aux.buy.set_message('Scanning auctions: page ' .. i .. ' ...')
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
local auction_item = Aux.info.auction_item(i)
|
||||
local stack_size = auction_item.charges and auction_item.charges or auction_item.count
|
||||
record_auction(auction_item.name, stack_size, auction_item.buyout_price, auction_item.quality, auction_item.owner, auction_item.itemlink)
|
||||
end,
|
||||
on_complete = function()
|
||||
Aux_Buy_ScrollbarUpdate()
|
||||
end
|
||||
}
|
||||
@@ -49,6 +59,13 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux.buy.set_message(msg)
|
||||
AuxBuyMessage:SetText(msg)
|
||||
AuxBuyMessage:Show()
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function AuxBuyBuySelectedButton_OnClick()
|
||||
|
||||
AuxBuySearchButton:Disable()
|
||||
@@ -63,18 +80,22 @@ function AuxBuyBuySelectedButton_OnClick()
|
||||
|
||||
Aux_Buy_ScrollbarUpdate()
|
||||
|
||||
Aux_Scan_Start{
|
||||
Aux.buy.set_message('Scanning auctions ...')
|
||||
Aux.scan.start{
|
||||
query = searchQuery,
|
||||
onReadDatum = function(datum)
|
||||
if datum.name and datum.count and datum.buyoutPrice then
|
||||
local key = datum.name.."_"..datum.count.."_"..datum.buyoutPrice
|
||||
on_start_page = function(i)
|
||||
Aux.buy.set_message('Scanning auctions: page ' .. i .. ' ...')
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
local auction_item = Aux.info.auction_item(i)
|
||||
|
||||
if auction_item.name and auction_item.count and auction_item.buyout_price then
|
||||
local key = auction_item.name.."_"..auction_item.count.."_"..auction_item.buyout_price
|
||||
if order[key] then
|
||||
|
||||
if GetMoney() >= datum.buyoutPrice then
|
||||
PlaceAuctionBid("list", datum.pageIndex, datum.buyoutPrice)
|
||||
if GetMoney() >= auction_item.buyout_price then
|
||||
PlaceAuctionBid("list", i, auction_item.buyout_price)
|
||||
purchasedCount = purchasedCount + 1
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
if order[key] > 1 then
|
||||
@@ -82,20 +103,18 @@ function AuxBuyBuySelectedButton_OnClick()
|
||||
else
|
||||
order[key] = nil
|
||||
end
|
||||
|
||||
return false
|
||||
else
|
||||
return true
|
||||
local stack_size = auction_item.charges and auction_item.charges or auction_item.count
|
||||
record_auction(auction_item.name, stack_size, auction_item.charges, auction_item.buyout_price, auction_item.quality, auction_item.owner, auction_item.itemlink)
|
||||
end
|
||||
end
|
||||
end,
|
||||
onComplete = function(data)
|
||||
processScanResults(data)
|
||||
on_complete = function()
|
||||
Aux_Buy_ScrollbarUpdate()
|
||||
AuxBuySearchButton:Enable()
|
||||
Aux_Buy_ShowReport(true, orderedCount, purchasedCount)
|
||||
end,
|
||||
onAbort = function()
|
||||
on_abort = function()
|
||||
AuxBuySearchButton:Enable()
|
||||
Aux_Buy_ShowReport(false, orderedCount, purchasedCount)
|
||||
end
|
||||
@@ -138,22 +157,18 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function processScanResults(rawData)
|
||||
|
||||
entries = {}
|
||||
|
||||
for _,rawDatum in ipairs(rawData) do
|
||||
|
||||
if rawDatum.buyoutPrice > 0 and rawDatum.owner ~= UnitName("player") then
|
||||
tinsert(entries, {
|
||||
name = rawDatum.name,
|
||||
stackSize = rawDatum.count,
|
||||
buyoutPrice = rawDatum.buyoutPrice,
|
||||
itemPrice = rawDatum.buyoutPrice / rawDatum.count,
|
||||
quality = rawDatum.quality,
|
||||
itemLink = rawDatum.itemLink,
|
||||
})
|
||||
end
|
||||
function record_auction(name, stack_size, buyout_price, quality, owner, itemlink)
|
||||
entries = entries or {}
|
||||
|
||||
if buyout_price > 0 and owner ~= UnitName("player") then
|
||||
tinsert(entries, {
|
||||
name = name,
|
||||
stackSize = stack_size,
|
||||
buyoutPrice = buyout_price,
|
||||
itemPrice = buyout_price / stack_size,
|
||||
quality = quality,
|
||||
itemLink = itemlink,
|
||||
})
|
||||
end
|
||||
|
||||
table.sort(entries, function(a,b) return a.itemPrice < b.itemPrice end)
|
||||
@@ -163,7 +178,7 @@ end
|
||||
|
||||
function Aux_Buy_ScrollbarUpdate()
|
||||
if entries and getn(entries) == 0 then
|
||||
Aux_SetMessage("No auctions were found")
|
||||
Aux.sell.set_message("No auctions were found")
|
||||
else
|
||||
AuxBuyMessage:Hide()
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
|
||||
<Script file="Buy.lua"/>
|
||||
<Script file="buy.lua"/>
|
||||
|
||||
<Button name="AuxBuyEntryTemplate" virtual="true" hidden="true">
|
||||
<Size><AbsDimension y="16"/></Size>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
AuxVersion = "1.1.2"
|
||||
AuxAuthors = "shirsig; Zerf; Zirco (AUX); Nimeral (AUX backport)"
|
||||
AuxVersion = "1.2.0"
|
||||
AuxAuthors = "shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)"
|
||||
|
||||
local lastRightClickAction = GetTime()
|
||||
|
||||
@@ -157,7 +157,7 @@ function Aux_SetupHookFunctions()
|
||||
BrowseButton8:SetScript("OnMouseDown", Aux_BrowseButton_OnMouseDown)
|
||||
|
||||
Aux.orig.AuctionSellItemButton_OnEvent = AuctionSellItemButton_OnEvent
|
||||
AuctionSellItemButton_OnEvent = Aux_AuctionSellItemButton_OnEvent
|
||||
AuctionSellItemButton_OnEvent = Aux.sell.AuctionSellItemButton_OnEvent
|
||||
|
||||
Aux.orig.AuctionFrameTab_OnClick = AuctionFrameTab_OnClick
|
||||
AuctionFrameTab_OnClick = Aux_AuctionFrameTab_OnClick
|
||||
@@ -172,7 +172,7 @@ function Aux_SetupHookFunctions()
|
||||
AuctionFrameAuctions_Update = Aux_AuctionFrameAuctions_Update
|
||||
|
||||
Aux.orig.AuctionsCreateAuctionButton_OnClick = AuctionsCreateAuctionButton:GetScript('OnClick')
|
||||
AuctionsCreateAuctionButton:SetScript('OnClick', Aux_AuctionsCreateAuctionButton_OnClick)
|
||||
AuctionsCreateAuctionButton:SetScript('OnClick', Aux.sell.AuctionsCreateAuctionButton_OnClick)
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@@ -193,8 +193,8 @@ function Aux_OnAuctionHouseClosed()
|
||||
|
||||
Aux.post.stop()
|
||||
Aux.stack.stop()
|
||||
if not Aux_Scan_IsIdle() then
|
||||
Aux_Scan_Abort()
|
||||
if not Aux.scan.idle() then
|
||||
Aux.scan.abort()
|
||||
end
|
||||
|
||||
AuxOptionsButtonPanel:Hide()
|
||||
@@ -215,8 +215,8 @@ function Aux_AuctionFrameTab_OnClick(index)
|
||||
|
||||
Aux.post.stop()
|
||||
Aux.stack.stop()
|
||||
if not Aux_Scan_IsIdle() then
|
||||
Aux_Scan_Abort()
|
||||
if not Aux.scan.idle() then
|
||||
Aux.scan.abort()
|
||||
end
|
||||
AuxSellPanel:Hide()
|
||||
AuxBuyPanel:Hide()
|
||||
@@ -231,7 +231,7 @@ function Aux_AuctionFrameTab_OnClick(index)
|
||||
|
||||
if index == Aux.tabs.sell.index then
|
||||
AuctionFrameTab_OnClick(3)
|
||||
Aux_Sell_OnOpen()
|
||||
Aux.sell.on_open()
|
||||
|
||||
PanelTemplates_SetTab(AuctionFrame, Aux.tabs.sell.index)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
|
||||
<Script file="Core.lua"/>
|
||||
<Script file="core.lua"/>
|
||||
|
||||
<!-- Frame to handle all core events -->
|
||||
<Frame>
|
||||
|
||||
@@ -1,107 +1,121 @@
|
||||
Aux.info = {}
|
||||
|
||||
local link_item, id, tooltip, charges
|
||||
local itemlink_item, item_id, item_charges
|
||||
|
||||
function Aux.info.container_item(bag, slot)
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
local container_item = link_item(link)
|
||||
local itemlink = GetContainerItemLink(bag, slot)
|
||||
local container_item = itemlink_item(itemlink)
|
||||
|
||||
local texture, itemCount, locked, quality, readable, lootable, itemLink = GetContainerItemInfo(bagID, slot)
|
||||
local texture, count, locked, quality, readable, lootable, itemlink = GetContainerItemInfo(bag, slot)
|
||||
container_item.texture = texture
|
||||
container_item.count = count
|
||||
container_item.locked = locked
|
||||
container_item.readable = readable
|
||||
container_item.lootable = lootable
|
||||
container_item.itemlink = itemlink
|
||||
|
||||
container_item.tooltip = tooltip(GameTooltip.SetBagItem(bag, slot))
|
||||
container_item.charges = charges(container_item.tooltip)
|
||||
container_item.tooltip = Aux.info.tooltip(function(tt) tt:SetBagItem(bag, slot) end)
|
||||
container_item.charges = item_charges(container_item.tooltip)
|
||||
|
||||
return container_item
|
||||
end
|
||||
|
||||
function Aux.info.auction_sell_item()
|
||||
local name, texture, count, quality, canUse, price, pricePerUnit, stackCount, totalCount = GetAuctionSellItemInfo()
|
||||
local name, texture, count, quality, usable, price, unit_price, max_stack, total_count = GetAuctionSellItemInfo()
|
||||
auction_sell_item = {
|
||||
name = name,
|
||||
texture = texture,
|
||||
count = count,
|
||||
quality = quality,
|
||||
can_use = canUse,
|
||||
usable = usable,
|
||||
price = price,
|
||||
unit_price = pricePerUnit,
|
||||
max_stack = stackCount,
|
||||
total_count = totalCount,
|
||||
unit_price = unit_price,
|
||||
max_stack = max_stack,
|
||||
total_count = total_count,
|
||||
}
|
||||
|
||||
auction_sell_item.tooltip = tooltip(GameTooltip.SetAuctionSellItem)
|
||||
auction_sell_item.charges = charges(auction_sell_item.tooltip)
|
||||
auction_sell_item.tooltip = Aux.info.tooltip(function(tt) tt:SetAuctionSellItem() end)
|
||||
auction_sell_item.charges = item_charges(auction_sell_item.tooltip)
|
||||
|
||||
return auction_sell_item
|
||||
end
|
||||
|
||||
function Aux.info.auction_item(index)
|
||||
local link = GetAuctionItemLink("list", index)
|
||||
local auction_item = item(link)
|
||||
local itemlink = GetAuctionItemLink("list", index)
|
||||
local auction_item = itemlink_item(itemlink)
|
||||
|
||||
local name, texture, count, quality, usable, level, min_bid, min_increment, buyout_price, bid_amount, high_bidder, owner, sale_status, id, has_all_info = GetAuctionItemInfo("list", index)
|
||||
local duration = GetAuctionItemTimeLeft("list", index)
|
||||
|
||||
local _, texture, count, _, canUse, level, levelColHeader, minBid, minIncrement, buyoutPrice, bidAmount, highBidder, owner, saleStatus, itemId, hasAllInfo = GetAuctionItemInfo("list", index)
|
||||
auction_item.texture = texture
|
||||
auction_item.count = count
|
||||
auction_item.min_bid = minBid
|
||||
auction_item.bid_amount = bidAmount
|
||||
auction_item.buyout = buyoutPrice
|
||||
auction_item.min_bid = min_bid
|
||||
auction_item.min_increment = min_increment
|
||||
auction_item.buyout_price = buyout_price
|
||||
auction_item.bid_amount = bid_amount
|
||||
auction_item.high_bidder = high_bidder
|
||||
auction_item.owner = owner
|
||||
auction_item.sale_status = sale_status
|
||||
auction_item.id = id
|
||||
auction_item.has_all_info = has_all_info
|
||||
auction_item.duration = duration
|
||||
|
||||
auction_item.tooltip = tooltip(GameTooltip.SetAuctionItem("list", index)
|
||||
auction_item.charges = charges(auction_item.tooltip)
|
||||
auction_item.tooltip = Aux.info.tooltip(function(tt) tt:SetAuctionItem("list", index) end)
|
||||
auction_item.charges = item_charges(auction_item.tooltip)
|
||||
|
||||
return auction_item
|
||||
end
|
||||
|
||||
function charges(tooltip)
|
||||
function Aux.info.tooltip(setter)
|
||||
for j = 1, 30 do
|
||||
leftEntry = getglobal('AuxInfoTooltipTextLeft'..j):SetText()
|
||||
rightEntry = getglobal('AuxInfoTooltipTextRight'..j):SetText()
|
||||
end
|
||||
|
||||
AuxInfoTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
setter(AuxInfoTooltip)
|
||||
AuxInfoTooltip:Show()
|
||||
|
||||
local tooltip = {}
|
||||
for j = 1, 30 do
|
||||
local leftEntry = getglobal('AuxInfoTooltipTextLeft'..j):GetText()
|
||||
if leftEntry then
|
||||
tinsert(tooltip, leftEntry)
|
||||
end
|
||||
local rightEntry = getglobal('AuxInfoTooltipTextRight'..j):GetText()
|
||||
if rightEntry then
|
||||
tinsert(tooltip, rightEntry)
|
||||
end
|
||||
end
|
||||
|
||||
for j = 1, 30 do
|
||||
leftEntry = getglobal('AuxInfoTooltipTextLeft'..j):SetText()
|
||||
rightEntry = getglobal('AuxInfoTooltipTextRight'..j):SetText()
|
||||
end
|
||||
|
||||
return tooltip
|
||||
end
|
||||
|
||||
function item_charges(tooltip)
|
||||
for _, entry in ipairs(tooltip) do
|
||||
local chargesString = gsub(entry, "(%d+) Charges", "%1")
|
||||
return tonumber(chargesString)
|
||||
local charges_string = gsub(entry, "(%d+) Charges", "%1")
|
||||
local charges = tonumber(charges_string)
|
||||
if charges then
|
||||
return charges
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function tooltip(setter)
|
||||
for j=1, 30 do
|
||||
leftEntry = getglobal('AuxScanTooltipTextLeft'..j):SetText()
|
||||
rightEntry = getglobal('AuxScanTooltipTextRight'..j):SetText()
|
||||
end
|
||||
AuxScanTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
AuxScanTooltip:setter()
|
||||
AuxScanTooltip:Show()
|
||||
local tooltip = Aux_Scan_ExtractTooltip()
|
||||
|
||||
local tooltip = {}
|
||||
for j=1, 30 do
|
||||
local leftEntry = getglobal('AuxScanTooltipTextLeft'..j):GetText()
|
||||
if leftEntry then
|
||||
tinsert(tooltip, leftEntry)
|
||||
end
|
||||
local rightEntry = getglobal('AuxScanTooltipTextRight'..j):GetText()
|
||||
if rightEntry then
|
||||
tinsert(tooltip, rightEntry)
|
||||
end
|
||||
end
|
||||
|
||||
for j=1, 30 do
|
||||
leftEntry = getglobal('AuxScanTooltipTextLeft'..j):SetText()
|
||||
rightEntry = getglobal('AuxScanTooltipTextRight'..j):SetText()
|
||||
end
|
||||
return tooltip
|
||||
end
|
||||
|
||||
function id(itemlink)
|
||||
local id_string = string.gsub(itemLink, "^.-:(%d*).*", "%1")
|
||||
function item_id(itemlink)
|
||||
local id_string = string.gsub(itemlink, "^.-:(%d*).*", "%1")
|
||||
return tonumber(id_string)
|
||||
end
|
||||
|
||||
function link_item(link)
|
||||
local name, link, quality, level, type, subtype, max_stack = GetItemInfo(id(link))
|
||||
function itemlink_item(itemlink)
|
||||
local name, link, quality, level, type, subtype, max_stack = GetItemInfo(item_id(itemlink))
|
||||
return {
|
||||
name = name,
|
||||
link = link,
|
||||
itemlink = itemlink,
|
||||
quality = quality,
|
||||
level = level,
|
||||
type = type,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
|
||||
<Script file="info.lua"/>
|
||||
|
||||
<GameTooltip name="AuxInfoTooltip" inherits="GameTooltipTemplate"/>
|
||||
</Ui>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
|
||||
<Script file="Options.lua"/>
|
||||
<Script file="options.lua"/>
|
||||
|
||||
<Frame name="AuxOptionsButtonTemplate" virtual="true" hidden="true">
|
||||
<Size>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
Aux.scan = {}
|
||||
|
||||
local STATE_IDLE = 0
|
||||
local STATE_PREQUERY = 1
|
||||
local STATE_POSTQUERY = 2
|
||||
@@ -9,8 +11,6 @@ local currentJob
|
||||
local currentPage
|
||||
local state = STATE_IDLE
|
||||
|
||||
local scanData
|
||||
|
||||
local timeOfLastUpdate = GetTime()
|
||||
|
||||
-- forward declaration of local functions
|
||||
@@ -18,58 +18,77 @@ local submitQuery, processQueryResults
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_IsIdle()
|
||||
function Aux.scan.on_event()
|
||||
if event == "AUCTION_ITEM_LIST_UPDATE" then
|
||||
if state == STATE_POSTQUERY then
|
||||
state = STATE_PROCESSING
|
||||
processQueryResults()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux.scan.on_update()
|
||||
if state == STATE_PREQUERY and GetTime() - timeOfLastUpdate > 0.5 then
|
||||
|
||||
timeOfLastUpdate = GetTime()
|
||||
|
||||
if CanSendAuctionQuery() then
|
||||
submitQuery()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux.scan.idle()
|
||||
return state == STATE_IDLE
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_Complete()
|
||||
function Aux.scan.complete()
|
||||
if state ~= STATE_IDLE then
|
||||
if currentJob.onComplete then
|
||||
currentJob.onComplete(scanData)
|
||||
if currentJob.on_complete then
|
||||
currentJob.on_complete()
|
||||
end
|
||||
|
||||
currentJob = nil
|
||||
currentPage = nil
|
||||
scanData = nil
|
||||
state = STATE_IDLE
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_Abort()
|
||||
function Aux.scan.abort()
|
||||
if state ~= STATE_IDLE then
|
||||
if currentJob and currentJob.onAbort then
|
||||
currentJob.onAbort()
|
||||
if currentJob and currentJob.on_abort then
|
||||
currentJob.on_abort()
|
||||
end
|
||||
|
||||
currentJob = nil
|
||||
currentPage = nil
|
||||
scanData = nil
|
||||
state = STATE_IDLE
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_Start(job)
|
||||
|
||||
Aux_SetMessage("Scanning auctions ...")
|
||||
function Aux.scan.start(job)
|
||||
|
||||
if state ~= STATE_IDLE then
|
||||
Aux_Scan_Abort()
|
||||
Aux.scan.abort()
|
||||
end
|
||||
|
||||
currentJob = job
|
||||
scanData = {}
|
||||
state = STATE_PREQUERY
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_CreateQuery(parameterMap)
|
||||
function Aux.scan.create_query(parameterMap)
|
||||
local query = {
|
||||
name = nil,
|
||||
minLevel = "",
|
||||
@@ -108,125 +127,23 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_ClearTooltip()
|
||||
for j=1, 30 do
|
||||
leftEntry = getglobal('AuxScanTooltipTextLeft'..j):SetText()
|
||||
rightEntry = getglobal('AuxScanTooltipTextRight'..j):SetText()
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_ExtractTooltip()
|
||||
local tooltip = {}
|
||||
for j=1, 30 do
|
||||
local leftEntry = getglobal('AuxScanTooltipTextLeft'..j):GetText()
|
||||
if leftEntry then
|
||||
tinsert(tooltip, leftEntry)
|
||||
end
|
||||
local rightEntry = getglobal('AuxScanTooltipTextRight'..j):GetText()
|
||||
if rightEntry then
|
||||
tinsert(tooltip, rightEntry)
|
||||
end
|
||||
end
|
||||
return tooltip
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_ItemCharges(tooltip)
|
||||
for _, entry in ipairs(tooltip) do
|
||||
local chargesString = gsub(entry, "(%d+) Charges", "%1")
|
||||
local charges = tonumber(chargesString)
|
||||
if charges then
|
||||
return charges
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function processQueryResults()
|
||||
|
||||
-- SortAuctionItems("list", "buyout")
|
||||
-- if IsAuctionSortReversed("list", "buyout") then
|
||||
-- SortAuctionItems("list", "buyout")
|
||||
-- end
|
||||
|
||||
local numBatchAuctions, totalAuctions = GetNumAuctionItems("list")
|
||||
|
||||
Aux_SetMessage("Scanning auctions: page "..currentPage.." ...")
|
||||
if currentJob.on_start_page then
|
||||
currentJob.on_start_page(currentPage)
|
||||
end
|
||||
|
||||
for i = 1, numBatchAuctions do
|
||||
|
||||
local name, texture, count, quality, canUse, level, minBid, minIncrement, buyoutPrice, bidAmount, highBidder, owner = GetAuctionItemInfo("list", i)
|
||||
local itemLink = GetAuctionItemLink("list", i)
|
||||
|
||||
local duration = GetAuctionItemTimeLeft("list", i)
|
||||
Aux_Scan_ClearTooltip()
|
||||
AuxScanTooltip:SetOwner(UIParent, "ANCHOR_NONE");
|
||||
AuxScanTooltip:SetAuctionItem("list", i)
|
||||
AuxScanTooltip:Show()
|
||||
local tooltip = Aux_Scan_ExtractTooltip()
|
||||
-- for _, x in ipairs(tooltip) do Aux_Log(x) end
|
||||
count = Aux_Scan_ItemCharges(tooltip) or count
|
||||
|
||||
local scanDatum = {
|
||||
name = name,
|
||||
texture = texture,
|
||||
count = count,
|
||||
quality = quality,
|
||||
canUse = canUse,
|
||||
level = level,
|
||||
minBid = minBid,
|
||||
minIncrement = minIncrement,
|
||||
buyoutPrice = buyoutPrice,
|
||||
bidAmount = bidAmount,
|
||||
highBidder = highBidder,
|
||||
owner = owner,
|
||||
duration = duration,
|
||||
itemLink = itemLink,
|
||||
page = currentPage,
|
||||
pageIndex = i
|
||||
}
|
||||
|
||||
if currentJob.onReadDatum then
|
||||
local keepDatum = currentJob.onReadDatum(scanDatum)
|
||||
if keepDatum then
|
||||
tinsert(scanData, scanDatum)
|
||||
end
|
||||
else
|
||||
tinsert(scanData, scanDatum)
|
||||
for i = 1, numBatchAuctions do
|
||||
if currentJob.on_read_auction then
|
||||
currentJob.on_read_auction(i)
|
||||
end
|
||||
end
|
||||
|
||||
if numBatchAuctions == NUM_AUCTION_ITEMS_PER_PAGE then
|
||||
state = STATE_PREQUERY
|
||||
else
|
||||
Aux_Scan_Complete()
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_OnEvent()
|
||||
if event == "AUCTION_ITEM_LIST_UPDATE" then
|
||||
if state == STATE_POSTQUERY then
|
||||
state = STATE_PROCESSING
|
||||
processQueryResults()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Scan_OnUpdate()
|
||||
if state == STATE_PREQUERY and GetTime() - timeOfLastUpdate > 0.5 then
|
||||
|
||||
timeOfLastUpdate = GetTime()
|
||||
|
||||
if CanSendAuctionQuery() then
|
||||
submitQuery()
|
||||
end
|
||||
Aux.scan.complete()
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
|
||||
<Script file="Scan.lua"/>
|
||||
<Script file="scan.lua"/>
|
||||
|
||||
<!-- Frame to handle all core events -->
|
||||
<Frame>
|
||||
@@ -9,12 +9,11 @@
|
||||
this:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
|
||||
</OnLoad>
|
||||
<OnEvent>
|
||||
Aux_Scan_OnEvent()
|
||||
Aux.scan.on_event()
|
||||
</OnEvent>
|
||||
<OnUpdate>
|
||||
Aux_Scan_OnUpdate()
|
||||
Aux.scan.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<GameTooltip name="AuxScanTooltip" inherits="GameTooltipTemplate"/>
|
||||
</Ui>
|
||||
@@ -1,3 +1,5 @@
|
||||
Aux.sell = {}
|
||||
|
||||
auxSellEntries = {} -- persisted
|
||||
|
||||
-----------------------------------------
|
||||
@@ -8,11 +10,11 @@ local currentAuction
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
local processScanResults, undercut, ItemType2AuctionClass, SubType2AuctionSubclass
|
||||
local record_auction, undercut, ItemType2AuctionClass, SubType2AuctionSubclass
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_Sell_OnOpen()
|
||||
function Aux.sell.on_open()
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@@ -62,9 +64,9 @@ end
|
||||
-- that we can note the auction values
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_AuctionsCreateAuctionButton_OnClick()
|
||||
function Aux.sell.AuctionsCreateAuctionButton_OnClick()
|
||||
if PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.sell.index then
|
||||
local name, stackSize, buyoutPrice = currentAuction.name, currentAuction.stackSize, MoneyInputFrame_GetCopper(BuyoutPrice)
|
||||
local name, stack_size, buyout_price = currentAuction.name, currentAuction.stackSize, MoneyInputFrame_GetCopper(BuyoutPrice)
|
||||
local duration
|
||||
if AuctionFrameAuctions.duration == 120 then
|
||||
duration = 2
|
||||
@@ -82,32 +84,11 @@ function Aux_AuctionsCreateAuctionButton_OnClick()
|
||||
MoneyInputFrame_GetCopper(BuyoutPrice),
|
||||
currentAuction.stackCount,
|
||||
function(posted)
|
||||
if posted > 0 and buyoutPrice > 0 then
|
||||
auxSellEntries[name] = auxSellEntries[name] or { created=GetTime() }
|
||||
local entry
|
||||
for _, existingEntry in ipairs(auxSellEntries[name]) do
|
||||
if existingEntry.buyoutPrice == buyoutPrice and existingEntry.stackSize == stackSize then
|
||||
existingEntry.count = existingEntry.count + posted
|
||||
existingEntry.numYours = existingEntry.numYours + posted
|
||||
existingEntry.maxTimeLeft = max(existingEntry.maxTimeLeft, duration)
|
||||
entry = existingEntry
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = {
|
||||
stackSize = stackSize,
|
||||
buyoutPrice = buyoutPrice,
|
||||
itemPrice = buyoutPrice / stackSize,
|
||||
maxTimeLeft = duration,
|
||||
count = posted,
|
||||
numYours = posted,
|
||||
}
|
||||
tinsert(auxSellEntries[name], entry)
|
||||
table.sort(auxSellEntries[name], function(a,b) return a.itemPrice < b.itemPrice end)
|
||||
end
|
||||
auxSellEntries[name].selected = entry
|
||||
Aux_UpdateRecommendation()
|
||||
for i = 1, posted do
|
||||
record_auction(name, stack_size, buyout_price, duration, UnitName("player"))
|
||||
end
|
||||
auxSellEntries[name].selected = entry
|
||||
Aux_UpdateRecommendation()
|
||||
end
|
||||
)
|
||||
else
|
||||
@@ -117,19 +98,17 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_AuctionSellItemButton_OnEvent()
|
||||
function Aux.sell.AuctionSellItemButton_OnEvent()
|
||||
Aux.orig.AuctionSellItemButton_OnEvent()
|
||||
Aux_OnNewAuctionUpdate()
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Aux_SetMessage(msg)
|
||||
function Aux.sell.set_message(msg)
|
||||
Aux_HideElems(Aux.tabs.sell.recommendationElements)
|
||||
AuxMessage:SetText(msg)
|
||||
AuxMessage:Show()
|
||||
AuxBuyMessage:SetText(msg) -- TODO doesn't belong here
|
||||
AuxBuyMessage:Show()
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@@ -171,7 +150,7 @@ function Aux_UpdateRecommendation()
|
||||
|
||||
Aux_Sell_SetStackSize(0)
|
||||
Aux_Sell_SetStackCount(0)
|
||||
Aux_SetMessage("Drag an item to the Auction Item area\n\nto see recommended pricing information")
|
||||
Aux.sell.set_message("Drag an item to the Auction Item area\n\nto see recommended pricing information")
|
||||
else
|
||||
AuxSellRefreshButton:Enable()
|
||||
|
||||
@@ -224,7 +203,7 @@ function Aux_UpdateRecommendation()
|
||||
AuxRecommendBasisText:SetText("(based on auction selected below)")
|
||||
end
|
||||
elseif auxSellEntries[currentAuction.name] then
|
||||
Aux_SetMessage("No auctions were found for \n\n"..currentAuction.name)
|
||||
Aux.sell.set_message("No auctions were found for \n\n"..currentAuction.name)
|
||||
auxSellEntries[currentAuction.name] = nil
|
||||
else
|
||||
Aux_HideElems(Aux.tabs.sell.shownElements)
|
||||
@@ -278,22 +257,16 @@ function Aux_OnNewAuctionUpdate()
|
||||
return
|
||||
end
|
||||
|
||||
if not Aux_Scan_IsIdle() then
|
||||
Aux_Scan_Abort()
|
||||
if not Aux.scan.idle() then
|
||||
Aux.scan.abort()
|
||||
end
|
||||
|
||||
local auctionItemName, auctionItemTexture, auctionItemStackSize = GetAuctionSellItemInfo()
|
||||
|
||||
Aux_Scan_ClearTooltip()
|
||||
AuxScanTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
AuxScanTooltip:SetAuctionSellItem()
|
||||
AuxScanTooltip:Show()
|
||||
local tooltip = Aux_Scan_ExtractTooltip()
|
||||
|
||||
currentAuction = auctionItemName and {
|
||||
name = auctionItemName,
|
||||
texture = auctionItemTexture,
|
||||
stackSize = Aux_Scan_ItemCharges(tooltip) or auctionItemStackSize,
|
||||
stackSize = Aux.info.auction_sell_item().charges or auctionItemStackSize,
|
||||
stackCount = 1,
|
||||
}
|
||||
|
||||
@@ -316,17 +289,27 @@ function Aux_RefreshEntries()
|
||||
local currentAuctionClass = ItemType2AuctionClass(sType)
|
||||
local currentAuctionSubclass = nil -- SubType2AuctionSubclass(currentAuctionClass, sSubType)
|
||||
|
||||
Aux_Scan_Start{
|
||||
query = Aux_Scan_CreateQuery{
|
||||
Aux.sell.set_message('Scanning auctions ...')
|
||||
Aux.scan.start{
|
||||
query = Aux.scan.create_query{
|
||||
name = currentAuction.name,
|
||||
classIndex = currentAuctionClass,
|
||||
subclassIndex = currentAuctionSubclass
|
||||
},
|
||||
onComplete = function(data)
|
||||
processScanResults(data, currentAuction.name)
|
||||
on_start_page = function(i)
|
||||
Aux.sell.set_message('Scanning auctions: page ' .. i .. ' ...')
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
local auction_item = Aux.info.auction_item(i)
|
||||
if auction_item.name == currentAuction.name then
|
||||
local stack_size = auction_item.charges and auction_item.charges or auction_item.count
|
||||
record_auction(auction_item.name, stack_size, auction_item.buyout_price, auction_item.duration, auction_item.owner)
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
Aux_SelectAuxEntry()
|
||||
Aux_UpdateRecommendation()
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -424,8 +407,8 @@ end
|
||||
-----------------------------------------
|
||||
|
||||
function AuxSellRefreshButton_OnClick()
|
||||
if not Aux_Scan_IsIdle() then
|
||||
Aux_Scan_Abort()
|
||||
if not Aux.scan.idle() then
|
||||
Aux.scan.abort()
|
||||
end
|
||||
Aux_RefreshEntries()
|
||||
Aux_SelectAuxEntry()
|
||||
@@ -447,46 +430,32 @@ end
|
||||
|
||||
--*****************************************************************]]
|
||||
|
||||
function processScanResults(rawData, auctionItemName)
|
||||
|
||||
auxSellEntries[auctionItemName] = { created=GetTime() }
|
||||
|
||||
----- Condense the scan rawData into a table that has only a single entry per stacksize/price combo
|
||||
|
||||
local condData = {}
|
||||
|
||||
for _, rawDatum in ipairs(rawData) do
|
||||
if auctionItemName == rawDatum.name and rawDatum.buyoutPrice > 0 then
|
||||
local key = "_"..rawDatum.count.."_"..rawDatum.buyoutPrice
|
||||
|
||||
if not condData[key] then
|
||||
condData[key] = {
|
||||
stackSize = rawDatum.count,
|
||||
buyoutPrice = rawDatum.buyoutPrice,
|
||||
itemPrice = rawDatum.buyoutPrice / rawDatum.count,
|
||||
maxTimeLeft = rawDatum.duration,
|
||||
count = 1,
|
||||
numYours = rawDatum.owner == UnitName("player") and 1 or 0
|
||||
}
|
||||
else
|
||||
condData[key].maxTimeLeft = math.max(condData[key].maxTimeLeft, rawDatum.duration)
|
||||
condData[key].count = condData[key].count + 1
|
||||
if rawDatum.owner == UnitName("player") then
|
||||
condData[key].numYours = condData[key].numYours + 1
|
||||
end
|
||||
function record_auction(name, stack_size, buyout_price, duration, owner)
|
||||
if buyout_price > 0 then
|
||||
auxSellEntries[name] = auxSellEntries[name] or { created = GetTime() }
|
||||
local entry
|
||||
for _, existingEntry in ipairs(auxSellEntries[name]) do
|
||||
if existingEntry.buyoutPrice == buyout_price and existingEntry.stackSize == stack_size then
|
||||
entry = existingEntry
|
||||
end
|
||||
end
|
||||
if entry then
|
||||
entry.count = entry.count + 1
|
||||
entry.numYours = entry.numYours + (owner == UnitName("player") and 1 or 0)
|
||||
entry.maxTimeLeft = max(entry.maxTimeLeft, duration)
|
||||
else
|
||||
entry = {
|
||||
stackSize = stack_size,
|
||||
buyoutPrice = buyout_price,
|
||||
itemPrice = buyout_price / stack_size,
|
||||
maxTimeLeft = duration,
|
||||
count = 1,
|
||||
numYours = owner == UnitName("player") and 1 or 0,
|
||||
}
|
||||
tinsert(auxSellEntries[name], entry)
|
||||
table.sort(auxSellEntries[name], function(a,b) return a.itemPrice < b.itemPrice end)
|
||||
end
|
||||
end
|
||||
|
||||
----- create a table of these entries sorted by itemPrice
|
||||
|
||||
local n = 1
|
||||
for _, condDatum in pairs(condData) do
|
||||
auxSellEntries[auctionItemName][n] = condDatum
|
||||
n = n + 1
|
||||
end
|
||||
|
||||
table.sort(auxSellEntries[auctionItemName], function(a,b) return a.itemPrice < b.itemPrice end)
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||
|
||||
<Script file="Sell.lua"/>
|
||||
<Script file="sell.lua"/>
|
||||
|
||||
<!-- Frame to handle all core events -->
|
||||
<Frame>
|
||||
|
||||
@@ -98,12 +98,7 @@ function stack_size(slot)
|
||||
end
|
||||
|
||||
function item_charges(slot)
|
||||
Aux_Scan_ClearTooltip()
|
||||
AuxScanTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
AuxScanTooltip:SetBagItem(slot.bag, slot.bag_slot)
|
||||
AuxScanTooltip:Show()
|
||||
local tooltip = Aux_Scan_ExtractTooltip()
|
||||
return Aux_Scan_ItemCharges(tooltip)
|
||||
return Aux.info.container_item(slot.bag, slot.bag_slot).charges
|
||||
end
|
||||
|
||||
function Aux.stack.onupdate()
|
||||
|
||||
Reference in New Issue
Block a user