From 711c6ddec3dbd300573f980790f26039046881e1 Mon Sep 17 00:00:00 2001 From: Thorwin Vogt Date: Fri, 28 Aug 2020 18:00:24 +0200 Subject: [PATCH] Added Roman number format option --- SEWorldGenPlugin/Generator/SystemGenerator.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/SEWorldGenPlugin/Generator/SystemGenerator.cs b/SEWorldGenPlugin/Generator/SystemGenerator.cs index 5dc214e..6a4804b 100644 --- a/SEWorldGenPlugin/Generator/SystemGenerator.cs +++ b/SEWorldGenPlugin/Generator/SystemGenerator.cs @@ -214,6 +214,7 @@ private void GenerateBelt(long distance, ref int beltIndex) string name = SettingsSession.Static.Settings.GeneratorSettings.BeltSettings.BeltNameFormat .SetProperty("ObjectNumber", beltIndex + 1) .SetProperty("ObjectNumberGreek", greek_letters[beltIndex]) + .SetProperty("ObjectNumberRoman", ConvertNumberToRoman(beltIndex + 1)) .SetProperty("ObjectLetterLower", (char)('a' + (beltIndex % 26))) .SetProperty("ObjectLetterUpper", (char)('A' + (beltIndex % 26))); @@ -246,6 +247,7 @@ private void GeneratePlanet(int index, long distance, int totalObjects, ref int string name = SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.PlanetNameFormat .SetProperty("ObjectNumber", planetIndex + 1) .SetProperty("ObjectNumberGreek", greek_letters[planetIndex]) + .SetProperty("ObjectNumberRoman", ConvertNumberToRoman(planetIndex + 1)) .SetProperty("ObjectLetterLower", (char)('a' + (planetIndex % 26))) .SetProperty("ObjectLetterUpper", (char)('A' + (planetIndex % 26))) .SetProperty("ObjectId", def.Id.SubtypeId.String); @@ -284,6 +286,7 @@ private MyPlanetMoonItem[] GenerateMoons(float planetSize, float surfaceGravity, string name = SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.MoonNameFormat .SetProperty("ObjectNumber", i + 1) .SetProperty("ObjectNumberGreek", greek_letters[i]) + .SetProperty("ObjectNumberRoman", ConvertNumberToRoman(i + 1)) .SetProperty("ObjectLetterLower", (char)('a' + (i % 26))) .SetProperty("ObjectLetterUpper", (char)('A' + (i % 26))) .SetProperty("ObjectId", def.Id.SubtypeId.String) @@ -519,5 +522,23 @@ private void AddBeltsGpss() GlobalGpsManager.Static.AddGps(obj.DisplayName, Color.Aqua, pos); } } + + private string ConvertNumberToRoman(int number) + { + if (number >= 1000) return "M" + ConvertNumberToRoman(number - 1000); + if (number >= 900) return "CM" + ConvertNumberToRoman(number - 900); + if (number >= 500) return "D" + ConvertNumberToRoman(number - 500); + if (number >= 400) return "CD" + ConvertNumberToRoman(number - 400); + if (number >= 100) return "C" + ConvertNumberToRoman(number - 100); + if (number >= 90) return "XC" + ConvertNumberToRoman(number - 90); + if (number >= 50) return "L" + ConvertNumberToRoman(number - 50); + if (number >= 40) return "XL" + ConvertNumberToRoman(number - 40); + if (number >= 10) return "X" + ConvertNumberToRoman(number - 10); + if (number >= 9) return "IX" + ConvertNumberToRoman(number - 9); + if (number >= 5) return "V" + ConvertNumberToRoman(number - 5); + if (number >= 4) return "IV" + ConvertNumberToRoman(number - 4); + if (number >= 1) return "I" + ConvertNumberToRoman(number - 1); + return ""; + } } }