|
43 | 43 | -- precision is express a multiplier/divide and displayPrecision is expresed as decimal precision on rounding.
|
44 | 44 | -- ifRequired determines whether trailing zeros are displayed or not.
|
45 | 45 | function itemLib.formatValue(value, baseValueScalar, valueScalar, precision, displayPrecision, ifRequired)
|
46 |
| - value = round(value * precision) -- resolve range to internal value |
47 |
| - if baseValueScalar and baseValueScalar ~= 1 then value = round(value * baseValueScalar) end -- apply corrupted mult |
48 |
| - if valueScalar and valueScalar ~= 1 then value = m_floor(value * valueScalar) end -- apply modifier magnitude |
| 46 | + value = roundSymmetric(value * precision) -- resolve range to internal value |
| 47 | + if baseValueScalar and baseValueScalar ~= 1 then value = roundSymmetric(value * baseValueScalar) end -- apply corrupted mult |
| 48 | + if valueScalar and valueScalar ~= 1 then value = floorSymmetric(value * valueScalar) end -- apply modifier magnitude |
49 | 49 | value = value / precision -- convert back to display space
|
50 |
| - if displayPrecision then value = round(value, displayPrecision) end -- presentation |
| 50 | + if displayPrecision then value = roundSymmetric(value, displayPrecision) end -- presentation |
51 | 51 | if displayPrecision and not ifRequired then -- whitespace is needed
|
52 | 52 | return string.format("%"..displayPrecision.."f", value)
|
53 | 53 | elseif displayPrecision then
|
54 |
| - return tostring(round(value, displayPrecision)) |
| 54 | + return tostring(roundSymmetric(value, displayPrecision)) |
55 | 55 | else
|
56 |
| - return tostring(round(value, precision and m_min(2, m_floor(math.log(precision, 10))) or 2)) -- max decimals ingame is 2 |
| 56 | + return tostring(roundSymmetric(value, precision and m_min(2, m_floor(math.log(precision, 10))) or 2)) -- max decimals ingame is 2 |
57 | 57 | end
|
58 | 58 | end
|
59 | 59 |
|
|
0 commit comments