Automatically TitleCase IC names (#10986)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user