Skip to content

Commit

Permalink
Added Roman number format option
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwin99 committed Aug 28, 2020
1 parent 4c09a05 commit 711c6dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions SEWorldGenPlugin/Generator/SystemGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 "";
}
}
}

0 comments on commit 711c6dd

Please sign in to comment.