diff --git a/Aux-Addon.toc b/Aux-Addon.toc
index efcae28..2481d85 100644
--- a/Aux-Addon.toc
+++ b/Aux-Addon.toc
@@ -4,9 +4,10 @@
## SavedVariablesPerCharacter: AUX_ENABLE_ALT, AUX_OPEN_FIRST, AUX_INSTANT_BUYOUT, AUX_AUCTION_DURATION
## SavedVariables: auxSellEntries
core.xml
-scan.xml
sell.xml
buy.xml
+scan.xml
+stack.xml
+post.xml
options.xml
about.xml
-post.lua
diff --git a/core.lua b/core.lua
index f477661..87af9e7 100644
--- a/core.lua
+++ b/core.lua
@@ -1,6 +1,8 @@
AuxVersion = "1.1.2"
AuxAuthors = "shirsig; Zerf; Zirco (AUX); Nimeral (AUX backport)"
+local lastRightClickAction = GetTime()
+
Aux = {
loaded = false,
orig = {},
@@ -117,6 +119,25 @@ function Aux_SetupHookFunctions()
Aux.orig.BrowseButton_OnClick = BrowseButton_OnClick
BrowseButton_OnClick = Aux_BrowseButton_OnClick
+
+ AuctionsButton1:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton1:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton2:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton2:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton3:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton3:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton4:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton4:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton5:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton5:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton6:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton6:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton7:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton7:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton8:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton8:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
+ AuctionsButton9:RegisterForClicks("LeftButtonUp", "RightButtonDown")
+ AuctionsButton9:SetScript("OnMouseDown", Aux_AuctionsButton_OnMouseDown)
BrowseButton1:RegisterForClicks("LeftButtonUp", "RightButtonDown")
BrowseButton1:SetScript("OnMouseDown", Aux_BrowseButton_OnMouseDown)
@@ -170,6 +191,8 @@ end
function Aux_OnAuctionHouseClosed()
+ Aux.post.stop()
+ Aux.stack.stop()
if not Aux_Scan_IsIdle() then
Aux_Scan_Abort()
end
@@ -190,6 +213,8 @@ function Aux_AuctionFrameTab_OnClick(index)
index = this:GetID()
end
+ Aux.post.stop()
+ Aux.stack.stop()
if not Aux_Scan_IsIdle() then
Aux_Scan_Abort()
end
@@ -375,8 +400,16 @@ end
-----------------------------------------
+function Aux_AuctionsButton_OnClick(button)
+ if arg1 == "LeftButton" then -- because we additionally registered right clicks we only let left ones pass here
+ Aux.orig.BrowseButton_OnClick(button)
+ end
+end
+
+-----------------------------------------
+
function Aux_BrowseButton_OnMouseDown()
- if arg1 == "RightButton" and AUX_INSTANT_BUYOUT then
+ if arg1 == "RightButton" and AUX_INSTANT_BUYOUT and GetTime() - lastRightClickAction > 0.5 then
local index = this:GetID() + FauxScrollFrame_GetOffset(BrowseScrollFrame)
SetSelectedAuctionItem("list", index)
@@ -387,6 +420,22 @@ function Aux_BrowseButton_OnMouseDown()
end
AuctionFrameBrowse_Update()
+ lastRightClickAction = GetTime()
+ end
+end
+
+-----------------------------------------
+
+function Aux_AuctionsButton_OnMouseDown()
+ if arg1 == "RightButton" and GetTime() - lastRightClickAction > 0.5 then
+ local index = this:GetID() + FauxScrollFrame_GetOffset(AuctionsScrollFrame)
+
+ SetSelectedAuctionItem("owner", index)
+
+ CancelAuction(index)
+
+ AuctionFrameAuctions_Update()
+ lastRightClickAction = GetTime()
end
end
diff --git a/post.lua b/post.lua
index 39e1d73..9c4ead7 100644
--- a/post.lua
+++ b/post.lua
@@ -1,106 +1,83 @@
-local target_size
-local slot
+Aux.post = {}
+local state
--- iterator for inventory
-function inventory()
- local inventory = {}
- for bag = 0, 4 do
- if GetBagName(bag) then
- for bagSlot = 1, GetContainerNumSlots(bag) do
- tinsert(inventory, { bag = bag, bagSlot = bagSlot })
+local post_auction
+
+function Aux.post.onupdate()
+ if state then
+ if state.auctioning then
+ if not GetContainerItemInfo(state.auctioning.bag, state.auctioning.bag_slot) then
+ state.auctioning = nil
+ state.posted = state.posted + 1
end
end
- end
-
- local i = 0
- local n = getn(inventory)
- return function()
- i = i + 1
- if i <= n then
- return inventory[i]
- end
- end
-end
-
-function findEmptySlot()
- for slot in inventory() do
- if not GetContainerItemInfo(slot.bag, slot.bagSlot) then
- return slot
- end
- end
-end
-
-function findItem(name)
- local slots = {}
- for slot in inventory() do
- if itemName(slot) == name then
- tinsert(slots, slot)
- end
- end
- return slots
-end
-
-function sameSlot(slot1, slot2)
- return slot1.bag == slot2.bag and slot1.bagSlot == slot2.bagSlot
-end
-
-function moveItem(fromSlot, toSlot, amount)
- ClearCursor()
- SplitContainerItem(fromSlot.bag, fromSlot.bagSlot, amount)
- PickupContainerItem(toSlot.bag, toSlot.bagSlot)
- ClearCursor()
-end
-
-function itemName(slot)
- local itemLink = GetContainerItemLink(slot.bag, slot.bagSlot)
- if itemLink then
- return string.gsub(itemLink, "^.-%[(.*)%].*", "%1")
- end
-end
-
-function stackSize(slot)
- local _, itemCount = GetContainerItemInfo(slot.bag, slot.bagSlot)
- return itemCount
-end
-
-function postAuction(slot)
- ClearCursor()
- pickupContainerItem(slot.bag, slot.bagSlot)
- ClickAuctionSellItemButton()
- ClearCursor()
- Aux.orig.AuctionsCreateAuctionButton_OnClick()
- -- StartAuction(request.bid, request.buyout, request.duration);
-end
-
-function createStack(name, size)
- ClearCursor()
- ClickAuctionSellItemButton()
- ClearCursor()
-
- local slots = findItem(name)
- local stackSlot = slots[1]
- tremove(slots, 1)
-
- for _, slot in ipairs(slots) do
- if stackSize(stackSlot) < size then
- moveItem(slot, stackSlot, size - stackSize(stackSlot))
- elseif stackSize(stackSlot) > size then
- moveItem(stackSlot, slot, stackSize(stackSlot) - size)
+ if state.posted < state.count then
+ if not state.stacking and not state.auctioning then
+ state.stacking = true
+ Aux.stack.start(
+ state.name,
+ state.stack_size,
+ function(slot)
+ if slot then
+ post_auction(slot)
+ else
+ Aux.post.stop()
+ end
+ end
+ )
+ end
else
- return stackSlot
- end
- end
-
- if stackSize(stackSlot) > size then
- local emptySlot = findEmptySlot()
- Aux_Log(stackSize(stackSlot) .. ' : ' .. emptySlot.bag .. ' ' .. emptySlot.bagSlot)
- moveItem(stackSlot, emptySlot, stackSize(stackSlot) - size)
- Aux_Log(stackSize(stackSlot) .. ' : ' .. emptySlot.bag .. ' ' .. emptySlot.bagSlot)
- if stackSize(stackSlot) == size then
- return stackSlot
+ Aux.post.stop()
end
end
end
--- /script createStack('Dried King Bolete', 3)
\ No newline at end of file
+function Aux.post.stop()
+ if state then
+ local callback = state.callback
+ local posted = state.posted
+
+ state = nil
+ PickupContainerItem = Aux.stack.orig.PickupContainerItem
+ SplitContainerItem = Aux.stack.orig.SplitContainerItem
+
+ if callback then
+ callback(posted)
+ end
+ end
+end
+
+function post_auction(slot)
+ ClearCursor()
+ ClickAuctionSellItemButton()
+ ClearCursor()
+ PickupContainerItem(slot.bag, slot.bag_slot)
+ ClickAuctionSellItemButton()
+ ClearCursor()
+ StartAuction(state.bid, state.buyout, state.duration)
+ state.auctioning = slot
+ state.stacking = false
+end
+
+function Aux.post.start(name, stack_size, duration, bid, buyout, count, callback)
+ Aux.post.stop()
+
+ ClearCursor()
+ ClickAuctionSellItemButton()
+ ClearCursor()
+
+ PickupContainerItem = function() end
+ SplitContainerItem = function() end
+
+ state = {
+ name = name,
+ stack_size = stack_size,
+ duration = duration,
+ bid = bid,
+ buyout = buyout,
+ count = count,
+ posted = 0,
+ callback = callback,
+ }
+end
\ No newline at end of file
diff --git a/post.xml b/post.xml
new file mode 100644
index 0000000..1bbdaa3
--- /dev/null
+++ b/post.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+ Aux.post.onupdate()
+
+
+
+
\ No newline at end of file
diff --git a/sell.lua b/sell.lua
index 66a7855..2350fb2 100644
--- a/sell.lua
+++ b/sell.lua
@@ -63,9 +63,51 @@ end
-----------------------------------------
function Aux_AuctionsCreateAuctionButton_OnClick()
- for i=1, currentAuction.stackCount do
- local slot = createStack(currentAuction.name, currentAuction.stackCount)
- postAuction(slot)
+ if PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.sell.index then
+ local name, stackSize, buyoutPrice = currentAuction.name, currentAuction.stackSize, MoneyInputFrame_GetCopper(BuyoutPrice)
+ local duration
+ if AuctionFrameAuctions.duration == 120 then
+ duration = 2
+ elseif AuctionFrameAuctions.duration == 480 then
+ duration = 3
+ elseif AuctionFrameAuctions.duration == 1440 then
+ duration = 4
+ end
+
+ Aux.post.start(
+ currentAuction.name,
+ currentAuction.stackSize,
+ AuctionFrameAuctions.duration,
+ MoneyInputFrame_GetCopper(StartPrice),
+ MoneyInputFrame_GetCopper(BuyoutPrice),
+ currentAuction.stackCount,
+ function(posted)
+ 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.duration = max(existingEntry.duration, duration)
+ newEntry = 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)
+ end
+ auxSellEntries[name].selected = entry
+ Aux_UpdateRecommendation()
+ end
+ )
+ else
+ Aux.orig.AuctionsCreateAuctionButton_OnClick()
end
end
@@ -122,10 +164,16 @@ function Aux_UpdateRecommendation()
if not currentAuction then
AuxSellRefreshButton:Disable()
+
+ Aux_Sell_SetStackSize(0)
+ Aux_Sell_SetStackCount(0)
Aux_SetMessage("Drag an item to the Auction Item area\n\nto see recommended pricing information")
else
AuxSellRefreshButton:Enable()
+ Aux_Sell_SetStackSize(currentAuction.stackSize)
+ Aux_Sell_SetStackCount(currentAuction.stackCount)
+
if auxSellEntries[currentAuction.name] and auxSellEntries[currentAuction.name].selected then
if not auxSellEntries[currentAuction.name].created or GetTime() - auxSellEntries[currentAuction.name].created > 1800 then
AuxRecommendStaleText:SetText("STALE DATA") -- data older than half an hour marked as stale
@@ -259,7 +307,7 @@ function Aux_RefreshEntries()
if currentAuction then
auxSellEntries[currentAuction.name] = nil
- local _, _, _, _, _, sType, sSubType, _ = GetItemInfo(currentAuction.name)
+ local _, _, _, _, _, sType, sSubType = GetItemInfo(currentAuction.name)
local currentAuctionClass = ItemType2AuctionClass(sType)
local currentAuctionSubclass = nil -- SubType2AuctionSubclass(currentAuctionClass, sSubType)
@@ -290,9 +338,9 @@ function Aux_ScrollbarUpdate()
numrows = getn(auxSellEntries[currentAuction.name])
end
- FauxScrollFrame_Update(AuxScrollFrame, numrows, 12, 16);
+ FauxScrollFrame_Update(AuxScrollFrame, numrows, 12, 16)
- for line = 1,12 do
+ for line = 1, 12 do
local dataOffset = line + FauxScrollFrame_GetOffset(AuxScrollFrame)
local lineEntry = getglobal("AuxSellEntry"..line)
@@ -403,7 +451,7 @@ function processScanResults(rawData, auctionItemName)
local condData = {}
- for _,rawDatum in ipairs(rawData) do
+ for _, rawDatum in ipairs(rawData) do
if auctionItemName == rawDatum.name and rawDatum.buyoutPrice > 0 then
local key = "_"..rawDatum.count.."_"..rawDatum.buyoutPrice
@@ -429,7 +477,7 @@ function processScanResults(rawData, auctionItemName)
----- create a table of these entries sorted by itemPrice
local n = 1
- for _,condDatum in pairs(condData) do
+ for _, condDatum in pairs(condData) do
auxSellEntries[auctionItemName][n] = condDatum
n = n + 1
end
diff --git a/stack.lua b/stack.lua
new file mode 100644
index 0000000..b39f951
--- /dev/null
+++ b/stack.lua
@@ -0,0 +1,175 @@
+Aux.stack = {
+ orig = {},
+}
+
+local state
+
+local DELAY = 1
+
+local inventory, item_slots, find_empty_slot, locked, same_slot, move_item, item_name, stack_size
+
+-- returns iterator for inventory slots
+function inventory()
+ local inventory = {}
+ for bag = 0, 4 do
+ if GetBagName(bag) then
+ for bag_slot = 1, GetContainerNumSlots(bag) do
+ tinsert(inventory, { bag = bag, bag_slot = bag_slot })
+ end
+ end
+ end
+
+ local i = 0
+ local n = getn(inventory)
+ return function()
+ i = i + 1
+ if i <= n then
+ return inventory[i]
+ end
+ end
+end
+
+function item_slots(name)
+ local slots = inventory()
+ return function()
+ repeat
+ slot = slots()
+ until slot == nil or item_name(slot) == name
+ return slot
+ end
+end
+
+function find_empty_slot()
+ for slot in inventory() do
+ if not GetContainerItemInfo(slot.bag, slot.bag_slot) then
+ return slot
+ end
+ end
+end
+
+function locked(slot)
+ local _, _, locked = GetContainerItemInfo(slog.bag, slot.bag_slot)
+ return locked
+end
+
+function same_slot(slot1, slot2)
+ return slot1.bag == slot2.bag and slot1.bag_slot == slot2.bag_slot
+end
+
+function move_item(from_slot, to_slot, amount)
+ if stack_size(to_slot) < max_stack(from_slot) then
+ amount = min(max_stack(from_slot) - stack_size(to_slot), amount)
+
+ state.processing = 3
+
+ ClearCursor()
+ Aux.stack.orig.SplitContainerItem(from_slot.bag, from_slot.bag_slot, amount)
+ Aux.stack.orig.PickupContainerItem(to_slot.bag, to_slot.bag_slot)
+ ClearCursor()
+ end
+end
+
+function item_name(slot)
+ local itemLink = GetContainerItemLink(slot.bag, slot.bag_slot)
+ if itemLink then
+ return string.gsub(itemLink, "^.-%[(.*)%].*", "%1")
+ end
+end
+
+function item_id(slot)
+ local itemLink = GetContainerItemLink(slot.bag, slot.bag_slot)
+ if itemLink then
+ local id_string = string.gsub(itemLink, "^.-:(%d*).*", "%1")
+ return tonumber(id_string)
+ end
+end
+
+function stack_size(slot)
+ local _, item_count = GetContainerItemInfo(slot.bag, slot.bag_slot)
+ return item_count or 0
+end
+
+function Aux.stack.onupdate()
+ if state and state.processing <= 0 then
+ local next_slot = state.other_slots()
+ local empty_slot = find_empty_slot()
+
+ if next_slot then
+ if stack_size(state.target_slot) < state.target_size then
+ move_item(
+ next_slot,
+ state.target_slot,
+ state.target_size - stack_size(state.target_slot)
+ )
+ return
+ elseif stack_size(state.target_slot) > state.target_size then
+ move_item(
+ state.target_slot,
+ next_slot,
+ stack_size(state.target_slot) - state.target_size
+ )
+ return
+ end
+ elseif empty_slot and stack_size(state.target_slot) > state.target_size then
+ move_item(
+ state.target_slot,
+ empty_slot,
+ stack_size(state.target_slot) - state.target_size
+ )
+ return
+ end
+
+ Aux.stack.stop()
+ end
+end
+
+function max_stack(slot)
+ local _, _, _, _, _, _, item_stack_count = GetItemInfo(item_id(slot))
+ return item_stack_count
+end
+
+function Aux.stack.item_lock_changed()
+ if state then
+ state.processing = state.processing - 1
+ end
+end
+
+function Aux.stack.stop()
+ if state then
+ local slot
+ if state.target_slot and stack_size(state.target_slot) == state.target_size then
+ slot = state.target_slot
+ end
+ local callback = state.callback
+
+ state = nil
+ PickupContainerItem = Aux.stack.orig.PickupContainerItem
+ SplitContainerItem = Aux.stack.orig.SplitContainerItem
+
+ if callback then
+ callback(slot)
+ end
+ end
+end
+
+function Aux.stack.start(name, size, callback)
+ Aux.stack.stop()
+
+ PickupContainerItem = function() end
+ SplitContainerItem = function() end
+
+ local slots = item_slots(name)
+ local target_slot = slots()
+
+ state = {
+ target_size = size,
+ target_slot = target_slot,
+ other_slots = slots,
+ callback = callback,
+ processing = 0,
+ }
+
+ if not state.target_slot then
+ Aux.stack.stop()
+ end
+end
\ No newline at end of file
diff --git a/stack.xml b/stack.xml
new file mode 100644
index 0000000..6cc7350
--- /dev/null
+++ b/stack.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ Aux.stack.orig.PickupContainerItem = PickupContainerItem
+ Aux.stack.orig.SplitContainerItem = SplitContainerItem
+ this:RegisterEvent('ITEM_LOCK_CHANGED')
+
+
+ Aux.stack.item_lock_changed()
+
+
+ Aux.stack.onupdate()
+
+
+
+
\ No newline at end of file