For abyssal modification range, show integer + 3 fraction digits, like CCP does

This commit is contained in:
DarkPhoenix
2018-11-19 14:59:34 +03:00
parent b0895611d6
commit dc2a4d4446
3 changed files with 20 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ import wx
from .helpers import AutoListCtrl
from gui.bitmap_loader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from gui.utils.numberFormatter import formatAmount, roundDec
class ItemParams(wx.Panel):
@@ -236,11 +236,13 @@ class ItemParams(wx.Panel):
self.Layout()
@staticmethod
def FormatValue(value, unit):
def FormatValue(value, unit, rounding='prec', digits=3):
"""Formats a value / unit combination into a string
@todo: move this to a more central location, since this is also used in the item mutator panel"""
if isinstance(value, (int, float)):
fvalue = formatAmount(value, 3, 0, 0)
if isinstance(value, (int, float)) and rounding == 'prec':
fvalue = formatAmount(value, digits, 0, 0)
elif isinstance(value, (int, float)) and rounding == 'dec':
fvalue = roundDec(value, digits)
else:
fvalue = value
return "%s %s" % (fvalue, unit)

View File

@@ -61,15 +61,17 @@ class ItemMutator(wx.Panel):
headingSizer.Add(displayName, 3, wx.ALL | wx.EXPAND, 0)
range_low = wx.StaticText(self, wx.ID_ANY, ItemParams.FormatValue(*m.attribute.unit.PreformatValue(round(worse_range[0], 3))))
range_low.SetForegroundColour(self.goodColor if worse_range[2] else self.badColor)
worst_val = ItemParams.FormatValue(*m.attribute.unit.PreformatValue(worse_range[0]), rounding='dec')
worst_text = wx.StaticText(self, wx.ID_ANY, worst_val)
worst_text.SetForegroundColour(self.goodColor if worse_range[2] else self.badColor)
range_high = wx.StaticText(self, wx.ID_ANY, ItemParams.FormatValue(*m.attribute.unit.PreformatValue(round(better_range[0], 3))))
range_high.SetForegroundColour(self.goodColor if better_range[2] else self.badColor)
best_val = ItemParams.FormatValue(*m.attribute.unit.PreformatValue(better_range[0]), rounding='dec')
best_text = wx.StaticText(self, wx.ID_ANY, best_val)
best_text.SetForegroundColour(self.goodColor if better_range[2] else self.badColor)
headingSizer.Add(range_low, 0, wx.ALL | wx.EXPAND, 0)
headingSizer.Add(worst_text, 0, wx.ALL | wx.EXPAND, 0)
headingSizer.Add(wx.StaticText(self, wx.ID_ANY, ""), 0, wx.RIGHT | wx.LEFT | wx.EXPAND, 5)
headingSizer.Add(range_high, 0, wx.RIGHT | wx.EXPAND, 10)
headingSizer.Add(best_text, 0, wx.RIGHT | wx.EXPAND, 10)
mainSizer.Add(headingSizer, 0, wx.ALL | wx.EXPAND, 5)

View File

@@ -110,3 +110,9 @@ def roundToPrec(val, prec):
if int(val) == val:
val = int(val)
return val
def roundDec(val, prec):
if int(val) == val:
return int(val)
return round(val, prec)