another massive refactoring, only post panel missing

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