From d9780610f4e4d854e36a21a91a9279b8a2026aad Mon Sep 17 00:00:00 2001 From: Simon Hirsig Date: Thu, 2 Nov 2017 20:12:50 +0100 Subject: [PATCH] bugfix --- core/tooltip.lua | 4 ++-- gui/auction_listing.lua | 19 +------------------ gui/core.lua | 17 +++++++++++++++++ tabs/post/core.lua | 9 +++++---- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/core/tooltip.lua b/core/tooltip.lua index 1933a0b..b6f7c2d 100644 --- a/core/tooltip.lua +++ b/core/tooltip.lua @@ -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 diff --git a/gui/auction_listing.lua b/gui/auction_listing.lua index b30571b..2852487 100644 --- a/gui/auction_listing.lua +++ b/gui/auction_listing.lua @@ -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 diff --git a/gui/core.lua b/gui/core.lua index 39cd471..2f75cfc 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -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 \ No newline at end of file diff --git a/tabs/post/core.lua b/tabs/post/core.lua index ae1597f..435fdda 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -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