better number formatting
This commit is contained in:
parent
731cc1e727
commit
bb0fd54713
7 changed files with 48 additions and 19 deletions
|
@ -86,3 +86,9 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/Ui.png
|
||||
|
||||
#begin Localization/NumberFormat.de.json5
|
||||
/copy:Localization/NumberFormat.de.json5
|
||||
|
||||
#begin Localization/NumberFormat.json5
|
||||
/copy:Localization/NumberFormat.json5
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"Options": "Optionen",
|
||||
"RainingTicketLimit": "Max. Fallende Tickets",
|
||||
"SoundVolume": "Lautstärke",
|
||||
"AGameByEllpeck": "Ein Spiel von Ellpeck",
|
||||
"----- Tutorial -----": "",
|
||||
"Tutorial1": "Hi! Willkommen zu Touchy Tickets. Um das Spiel zu starten, tippe einfach den Ticket-Laden an, um ein <i ticket> zu verkaufen. Verkaufe erstmal 50<i ticket>!",
|
||||
"Tutorial2": "Super! Jetzt kannst du deine erste Attraktion kaufen. Wechsel durch Wischen zum rechten Menü und kaufe ein Karussell.",
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"Options": "Options",
|
||||
"RainingTicketLimit": "Max Raining Tickets",
|
||||
"SoundVolume": "Sound Volume",
|
||||
"AGameByEllpeck":"A game by Ellpeck",
|
||||
"----- Tutorial -----": "",
|
||||
"Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!",
|
||||
"Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.",
|
||||
|
|
14
TouchyTickets/Content/Localization/NumberFormat.de.json5
Normal file
14
TouchyTickets/Content/Localization/NumberFormat.de.json5
Normal file
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
"0", // Hundert
|
||||
"0,.##t", // Tausend
|
||||
"0,,.##M", // Millionen
|
||||
"0,,,.##Mr", // Milliarden
|
||||
"0,,,,.##B", // Billionen
|
||||
"0,,,,,.##Br", // Billiarden
|
||||
"0,,,,,,.##T", // Trillionen
|
||||
"0,,,,,,,.##Tr", // Trilliarden
|
||||
"0,,,,,,,,.##Q", // Quadrillionen
|
||||
"0,,,,,,,,,.##Qr", // Quadrilliarden
|
||||
"0,,,,,,,,,,.##Qi", // Quintillionen
|
||||
"0,,,,,,,,,,,.##Qir", // Quintilliarden
|
||||
]
|
14
TouchyTickets/Content/Localization/NumberFormat.json5
Normal file
14
TouchyTickets/Content/Localization/NumberFormat.json5
Normal file
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
"0", // hundreds
|
||||
"0,.##K", // thousands
|
||||
"0,,.##M", // millions
|
||||
"0,,,.##B", // billions
|
||||
"0,,,,.##T", // trillions
|
||||
"0,,,,,.##Q", // quadrillions
|
||||
"0,,,,,,.##Qi", // quintillions
|
||||
"0,,,,,,,.##S", // sextillions
|
||||
"0,,,,,,,,.##Sp", // septillions
|
||||
"0,,,,,,,,,.##O", // octillions
|
||||
"0,,,,,,,,,,.##N", // nonillions
|
||||
"0,,,,,,,,,,,.##D", // decillions
|
||||
]
|
|
@ -10,6 +10,7 @@ using Newtonsoft.Json;
|
|||
namespace TouchyTickets {
|
||||
public static class Localization {
|
||||
|
||||
public static readonly List<string> NumberFormat = LoadLocalized<List<string>>("NumberFormat", "json5");
|
||||
private static readonly Dictionary<string, string> Strings = LoadLocalized<Dictionary<string, string>>("Localization");
|
||||
private static readonly List<string> News = LoadLocalized<List<string>>("News");
|
||||
private static readonly Random Random = new Random();
|
||||
|
@ -22,10 +23,10 @@ namespace TouchyTickets {
|
|||
return News[Random.Next(News.Count)];
|
||||
}
|
||||
|
||||
private static T LoadLocalized<T>(string name) {
|
||||
private static T LoadLocalized<T>(string name, string extension = "json") {
|
||||
var location = GameImpl.Instance.Content.RootDirectory + "/Localization/" + name;
|
||||
var culture = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
|
||||
foreach (var path in new[] {$"{location}.{culture}.json", $"{location}.json"}) {
|
||||
foreach (var path in new[] {$"{location}.{culture}.{extension}", $"{location}.{extension}"}) {
|
||||
try {
|
||||
using (var reader = new JsonTextReader(new StreamReader(TitleContainer.OpenStream(path))))
|
||||
return SaveHandler.Serializer.Deserialize<T>(reader);
|
||||
|
|
|
@ -460,7 +460,7 @@ namespace TouchyTickets {
|
|||
};
|
||||
var center = splash.AddChild(new Group(Anchor.Center, new Vector2(0.5F, 0.5F), false) {DrawAlpha = 0});
|
||||
center.AddChild(new Image(Anchor.AutoCenter, new Vector2(1, -1), Texture[4, 0]));
|
||||
center.AddChild(new Paragraph(Anchor.AutoCenter, 10000, "A game by Ellpeck", true));
|
||||
center.AddChild(new Paragraph(Anchor.AutoCenter, 10000, Localization.Get("AGameByEllpeck"), true));
|
||||
GameImpl.Instance.UiSystem.Add("Splash", splash).Priority = 100000;
|
||||
while (center.DrawAlpha < 1) {
|
||||
center.DrawAlpha += 0.015F;
|
||||
|
@ -584,7 +584,8 @@ namespace TouchyTickets {
|
|||
});
|
||||
var right = button.AddChild(new Group(Anchor.TopRight, new Vector2(0.8F, 1)) {CanBeMoused = false});
|
||||
right.AddChild(new Paragraph(Anchor.TopLeft, 1, Localization.Get(upgrade.Name), true));
|
||||
right.AddChild(new Paragraph(Anchor.TopRight, 1, p => upgrade.Price + "<i star>", true));
|
||||
if (!reachedActive)
|
||||
right.AddChild(new Paragraph(Anchor.TopRight, 1, p => upgrade.Price + "<i star>", true));
|
||||
right.AddChild(new Paragraph(Anchor.AutoLeft, 1, Localization.Get(upgrade.Name + "Description"), true) {TextScale = 0.08F});
|
||||
}
|
||||
}
|
||||
|
@ -600,21 +601,12 @@ namespace TouchyTickets {
|
|||
}
|
||||
|
||||
private static string PrettyPrintNumber(BigInteger number) {
|
||||
if (number < 1000)
|
||||
return number.ToString();
|
||||
// thousands
|
||||
if (number < 1000000)
|
||||
return number.ToString("0,.##K");
|
||||
// millions
|
||||
if (number < 1000000000)
|
||||
return number.ToString("0,,.##M");
|
||||
// billions
|
||||
if (number < 1000000000000)
|
||||
return number.ToString("0,,,.##B");
|
||||
// trillions
|
||||
if (number < 1000000000000000)
|
||||
return number.ToString("0,,,,.##T");
|
||||
return number.ToString("0,,,,,.##Q");
|
||||
for (var i = 0; i < Localization.NumberFormat.Count; i++) {
|
||||
if (number < BigInteger.Pow(1000, i + 1))
|
||||
return number.ToString(Localization.NumberFormat[i]);
|
||||
}
|
||||
// if the number is too large, just return the highest possible
|
||||
return number.ToString(Localization.NumberFormat.Last());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue