2022-11-01 18:01:28 +01:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace EDPlayerJournal;
|
|
|
|
|
|
|
|
|
|
public class Credits {
|
2022-11-25 13:45:02 +01:00
|
|
|
|
public static string FormatCredits(uint amount) {
|
|
|
|
|
return FormatCredits((long)amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string FormatCredits(ulong amount) {
|
2022-11-01 18:01:28 +01:00
|
|
|
|
return FormatCredits((long)amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string FormatCredits(long amount) {
|
|
|
|
|
var format = new CultureInfo(CultureInfo.CurrentCulture.Name, true).NumberFormat;
|
|
|
|
|
format.NumberGroupSeparator = ",";
|
|
|
|
|
format.NumberDecimalSeparator = ".";
|
|
|
|
|
format.NumberGroupSizes = new int[1] { 3 };
|
|
|
|
|
format.NumberDecimalDigits = 0;
|
|
|
|
|
if (amount > 0 && (amount % 1000000000) == 0) {
|
|
|
|
|
amount /= 1000000000;
|
|
|
|
|
return string.Format("{0}M CR", amount.ToString("N", format));
|
|
|
|
|
} else if (amount > 0 && (amount % 1000000) == 0) {
|
|
|
|
|
amount /= 1000000;
|
|
|
|
|
return string.Format("{0}M CR", amount.ToString("N", format));
|
|
|
|
|
} else if (amount > 0 && (amount % 100000) == 0) {
|
|
|
|
|
double am = ((double)amount) / 1000000;
|
|
|
|
|
format.NumberDecimalDigits = 1;
|
|
|
|
|
return string.Format("{0}M CR", am.ToString("N", format));
|
|
|
|
|
} else if (amount > 0 && (amount % 1000) == 0) {
|
|
|
|
|
amount /= 1000;
|
|
|
|
|
return string.Format("{0}K CR", amount.ToString("N", format));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Format("{0} CR", amount.ToString("N", format));
|
|
|
|
|
}
|
2023-02-23 21:44:55 +01:00
|
|
|
|
|
|
|
|
|
public static string FormatMillions(long amount) {
|
|
|
|
|
double millions = (amount / 1000000.0);
|
|
|
|
|
|
|
|
|
|
if (amount >= 100000) {
|
|
|
|
|
return string.Format("{0:0.0}M", millions);
|
|
|
|
|
} else if (amount >= 10000) {
|
|
|
|
|
return string.Format("{0:0.00}M", millions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2022-11-01 18:01:28 +01:00
|
|
|
|
}
|