cache exponent values for number formats
This commit is contained in:
parent
bb0fd54713
commit
f03b14d07b
3 changed files with 24 additions and 23 deletions
|
@ -23,6 +23,7 @@ namespace TouchyTickets {
|
||||||
public class Ui {
|
public class Ui {
|
||||||
|
|
||||||
public static readonly UniformTextureAtlas Texture = new UniformTextureAtlas(MlemGame.LoadContent<Texture2D>("Textures/Ui"), 16, 16);
|
public static readonly UniformTextureAtlas Texture = new UniformTextureAtlas(MlemGame.LoadContent<Texture2D>("Textures/Ui"), 16, 16);
|
||||||
|
private static readonly BigInteger[] ExpoNums = Enumerable.Range(0, Localization.NumberFormat.Count).Select(i => BigInteger.Pow(1000, i + 1)).ToArray();
|
||||||
private readonly UiSystem uiSystem;
|
private readonly UiSystem uiSystem;
|
||||||
private readonly Element[] swipeRelations;
|
private readonly Element[] swipeRelations;
|
||||||
private Element currentUi;
|
private Element currentUi;
|
||||||
|
@ -602,7 +603,7 @@ namespace TouchyTickets {
|
||||||
|
|
||||||
private static string PrettyPrintNumber(BigInteger number) {
|
private static string PrettyPrintNumber(BigInteger number) {
|
||||||
for (var i = 0; i < Localization.NumberFormat.Count; i++) {
|
for (var i = 0; i < Localization.NumberFormat.Count; i++) {
|
||||||
if (number < BigInteger.Pow(1000, i + 1))
|
if (number < ExpoNums[i])
|
||||||
return number.ToString(Localization.NumberFormat[i]);
|
return number.ToString(Localization.NumberFormat[i]);
|
||||||
}
|
}
|
||||||
// if the number is too large, just return the highest possible
|
// if the number is too large, just return the highest possible
|
||||||
|
|
Loading…
Reference in a new issue