another massive refactoring, only post panel missing
This commit is contained in:
+77
-65
@@ -1,15 +1,28 @@
|
||||
local private, public = {}, {}
|
||||
Aux.auctions_frame = public
|
||||
|
||||
local refresh
|
||||
local auction_records
|
||||
local selected_auction
|
||||
|
||||
function private.select_auction(entry)
|
||||
selected_auction = entry
|
||||
refresh = true
|
||||
private.cancel_button:Disable()
|
||||
end
|
||||
|
||||
function private.clear_selection(entry)
|
||||
selected_auction = nil
|
||||
refresh = true
|
||||
private.cancel_button:Disable()
|
||||
end
|
||||
|
||||
function public.on_load()
|
||||
private.auction_listing_config = {
|
||||
frame = AuxAuctionsFrameListingAuctionListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
public.on_auction_click(sheet.data[data_index])
|
||||
private.on_row_click(sheet.data[data_index])
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
@@ -25,6 +38,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return datum == selected_auction
|
||||
end,
|
||||
row_setter = function(row, datum)
|
||||
row:SetAlpha(datum.gone and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(datum.item_id, datum.suffix_id, nil, datum.enchant_id)
|
||||
@@ -103,13 +119,13 @@ function public.on_load()
|
||||
{
|
||||
title = 'Current Bid',
|
||||
width = 80,
|
||||
comparator = function(auction1, auction2) return Aux.util.compare(auction1.current_bid, auction2.current_bid, Aux.util.GT) end,
|
||||
comparator = function(auction1, auction2) return Aux.util.compare(auction1.high_bid, auction2.high_bid, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
|
||||
cell_setter = function(cell, auction)
|
||||
cell.text:SetText(auction.current_bid and Aux.util.money_string(auction.current_bid) or RED_FONT_COLOR_CODE..'No Bids'..FONT_COLOR_CODE_CLOSE)
|
||||
cell.text:SetText(auction.high_bid and Aux.util.money_string(auction.high_bid) or RED_FONT_COLOR_CODE..'No Bids'..FONT_COLOR_CODE_CLOSE)
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.money_column('Min Bid', function(entry) return entry.min_bid end),
|
||||
Aux.listing_util.money_column('Min Bid', function(entry) return entry.start_price end),
|
||||
Aux.listing_util.money_column('Buy', function(entry) return entry.buyout_price end),
|
||||
},
|
||||
sort_order = {{ column = 1, order = 'ascending' }},
|
||||
@@ -138,12 +154,11 @@ end
|
||||
|
||||
function public.on_open()
|
||||
public.update_auction_records()
|
||||
public.update_listing()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
private.listing:clear_selection()
|
||||
private.cancel_button:Disable()
|
||||
private.clear_selection()
|
||||
end
|
||||
|
||||
function public.update_auction_records()
|
||||
@@ -168,7 +183,7 @@ function public.update_auction_records()
|
||||
on_complete = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
public.update_listing()
|
||||
refresh = true
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
@@ -183,7 +198,11 @@ function public.update_auction_records()
|
||||
}
|
||||
end
|
||||
|
||||
function public.update_listing()
|
||||
function private.update_listing()
|
||||
if not AuxAuctionsFrame:IsVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
AuxAuctionsFrameListingAuctionListing:Show()
|
||||
Aux.sheet.populate(private.listing, auction_records)
|
||||
AuxAuctionsFrameListing:SetWidth(AuxAuctionsFrameListingAuctionListing:GetWidth() + 40)
|
||||
@@ -192,10 +211,7 @@ end
|
||||
|
||||
function private.create_auction_record(auction_info, page)
|
||||
|
||||
local aux_quantity = auction_info.charges or auction_info.count
|
||||
local bid = (auction_info.current_bid > 0 and auction_info.current_bid or auction_info.min_bid) + auction_info.min_increment
|
||||
local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil
|
||||
local buyout_price_per_unit = buyout_price and Aux.round(auction_info.buyout_price / aux_quantity)
|
||||
|
||||
local status
|
||||
if auction_info.high_bidder then
|
||||
@@ -208,93 +224,89 @@ function private.create_auction_record(auction_info, page)
|
||||
page = page,
|
||||
|
||||
item_id = auction_info.item_id,
|
||||
key = auction_info.item_signature,
|
||||
signature = Aux.auction_signature(auction_info.hyperlink, aux_quantity, bid, auction_info.buyout_price, auction_info.duration),
|
||||
item_key = auction_info.item_key,
|
||||
signature = auction_info.signature,
|
||||
|
||||
name = auction_info.name,
|
||||
tooltip = auction_info.tooltip,
|
||||
aux_quantity = aux_quantity,
|
||||
aux_quantity = auction_info.aux_quantity,
|
||||
buyout_price = buyout_price,
|
||||
buyout_price_per_unit = buyout_price_per_unit,
|
||||
quality = auction_info.quality,
|
||||
hyperlink = auction_info.hyperlink,
|
||||
itemstring = auction_info.itemstring,
|
||||
bid = bid,
|
||||
duration = auction_info.duration,
|
||||
usable = auction_info.usable,
|
||||
high_bidder = auction_info.high_bidder,
|
||||
current_bid = auction_info.current_bid > 0 and auction_info.current_bid or nil,
|
||||
min_bid = auction_info.min_bid,
|
||||
high_bid = auction_info.high_bid > 0 and auction_info.high_bid or nil,
|
||||
start_price = auction_info.start_price,
|
||||
status = status,
|
||||
|
||||
EnhTooltip_info = auction_info.EnhTooltip_info,
|
||||
}
|
||||
end
|
||||
|
||||
function private.find_auction(entry, express_mode)
|
||||
function private.process_request(entry, express_mode)
|
||||
|
||||
if entry.gone then
|
||||
return
|
||||
end
|
||||
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
|
||||
local function test(index)
|
||||
return private.create_auction_record(Aux.info.auction(index, 'owner')).signature == entry.signature
|
||||
local auction_record = private.create_auction_record(Aux.info.auction(index, 'owner'))
|
||||
return auction_record.signature == entry.signature and auction_record.bid_price == entry.bid_price and auction_record.duration == entry.duration
|
||||
end
|
||||
|
||||
Aux.scan_util.find_auction('owner', test, {}, entry.page, private.status_bar, function(index)
|
||||
|
||||
if not index then
|
||||
entry.gone = true
|
||||
private.listing:clear_selection()
|
||||
refresh = true
|
||||
return
|
||||
end
|
||||
|
||||
if not test(index) then
|
||||
return private.find_auction(entry, express_mode) -- try again
|
||||
end
|
||||
|
||||
if express_mode then
|
||||
CancelAuction(index)
|
||||
entry.gone = true
|
||||
|
||||
private.listing:clear_selection()
|
||||
refresh = true
|
||||
else
|
||||
private.cancel_button:SetScript('OnClick', function()
|
||||
|
||||
if not test(index) then
|
||||
private.cancel_button:Disable()
|
||||
return private.find_auction(entry, express_mode) -- try again
|
||||
end
|
||||
local function remove_entry()
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
private.clear_selection()
|
||||
end
|
||||
|
||||
if express_mode then
|
||||
Aux.scan_util.find('owner', test, {}, entry.page, private.status_bar, remove_entry, function(index)
|
||||
if not entry.gone then
|
||||
CancelAuction(index)
|
||||
entry.gone = true
|
||||
remove_entry()
|
||||
end
|
||||
end)
|
||||
else
|
||||
private.select_auction(entry)
|
||||
|
||||
private.cancel_button:Disable()
|
||||
private.listing:clear_selection()
|
||||
refresh = true -- TODO
|
||||
Aux.scan_util.find('owner', test, {}, entry.page, private.status_bar, remove_entry, function(index)
|
||||
|
||||
private.cancel_button:SetScript('OnClick', function()
|
||||
if test(index) and not entry.gone then
|
||||
CancelAuction(index)
|
||||
remove_entry()
|
||||
else
|
||||
private.clear_selection()
|
||||
end
|
||||
end)
|
||||
private.cancel_button:Enable()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function public.on_auction_click(auction_record)
|
||||
|
||||
local express_mode = IsAltKeyDown()
|
||||
function private.on_row_click(datum)
|
||||
|
||||
if IsControlKeyDown() then
|
||||
DressUpItemLink(auction_record.hyperlink)
|
||||
DressUpItemLink(datum.hyperlink)
|
||||
elseif IsShiftKeyDown() then
|
||||
if ChatFrameEditBox:IsVisible() then
|
||||
ChatFrameEditBox:Insert(auction_record.hyperlink)
|
||||
ChatFrameEditBox:Insert(datum.hyperlink)
|
||||
end
|
||||
elseif not auction_record.gone then
|
||||
if not express_mode then
|
||||
private.cancel_button:Disable()
|
||||
private.listing:clear_selection()
|
||||
private.listing:select(auction_record)
|
||||
end
|
||||
private.find_auction(auction_record, express_mode)
|
||||
else
|
||||
local express_mode = IsAltKeyDown()
|
||||
private.process_request(datum, express_mode)
|
||||
end
|
||||
end
|
||||
|
||||
function public.on_update()
|
||||
if refresh then
|
||||
refresh = false
|
||||
private.update_listing()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
<Script file="auctions_frame.lua"/>
|
||||
|
||||
<Frame>
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.auctions_frame.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
<Frame name="AuxAuctionsFrame" hidden="true" parent="AuxFrame" setAllPoints="true">
|
||||
<Frames>
|
||||
<Frame name="$parentListing" inherits="AuxFrameBoxTemplate">
|
||||
|
||||
+94
-90
@@ -1,19 +1,35 @@
|
||||
local private, public = {}, {}
|
||||
Aux.bids_frame = public
|
||||
|
||||
local refresh
|
||||
local bid_records
|
||||
local selected_auction
|
||||
|
||||
function private.select_auction(entry)
|
||||
selected_auction = entry
|
||||
refresh = true
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function private.clear_selection(entry)
|
||||
selected_auction = nil
|
||||
refresh = true
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function public.on_load()
|
||||
private.bid_listing_config = {
|
||||
frame = AuxBidsFrameListingBidListing,
|
||||
on_row_click = function(sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
public.on_bid_click(sheet.data[data_index])
|
||||
private.on_row_click(sheet.data[data_index])
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
on_row_enter = function(sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
end,
|
||||
on_row_leave = function (sheet, row_index)
|
||||
on_row_leave = function(sheet, row_index)
|
||||
AuxTooltip:Hide()
|
||||
ResetCursor()
|
||||
end,
|
||||
@@ -26,6 +42,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return datum == selected_auction
|
||||
end,
|
||||
row_setter = function(row, datum)
|
||||
row:SetAlpha(datum.gone and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(datum.item_id, datum.suffix_id, nil, datum.enchant_id)
|
||||
@@ -111,7 +130,8 @@ function public.on_load()
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.owner_column(function(datum) return datum.owner end),
|
||||
Aux.listing_util.money_column('Your Bid', function(entry) return entry.current_bid end),
|
||||
Aux.listing_util.money_column('Your Bid', function(entry) return entry.your_bid end),
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid_price end),
|
||||
Aux.listing_util.money_column('Buy', function(entry) return entry.buyout_price end),
|
||||
},
|
||||
sort_order = {{ column = 1, order = 'ascending' }},
|
||||
@@ -149,13 +169,11 @@ end
|
||||
|
||||
function public.on_open()
|
||||
public.update_bid_records()
|
||||
public.update_listing()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
private.listing:clear_selection()
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
private.clear_selection()
|
||||
end
|
||||
|
||||
function public.update_bid_records()
|
||||
@@ -175,12 +193,12 @@ function public.update_bid_records()
|
||||
current_page = page
|
||||
end,
|
||||
on_read_auction = function(auction_info)
|
||||
tinsert(bid_records, private.create_bid_record(auction_info, current_page))
|
||||
tinsert(bid_records, private.create_auction_record(auction_info, current_page))
|
||||
end,
|
||||
on_complete = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
public.update_listing()
|
||||
refresh = true
|
||||
end,
|
||||
on_abort = function()
|
||||
private.status_bar:update_status(100, 100)
|
||||
@@ -195,19 +213,20 @@ function public.update_bid_records()
|
||||
}
|
||||
end
|
||||
|
||||
function public.update_listing()
|
||||
function private.update_listing()
|
||||
if not AuxBidsFrame:IsVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
AuxBidsFrameListingBidListing:Show()
|
||||
Aux.sheet.populate(private.listing, bid_records)
|
||||
AuxBidsFrameListing:SetWidth(AuxBidsFrameListingBidListing:GetWidth() + 40)
|
||||
AuxFrame:SetWidth(AuxBidsFrameListing:GetWidth() + 15)
|
||||
end
|
||||
|
||||
function private.create_bid_record(auction_info, page)
|
||||
function private.create_auction_record(auction_info, page)
|
||||
|
||||
local aux_quantity = auction_info.charges or auction_info.count
|
||||
local bid = (auction_info.current_bid > 0 and auction_info.current_bid or auction_info.min_bid) + auction_info.min_increment
|
||||
local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil
|
||||
local buyout_price_per_unit = buyout_price and Aux.round(auction_info.buyout_price / aux_quantity)
|
||||
|
||||
local status
|
||||
if auction_info.high_bidder then
|
||||
@@ -220,119 +239,104 @@ function private.create_bid_record(auction_info, page)
|
||||
page = page,
|
||||
|
||||
item_id = auction_info.item_id,
|
||||
key = auction_info.item_signature,
|
||||
signature = Aux.auction_signature(auction_info.hyperlink, aux_quantity, bid, auction_info.buyout_price),
|
||||
suffix_id = auction_info.suffix_id,
|
||||
unique_id = auction_info.unique_id,
|
||||
enchant_id = auction_info.enchant_id,
|
||||
|
||||
item_id = auction_info.item_id,
|
||||
item_key = auction_info.item_key,
|
||||
signature = auction_info.signature,
|
||||
|
||||
name = auction_info.name,
|
||||
tooltip = auction_info.tooltip,
|
||||
aux_quantity = aux_quantity,
|
||||
aux_quantity = auction_info.aux_quantity,
|
||||
buyout_price = buyout_price,
|
||||
buyout_price_per_unit = buyout_price_per_unit,
|
||||
quality = auction_info.quality,
|
||||
hyperlink = auction_info.hyperlink,
|
||||
itemstring = auction_info.itemstring,
|
||||
bid = bid,
|
||||
bid_price = auction_info.bid_price,
|
||||
owner = auction_info.owner,
|
||||
duration = auction_info.duration,
|
||||
usable = auction_info.usable,
|
||||
high_bidder = auction_info.high_bidder,
|
||||
current_bid = auction_info.current_bid > 0 and auction_info.current_bid or nil,
|
||||
your_bid = auction_info.high_bidder and auction_info.high_bid,
|
||||
status = status,
|
||||
|
||||
EnhTooltip_info = auction_info.EnhTooltip_info,
|
||||
}
|
||||
end
|
||||
|
||||
function private.find_auction(entry, express_mode, buyout_mode)
|
||||
function private.process_request(entry, express_mode, buyout_mode)
|
||||
|
||||
if buyout_mode and not entry.buyout_price then
|
||||
if entry.gone or (buyout_mode and not entry.buyout_price) or (express_mode and not buyout_mode and entry.high_bidder) or entry.owner == UnitName('player') then
|
||||
return
|
||||
end
|
||||
|
||||
local amount
|
||||
if buyout_mode then
|
||||
amount = entry.buyout_price
|
||||
else
|
||||
amount = entry.bid
|
||||
end
|
||||
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
|
||||
local function test(index)
|
||||
return private.create_bid_record(Aux.info.auction(index, 'bidder')).signature == entry.signature
|
||||
local auction_record = private.create_auction_record(Aux.info.auction(index, 'bidder'))
|
||||
return auction_record.signature == entry.signature and auction_record.bid_price == entry.bid_price and auction_record.owner ~= UnitName('player')
|
||||
end
|
||||
|
||||
Aux.scan_util.find_auction('bidder', test, {}, entry.page, private.status_bar, function(index)
|
||||
local function remove_entry()
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
private.clear_selection()
|
||||
end
|
||||
|
||||
if not index then
|
||||
entry.gone = true
|
||||
private.listing:clear_selection()
|
||||
refresh = true
|
||||
return
|
||||
end
|
||||
if express_mode then
|
||||
Aux.scan_util.find('bidder', test, {}, entry.page, private.status_bar, remove_entry, function(index)
|
||||
if not entry.gone then
|
||||
Aux.place_bid('bidder', index, buyout_mode and entry.buyout_price or entry.bid_price, remove_entry)
|
||||
end
|
||||
end)
|
||||
else
|
||||
private.select_auction(entry)
|
||||
|
||||
if not test(index) then
|
||||
return private.find_auction(entry, express_mode, buyout_mode) -- try again
|
||||
end
|
||||
Aux.scan_util.find('bidder', test, {}, entry.page, private.status_bar, remove_entry, function(index)
|
||||
|
||||
if express_mode then
|
||||
if Aux.bid_lock then
|
||||
return
|
||||
if not entry.high_bidder then
|
||||
private.bid_button:SetScript('OnClick', function()
|
||||
if test(index) and not entry.gone then
|
||||
Aux.place_bid('bidder', index, entry.bid_price, remove_entry)
|
||||
end
|
||||
private.clear_selection()
|
||||
end)
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
if entry.buyout_price then
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if test(index) and not entry.gone then
|
||||
Aux.place_bid('bidder', index, entry.buyout_price, remove_entry)
|
||||
end
|
||||
private.clear_selection()
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
Aux.place_bid('bidder', index, amount)
|
||||
|
||||
private.listing:clear_selection()
|
||||
refresh = true
|
||||
else
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if Aux.bid_lock then
|
||||
return
|
||||
end
|
||||
|
||||
if not test(index) then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
return private.find_auction(entry, express_mode, buyout_mode) -- try again
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
end
|
||||
Aux.place_bid('bidder', index, entry.buyout_price)
|
||||
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
private.listing:clear_selection()
|
||||
refresh = true
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function public.on_bid_click(bid_record)
|
||||
|
||||
local express_mode = IsAltKeyDown()
|
||||
local buyout_mode = express_mode and arg1 == 'LeftButton'
|
||||
function private.on_row_click(datum)
|
||||
|
||||
if IsControlKeyDown() then
|
||||
DressUpItemLink(bid_record.hyperlink)
|
||||
DressUpItemLink(datum.hyperlink)
|
||||
elseif IsShiftKeyDown() then
|
||||
if ChatFrameEditBox:IsVisible() then
|
||||
ChatFrameEditBox:Insert(bid_record.hyperlink)
|
||||
ChatFrameEditBox:Insert(datum.hyperlink)
|
||||
end
|
||||
elseif not bid_record.gone then
|
||||
if not express_mode then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
private.listing:clear_selection()
|
||||
private.listing:select(bid_record)
|
||||
end
|
||||
private.find_auction(bid_record, express_mode, buyout_mode)
|
||||
else
|
||||
local express_mode = IsAltKeyDown()
|
||||
local buyout_mode = express_mode and arg1 == 'LeftButton'
|
||||
private.process_request(datum, express_mode, buyout_mode)
|
||||
end
|
||||
end
|
||||
|
||||
function public.on_update()
|
||||
if refresh then
|
||||
refresh = false
|
||||
private.update_listing()
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
<Script file="bids_frame.lua"/>
|
||||
|
||||
<Frame>
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.bids_frame.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
<Frame name="AuxBidsFrame" hidden="true" parent="AuxFrame" setAllPoints="true">
|
||||
<Frames>
|
||||
<Frame name="$parentListing" inherits="AuxFrameBoxTemplate">
|
||||
|
||||
@@ -7,15 +7,6 @@ Aux = {
|
||||
blizzard_ui_shown = false,
|
||||
loaded = false,
|
||||
orig = {},
|
||||
elements = {},
|
||||
tabs = {
|
||||
browse = {
|
||||
index = 1
|
||||
},
|
||||
post = {
|
||||
index = 2
|
||||
},
|
||||
},
|
||||
last_picked_up = {},
|
||||
view = {
|
||||
BUYOUT = 1,
|
||||
@@ -131,16 +122,28 @@ function Aux_OnAddonLoaded()
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.place_bid(type, index, bid)
|
||||
local money = GetMoney()
|
||||
if money >= bid then
|
||||
Aux.bid_lock = true
|
||||
local t0 = GetTime()
|
||||
Aux.control.as_soon_as(function() return GetMoney() < money or GetTime() - t0 > 10 end, function()
|
||||
Aux.bid_lock = false
|
||||
end)
|
||||
do
|
||||
local locked
|
||||
|
||||
function Aux.place_bid(type, index, amount, on_success)
|
||||
|
||||
if locked then
|
||||
return
|
||||
end
|
||||
|
||||
local money = GetMoney()
|
||||
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
|
||||
on_success()
|
||||
end
|
||||
locked = false
|
||||
end)
|
||||
end
|
||||
PlaceAuctionBid(type, index, amount)
|
||||
end
|
||||
PlaceAuctionBid(type, index, bid)
|
||||
end
|
||||
|
||||
function Aux.log_frame_load()
|
||||
@@ -374,10 +377,6 @@ function Aux_QualityColor(code)
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.auction_signature(hyperlink, stack_size, bid, amount)
|
||||
return hyperlink .. (stack_size or '0') .. '_' .. (bid or '0') .. '_' .. (amount or '0')
|
||||
end
|
||||
|
||||
function Aux.item_class_index(item_class)
|
||||
for i, class in ipairs({ GetAuctionItemClasses() }) do
|
||||
if class == item_class then
|
||||
|
||||
+102
-117
@@ -1,5 +1,3 @@
|
||||
Aux.buy = {}
|
||||
|
||||
local private, public = {}, {}
|
||||
Aux.filter_search_frame = public
|
||||
|
||||
@@ -7,11 +5,24 @@ local auctions
|
||||
local search_query
|
||||
local tooltip_patterns = {}
|
||||
local refresh
|
||||
local selected_auction
|
||||
|
||||
function private.select_auction(entry)
|
||||
selected_auction = entry
|
||||
refresh = true
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function private.clear_selection(entry)
|
||||
selected_auction = nil
|
||||
refresh = true
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
private.clear_selection()
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
@@ -22,14 +33,14 @@ function public.on_load()
|
||||
private.views = {
|
||||
[Aux.view.BUYOUT] = {
|
||||
frame = AuxFilterSearchFrameResultsBuyListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
on_row_click = function(sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
private.on_row_click(sheet, sheet.data[data_index], true)
|
||||
private.on_row_click(sheet.data[data_index], true)
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
on_row_enter = function(sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
end,
|
||||
on_row_leave = function (sheet, row_index)
|
||||
on_row_leave = function(sheet, row_index)
|
||||
AuxTooltip:Hide()
|
||||
ResetCursor()
|
||||
end,
|
||||
@@ -42,6 +53,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return Aux.util.any(datum, function(entry) return entry == selected_auction end)
|
||||
end,
|
||||
row_setter = function(row, group)
|
||||
row:SetAlpha(Aux.util.all(group, function(auction) return auction.gone end) and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(group[1].item_id, group[1].suffix_id, nil, group[1].enchant_id)
|
||||
@@ -99,7 +113,7 @@ function public.on_load()
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.money_column('Buy', function(group) return group[1].buyout_price end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(group) return group[1].buyout_price_per_unit end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(group) return group[1].unit_buyout_price end),
|
||||
{
|
||||
title = 'Avail',
|
||||
width = 40,
|
||||
@@ -109,20 +123,20 @@ function public.on_load()
|
||||
cell.text:SetText(getn(Aux.util.filter(group, function(auction) return not auction.gone end)))
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.percentage_market_column(function(group) return group[1].item_key end, function(group) return group[1].buyout_price_per_unit end),
|
||||
Aux.listing_util.percentage_market_column(function(group) return group[1].item_key end, function(group) return group[1].unit_buyout_price end),
|
||||
},
|
||||
sort_order = {{column = 1, order = 'ascending' }, {column = 4, order = 'ascending'}},
|
||||
},
|
||||
[Aux.view.BID] = {
|
||||
frame = AuxFilterSearchFrameResultsBidListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
on_row_click = function(sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
private.on_row_click(sheet, sheet.data[data_index])
|
||||
private.on_row_click(sheet.data[data_index])
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
on_row_enter = function(sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
end,
|
||||
on_row_leave = function (sheet, row_index)
|
||||
on_row_leave = function(sheet, row_index)
|
||||
AuxTooltip:Hide()
|
||||
ResetCursor()
|
||||
end,
|
||||
@@ -135,6 +149,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return datum == selected_auction
|
||||
end,
|
||||
row_setter = function(row, datum)
|
||||
row:SetAlpha(datum.gone and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(datum.item_id, datum.suffix_id, datum.unique_id, datum.enchant_id)
|
||||
@@ -191,8 +208,8 @@ function public.on_load()
|
||||
cell.text:SetText(datum.aux_quantity)
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.bid_per_unit end),
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid_price end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.unit_bid_price end),
|
||||
{
|
||||
title = 'Status',
|
||||
width = 70,
|
||||
@@ -235,14 +252,14 @@ function public.on_load()
|
||||
},
|
||||
[Aux.view.FULL] = {
|
||||
frame = AuxFilterSearchFrameResultsFullListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
on_row_click = function(sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
private.on_row_click(sheet, sheet.data[data_index])
|
||||
private.on_row_click(sheet.data[data_index])
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
on_row_enter = function(sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
end,
|
||||
on_row_leave = function (sheet, row_index)
|
||||
on_row_leave = function(sheet, row_index)
|
||||
AuxTooltip:Hide()
|
||||
ResetCursor()
|
||||
end,
|
||||
@@ -255,6 +272,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return datum == selected_auction
|
||||
end,
|
||||
row_setter = function(row, datum)
|
||||
row:SetAlpha(datum.gone and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(datum.item_id, datum.suffix_id, datum.unique_id, datum.enchant_id)
|
||||
@@ -327,10 +347,10 @@ function public.on_load()
|
||||
cell.text:SetText(datum.aux_quantity)
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid end),
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid_price end),
|
||||
Aux.listing_util.money_column('Buy', function(entry) return entry.buyout_price end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.bid_per_unit end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(entry) return entry.buyout_price_per_unit end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.unit_bid_price end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(entry) return entry.unit_buyout_price end),
|
||||
{
|
||||
title = 'Status',
|
||||
width = 70,
|
||||
@@ -360,7 +380,7 @@ function public.on_load()
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.owner_column(function(datum) return datum.owner end),
|
||||
Aux.listing_util.percentage_market_column(function(entry) return entry.item_key end, function(entry) return entry.buyout_price_per_unit end),
|
||||
Aux.listing_util.percentage_market_column(function(entry) return entry.item_key end, function(entry) return entry.unit_buyout_price end),
|
||||
},
|
||||
sort_order = {{column = 1, order = 'ascending' }, {column = 7, order = 'ascending' }},
|
||||
},
|
||||
@@ -647,21 +667,17 @@ function private.update_listing()
|
||||
end
|
||||
|
||||
function public.set_view(view)
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
private.clear_selection()
|
||||
aux_view = view
|
||||
private.update_listing()
|
||||
end
|
||||
|
||||
function public.set_item(item_id)
|
||||
private.item_id = item_id
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function public.start_search()
|
||||
|
||||
Aux.scan.abort(function()
|
||||
|
||||
private.clear_selection()
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
@@ -740,82 +756,60 @@ function public.start_search()
|
||||
end)
|
||||
end
|
||||
|
||||
function private.clear_selection()
|
||||
private.listings[aux_view]:clear_selection()
|
||||
end
|
||||
function private.process_request(entry, express_mode, buyout_mode)
|
||||
|
||||
function private.find_auction(entry, express_mode, buyout_mode)
|
||||
|
||||
if buyout_mode and not entry.buyout_price then
|
||||
return
|
||||
end
|
||||
|
||||
local amount
|
||||
if buyout_mode then
|
||||
amount = entry.buyout_price
|
||||
else
|
||||
amount = entry.bid
|
||||
if entry.gone or (buyout_mode and not entry.buyout_price) or (express_mode and not buyout_mode and entry.high_bidder) or entry.owner == UnitName('player') then
|
||||
return
|
||||
end
|
||||
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
|
||||
local function test(index)
|
||||
return private.create_auction_record(Aux.info.auction(index)).signature == entry.signature
|
||||
local auction_record = private.create_auction_record(Aux.info.auction(index))
|
||||
return auction_record.signature == entry.signature and auction_record.bid_price == entry.bid_price and auction_record.owner ~= UnitName('player')
|
||||
end
|
||||
|
||||
Aux.scan_util.find_auction('list', test, search_query, entry.page, private.status_bar, function(index)
|
||||
if not index then
|
||||
entry.gone = true
|
||||
private.clear_selection()
|
||||
refresh = true
|
||||
return
|
||||
end
|
||||
local function remove_entry()
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
private.clear_selection()
|
||||
end
|
||||
|
||||
if not test(index) then
|
||||
return private.find_auction(entry, express_mode, buyout_mode) -- try again
|
||||
end
|
||||
if express_mode then
|
||||
Aux.scan_util.find('list', test, search_query, entry.page, private.status_bar, remove_entry, function(index)
|
||||
if not entry.gone then
|
||||
Aux.place_bid('list', index, buyout_mode and entry.buyout_price or entry.bid_price, remove_entry)
|
||||
end
|
||||
end)
|
||||
else
|
||||
private.select_auction(entry)
|
||||
|
||||
if express_mode then
|
||||
if Aux.bid_lock then
|
||||
return
|
||||
Aux.scan_util.find('list', test, search_query, entry.page, private.status_bar, remove_entry, function(index)
|
||||
|
||||
if not entry.high_bidder then
|
||||
private.bid_button:SetScript('OnClick', function()
|
||||
if test(index) and not entry.gone then
|
||||
Aux.place_bid('list', index, entry.bid_price, remove_entry)
|
||||
end
|
||||
private.clear_selection()
|
||||
end)
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
if entry.buyout_price then
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if test(index) and not entry.gone then
|
||||
Aux.place_bid('list', index, entry.buyout_price, remove_entry)
|
||||
end
|
||||
private.clear_selection()
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
Aux.place_bid('list', index, amount)
|
||||
|
||||
private.clear_selection()
|
||||
refresh = true
|
||||
else
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if Aux.bid_lock then
|
||||
return
|
||||
end
|
||||
|
||||
if not test(index) then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
return private.find_auction(entry, express_mode, buyout_mode) -- try again
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
end
|
||||
Aux.place_bid('list', index, entry.buyout_price)
|
||||
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
private.clear_selection()
|
||||
refresh = true
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function private.on_row_click(sheet, datum, grouped)
|
||||
function private.on_row_click(datum, grouped)
|
||||
|
||||
local entry
|
||||
if grouped then
|
||||
@@ -824,32 +818,23 @@ function private.on_row_click(sheet, datum, grouped)
|
||||
entry = datum
|
||||
end
|
||||
|
||||
local express_mode = IsAltKeyDown()
|
||||
local buyout_mode = express_mode and arg1 == 'LeftButton'
|
||||
|
||||
if IsControlKeyDown() then
|
||||
DressUpItemLink(entry.hyperlink)
|
||||
elseif IsShiftKeyDown() then
|
||||
if ChatFrameEditBox:IsVisible() then
|
||||
ChatFrameEditBox:Insert(entry.hyperlink)
|
||||
end
|
||||
elseif not entry.gone and entry.owner ~= UnitName('player') then
|
||||
if not express_mode then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
sheet:clear_selection()
|
||||
sheet:select(datum)
|
||||
end
|
||||
private.find_auction(entry, express_mode, buyout_mode)
|
||||
else
|
||||
local express_mode = IsAltKeyDown()
|
||||
local buyout_mode = express_mode and arg1 == 'LeftButton'
|
||||
private.process_request(entry, express_mode, buyout_mode)
|
||||
end
|
||||
end
|
||||
|
||||
function private.create_auction_record(auction_info, current_page)
|
||||
|
||||
local aux_quantity = auction_info.charges or auction_info.count
|
||||
local bid = (auction_info.current_bid > 0 and auction_info.current_bid or auction_info.min_bid) + auction_info.min_increment
|
||||
function private.create_auction_record(auction_info, page)
|
||||
|
||||
local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil
|
||||
local buyout_price_per_unit = buyout_price and Aux.round(auction_info.buyout_price / aux_quantity)
|
||||
local unit_buyout_price = buyout_price and Aux.round(auction_info.buyout_price / auction_info.aux_quantity)
|
||||
local status
|
||||
if auction_info.current_bid == 0 then
|
||||
status = 'No Bid'
|
||||
@@ -860,27 +845,27 @@ function private.create_auction_record(auction_info, current_page)
|
||||
end
|
||||
|
||||
return {
|
||||
page = page,
|
||||
|
||||
item_id = auction_info.item_id,
|
||||
suffix_id = auction_info.suffix_id,
|
||||
unique_id = auction_info.unique_id,
|
||||
enchant_id = auction_info.enchant_id,
|
||||
|
||||
item_key = auction_info.item_key,
|
||||
key = auction_info.item_signature,
|
||||
signature = Aux.auction_signature(auction_info.hyperlink, aux_quantity, bid, auction_info.buyout_price),
|
||||
signature = auction_info.signature,
|
||||
|
||||
name = auction_info.name,
|
||||
level = auction_info.level,
|
||||
tooltip = auction_info.tooltip,
|
||||
aux_quantity = aux_quantity,
|
||||
aux_quantity = auction_info.aux_quantity,
|
||||
buyout_price = buyout_price,
|
||||
buyout_price_per_unit = buyout_price_per_unit,
|
||||
unit_buyout_price = unit_buyout_price,
|
||||
quality = auction_info.quality,
|
||||
hyperlink = auction_info.hyperlink,
|
||||
itemstring = auction_info.itemstring,
|
||||
page = current_page,
|
||||
bid = bid,
|
||||
bid_per_unit = Aux.round(bid / aux_quantity),
|
||||
bid_price = auction_info.bid_price,
|
||||
unit_bid_price = Aux.round(auction_info.bid_price / auction_info.aux_quantity),
|
||||
owner = auction_info.owner,
|
||||
duration = auction_info.duration,
|
||||
usable = auction_info.usable,
|
||||
@@ -891,7 +876,7 @@ function private.create_auction_record(auction_info, current_page)
|
||||
}
|
||||
end
|
||||
|
||||
function Aux.buy.onupdate()
|
||||
function public.on_update()
|
||||
if refresh then
|
||||
refresh = false
|
||||
private.update_listing()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Frame>
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.buy.onupdate()
|
||||
Aux.filter_search_frame.on_update()
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
@@ -50,7 +50,7 @@ end
|
||||
|
||||
|
||||
function m.resize_tab(tab, width, padding)
|
||||
tab:SetWidth(width + padding + 8)
|
||||
tab:SetWidth(width + padding + 10)
|
||||
end
|
||||
|
||||
function m.update_tab(tab)
|
||||
|
||||
@@ -78,10 +78,11 @@ function public.auction(index, type)
|
||||
local item_id, suffix_id, unique_id, enchant_id = private.parse_hyperlink(hyperlink)
|
||||
local item_info = public.item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local name, texture, count, quality, usable, level, min_bid, min_increment, buyout_price, current_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(type, index)
|
||||
local name, texture, count, quality, usable, level, start_price, min_increment, buyout_price, high_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(type, index)
|
||||
local duration = GetAuctionItemTimeLeft(type, index)
|
||||
local tooltip = public.tooltip(function(tt) tt:SetAuctionItem(type, index) end)
|
||||
local charges = private.item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
|
||||
return {
|
||||
index = index,
|
||||
@@ -94,7 +95,7 @@ function public.auction(index, type)
|
||||
hyperlink = hyperlink,
|
||||
itemstring = item_info.itemstring,
|
||||
item_key = item_id..':'..suffix_id,
|
||||
signature = public.auction_signature(index, type),
|
||||
signature = Aux.persistence.serialize({item_id, suffix_id, unique_id, enchant_id, aux_quantity, start_price, buyout_price}, ':'), -- not unique!
|
||||
|
||||
name = name,
|
||||
texture = texture,
|
||||
@@ -105,10 +106,13 @@ function public.auction(index, type)
|
||||
max_stack = item_info.max_stack,
|
||||
|
||||
count = count,
|
||||
min_bid = min_bid,
|
||||
min_bid = start_price, -- deprecated
|
||||
start_price = start_price,
|
||||
high_bid = high_bid,
|
||||
current_bid = high_bid, -- deprecated
|
||||
min_increment = min_increment,
|
||||
bid_price = (high_bid > 0 and high_bid or start_price) + min_increment,
|
||||
buyout_price = buyout_price,
|
||||
current_bid = current_bid,
|
||||
high_bidder = high_bidder,
|
||||
owner = owner,
|
||||
sale_status = sale_status,
|
||||
@@ -116,7 +120,7 @@ function public.auction(index, type)
|
||||
usable = usable,
|
||||
tooltip = tooltip,
|
||||
charges = charges,
|
||||
aux_quantity = charges or count,
|
||||
aux_quantity = aux_quantity,
|
||||
|
||||
EnhTooltip_info = {
|
||||
name = name,
|
||||
@@ -208,33 +212,6 @@ function private.item_charges(tooltip)
|
||||
end
|
||||
end
|
||||
|
||||
-- not unique!
|
||||
function public.auction_signature(index, type)
|
||||
type = type or 'list'
|
||||
-- owner not used because waiting for it would slow down the scan too much
|
||||
local _, _, count, _, _, _, min_bid, _, buyout_price, _, _, owner = GetAuctionItemInfo('list', index)
|
||||
local hyperlink = GetAuctionItemLink(type, index)
|
||||
local item_id, suffix_id, unique_id, enchant_id = private.parse_hyperlink(hyperlink)
|
||||
return format(
|
||||
'%s:%s:%s:%s:%s:%s:%s',
|
||||
item_id or 0,
|
||||
suffix_id or 0,
|
||||
unique_id or 0,
|
||||
enchant_id or 0,
|
||||
count or 0,
|
||||
min_bid or 0,
|
||||
buyout_price or 0
|
||||
)
|
||||
end
|
||||
|
||||
function public.break_auction_signature(signature)
|
||||
local parts = strfind(signature, '^(%d+):(%d+):(%d+):(%d+):(%d+):(%d+):(%d+)$')
|
||||
for i=1,2 do
|
||||
tremove(parts, 1)
|
||||
end
|
||||
return unpack(parts)
|
||||
end
|
||||
|
||||
function public.item_key(hyperlink)
|
||||
local item_id, suffix_id = private.parse_hyperlink(hyperlink)
|
||||
return item_id..':'..suffix_id
|
||||
|
||||
+99
-116
@@ -3,15 +3,27 @@ Aux.item_search_frame = public
|
||||
|
||||
aux_recently_searched = {}
|
||||
|
||||
local hide_sheet
|
||||
local auctions
|
||||
local search_query
|
||||
local refresh
|
||||
local selected_auction
|
||||
|
||||
function private.select_auction(entry)
|
||||
selected_auction = entry
|
||||
refresh = true
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function private.clear_selection(entry)
|
||||
selected_auction = nil
|
||||
refresh = true
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function public.on_close()
|
||||
private.clear_selection()
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
@@ -79,14 +91,14 @@ function public.on_load()
|
||||
private.views = {
|
||||
[Aux.view.BUYOUT] = {
|
||||
frame = AuxItemSearchFrameAuctionsBuyListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
on_row_click = function(sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
private.on_row_click(sheet, sheet.data[data_index], true)
|
||||
private.on_row_click(sheet.data[data_index], true)
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
on_row_enter = function(sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
end,
|
||||
on_row_leave = function (sheet, row_index)
|
||||
on_row_leave = function(sheet, row_index)
|
||||
AuxTooltip:Hide()
|
||||
ResetCursor()
|
||||
end,
|
||||
@@ -99,6 +111,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return Aux.util.any(datum, function(entry) return entry == selected_auction end)
|
||||
end,
|
||||
row_setter = function(row, group)
|
||||
row:SetAlpha(Aux.util.all(group, function(auction) return auction.gone end) and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(group[1].item_id, group[1].suffix_id, nil, group[1].enchant_id)
|
||||
@@ -115,7 +130,7 @@ function public.on_load()
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.money_column('Buy', function(group) return group[1].buyout_price end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(group) return group[1].buyout_price_per_unit end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(group) return group[1].unit_buyout_price end),
|
||||
{
|
||||
title = 'Avail',
|
||||
width = 40,
|
||||
@@ -125,20 +140,20 @@ function public.on_load()
|
||||
cell.text:SetText(getn(Aux.util.filter(group, function(auction) return not auction.gone end)))
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.percentage_market_column(function(group) return group[1].item_key end, function(group) return group[1].buyout_price_per_unit end),
|
||||
Aux.listing_util.percentage_market_column(function(group) return group[1].item_key end, function(group) return group[1].unit_buyout_price end),
|
||||
},
|
||||
sort_order = {{column = 3, order = 'ascending' }},
|
||||
},
|
||||
[Aux.view.BID] = {
|
||||
frame = AuxItemSearchFrameAuctionsBidListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
on_row_click = function(sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
private.on_row_click(sheet, sheet.data[data_index])
|
||||
private.on_row_click(sheet.data[data_index])
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
on_row_enter = function(sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
end,
|
||||
on_row_leave = function (sheet, row_index)
|
||||
on_row_leave = function(sheet, row_index)
|
||||
AuxTooltip:Hide()
|
||||
ResetCursor()
|
||||
end,
|
||||
@@ -151,6 +166,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return datum == selected_auction
|
||||
end,
|
||||
row_setter = function(row, datum)
|
||||
row:SetAlpha(datum.gone and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(datum.item_id, datum.suffix_id, datum.unique_id, datum.enchant_id)
|
||||
@@ -166,8 +184,8 @@ function public.on_load()
|
||||
cell.text:SetText(datum.aux_quantity)
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.bid_per_unit end),
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid_price end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.unit_bid_price end),
|
||||
{
|
||||
title = 'Status',
|
||||
width = 70,
|
||||
@@ -212,12 +230,12 @@ function public.on_load()
|
||||
frame = AuxItemSearchFrameAuctionsFullListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
private.on_row_click(sheet, sheet.data[data_index])
|
||||
private.on_row_click(sheet.data[data_index])
|
||||
end,
|
||||
on_row_enter = function (sheet, row_index)
|
||||
on_row_enter = function(sheet, row_index)
|
||||
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
|
||||
end,
|
||||
on_row_leave = function (sheet, row_index)
|
||||
on_row_leave = function(sheet, row_index)
|
||||
AuxTooltip:Hide()
|
||||
ResetCursor()
|
||||
end,
|
||||
@@ -230,6 +248,9 @@ function public.on_load()
|
||||
ResetCursor()
|
||||
end
|
||||
end,
|
||||
selected = function(datum)
|
||||
return datum == selected_auction
|
||||
end,
|
||||
row_setter = function(row, datum)
|
||||
row:SetAlpha(datum.gone and 0.3 or 1)
|
||||
row.itemstring = Aux.info.itemstring(datum.item_id, datum.suffix_id, datum.unique_id, datum.enchant_id)
|
||||
@@ -245,10 +266,10 @@ function public.on_load()
|
||||
cell.text:SetText(datum.aux_quantity)
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid end),
|
||||
Aux.listing_util.money_column('Bid', function(entry) return entry.bid_price end),
|
||||
Aux.listing_util.money_column('Buy', function(entry) return entry.buyout_price end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.bid_per_unit end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(entry) return entry.buyout_price_per_unit end),
|
||||
Aux.listing_util.money_column('Bid/ea', function(entry) return entry.unit_bid_price end),
|
||||
Aux.listing_util.money_column('Buy/ea', function(entry) return entry.unit_buyout_price end),
|
||||
{
|
||||
title = 'Lvl',
|
||||
width = 25,
|
||||
@@ -303,7 +324,7 @@ function public.on_load()
|
||||
cell.text:SetText(datum.page)
|
||||
end,
|
||||
},
|
||||
Aux.listing_util.percentage_market_column(function(entry) return entry.item_key end, function(entry) return entry.buyout_price_per_unit end),
|
||||
Aux.listing_util.percentage_market_column(function(entry) return entry.item_key end, function(entry) return entry.unit_buyout_price end),
|
||||
},
|
||||
sort_order = {{column = 5, order = 'ascending'}},
|
||||
},
|
||||
@@ -462,18 +483,10 @@ function private.update_listing()
|
||||
end
|
||||
end
|
||||
|
||||
function hide_sheet()
|
||||
AuxItemSearchFrameAuctionsBuyListing:Hide()
|
||||
AuxItemSearchFrameAuctionsBidListing:Hide()
|
||||
AuxItemSearchFrameAuctionsFullListing:Hide()
|
||||
end
|
||||
|
||||
function public.set_view(view)
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
private.clear_selection()
|
||||
aux_view = view
|
||||
private.update_listing()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function private.update_recently_searched()
|
||||
@@ -523,6 +536,8 @@ function public.start_search()
|
||||
|
||||
Aux.scan.abort(function()
|
||||
|
||||
private.clear_selection()
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
@@ -595,83 +610,60 @@ function public.start_search()
|
||||
end)
|
||||
end
|
||||
|
||||
function private.clear_selection()
|
||||
private.listings[aux_view]:clear_selection()
|
||||
end
|
||||
function private.process_request(entry, express_mode, buyout_mode)
|
||||
|
||||
function private.find_auction(entry, express_mode, buyout_mode)
|
||||
|
||||
if buyout_mode and not entry.buyout_price then
|
||||
return
|
||||
end
|
||||
|
||||
local amount
|
||||
if buyout_mode then
|
||||
amount = entry.buyout_price
|
||||
else
|
||||
amount = entry.bid
|
||||
if entry.gone or (buyout_mode and not entry.buyout_price) or (express_mode and not buyout_mode and entry.high_bidder) or entry.owner == UnitName('player') then
|
||||
return
|
||||
end
|
||||
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
|
||||
local function test(index)
|
||||
return private.create_auction_record(Aux.info.auction(index)).signature == entry.signature
|
||||
local auction_record = private.create_auction_record(Aux.info.auction(index))
|
||||
return auction_record.signature == entry.signature and auction_record.bid_price == entry.bid_price and auction_record.owner ~= UnitName('player')
|
||||
end
|
||||
|
||||
Aux.scan_util.find_auction('list', test, search_query, entry.page, private.status_bar, function(index)
|
||||
local function remove_entry()
|
||||
entry.gone = true
|
||||
refresh = true
|
||||
private.clear_selection()
|
||||
end
|
||||
|
||||
if not index then
|
||||
entry.gone = true
|
||||
private.clear_selection()
|
||||
refresh = true
|
||||
return
|
||||
end
|
||||
if express_mode then
|
||||
Aux.scan_util.find('list', test, search_query, entry.page, private.status_bar, remove_entry, function(index)
|
||||
if not entry.gone then
|
||||
Aux.place_bid('list', index, buyout_mode and entry.buyout_price or entry.bid_price, remove_entry)
|
||||
end
|
||||
end)
|
||||
else
|
||||
private.select_auction(entry)
|
||||
|
||||
if not test(index) then
|
||||
return private.find_auction(entry, express_mode, buyout_mode) -- try again
|
||||
end
|
||||
Aux.scan_util.find('list', test, search_query, entry.page, private.status_bar, remove_entry, function(index)
|
||||
|
||||
if express_mode then
|
||||
if Aux.bid_lock then
|
||||
return
|
||||
if not entry.high_bidder then
|
||||
private.bid_button:SetScript('OnClick', function()
|
||||
if test(index) and not entry.gone then
|
||||
Aux.place_bid('list', index, entry.bid_price, remove_entry)
|
||||
end
|
||||
private.clear_selection()
|
||||
end)
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
if entry.buyout_price then
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if test(index) and not entry.gone then
|
||||
Aux.place_bid('list', index, entry.buyout_price, remove_entry)
|
||||
end
|
||||
private.clear_selection()
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
end
|
||||
Aux.place_bid('list', index, amount)
|
||||
|
||||
private.clear_selection()
|
||||
refresh = true
|
||||
else
|
||||
private.buyout_button:SetScript('OnClick', function()
|
||||
if Aux.bid_lock then
|
||||
return
|
||||
end
|
||||
|
||||
if not test(index) then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
return private.find_auction(entry, express_mode, buyout_mode) -- try again
|
||||
end
|
||||
|
||||
if GetMoney() >= amount then
|
||||
entry.gone = true
|
||||
end
|
||||
Aux.place_bid('list', index, entry.buyout_price)
|
||||
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
private.clear_selection()
|
||||
refresh = true
|
||||
end)
|
||||
private.buyout_button:Enable()
|
||||
private.bid_button:Enable()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function private.on_row_click(sheet, datum, grouped)
|
||||
function private.on_row_click(datum, grouped)
|
||||
|
||||
local entry
|
||||
if grouped then
|
||||
@@ -680,32 +672,23 @@ function private.on_row_click(sheet, datum, grouped)
|
||||
entry = datum
|
||||
end
|
||||
|
||||
local express_mode = IsAltKeyDown()
|
||||
local buyout_mode = express_mode and arg1 == 'LeftButton'
|
||||
|
||||
if IsControlKeyDown() then
|
||||
DressUpItemLink(entry.hyperlink)
|
||||
if IsControlKeyDown() then
|
||||
DressUpItemLink(entry.hyperlink)
|
||||
elseif IsShiftKeyDown() then
|
||||
if ChatFrameEditBox:IsVisible() then
|
||||
ChatFrameEditBox:Insert(entry.hyperlink)
|
||||
end
|
||||
elseif not entry.gone and entry.owner ~= UnitName('player') then
|
||||
if not express_mode then
|
||||
private.buyout_button:Disable()
|
||||
private.bid_button:Disable()
|
||||
sheet:clear_selection()
|
||||
sheet:select(datum)
|
||||
end
|
||||
private.find_auction(entry, express_mode, buyout_mode)
|
||||
else
|
||||
local express_mode = IsAltKeyDown()
|
||||
local buyout_mode = express_mode and arg1 == 'LeftButton'
|
||||
private.process_request(entry, express_mode, buyout_mode)
|
||||
end
|
||||
end
|
||||
|
||||
function private.create_auction_record(auction_info, current_page)
|
||||
function private.create_auction_record(auction_info, page)
|
||||
|
||||
local aux_quantity = auction_info.charges or auction_info.count
|
||||
local bid = (auction_info.current_bid > 0 and auction_info.current_bid or auction_info.min_bid) + auction_info.min_increment
|
||||
local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil
|
||||
local buyout_price_per_unit = buyout_price and Aux.round(auction_info.buyout_price / aux_quantity)
|
||||
local unit_buyout_price = buyout_price and Aux.round(auction_info.buyout_price / auction_info.aux_quantity)
|
||||
local status
|
||||
if auction_info.current_bid == 0 then
|
||||
status = 'No Bid'
|
||||
@@ -716,25 +699,25 @@ function private.create_auction_record(auction_info, current_page)
|
||||
end
|
||||
|
||||
return {
|
||||
page = page,
|
||||
|
||||
item_id = auction_info.item_id,
|
||||
suffix_id = auction_info.suffix_id,
|
||||
unique_id = auction_info.unique_id,
|
||||
enchant_id = auction_info.enchant_id,
|
||||
|
||||
item_key = auction_info.item_key,
|
||||
|
||||
signature = Aux.auction_signature(auction_info.hyperlink, aux_quantity, bid, auction_info.buyout_price),
|
||||
signature = auction_info.signature,
|
||||
|
||||
name = auction_info.name,
|
||||
level = auction_info.level,
|
||||
aux_quantity = aux_quantity,
|
||||
aux_quantity = auction_info.aux_quantity,
|
||||
buyout_price = buyout_price,
|
||||
buyout_price_per_unit = buyout_price_per_unit,
|
||||
unit_buyout_price = unit_buyout_price,
|
||||
quality = auction_info.quality,
|
||||
hyperlink = auction_info.hyperlink,
|
||||
page = current_page,
|
||||
bid = bid,
|
||||
bid_per_unit = Aux.round(bid / aux_quantity),
|
||||
bid_price = auction_info.bid_price,
|
||||
unit_bid_price = Aux.round(auction_info.bid_price / auction_info.aux_quantity),
|
||||
owner = auction_info.owner,
|
||||
duration = auction_info.duration,
|
||||
usable = auction_info.usable,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<Frame>
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
Aux.buy.onupdate()
|
||||
<!--Aux.buy.onupdate()-->
|
||||
</OnUpdate>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
+9
-5
@@ -1,7 +1,7 @@
|
||||
local m = {}
|
||||
Aux.scan_util = m
|
||||
|
||||
function m.find_auction(type, test, search_query, page, status_bar, callback)
|
||||
function m.find(type, test, search_query, page, status_bar, on_failure, on_success)
|
||||
|
||||
Aux.scan.abort(function()
|
||||
|
||||
@@ -16,17 +16,21 @@ function m.find_auction(type, test, search_query, page, status_bar, callback)
|
||||
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)
|
||||
if not test(auction_info.index) then
|
||||
return on_failure()
|
||||
else
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction found')
|
||||
return on_success(auction_info.index)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction not found')
|
||||
callback()
|
||||
on_failure()
|
||||
end,
|
||||
next_page = function()
|
||||
if getn(pages) == 1 then
|
||||
|
||||
@@ -47,7 +47,7 @@ function public.render(sheet)
|
||||
local datum = data[i + offset]
|
||||
|
||||
if datum then
|
||||
if sheet.selected[datum] then
|
||||
if sheet.selected and sheet.selected(datum) then
|
||||
row.highlight:SetAlpha(0.5)
|
||||
else
|
||||
row.highlight:SetAlpha(0)
|
||||
@@ -199,7 +199,7 @@ function public.create(params)
|
||||
end)
|
||||
row:SetScript('OnLeave', function()
|
||||
local data_index = row_idx + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
if not sheet.selected[sheet.data[data_index]] then
|
||||
if not (sheet.selected and sheet.selected(sheet.data[data_index])) then
|
||||
sheet.rows[row_idx].highlight:SetAlpha(0)
|
||||
end
|
||||
if sheet.on_row_leave then
|
||||
@@ -250,42 +250,15 @@ function public.create(params)
|
||||
rows = rows,
|
||||
columns = params.columns,
|
||||
data = {},
|
||||
selected = {},
|
||||
sort_order = params.sort_order,
|
||||
row_setter = params.row_setter,
|
||||
selected = params.selected,
|
||||
on_row_click = params.on_row_click,
|
||||
on_row_enter = params.on_row_enter,
|
||||
on_row_leave = params.on_row_leave,
|
||||
on_row_update = params.on_row_update,
|
||||
}
|
||||
scroll_frame.sheet = sheet
|
||||
|
||||
function sheet:clear_selection()
|
||||
self.selected = {}
|
||||
public.render(self)
|
||||
end
|
||||
|
||||
function sheet:select(datum)
|
||||
self.selected[datum] = true
|
||||
public.render(self)
|
||||
end
|
||||
|
||||
function sheet:deselect(datum)
|
||||
self.selected[datum] = false
|
||||
public.render(self)
|
||||
end
|
||||
|
||||
function sheet:get_selection()
|
||||
local selection = {}
|
||||
for datum, _ in pairs(self.selected) do
|
||||
tinsert(selection, datum)
|
||||
end
|
||||
return selection
|
||||
end
|
||||
|
||||
function sheet:get_selected()
|
||||
return self:get_selection()[1]
|
||||
end
|
||||
|
||||
return sheet
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user