diff --git a/tabs/post/core.lua b/tabs/post/core.lua index fcffbc9..5cddff1 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -107,22 +107,6 @@ function update_inventory_listing() item_listing.populate(inventory_listing, records) end -function price_color(record, reference) - local unit_undercut = undercut(record, stack_size_slider:GetValue()) - unit_undercut = money.from_string(money.to_string(unit_undercut, true, nil, 3)) - - local stack_undercut = undercut(record, stack_size_slider:GetValue(), true) - stack_undercut = money.from_string(money.to_string(stack_undercut, true, nil, 3)) - - if unit_undercut < reference and stack_undercut < reference then - return color.red - elseif unit_undercut < reference then - return color.orange - elseif stack_undercut < reference then - return color.yellow - end -end - function update_auction_listing(listing, records, reference) local rows = T if selected_item then @@ -135,7 +119,7 @@ function update_auction_listing(listing, records, reference) O('value', record.own and color.yellow(record.count) or record.count), O('value', al.time_left(record.duration)), O('value', record.stack_size == stack_size and color.yellow(record.stack_size) or record.stack_size), - O('value', money.to_string(record.unit_price, true, nil, 3, price_color(record, reference, stack_size))), + O('value', money.to_string(record.unit_price, true, nil, 3, undercut(record, stack_size_slider:GetValue(), listing == 'bid') < reference and color.red)), O('value', historical_value and al.percentage_historical(round(record.unit_price / historical_value * 100)) or '---') ), 'record', record @@ -155,8 +139,8 @@ function update_auction_listing(listing, records, reference) end sort(rows, function(a, b) return sort_util.multi_lt( - a.record.unit_price, - b.record.unit_price, + a.record.unit_price * (listing == 'bid' and a.record.stack_size or 1), + b.record.unit_price * (listing == 'bid' and b.record.stack_size or 1), a.record.historical_value and 1 or 0, b.record.historical_value and 1 or 0, @@ -172,12 +156,16 @@ function update_auction_listing(listing, records, reference) ) end) end - listing:SetData(rows) + if listing == 'bid' then + bid_listing:SetData(rows) + elseif listing == 'buyout' then + buyout_listing:SetData(rows) + end end function update_auction_listings() - update_auction_listing(bid_listing, bid_records, unit_start_price) - update_auction_listing(buyout_listing, buyout_records, unit_buyout_price) + update_auction_listing('bid', bid_records, unit_start_price) + update_auction_listing('buyout', buyout_records, unit_buyout_price) end function M.select_item(item_key) @@ -195,14 +183,10 @@ function price_update() local historical_value = history.value(selected_item.key) - if aux_post_bid then - if bid_listing:GetSelection() then - unit_start_price = undercut(bid_listing:GetSelection().record, stack_size_slider:GetValue()) - end - else - if buyout_listing:GetSelection() then - unit_start_price = undercut(buyout_listing:GetSelection().record, stack_size_slider:GetValue()) - end + if bid_listing:GetSelection() then + unit_start_price = undercut(bid_listing:GetSelection().record, stack_size_slider:GetValue(), true) + elseif buyout_listing:GetSelection() then + unit_start_price = undercut(buyout_listing:GetSelection().record, stack_size_slider:GetValue()) end settings.start_price = unit_start_price start_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_start_price / historical_value * 100)) or '---') @@ -245,7 +229,7 @@ function post_auctions() stack_count, function(posted) for i = 1, posted do - record_auction(key, stack_size, unit_start_price, unit_buyout_price, duration_code, UnitName'player') + record_auction(key, stack_size, unit_start_price * stack_size, unit_buyout_price, duration_code, UnitName'player') end update_inventory_records() local same diff --git a/tabs/post/frame.lua b/tabs/post/frame.lua index 8a8eda8..5f2e4b4 100644 --- a/tabs/post/frame.lua +++ b/tabs/post/frame.lua @@ -77,7 +77,7 @@ bid_listing:SetColInfo{ {name='Auctions', width=.17, align='CENTER'}, {name='Time\nLeft', width=.11, align='CENTER'}, {name='Stack\nSize', width=.11, align='CENTER'}, - {name='Auction Bid\n(per item)', width=.4, align='RIGHT'}, + {name='Auction Bid\n(per stack)', width=.4, align='RIGHT'}, {name='% Hist.\nValue', width=.21, align='CENTER'}, } bid_listing:SetHandler('OnClick', function(table, row_data, column, button) @@ -234,7 +234,7 @@ do end end) editbox.formatter = function() return money.to_string(unit_start_price, true, nil, 3) end - editbox.char = function() bid_listing:ClearSelection() end + editbox.char = function() bid_listing:ClearSelection(); buyout_listing:ClearSelection() end editbox.change = function() refresh = true end editbox.enter = function() this:ClearFocus() end editbox.focus_loss = function()