improvement in buying mechanism
This commit is contained in:
@@ -12,6 +12,7 @@ persistence.lua
|
||||
util.lua
|
||||
|
||||
scan.lua
|
||||
scan_util.lua
|
||||
stack.lua
|
||||
post.lua
|
||||
sheet.lua
|
||||
|
||||
+45
-83
@@ -7,7 +7,6 @@ local create_auction_record, show_dialog, find_auction, hide_sheet, update_sheet
|
||||
local auctions
|
||||
local search_query
|
||||
local tooltip_patterns = {}
|
||||
local current_page
|
||||
local refresh
|
||||
|
||||
function auction_alpha_setter(cell, auction)
|
||||
@@ -520,7 +519,6 @@ function public.on_close()
|
||||
if AuxFilterSearchFrameResultsConfirmation:IsVisible() then
|
||||
public.dialog_cancel()
|
||||
end
|
||||
current_page = nil
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
@@ -642,6 +640,8 @@ function public.start_search()
|
||||
usable = AuxFilterSearchFrameFiltersUsableCheckButton:GetChecked()
|
||||
}
|
||||
|
||||
local current_page
|
||||
|
||||
Aux.log('Scanning auctions ...')
|
||||
Aux.scan.start{
|
||||
query = search_query,
|
||||
@@ -720,12 +720,12 @@ end
|
||||
function find_auction(entry, buyout_mode, express_mode)
|
||||
|
||||
if entry.gone then
|
||||
Aux.log('Auction not available.')
|
||||
-- Aux.log('Auction not available.')
|
||||
return
|
||||
end
|
||||
|
||||
if buyout_mode and not entry.buyout_price then
|
||||
Aux.log('Auction has no buyout price.')
|
||||
-- Aux.log('Auction has no buyout price.')
|
||||
return
|
||||
end
|
||||
|
||||
@@ -736,88 +736,50 @@ function find_auction(entry, buyout_mode, express_mode)
|
||||
amount = entry.bid
|
||||
end
|
||||
|
||||
Aux.log('Searching auction ...')
|
||||
AuxFilterSearchFrameFiltersSearchButton:Disable()
|
||||
|
||||
if not express_mode then
|
||||
show_dialog(buyout_mode, entry, amount)
|
||||
end
|
||||
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
|
||||
local found
|
||||
|
||||
Aux.scan.start{
|
||||
query = search_query,
|
||||
page = entry.page ~= current_page and entry.page,
|
||||
on_submit_query = function()
|
||||
current_page = nil
|
||||
end,
|
||||
on_page_loaded = function(page)
|
||||
current_page = page
|
||||
end,
|
||||
on_read_auction = function(auction_info, ctrl)
|
||||
|
||||
local auction_record = create_auction_record(auction_info)
|
||||
|
||||
if entry.signature == auction_record.signature then
|
||||
ctrl.suspend()
|
||||
found = true
|
||||
Aux.log('Matching auction found.')
|
||||
local function test(index)
|
||||
return create_auction_record(Aux.info.auction(index)).signature == entry.signature
|
||||
end
|
||||
|
||||
if express_mode then
|
||||
if GetMoney() >= amount then
|
||||
PlaceAuctionBid('list', auction_info.index, amount)
|
||||
Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' ('..auction_record.aux_quantity..').')
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
else
|
||||
Aux.log((buyout_mode and 'Purchase' or 'Bid')..' failed: Not enough money.')
|
||||
end
|
||||
Aux.scan.abort()
|
||||
else
|
||||
public.dialog_action = function()
|
||||
if create_auction_record(Aux.info.auction(auction_info.index)).signature == entry.signature then
|
||||
if GetMoney() >= amount then
|
||||
PlaceAuctionBid('list', auction_info.index, buyout_mode and amount or MoneyInputFrame_GetCopper(AuxFilterSearchFrameResultsConfirmationContentBid))
|
||||
Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' ('..auction_record.aux_quantity..').')
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
else
|
||||
Aux.log('Not enough money.')
|
||||
end
|
||||
Aux.scan.abort()
|
||||
AuxFilterSearchFrameFiltersSearchButton:Enable()
|
||||
AuxFilterSearchFrameResultsConfirmation:Hide()
|
||||
update_sheet()
|
||||
end
|
||||
end
|
||||
AuxFilterSearchFrameResultsConfirmationContentActionButton:Enable()
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
if not found then
|
||||
Aux.log('No matching auction found. Removing entry from the cache.')
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
public.dialog_cancel()
|
||||
end
|
||||
if express_mode then
|
||||
AuxFilterSearchFrameFiltersSearchButton:Enable()
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
if express_mode then
|
||||
AuxFilterSearchFrameFiltersSearchButton:Enable()
|
||||
end
|
||||
end,
|
||||
next_page = function(page, total_pages)
|
||||
if not page or page == entry.page then
|
||||
return entry.page - 1
|
||||
end
|
||||
end,
|
||||
}
|
||||
Aux.scan_util.find_auction(test, search_query, entry.page, private.status_bar, function(index)
|
||||
if not index then
|
||||
entry.gone = true
|
||||
private.selected = nil
|
||||
refresh = true
|
||||
return
|
||||
end
|
||||
|
||||
if not test(index) then
|
||||
return find_auction(entry, buyout_mode, express_mode) -- try again
|
||||
end
|
||||
|
||||
if express_mode then
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
end
|
||||
PlaceAuctionBid('list', index, amount)
|
||||
private.selected = nil
|
||||
refresh = true
|
||||
else
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if not test(index) then
|
||||
private.buyout_button:Disable()
|
||||
return find_auction(entry, buyout_mode, express_mode) -- try again
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
end
|
||||
PlaceAuctionBid('list', index, amount)
|
||||
|
||||
private.buyout_button:Disable()
|
||||
private.selected = nil
|
||||
refresh = true
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function private.on_row_click(entry)
|
||||
|
||||
+52
-91
@@ -3,10 +3,9 @@ Aux.item_search_frame = public
|
||||
|
||||
aux_recently_searched = {}
|
||||
|
||||
local create_auction_record, show_dialog, find_auction, hide_sheet, update_listing, auction_alpha_setter, group_alpha_setter, create_auction_record
|
||||
local create_auction_record, find_auction, hide_sheet, update_listing, auction_alpha_setter, group_alpha_setter, create_auction_record
|
||||
local auctions
|
||||
local search_query
|
||||
local current_page
|
||||
local refresh
|
||||
|
||||
function auction_alpha_setter(cell, auction)
|
||||
@@ -464,7 +463,8 @@ public.views = {
|
||||
}
|
||||
|
||||
function public.on_close()
|
||||
current_page = nil
|
||||
private.selected = nil
|
||||
private.buyout_button:Disable()
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
@@ -659,14 +659,13 @@ function public.start_search()
|
||||
AuxItemSearchFrameItemStopButton:Show()
|
||||
|
||||
auctions = nil
|
||||
|
||||
refresh = true
|
||||
|
||||
local item_id = private.item_id
|
||||
local item_info = Aux.static.item_info(item_id)
|
||||
|
||||
-- local class_index = Aux.item_class_index(item_info.class)
|
||||
-- local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass)
|
||||
-- local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) -- TODO test if needed
|
||||
|
||||
search_query = {
|
||||
name = item_info.name,
|
||||
@@ -679,13 +678,11 @@ function public.start_search()
|
||||
usable = item_info.usable,
|
||||
}
|
||||
|
||||
-- Aux.log('Scanning auctions ...')
|
||||
local current_page
|
||||
|
||||
Aux.scan.start{
|
||||
query = search_query,
|
||||
page = AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() and 0 or AuxItemSearchFrameItemPageEditBox:GetNumber(),
|
||||
on_submit_query = function()
|
||||
current_page = nil
|
||||
end,
|
||||
on_page_loaded = function(page, total_pages)
|
||||
private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages) -- TODO
|
||||
private.status_bar:set_text(string.format('Scanning (Page %d / %d)', page + 1, total_pages))
|
||||
@@ -729,15 +726,15 @@ function public.start_search()
|
||||
end)
|
||||
end
|
||||
|
||||
function find_auction(entry, buyout_mode, express_mode)
|
||||
function find_auction(entry, express_mode, buyout_mode)
|
||||
|
||||
if entry.gone then
|
||||
Aux.log('Auction not available.')
|
||||
-- Aux.log('Auction not available.')
|
||||
return
|
||||
end
|
||||
|
||||
if buyout_mode and not entry.buyout_price then
|
||||
Aux.log('Auction has no buyout price.')
|
||||
-- Aux.log('Auction has no buyout price.')
|
||||
return
|
||||
end
|
||||
|
||||
@@ -748,86 +745,50 @@ function find_auction(entry, buyout_mode, express_mode)
|
||||
amount = entry.bid
|
||||
end
|
||||
|
||||
private.status_bar:update_status(0, 0)
|
||||
private.status_bar:set_text('Searching auction...')
|
||||
|
||||
-- if not express_mode then
|
||||
-- show_dialog(buyout_mode, entry, amount)
|
||||
-- end
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
|
||||
local found
|
||||
|
||||
Aux.scan.start{
|
||||
query = search_query,
|
||||
page = entry.page ~= current_page and entry.page,
|
||||
on_submit_query = function()
|
||||
current_page = nil
|
||||
end,
|
||||
on_page_loaded = function(page)
|
||||
current_page = page
|
||||
end,
|
||||
on_read_auction = function(auction_info, ctrl)
|
||||
local auction_record = create_auction_record(auction_info)
|
||||
if entry.signature == auction_record.signature then
|
||||
ctrl.suspend()
|
||||
found = true
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Auction found')
|
||||
local function test(index)
|
||||
return create_auction_record(Aux.info.auction(index)).signature == entry.signature
|
||||
end
|
||||
|
||||
if express_mode then
|
||||
if GetMoney() >= amount then
|
||||
PlaceAuctionBid('list', auction_info.index, amount)
|
||||
Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' ('..auction_record.aux_quantity..').')
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
else
|
||||
Aux.log((buyout_mode and 'Purchase' or 'Bid')..' failed: Not enough money.')
|
||||
end
|
||||
Aux.scan.abort()
|
||||
else
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if create_auction_record(Aux.info.auction(auction_info.index)).signature == entry.signature then
|
||||
if GetMoney() >= amount then
|
||||
PlaceAuctionBid('list', auction_info.index, amount)
|
||||
Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' ('..auction_record.aux_quantity..').')
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
else
|
||||
Aux.log('Not enough money.')
|
||||
end
|
||||
Aux.scan.abort()
|
||||
update_listing()
|
||||
end
|
||||
private.buyout_button:Disable()
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
if not found then
|
||||
Aux.log('No matching auction found. Removing entry from the cache.')
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
public.dialog_cancel()
|
||||
end
|
||||
if express_mode then
|
||||
AuxItemSearchFrameItemRefreshButton:Enable()
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
if express_mode then
|
||||
AuxItemSearchFrameItemRefreshButton:Enable()
|
||||
end
|
||||
end,
|
||||
next_page = function(page, total_pages)
|
||||
if not page or page == entry.page then
|
||||
return entry.page - 1
|
||||
end
|
||||
end,
|
||||
}
|
||||
Aux.scan_util.find_auction(test, search_query, entry.page, private.status_bar, function(index)
|
||||
if not index then
|
||||
entry.gone = true
|
||||
private.selected = nil
|
||||
refresh = true
|
||||
return
|
||||
end
|
||||
|
||||
if not test(index) then
|
||||
return find_auction(entry, buyout_mode, express_mode) -- try again
|
||||
end
|
||||
|
||||
if express_mode then
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
end
|
||||
PlaceAuctionBid('list', index, amount)
|
||||
private.selected = nil
|
||||
refresh = true
|
||||
else
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if not test(index) then
|
||||
private.buyout_button:Disable()
|
||||
return find_auction(entry, buyout_mode, express_mode) -- try again
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
end
|
||||
PlaceAuctionBid('list', index, amount)
|
||||
|
||||
private.buyout_button:Disable()
|
||||
private.selected = nil
|
||||
refresh = true
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function public.on_row_click(entry)
|
||||
@@ -845,7 +806,7 @@ function public.on_row_click(entry)
|
||||
ChatFrameEditBox:Insert(entry.hyperlink)
|
||||
end
|
||||
else
|
||||
find_auction(entry, buyout_mode, express_mode)
|
||||
find_auction(entry, express_mode, buyout_mode)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
local m = {}
|
||||
Aux.scan_util = m
|
||||
|
||||
function m.find_auction(test, search_query, page, status_bar, callback)
|
||||
|
||||
Aux.scan.abort(function()
|
||||
|
||||
status_bar:update_status(0, 0)
|
||||
status_bar:set_text('Searching auction...')
|
||||
|
||||
local pages = page > 0 and { page, page - 1 } or { page }
|
||||
|
||||
Aux.scan.start{
|
||||
query = search_query,
|
||||
on_read_auction = function(auction_info, ctrl)
|
||||
if test(auction_info.index) then
|
||||
ctrl.suspend()
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction found')
|
||||
Aux.scan.abort(function()
|
||||
callback(auction_info.index)
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction not found')
|
||||
callback()
|
||||
end,
|
||||
next_page = function()
|
||||
if getn(pages) == 1 then
|
||||
status_bar:update_status(50, 50)
|
||||
end
|
||||
local page = pages[1]
|
||||
tremove(pages, 1)
|
||||
return page
|
||||
end,
|
||||
}
|
||||
end)
|
||||
end
|
||||
@@ -80,8 +80,8 @@ function public.create(params)
|
||||
local scroll_frame = CreateFrame('ScrollFrame', name..'ScrollFrame', params.frame, 'FauxScrollFrameTemplate')
|
||||
|
||||
local scrollbar = getglobal(scroll_frame:GetName()..'ScrollBar')
|
||||
scrollbar:SetPoint('TOPLEFT', scroll_frame, 'TOPRIGHT', 6, -4)
|
||||
scrollbar:SetPoint('BOTTOMLEFT', scroll_frame, 'BOTTOMRIGHT', 6, 4)
|
||||
scrollbar:SetPoint('TOPLEFT', scroll_frame, 'TOPRIGHT', 6, 0)
|
||||
scrollbar:SetPoint('BOTTOMLEFT', scroll_frame, 'BOTTOMRIGHT', 6, 0)
|
||||
scrollbar:SetWidth(12)
|
||||
local thumbTex = scrollbar:GetThumbTexture()
|
||||
thumbTex:SetPoint('CENTER', 0, 0)
|
||||
@@ -91,8 +91,8 @@ function public.create(params)
|
||||
local scrollbg = scrollbar:CreateTexture(nil, 'BACKGROUND')
|
||||
scrollbg:SetAllPoints(scrollbar)
|
||||
scrollbg:SetTexture(24/255, 24/255, 24/255, 1)
|
||||
local scrollbar = getglobal(scroll_frame:GetName()..'ScrollBarScrollUpButton'):Hide()
|
||||
local scrollbar = getglobal(scroll_frame:GetName()..'ScrollBarScrollDownButton'):Hide()
|
||||
getglobal(scroll_frame:GetName()..'ScrollBarScrollUpButton'):Hide()
|
||||
getglobal(scroll_frame:GetName()..'ScrollBarScrollDownButton'):Hide()
|
||||
|
||||
scroll_frame:SetScript('OnVerticalScroll', function()
|
||||
FauxScrollFrame_OnVerticalScroll(16, function() public.render(this.sheet) end)
|
||||
|
||||
Reference in New Issue
Block a user