improvement for buying/cancelling mechanism

This commit is contained in:
Manuel Simon Hirsig
2016-04-24 05:33:17 +02:00
parent 1bbfe99557
commit 12e8a2045b
2 changed files with 38 additions and 34 deletions
+1 -28
View File
@@ -105,32 +105,6 @@ function private.record_remover(record)
end
end
do
local found_index
function private.find_auction(record)
if not Aux.util.index_of(record, auction_records) then
return
end
found_index = nil
Aux.scan_util.find(record, private.status_bar, Aux.util.pass, private.record_remover(record), function(index)
found_index = index
private.cancel_button:SetScript('OnClick', function()
if private.test(record)(index) and Aux.util.index_of(record, auction_records) then
CancelAuction(index)
private.record_remover(record)()
end
end)
private.cancel_button:Enable()
end)
end
end
do
local scan_id
local IDLE, SEARCHING, FOUND = {}, {}, {}
@@ -160,8 +134,7 @@ do
private.cancel_button:SetScript('OnClick', function()
if private.test(record)(index) and private.listing:ContainsRecord(record) then
CancelAuction(index)
private.record_remover(record)()
Aux.cancel_auction(index, private.record_remover(record))
end
end)
private.cancel_button:Enable()
+37 -6
View File
@@ -1,5 +1,5 @@
Aux = {
version = '2.11.2',
version = '2.11.3',
blizzard_ui_shown = false,
orig = {},
}
@@ -167,17 +167,48 @@ do
end
local money = GetMoney()
PlaceAuctionBid(type, index, amount)
if money >= amount then
locked = true
local t0 = GetTime()
Aux.control.as_soon_as(function() return GetMoney() < money or GetTime() - t0 > 10 end, function()
if GetMoney() < money then
local listener = Aux.control.event_listener('CHAT_MSG_SYSTEM')
listener:set_action(function()
if arg1 == ERR_AUCTION_BID_PLACED then
on_success()
locked = false
listener:stop()
end
locked = false
end)
listener:start()
end
PlaceAuctionBid(type, index, amount)
end
end
do
local locked
function Aux.cancel_in_progress()
return locked
end
function Aux.cancel_auction(index, on_success)
if locked then
return
end
locked = true
CancelAuction(index)
local listener = Aux.control.event_listener('CHAT_MSG_SYSTEM')
listener:set_action(function()
if arg1 == ERR_AUCTION_REMOVED then
on_success()
locked = false
listener:stop()
end
end)
listener:start()
end
end