This commit is contained in:
Simon Hirsig
2017-11-02 20:12:50 +01:00
parent 2721bcf663
commit d9780610f4
4 changed files with 25 additions and 24 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ local info = require 'aux.util.info'
local money = require 'aux.util.money'
local disenchant = require 'aux.core.disenchant'
local history = require 'aux.core.history'
local auction_listing = require 'aux.gui.auction_listing'
local gui = require 'aux.gui'
local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE
@@ -92,7 +92,7 @@ function M.extend_tooltip(tooltip, link, quantity)
end
if settings.daily then
local market_value = history.market_value(item_key)
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. auction_listing.percentage_historical(round(market_value / value * 100)) .. ')' or UNKNOWN), color.tooltip.value())
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. gui.percentage_historical(round(market_value / value * 100)) .. ')' or UNKNOWN), color.tooltip.value())
end
end
+1 -18
View File
@@ -226,7 +226,7 @@ M.search_columns = {
align = 'CENTER',
fill = function(cell, record)
local pct, bidPct = record_percentage(record)
cell.text:SetText((pct or bidPct) and percentage_historical(pct or bidPct, not pct) or '?')
cell.text:SetText((pct or bidPct) and gui.percentage_historical(pct or bidPct, not pct) or '?')
end,
cmp = function(record_a, record_b, desc)
local pct_a = record_percentage(record_a) or (desc and -huge or huge)
@@ -522,23 +522,6 @@ function record_percentage(record)
end
end
function M.percentage_historical(pct, bid)
local text = (pct > 10000 and '>10000' or pct) .. '%'
if bid then
return color.gray(text)
elseif pct < 50 then
return color.blue(text)
elseif pct < 80 then
return color.green(text)
elseif pct < 110 then
return color.yellow(text)
elseif pct < 135 then
return color.orange(text)
else
return color.red(text)
end
end
function M.time_left(code)
return TIME_LEFT_STRINGS[code]
end
+17
View File
@@ -550,4 +550,21 @@ do
editbox:SetFocus()
editbox:ClearFocus()
end
end
function M.percentage_historical(pct, bid)
local text = (pct > 10000 and '>10000' or pct) .. '%'
if bid then
return color.gray(text)
elseif pct < 50 then
return color.blue(text)
elseif pct < 80 then
return color.green(text)
elseif pct < 110 then
return color.yellow(text)
elseif pct < 135 then
return color.orange(text)
else
return color.red(text)
end
end
+5 -4
View File
@@ -14,6 +14,7 @@ local scan = require 'aux.core.scan'
local history = require 'aux.core.history'
local item_listing = require 'aux.gui.item_listing'
local al = require 'aux.gui.auction_listing'
local gui = require 'aux.gui'
local tab = TAB 'Post'
@@ -123,7 +124,7 @@ function update_auction_listing(listing, records, reference)
T.map('value', al.time_left(record.duration)),
T.map('value', record.stack_size == stack_size and color.green(record.stack_size) or record.stack_size),
T.map('value', money.to_string(price, true, nil, price_color)),
T.map('value', historical_value and al.percentage_historical(round(price / historical_value * 100)) or '---')
T.map('value', historical_value and gui.percentage_historical(round(price / historical_value * 100)) or '---')
),
'record', record
))
@@ -135,7 +136,7 @@ function update_auction_listing(listing, records, reference)
T.map('value', '---'),
T.map('value', '---'),
T.map('value', money.to_string(historical_value, true, nil, color.green)),
T.map('value', historical_value and al.percentage_historical(100) or '---')
T.map('value', historical_value and gui.percentage_historical(100) or '---')
),
'record', T.map('historical_value', true, 'stack_size', stack_size, 'unit_price', historical_value, 'own', true)
))
@@ -191,8 +192,8 @@ function price_update()
set_unit_buyout_price(undercut(get_buyout_selection(), stack_size_slider:GetValue()))
unit_buyout_price_input:SetText(money.to_string(get_unit_buyout_price(), true, nil, nil, true))
end
start_price_percentage:SetText(historical_value and al.percentage_historical(round(get_unit_start_price() / historical_value * 100)) or '---')
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(get_unit_buyout_price() / historical_value * 100)) or '---')
start_price_percentage:SetText(historical_value and gui.percentage_historical(round(get_unit_start_price() / historical_value * 100)) or '---')
buyout_price_percentage:SetText(historical_value and gui.percentage_historical(round(get_unit_buyout_price() / historical_value * 100)) or '---')
end
end