Automatically TitleCase IC names (#10986)

This commit is contained in:
AJCM-git
2022-09-14 05:50:15 -04:00
committed by GitHub
parent 793dc3a569
commit 03cc0508f3
2 changed files with 17 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using System.Linq;
using System.Globalization;
using System.Text.RegularExpressions;
using Content.Shared.CCVar;
using Content.Shared.CharacterAppearance;
@@ -328,11 +329,20 @@ namespace Content.Shared.Preferences
name = name.Trim();
if (IoCManager.Resolve<IConfigurationManager>().GetCVar(CCVars.RestrictedNames))
var configManager = IoCManager.Resolve<IConfigurationManager>();
if (configManager.GetCVar(CCVars.RestrictedNames))
{
name = Regex.Replace(name, @"[^A-Z,a-z,0-9, -]", string.Empty);
}
if (configManager.GetCVar(CCVars.ICNameCase))
{
// This regex replaces the first character of the first and last words of the name with their uppercase version
name = Regex.Replace(name,
@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)",
m => m.Groups["word"].Value.ToUpper());
}
if (string.IsNullOrEmpty(name))
{
name = Sex.GetName(Species);