diff --git a/Auctionator.lua b/Auctionator.lua
index b71a7b4..9408956 100644
--- a/Auctionator.lua
+++ b/Auctionator.lua
@@ -1,5 +1,3 @@
-local AuctionatorLoaded = false
-
local recommendationElements = {}
local defaultAuctionTabElements = {}
local defaultBrowseTabElements = {}
@@ -42,14 +40,13 @@ local lastItemPosted = nil
-----------------------------------------
-local processScanResults, relevel, log, pluralizeIf, round, undercut, roundPriceDown
+local processScanResults, relevel, Auctionator_Log, pluralizeIf, round, undercut, roundPriceDown
local val2gsc, priceToString, ItemType2AuctionClass, SubType2AuctionSubclass
-----------------------------------------
function Auctionator_EventHandler()
- if event == "VARIABLES_LOADED" then Auctionator_OnLoad() end
if event == "ADDON_LOADED" then Auctionator_OnAddonLoaded() end
if event == "AUCTION_OWNED_LIST_UPDATE" then Auctionator_OnAuctionOwnedUpdate() end
if event == "AUCTION_HOUSE_SHOW" then Auctionator_OnAuctionHouseShow() end
@@ -59,16 +56,6 @@ end
-----------------------------------------
-function Auctionator_OnLoad()
-
- log("Auctionator Loaded")
-
- AuctionatorLoaded = true
-
-end
-
------------------------------------------
-
function Auctionator_AddPanels()
local sellFrame = CreateFrame("Frame", "Auctionator_Sell_Panel", AuctionFrame, "Auctionator_Sell_Template")
@@ -88,7 +75,6 @@ function Auctionator_AddPanels()
optionsFrame:SetPoint("TOPLEFT", "AuctionFrame", "TOPLEFT", 210, 0)
relevel(optionsFrame)
optionsFrame:Hide()
-
end
-----------------------------------------
@@ -323,22 +309,22 @@ function Auctionator_AddTabs()
Auctionator.tabs.sell.index = AuctionFrame.numTabs + 1
Auctionator.tabs.buy.index = AuctionFrame.numTabs + 2
- local sellFrameName = "AuctionFrameTab"..Auctionator.tabs.sell.index
- local buyFrameName = "AuctionFrameTab"..Auctionator.tabs.buy.index
+ local sellTabName = "AuctionFrameTab"..Auctionator.tabs.sell.index
+ local buyTabName = "AuctionFrameTab"..Auctionator.tabs.buy.index
- local sellFrame = CreateFrame("Button", sellFrameName, AuctionFrame, "AuctionTabTemplate")
- local buyFrame = CreateFrame("Button", buyFrameName, AuctionFrame, "AuctionTabTemplate")
+ local sellTab = CreateFrame("Button", sellTabName, AuctionFrame, "AuctionTabTemplate")
+ local buyTab = CreateFrame("Button", buyTabName, AuctionFrame, "AuctionTabTemplate")
- setglobal(sellFrameName, sellFrame)
- setglobal(buyFrameName, buyFrame)
+ setglobal(sellTabName, sellTab)
+ setglobal(buyTabName, buyTab)
- sellFrame:SetID(Auctionator.tabs.sell.index)
- sellFrame:SetText("Auctionator")
- sellFrame:SetPoint("LEFT", getglobal("AuctionFrameTab"..AuctionFrame.numTabs), "RIGHT", -8, 0)
+ sellTab:SetID(Auctionator.tabs.sell.index)
+ sellTab:SetText("Auctionator")
+ sellTab:SetPoint("LEFT", getglobal("AuctionFrameTab"..AuctionFrame.numTabs), "RIGHT", -8, 0)
- buyFrame:SetID(Auctionator.tabs.buy.index)
- buyFrame:SetText("Buy")
- -- buyFrame:SetPoint("LEFT", getglobal("AuctionFrameTab"..Auctionator.tabs.sell.index), "RIGHT", -8, 0)
+ buyTab:SetID(Auctionator.tabs.buy.index)
+ buyTab:SetText("Buy")
+ -- buyTab:SetPoint("LEFT", getglobal("AuctionFrameTab"..Auctionator.tabs.sell.index), "RIGHT", -8, 0)
PanelTemplates_SetNumTabs(AuctionFrame, Auctionator.tabs.buy.index)
PanelTemplates_EnableTab(AuctionFrame, Auctionator.tabs.sell.index)
@@ -568,7 +554,7 @@ function Auctionator_ScrollbarUpdate()
lineEntry:SetID(dataOffset)
- if currentAuctionItemName and dataOffset <= numrows and auctionatorEntries[currentAuctionItemName][dataOffset] then
+ if currentAuctionItemName and dataOffset <= numrows and auctionatorEntries[currentAuctionItemName] then
local auctionatorEntry = auctionatorEntries[currentAuctionItemName][dataOffset]
@@ -711,14 +697,6 @@ end
-----------------------------------------
-function log(msg)
- if DEFAULT_CHAT_FRAME then
- DEFAULT_CHAT_FRAME:AddMessage(msg)
- end
-end
-
------------------------------------------
-
function undercut(price)
return math.max(0, price - 1)
end
@@ -781,7 +759,7 @@ function ItemType2AuctionClass(itemType)
end
end
end
- else log("Can't GetAuctionItemClasses") end
+ else Auctionator_Log("Can't GetAuctionItemClasses") end
end
-----------------------------------------
diff --git a/Auctionator.toc b/Auctionator.toc
index 3e1c781..f94929a 100644
--- a/Auctionator.toc
+++ b/Auctionator.toc
@@ -3,7 +3,8 @@
## Notes: A lightweight addon designed to help manage auctions
## SavedVariablesPerCharacter: AUCTIONATOR_ENABLE_ALT, AUCTIONATOR_OPEN_FIRST, AUCTIONATOR_INSTANT_BUYOUT
## SavedVariables: auctionatorEntries
-Scan.lua
+Core.xml
+Scan.xml
Auctionator.xml
Buy.xml
Options.xml
diff --git a/Auctionator.xml b/Auctionator.xml
index 4133965..ac0ac0a 100644
--- a/Auctionator.xml
+++ b/Auctionator.xml
@@ -3,7 +3,7 @@
-
+
this:RegisterEvent("VARIABLES_LOADED")
diff --git a/Buy.lua b/Buy.lua
index 4b79602..744a40d 100644
--- a/Buy.lua
+++ b/Buy.lua
@@ -1,4 +1,4 @@
-local processScanResults
+local processScanResults, scrollbarUpdate
local processedData;
function AuctionatorBuySearchButton_OnClick()
@@ -7,14 +7,15 @@ function AuctionatorBuySearchButton_OnClick()
name = AuctionatorBuySearchBox:GetText(),
exactMatch = true,
onComplete = function(data)
- table.sort(data, function(a,b) return a.buyoutPrice < b.buyoutPrice end)
- scanData = data
+ processScanResults(data)
+ scrollbarUpdate()
+ Auctionator_Log("done"..getn(data))
end
})
end
-function processScanResults(rawData, auctionItemName)
+function processScanResults(rawData)
processedData = {}
@@ -50,6 +51,77 @@ function processScanResults(rawData, auctionItemName)
table.sort(processedData, function(a,b) return a.itemPrice < b.itemPrice end)
end
+function scrollbarUpdate()
+
+ local line -- 1 through 15 of our window to scroll
+ local dataOffset -- an index into our data calculated from the scroll offset
+
+ local numrows
+ if not currentAuctionItemName or not auctionatorEntries[currentAuctionItemName] then
+ numrows = 0
+ else
+ numrows = getn(auctionatorEntries[currentAuctionItemName])
+ end
+
+ FauxScrollFrame_Update(AuctionatorScrollFrame, numrows, 12, 16);
+
+ for line = 1,15 do
+
+ dataOffset = line + FauxScrollFrame_GetOffset(AuctionatorScrollFrame)
+ log(line)
+ local lineEntry = getglobal("AuctionatorBuyEntry"..line)
+
+ if numrows <= 15 then
+ lineEntry:SetWidth(603)
+ else
+ lineEntry:SetWidth(585)
+ end
+
+ lineEntry:SetID(dataOffset)
+
+ if currentAuctionItemName and dataOffset <= numrows and auctionatorEntries[currentAuctionItemName][dataOffset] then
+
+ local auctionatorEntry = auctionatorEntries[currentAuctionItemName][dataOffset]
+
+ local lineEntry_avail = getglobal("AuctionatorBuyEntry"..line.."_Availability")
+ local lineEntry_comm = getglobal("AuctionatorBuyEntry"..line.."_Comment")
+ local lineEntry_stack = getglobal("AuctionatorBuyEntry"..line.."_StackPrice")
+
+ if selectedAuctionatorEntry and auctionatorEntry.itemPrice == selectedAuctionatorEntry.itemPrice and auctionatorEntry.stackSize == selectedAuctionatorEntry.stackSize then
+ lineEntry:LockHighlight()
+ else
+ lineEntry:UnlockHighlight()
+ end
+
+ if auctionatorEntry.stackSize == currentAuctionItemStackSize then
+ lineEntry_avail:SetTextColor(0.2, 0.9, 0.2)
+ else
+ 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
+
+ local tx = string.format("%i %s of %i", auctionatorEntry.count, pluralizeIf("stack", auctionatorEntry.count), auctionatorEntry.stackSize)
+
+ MoneyFrame_Update("AuctionatorBuyEntry"..line.."_PerItem_Price", round(auctionatorEntry.buyoutPrice/auctionatorEntry.stackSize))
+
+ lineEntry_avail:SetText(tx)
+ lineEntry_stack:SetText(priceToString(auctionatorEntry.buyoutPrice))
+
+ lineEntry:Show()
+ else
+ lineEntry:Hide()
+ end
+ end
+end
+
-----------------------------------------
-- These functions were meant to be used for a search sorted by buyout price but that actually seems impossible to implement nicely with the vanilla interface
diff --git a/Buy.xml b/Buy.xml
index b9938c8..009068a 100644
--- a/Buy.xml
+++ b/Buy.xml
@@ -21,34 +21,31 @@
-
+
-
-
-
-
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Core.lua b/Core.lua
new file mode 100644
index 0000000..506a410
--- /dev/null
+++ b/Core.lua
@@ -0,0 +1,24 @@
+AuctionatorLoaded = false
+
+-----------------------------------------
+
+function Auctionator_Log(msg)
+ if DEFAULT_CHAT_FRAME then
+ DEFAULT_CHAT_FRAME:AddMessage(msg)
+ end
+end
+
+-----------------------------------------
+
+function Auctionator_OnLoad()
+ Auctionator_Log("Auctionator Loaded")
+ AuctionatorLoaded = true
+end
+
+-----------------------------------------
+
+function Auctionator_Core_OnEvent()
+ if event == "VARIABLES_LOADED" then
+ Auctionator_OnLoad()
+ end
+end
\ No newline at end of file
diff --git a/Core.xml b/Core.xml
new file mode 100644
index 0000000..80a4e40
--- /dev/null
+++ b/Core.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+ this:RegisterEvent("VARIABLES_LOADED")
+
+
+ Auctionator_Core_OnEvent()
+
+
+
+
\ No newline at end of file
diff --git a/Scan.lua b/Scan.lua
index 74425c4..e56f2ed 100644
--- a/Scan.lua
+++ b/Scan.lua
@@ -26,7 +26,7 @@ end
function Auctionator_Scan_Complete()
if currentQuery.onComplete then
- currentQuery.onComplete(scanData);
+ currentQuery.onComplete(scanData)
end
currentQuery = nil
@@ -40,7 +40,7 @@ end
function Auctionator_Scan_Abort()
if currentQuery and currentQuery.onAbort then
- currentQuery.onAbort();
+ currentQuery.onAbort()
end
currentQuery = nil
@@ -158,8 +158,17 @@ end
-----------------------------------------
-local eventFrame = CreateFrame("Frame")
-eventFrame:SetScript("OnUpdate", function()
+function Auctionator_Scan_OnEvent()
+ if event == "AUCTION_ITEM_LIST_UPDATE" then
+ if state == STATE_POSTQUERY then
+ processQueryResults()
+ end
+ end
+end
+
+-----------------------------------------
+
+function Auctionator_Scan_OnUpdate()
if state == STATE_PREQUERY and GetTime() - timeOfLastUpdate > 0.5 then
timeOfLastUpdate = GetTime()
@@ -168,10 +177,4 @@ eventFrame:SetScript("OnUpdate", function()
submitQuery()
end
end
-end)
-eventFrame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
-eventFrame:SetScript("OnEvent", function(event)
- if state == STATE_POSTQUERY then
- processQueryResults()
- end
-end)
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/Scan.xml b/Scan.xml
new file mode 100644
index 0000000..9bab952
--- /dev/null
+++ b/Scan.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+ this:RegisterEvent("AUCTION_ITEM_LIST_UPDATE")
+
+
+ Auctionator_Scan_OnEvent()
+
+
+ Auctionator_Scan_OnUpdate()
+
+
+
+
\ No newline at end of file