Merge branch 'master' of https://github.com/shirsig/Auctionator-Vanilla
This commit is contained in:
+23
-28
@@ -22,8 +22,6 @@ Auctionator = {
|
||||
}
|
||||
}
|
||||
|
||||
local timeOfLastUpdate = GetTime()
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
local Auctionator_Orig_AuctionFrameBrowse_Update
|
||||
@@ -56,11 +54,9 @@ function Auctionator_EventHandler()
|
||||
|
||||
if event == "VARIABLES_LOADED" then Auctionator_OnLoad() end
|
||||
if event == "ADDON_LOADED" then Auctionator_OnAddonLoaded() end
|
||||
if event == "AUCTION_ITEM_LIST_UPDATE" then Auctionator_OnAuctionUpdate() end
|
||||
if event == "AUCTION_OWNED_LIST_UPDATE" then Auctionator_OnAuctionOwnedUpdate() end
|
||||
if event == "AUCTION_HOUSE_SHOW" then Auctionator_OnAuctionHouseShow() end
|
||||
if event == "AUCTION_HOUSE_CLOSED" then Auctionator_OnAuctionHouseClosed() end
|
||||
if event == "NEW_AUCTION_UPDATE" then Auctionator_OnNewAuctionUpdate() end
|
||||
|
||||
end
|
||||
|
||||
@@ -254,12 +250,21 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_AuctionSellItemButton_OnEvent()
|
||||
Auctionator_Orig_AuctionSellItemButton_OnEvent()
|
||||
Auctionator_OnNewAuctionUpdate()
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_BrowseButton_OnClick(button)
|
||||
if arg1 == "LeftButton" then
|
||||
Auctionator_Orig_BrowseButton_OnClick(button)
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_BrowseButton_OnMouseDown()
|
||||
if arg1 == "RightButton" and AUCTIONATOR_INSTANT_BUYOUT then
|
||||
local index = this:GetID() + FauxScrollFrame_GetOffset(BrowseScrollFrame)
|
||||
@@ -303,6 +308,9 @@ function Auctionator_SetupHookFunctions()
|
||||
BrowseButton8:RegisterForClicks("LeftButtonUp", "RightButtonDown")
|
||||
BrowseButton8:SetScript("OnMouseDown", Auctionator_BrowseButton_OnMouseDown)
|
||||
|
||||
Auctionator_Orig_AuctionSellItemButton_OnEvent = AuctionSellItemButton_OnEvent
|
||||
AuctionSellItemButton_OnEvent = Auctionator_AuctionSellItemButton_OnEvent
|
||||
|
||||
Auctionator_Orig_AuctionFrameTab_OnClick = AuctionFrameTab_OnClick
|
||||
AuctionFrameTab_OnClick = Auctionator_AuctionFrameTab_OnClick
|
||||
|
||||
@@ -372,14 +380,6 @@ end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_OnAuctionUpdate()
|
||||
if Auctionator_Scan_State_Postquery() then
|
||||
Auctionator_Scan_Process()
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_SetMessage(msg)
|
||||
Auctionator_HideElems(recommendationElements)
|
||||
AuctionatorMessage:SetText(msg)
|
||||
@@ -403,7 +403,6 @@ function Auctionator_SelectAuctionatorEntry()
|
||||
----- find the best price per stacksize and overall -----
|
||||
|
||||
for _,auctionatorEntry in ipairs(auctionatorEntries[currentAuctionItemName]) do
|
||||
|
||||
if not bestPrice[auctionatorEntry.stackSize] or bestPrice[auctionatorEntry.stackSize].itemPrice >= auctionatorEntry.itemPrice then
|
||||
bestPrice[auctionatorEntry.stackSize] = auctionatorEntry
|
||||
end
|
||||
@@ -464,7 +463,7 @@ function Auctionator_UpdateRecommendation()
|
||||
MoneyFrame_Update("Auctionator_RecommendPerStack_Price", round(newBuyoutPrice))
|
||||
|
||||
MoneyInputFrame_SetCopper(BuyoutPrice, newBuyoutPrice)
|
||||
MoneyInputFrame_SetCopper(StartPrice, newStartPrice)
|
||||
MoneyInputFrame_SetCopper(StartPrice, newStartPrice)
|
||||
|
||||
if selectedAuctionatorEntry.stackSize == auctionatorEntries[currentAuctionItemName][1].stackSize and selectedAuctionatorEntry.buyoutPrice == auctionatorEntries[currentAuctionItemName][1].buyoutPrice then
|
||||
Auctionator_Recommend_Basis_Text:SetText("(based on cheapest)")
|
||||
@@ -515,9 +514,7 @@ function Auctionator_OnNewAuctionUpdate()
|
||||
return
|
||||
end
|
||||
|
||||
if not Auctionator_Scan_State_Idle() then
|
||||
Auctionator_Scan_Abort()
|
||||
end
|
||||
Auctionator_Scan_Abort()
|
||||
|
||||
currentAuctionItemName, currentAuctionItemTexture, currentAuctionItemStackSize = GetAuctionSellItemInfo()
|
||||
|
||||
@@ -556,14 +553,7 @@ function Auctionator_OnUpdate()
|
||||
return
|
||||
end
|
||||
|
||||
if Auctionator_Scan_State_Prequery() and GetTime() - timeOfLastUpdate > 0.5 then
|
||||
|
||||
timeOfLastUpdate = GetTime()
|
||||
|
||||
if CanSendAuctionQuery() then
|
||||
Auctionator_Scan_Query()
|
||||
end
|
||||
end
|
||||
|
||||
if forceRefresh then
|
||||
Auctionator_OnNewAuctionUpdate()
|
||||
@@ -605,6 +595,7 @@ function Auctionator_ScrollbarUpdate()
|
||||
local auctionatorEntry = auctionatorEntries[currentAuctionItemName][dataOffset]
|
||||
|
||||
local lineEntry_avail = getglobal("AuctionatorEntry"..line.."_Availability")
|
||||
local lineEntry_comm = getglobal("AuctionatorEntry"..line.."_Comment")
|
||||
local lineEntry_stack = getglobal("AuctionatorEntry"..line.."_StackPrice")
|
||||
|
||||
if selectedAuctionatorEntry and auctionatorEntry.itemPrice == selectedAuctionatorEntry.itemPrice and auctionatorEntry.stackSize == selectedAuctionatorEntry.stackSize then
|
||||
@@ -619,10 +610,14 @@ function Auctionator_ScrollbarUpdate()
|
||||
lineEntry_avail:SetTextColor(1.0, 1.0, 1.0)
|
||||
end
|
||||
|
||||
-- if auctionatorEntry.numYours == 0 then lineEntry_comm:SetText("")
|
||||
-- elseif auctionatorEntry.numYours == auctionatorEntry.count then lineEntry_comm:SetText("yours")
|
||||
-- else lineEntry_comm:SetText("yours: "..auctionatorEntry.numYours)
|
||||
-- end
|
||||
if auctionatorEntry.numYours == 0 then
|
||||
lineEntry_comm:SetText("")
|
||||
elseif
|
||||
auctionatorEntry.numYours == auctionatorEntry.count then
|
||||
lineEntry_comm:SetText("yours")
|
||||
else
|
||||
lineEntry_comm:SetText("yours: "..auctionatorEntry.numYours)
|
||||
end
|
||||
|
||||
local tx = string.format("%i %s of %i", auctionatorEntry.count, pluralizeIf("stack", auctionatorEntry.count), auctionatorEntry.stackSize)
|
||||
|
||||
|
||||
+3
-5
@@ -3,16 +3,14 @@
|
||||
<Script file="Auctionator.lua"/>
|
||||
|
||||
<!-- Frame to handle all core events -->
|
||||
<Frame name="Auctionator_core">
|
||||
<Frame name="Auctionator_Core">
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
this:RegisterEvent("ADDON_LOADED")
|
||||
this:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
|
||||
this:RegisterEvent("AUCTION_OWNED_LIST_UPDATE")
|
||||
this:RegisterEvent("AUCTION_HOUSE_SHOW")
|
||||
this:RegisterEvent("AUCTION_HOUSE_CLOSED")
|
||||
this:RegisterEvent("NEW_AUCTION_UPDATE")
|
||||
</OnLoad>
|
||||
<OnUpdate>
|
||||
Auctionator_OnUpdate()
|
||||
@@ -90,7 +88,7 @@
|
||||
</Scripts>
|
||||
</Button>
|
||||
|
||||
<Frame name="Auctionator_Sell_Template" virtual="true" frameStrata="HIGH" hidden="true">
|
||||
<Frame name="Auctionator_Sell_Template" virtual="true" hidden="true">
|
||||
<Size>
|
||||
<AbsDimension x="550" y="447"/>
|
||||
</Size>
|
||||
@@ -151,7 +149,7 @@
|
||||
<Anchors><Anchor point="LEFT" relativePoint="LEFT" relativeTo="$parentMiddle"><Offset><AbsDimension x="220" y="1"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
|
||||
<FontString inherits="GameFontHighlightSmall" text=" ">
|
||||
<FontString inherits="GameFontHighlightSmall" text="">
|
||||
<Anchors><Anchor point="LEFT" relativePoint="LEFT" relativeTo="$parentMiddle"><Offset><AbsDimension x="325" y="1"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
<Script file="Options.lua"/>
|
||||
|
||||
<Frame name="AuctionatorOptionsButtonTemplate" virtual="true" frameStrata="HIGH" hidden="true">
|
||||
<Frame name="AuctionatorOptionsButtonTemplate" virtual="true" hidden="true">
|
||||
<Size>
|
||||
<AbsDimension x="550" y="447"/>
|
||||
</Size>
|
||||
|
||||
@@ -1,27 +1,44 @@
|
||||
local SCAN_STATE_IDLE = 0
|
||||
local SCAN_STATE_PREQUERY = 1
|
||||
local SCAN_STATE_POSTQUERY = 2
|
||||
local STATE_IDLE = 0
|
||||
local STATE_PREQUERY = 1
|
||||
local STATE_POSTQUERY = 2
|
||||
|
||||
NUM_AUCTION_ITEMS_PER_PAGE = 50
|
||||
local NUM_AUCTION_ITEMS_PER_PAGE = 50
|
||||
|
||||
local currentQuery
|
||||
local currentPage
|
||||
local scanState = SCAN_STATE_IDLE
|
||||
local state = STATE_IDLE
|
||||
|
||||
local scanData
|
||||
|
||||
local timeOfLastUpdate = GetTime()
|
||||
|
||||
-- forward declaration of local functions
|
||||
local submitQuery, processQueryResults
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_Scan_State_Idle()
|
||||
return scanState == SCAN_STATE_IDLE
|
||||
end
|
||||
local eventFrame = CreateFrame("Frame")
|
||||
eventFrame:SetScript("OnUpdate", function()
|
||||
if state == STATE_PREQUERY and GetTime() - timeOfLastUpdate > 0.5 then
|
||||
|
||||
timeOfLastUpdate = GetTime()
|
||||
|
||||
function Auctionator_Scan_State_Prequery()
|
||||
return scanState == SCAN_STATE_PREQUERY
|
||||
end
|
||||
if CanSendAuctionQuery() then
|
||||
submitQuery()
|
||||
end
|
||||
end
|
||||
end)
|
||||
eventFrame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
|
||||
eventFrame:SetScript("OnEvent", function(event)
|
||||
if state == STATE_POSTQUERY then
|
||||
processQueryResults()
|
||||
end
|
||||
end)
|
||||
|
||||
function Auctionator_Scan_State_Postquery()
|
||||
return scanState == SCAN_STATE_POSTQUERY
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_Scan_Idle()
|
||||
return state == STATE_IDLE
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@@ -35,7 +52,7 @@ function Auctionator_Scan_Complete()
|
||||
currentQuery = nil
|
||||
currentPage = nil
|
||||
scanData = nil
|
||||
scanState = SCAN_STATE_IDLE
|
||||
state = STATE_IDLE
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@@ -49,82 +66,7 @@ function Auctionator_Scan_Abort()
|
||||
currentQuery = nil
|
||||
currentPage = nil
|
||||
scanData = nil
|
||||
scanState = SCAN_STATE_IDLE
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_Scan_Query()
|
||||
if scanState == SCAN_STATE_PREQUERY then
|
||||
|
||||
QueryAuctionItems(
|
||||
currentQuery.name,
|
||||
currentQuery.minLevel,
|
||||
currentQuery.maxLevel,
|
||||
currentQuery.invTypeIndex,
|
||||
currentQuery.classIndex,
|
||||
currentQuery.subclassIndex,
|
||||
currentPage,
|
||||
currentQuery.isUsable,
|
||||
currentQuery.qualityIndex
|
||||
)
|
||||
scanState = SCAN_STATE_POSTQUERY
|
||||
currentPage = currentPage + 1
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function Auctionator_Scan_Process()
|
||||
|
||||
if scanState == SCAN_STATE_POSTQUERY then
|
||||
|
||||
-- SortAuctionItems("list", "buyout")
|
||||
-- if IsAuctionSortReversed("list", "buyout") then
|
||||
-- SortAuctionItems("list", "buyout")
|
||||
-- end
|
||||
|
||||
local numBatchAuctions, totalAuctions = GetNumAuctionItems("list")
|
||||
|
||||
if totalAuctions >= NUM_AUCTION_ITEMS_PER_PAGE then
|
||||
Auctionator_SetMessage("Scanning auctions: 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 duration = GetAuctionItemTimeLeft("list", i)
|
||||
|
||||
local scanDatum = {
|
||||
name = name,
|
||||
texture = texture,
|
||||
stackSize = count,
|
||||
quality = quality,
|
||||
canUse = canUse,
|
||||
level = level,
|
||||
minBid = minBid,
|
||||
minIncrement = minIncrement,
|
||||
buyoutPrice = buyoutPrice,
|
||||
bidAmount = bidAmount,
|
||||
highBidder = highBidder,
|
||||
owner = owner,
|
||||
duration = duration
|
||||
}
|
||||
|
||||
if not currentQuery.exactMatch or (currentQuery.name == scanDatum.name and scanDatum.buyoutPrice > 0) then -- TODO separate option for buyout price
|
||||
tinsert(scanData, scanDatum)
|
||||
if currentQuery.onReadDatum then
|
||||
currentQuery.onReadDatum(scanDatum)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if numBatchAuctions == NUM_AUCTION_ITEMS_PER_PAGE then
|
||||
scanState = SCAN_STATE_PREQUERY
|
||||
else
|
||||
Auctionator_Scan_Complete()
|
||||
end
|
||||
end
|
||||
state = STATE_IDLE
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@@ -133,14 +75,14 @@ function Auctionator_Scan_Start(query)
|
||||
|
||||
Auctionator_SetMessage("Scanning auctions ...")
|
||||
|
||||
if scanState ~= SCAN_STATE_IDLE then
|
||||
if state ~= STATE_IDLE then
|
||||
Auctionator_Scan_Abort()
|
||||
end
|
||||
|
||||
currentQuery = query
|
||||
currentPage = 0
|
||||
scanData = {}
|
||||
scanState = SCAN_STATE_PREQUERY
|
||||
state = STATE_PREQUERY
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
@@ -163,4 +105,73 @@ function Auctionator_Scan_CreateQuery(parameterMap)
|
||||
end
|
||||
|
||||
return query
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function submitQuery()
|
||||
QueryAuctionItems(
|
||||
currentQuery.name,
|
||||
currentQuery.minLevel,
|
||||
currentQuery.maxLevel,
|
||||
currentQuery.invTypeIndex,
|
||||
currentQuery.classIndex,
|
||||
currentQuery.subclassIndex,
|
||||
currentPage,
|
||||
currentQuery.isUsable,
|
||||
currentQuery.qualityIndex
|
||||
)
|
||||
state = STATE_POSTQUERY
|
||||
currentPage = currentPage + 1
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
function processQueryResults()
|
||||
|
||||
-- SortAuctionItems("list", "buyout")
|
||||
-- if IsAuctionSortReversed("list", "buyout") then
|
||||
-- SortAuctionItems("list", "buyout")
|
||||
-- end
|
||||
|
||||
local numBatchAuctions, totalAuctions = GetNumAuctionItems("list")
|
||||
|
||||
if totalAuctions >= NUM_AUCTION_ITEMS_PER_PAGE then
|
||||
Auctionator_SetMessage("Scanning auctions: 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 duration = GetAuctionItemTimeLeft("list", i)
|
||||
|
||||
local scanDatum = {
|
||||
name = name,
|
||||
texture = texture,
|
||||
stackSize = count,
|
||||
quality = quality,
|
||||
canUse = canUse,
|
||||
level = level,
|
||||
minBid = minBid,
|
||||
minIncrement = minIncrement,
|
||||
buyoutPrice = buyoutPrice,
|
||||
bidAmount = bidAmount,
|
||||
highBidder = highBidder,
|
||||
owner = owner,
|
||||
duration = duration
|
||||
}
|
||||
|
||||
if not currentQuery.exactMatch or (currentQuery.name == scanDatum.name and scanDatum.buyoutPrice > 0) then -- TODO separate option for buyout price
|
||||
tinsert(scanData, scanDatum)
|
||||
if currentQuery.onReadDatum then
|
||||
currentQuery.onReadDatum(scanDatum)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if numBatchAuctions == NUM_AUCTION_ITEMS_PER_PAGE then
|
||||
state = STATE_PREQUERY
|
||||
else
|
||||
Auctionator_Scan_Complete()
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user