table functionality for bids/auctions tabs completed

This commit is contained in:
Manuel Simon Hirsig
2016-03-25 09:02:08 +01:00
parent 4bd18e8a10
commit 0ae559ac92
3 changed files with 124 additions and 193 deletions
+60 -75
View File
@@ -2,35 +2,20 @@ local private, public = {}, {}
Aux.auctions_frame = public
local auction_records
local selected_auction
function public.on_load()
-- private.listing:SetHandler('OnClick', function(table, row_data, column, button)
-- if button == 'LeftButton' then
-- private.on_row_click(row_data.record)
-- elseif button == 'RightButton' then
-- Aux.tab_group:set_tab(1)
-- Aux.search_frame.start_search(strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact')
-- end
-- end)
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxAuctionsFrameListing, Aux.auction_listing.auctions_config)
private.listing:Show()
private.listing:SetSort(7)
private.listing:Clear()
private.listing:SetHandler('OnCellClick', function(cell, button)
-- if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record then
-- if button == 'LeftButton' and private.buyout_button:IsEnabled() then
-- private.buyout_button:Click()
-- return
-- elseif button == 'RightButton' and private.bid_button:IsEnabled() then
-- private.bid_button:Click()
-- return
-- end
-- end
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record and private.cancel_button:IsEnabled() then
private.cancel_button:Click()
end
end)
private.listing:SetHandler('OnSelectionChanged', function(rt, datum)
-- if not datum then return end
-- private.find_auction(datum.record)
if not datum then return end
private.find_auction(datum.record)
end)
do
@@ -84,7 +69,6 @@ function public.scan_auctions()
private.status_bar:set_text('Scanning auctions...')
auction_records = {}
selected_auction = nil
private.update_listing()
Aux.scan.start{
type = 'owner',
@@ -117,27 +101,10 @@ end
function private.record_remover(record)
return function()
local index = Aux.util.index_of(record, auction_records)
if index then
tremove(auction_records, index)
end
private.update_listing()
private.listing:RemoveAuctionRecord(record)
end
end
function private.find_auction_and_cancel(record)
if not Aux.util.index_of(record, auction_records) then
return
end
Aux.scan_util.find(record, private.status_bar, Aux.util.pass, private.record_remover(record), function(index)
if Aux.util.index_of(record, auction_records) then
CancelAuction(index)
private.record_remover(record)()
end
end)
end
do
local found_index
@@ -162,47 +129,65 @@ do
end)
end
end
do
local scan_id
local IDLE, SEARCHING, FOUND = {}, {}, {}
local state = IDLE
local found_index
function private.find_auction(record)
if not private.listing:ContainsRecord(record) then
return
end
Aux.scan.abort(scan_id)
state = SEARCHING
scan_id = Aux.scan_util.find(
record,
private.status_bar,
function()
state = IDLE
end,
function()
state = IDLE
private.record_remover(record)()
end,
function(index)
state = FOUND
found_index = index
private.cancel_button:SetScript('OnClick', function()
if private.test(record)(index) and private.listing:ContainsRecord(record) then
CancelAuction(index)
private.record_remover(record)()
end
end)
private.cancel_button:Enable()
end
)
end
function public.on_update()
if not private.cancel_button:IsEnabled() then
if state == IDLE or state == SEARCHING then
private.cancel_button:Disable()
end
if state == SEARCHING then
return
end
if not found_index then
local selection = private.listing:GetSelection()
if not selection then
state = IDLE
elseif selection and state == IDLE then
private.find_auction(selection.record)
elseif state == FOUND and not private.test(selection.record)(found_index) then
private.cancel_button:Disable()
return
end
if not selected_auction then
private.cancel_button:Disable()
return
end
if found_index and not private.test(selected_auction)(found_index) then
private.cancel_button:Disable()
private.find_auction(selected_auction)
-- if not Aux.bid_in_progress() then
state = IDLE
-- end
end
end
end
function private.on_row_click(auction_record)
-- if IsControlKeyDown() then
-- DressUpItemLink(datum.hyperlink)
-- elseif IsShiftKeyDown() then
-- if ChatFrameEditBox:IsVisible() then
-- ChatFrameEditBox:Insert(datum.hyperlink)
-- end
-- else
local express_mode = IsAltKeyDown()
if express_mode then
selected_auction = nil
private.find_auction_and_cancel(auction_record)
else
selected_auction = auction_record
private.find_auction(auction_record)
end
-- end
end
end
+61 -97
View File
@@ -1,37 +1,25 @@
local private, public = {}, {}
Aux.bids_frame = public
local refresh
local auction_records
local selected_auction
function public.on_load()
-- private.listing:SetHandler('OnClick', function(table, row_data, column, button)
-- if button == 'LeftButton' then
-- private.on_row_click(row_data.record)
-- elseif button == 'RightButton' then
-- Aux.tab_group:set_tab(1)
-- Aux.search_frame.start_search(strlower(Aux.info.item(this.row.data.record.item_id).name)..'/exact')
-- end
-- end)
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxBidsFrameListing, Aux.auction_listing.bids_config)
private.listing:Show()
private.listing:SetSort(9)
private.listing:Clear()
private.listing:SetHandler('OnCellClick', function(cell, button)
-- if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record then
-- if button == 'LeftButton' and private.buyout_button:IsEnabled() then
-- private.buyout_button:Click()
-- return
-- elseif button == 'RightButton' and private.bid_button:IsEnabled() then
-- private.bid_button:Click()
-- return
-- end
-- end
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and private.buyout_button:IsEnabled() then
private.buyout_button:Click()
elseif button == 'RightButton' and private.bid_button:IsEnabled() then
private.bid_button:Click()
end
end
end)
private.listing:SetHandler('OnSelectionChanged', function(rt, datum)
-- if not datum then return end
-- private.find_auction(datum.record)
if not datum then return end
private.find_auction(datum.record)
end)
do
@@ -94,7 +82,6 @@ function public.scan_bids()
private.status_bar:set_text('Scanning auctions...')
auction_records = {}
selected_auction = nil
private.update_listing()
Aux.scan.start{
type = 'bidder',
@@ -127,102 +114,79 @@ end
function private.record_remover(record)
return function()
local index = Aux.util.index_of(record, auction_records)
if index then
tremove(auction_records, index)
end
private.update_listing()
private.listing:RemoveAuctionRecord(record)
end
end
function private.find_auction_and_bid(record, buyout_mode)
if not Aux.util.index_of(record, auction_records) or (buyout_mode and not record.buyout_price) or (not buyout_mode and record.high_bidder) or Aux.is_player(record.owner) then
return
end
Aux.scan_util.find(record, private.status_bar, Aux.util.pass, private.record_remover(record), function(index)
if Aux.util.index_of(record, auction_records) then
Aux.place_bid('bidder', index, buyout_mode and record.buyout_price or record.bid_price, private.record_remover(record))
end
end)
end
do
local scan_id
local IDLE, SEARCHING, FOUND = {}, {}, {}
local state = IDLE
local found_index
function private.find_auction(record)
if not Aux.util.index_of(record, auction_records) or Aux.is_player(record.owner) then
if not private.listing:ContainsRecord(record) then
return
end
found_index = nil
Aux.scan.abort(scan_id)
state = SEARCHING
scan_id = Aux.scan_util.find(
record,
private.status_bar,
function()
state = IDLE
end,
function()
state = IDLE
private.record_remover(record)()
end,
function(index)
state = FOUND
found_index = index
Aux.scan_util.find(record, private.status_bar, Aux.util.pass, private.record_remover(record), function(index)
if not record.high_bidder then
private.bid_button:SetScript('OnClick', function()
if private.test(record)(index) and private.listing:ContainsRecord(record) then
Aux.place_bid('bidder', index, record.bid_price, private.record_remover(record))
end
end)
private.bid_button:Enable()
end
found_index = index
if not record.high_bidder then
private.bid_button:SetScript('OnClick', function()
if private.test(record)(index) and Aux.util.index_of(record, auction_records) then
Aux.place_bid('bidder', index, record.bid_price, private.record_remover(record))
end
end)
private.bid_button:Enable()
if record.buyout_price > 0 then
private.buyout_button:SetScript('OnClick', function()
if private.test(record)(index) and private.listing:ContainsRecord(record) then
Aux.place_bid('bidder', index, record.buyout_price, private.record_remover(record))
end
end)
private.buyout_button:Enable()
end
end
if record.buyout_price > 0 then
private.buyout_button:SetScript('OnClick', function()
if private.test(record)(index) and Aux.util.index_of(record, auction_records) then
Aux.place_bid('bidder', index, record.buyout_price, private.record_remover(record))
end
end)
private.buyout_button:Enable()
end
end)
)
end
function public.on_update()
if not (private.buyout_button:IsEnabled() or private.bid_button:IsEnabled()) then
if state == IDLE or state == SEARCHING then
private.buyout_button:Disable()
private.bid_button:Disable()
end
if state == SEARCHING then
return
end
if not found_index then
local selection = private.listing:GetSelection()
if not selection then
state = IDLE
elseif selection and state == IDLE then
private.find_auction(selection.record)
elseif state == FOUND and not private.test(selection.record)(found_index) then
private.buyout_button:Disable()
private.bid_button:Disable()
return
end
if not selected_auction then
private.buyout_button:Disable()
private.bid_button:Disable()
return
end
if found_index and not private.test(selected_auction)(found_index) then
private.buyout_button:Disable()
private.bid_button:Disable()
private.find_auction(selected_auction)
if not Aux.bid_in_progress() then
state = IDLE
end
end
end
end
function private.on_row_click(auction_record)
-- if IsControlKeyDown() then
-- DressUpItemLink(datum.hyperlink)
-- elseif IsShiftKeyDown() then
-- if ChatFrameEditBox:IsVisible() then
-- ChatFrameEditBox:Insert(datum.hyperlink)
-- end
-- else
local express_mode = IsAltKeyDown()
local buyout_mode = express_mode and arg1 == 'LeftButton'
if express_mode then
selected_auction = nil
private.find_auction_and_bid(auction_record, buyout_mode)
else
selected_auction = auction_record
private.find_auction(auction_record)
end
-- end
end
+3 -21
View File
@@ -6,7 +6,6 @@ aux_recent_searches = {}
local scanned_records = {}
local aborted_search
local search_scan_id
local find_scan_id
private.popup_info = {
rename = {}
@@ -701,10 +700,8 @@ function public.on_load()
if IsAltKeyDown() and private.results_listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and private.buyout_button:IsEnabled() then
private.buyout_button:Click()
return
elseif button == 'RightButton' and private.bid_button:IsEnabled() then
private.bid_button:Click()
return
end
end
end)
@@ -910,19 +907,8 @@ function private.record_remover(record)
end
end
function private.find_auction_and_bid(record, buyout_mode)
if not private.results_listing:ContainsRecord(record) or (buyout_mode and not record.buyout_price) or (not buyout_mode and record.high_bidder) or Aux.is_player(record.owner) then
return
end
Aux.scan_util.find(record, private.status_bar, Aux.util.pass, private.record_remover(record), function(index)
if private.results_listing:ContainsRecord(record) then
Aux.place_bid('list', index, buyout_mode and record.buyout_price or record.bid_price, private.record_remover(record))
end
end)
end
do
local scan_id
local IDLE, SEARCHING, FOUND = {}, {}, {}
local state = IDLE
local found_index
@@ -932,9 +918,9 @@ do
return
end
Aux.scan.abort(find_scan_id)
Aux.scan.abort(scan_id)
state = SEARCHING
find_scan_id = Aux.scan_util.find(
scan_id = Aux.scan_util.find(
record,
private.status_bar,
function()
@@ -970,10 +956,6 @@ do
end
function public.on_update()
if not AuxSearchFrame:IsVisible() then
return
end
if state == IDLE or state == SEARCHING then
private.buyout_button:Disable()
private.bid_button:Disable()