HumanoidCharacterProfile and IdCardConsoleComponent constants moved to cvar. Sync id card length with character name length (#35407)
* commit * mark TODOs * compiles * cleanup * cleanup * oops * changed my mind * requested changes * genpop fix
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Content.Shared.Access;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.CrewManifest;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Access.Components.IdCardConsoleComponent;
|
||||
|
||||
@@ -11,13 +13,21 @@ namespace Content.Client.Access.UI
|
||||
public sealed class IdCardConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
private readonly SharedIdCardConsoleSystem _idCardConsoleSystem = default!;
|
||||
|
||||
private IdCardConsoleWindow? _window;
|
||||
|
||||
// CCVar.
|
||||
private int _maxNameLength;
|
||||
private int _maxIdJobLength;
|
||||
|
||||
public IdCardConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
_idCardConsoleSystem = EntMan.System<SharedIdCardConsoleSystem>();
|
||||
|
||||
_maxNameLength =_cfgManager.GetCVar(CCVars.MaxNameLength);
|
||||
_maxIdJobLength = _cfgManager.GetCVar(CCVars.MaxIdJobLength);
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
@@ -66,11 +76,11 @@ namespace Content.Client.Access.UI
|
||||
|
||||
public void SubmitData(string newFullName, string newJobTitle, List<ProtoId<AccessLevelPrototype>> newAccessList, string newJobPrototype)
|
||||
{
|
||||
if (newFullName.Length > MaxFullNameLength)
|
||||
newFullName = newFullName[..MaxFullNameLength];
|
||||
if (newFullName.Length > _maxNameLength)
|
||||
newFullName = newFullName[.._maxNameLength];
|
||||
|
||||
if (newJobTitle.Length > MaxJobTitleLength)
|
||||
newJobTitle = newJobTitle[..MaxJobTitleLength];
|
||||
if (newJobTitle.Length > _maxIdJobLength)
|
||||
newJobTitle = newJobTitle[.._maxIdJobLength];
|
||||
|
||||
SendMessage(new WriteToTargetIdMessage(
|
||||
newFullName,
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Access;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Access.Components.IdCardConsoleComponent;
|
||||
|
||||
@@ -14,12 +16,17 @@ namespace Content.Client.Access.UI
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class IdCardConsoleWindow : DefaultWindow
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly ILogManager _logManager = default!;
|
||||
private readonly ISawmill _logMill = default!;
|
||||
|
||||
private readonly IdCardConsoleBoundUserInterface _owner;
|
||||
|
||||
// CCVar.
|
||||
private int _maxNameLength;
|
||||
private int _maxIdJobLength;
|
||||
|
||||
private AccessLevelControl _accessButtons = new();
|
||||
private readonly List<string> _jobPrototypeIds = new();
|
||||
|
||||
@@ -39,7 +46,11 @@ namespace Content.Client.Access.UI
|
||||
|
||||
_owner = owner;
|
||||
|
||||
_maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
|
||||
_maxIdJobLength = _cfgManager.GetCVar(CCVars.MaxIdJobLength);
|
||||
|
||||
FullNameLineEdit.OnTextEntered += _ => SubmitData();
|
||||
FullNameLineEdit.IsValid = s => s.Length <= _maxNameLength;
|
||||
FullNameLineEdit.OnTextChanged += _ =>
|
||||
{
|
||||
FullNameSaveButton.Disabled = FullNameSaveButton.Text == _lastFullName;
|
||||
@@ -47,6 +58,7 @@ namespace Content.Client.Access.UI
|
||||
FullNameSaveButton.OnPressed += _ => SubmitData();
|
||||
|
||||
JobTitleLineEdit.OnTextEntered += _ => SubmitData();
|
||||
JobTitleLineEdit.IsValid = s => s.Length <= _maxIdJobLength;
|
||||
JobTitleLineEdit.OnTextChanged += _ =>
|
||||
{
|
||||
JobTitleSaveButton.Disabled = JobTitleLineEdit.Text == _lastJobTitle;
|
||||
|
||||
@@ -53,6 +53,10 @@ namespace Content.Client.Lobby.UI
|
||||
|
||||
private readonly SpriteSystem _sprite;
|
||||
|
||||
// CCvar.
|
||||
private int _maxNameLength;
|
||||
private bool _allowFlavorText;
|
||||
|
||||
private FlavorText.FlavorText? _flavorText;
|
||||
private TextEdit? _flavorTextEdit;
|
||||
|
||||
@@ -131,6 +135,10 @@ namespace Content.Client.Lobby.UI
|
||||
_requirements = requirements;
|
||||
_controller = UserInterfaceManager.GetUIController<LobbyUIController>();
|
||||
_sprite = _entManager.System<SpriteSystem>();
|
||||
|
||||
_maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
|
||||
_allowFlavorText = _cfgManager.GetCVar(CCVars.FlavorText);
|
||||
|
||||
ImportButton.OnPressed += args =>
|
||||
{
|
||||
ImportProfile();
|
||||
@@ -166,6 +174,7 @@ namespace Content.Client.Lobby.UI
|
||||
#region Name
|
||||
|
||||
NameEdit.OnTextChanged += args => { SetName(args.Text); };
|
||||
NameEdit.IsValid = args => args.Length <= _maxNameLength;
|
||||
NameRandomize.OnPressed += args => RandomizeName();
|
||||
RandomizeEverythingButton.OnPressed += args => { RandomizeEverything(); };
|
||||
WarningLabel.SetMarkup($"[color=red]{Loc.GetString("humanoid-profile-editor-naming-rules-warning")}[/color]");
|
||||
@@ -451,7 +460,7 @@ namespace Content.Client.Lobby.UI
|
||||
/// </summary>
|
||||
public void RefreshFlavorText()
|
||||
{
|
||||
if (_cfgManager.GetCVar(CCVars.FlavorText))
|
||||
if (_allowFlavorText)
|
||||
{
|
||||
if (_flavorText != null)
|
||||
return;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.Numerics;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Preferences.Loadouts;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
@@ -23,12 +25,18 @@ public sealed partial class LoadoutWindow : FancyWindow
|
||||
|
||||
public HumanoidCharacterProfile Profile;
|
||||
|
||||
// CCvar.
|
||||
private int _maxLoadoutNameLength;
|
||||
|
||||
public LoadoutWindow(HumanoidCharacterProfile profile, RoleLoadout loadout, RoleLoadoutPrototype proto, ICommonSession session, IDependencyCollection collection)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
Profile = profile;
|
||||
var protoManager = collection.Resolve<IPrototypeManager>();
|
||||
RoleNameEdit.IsValid = text => text.Length <= HumanoidCharacterProfile.MaxLoadoutNameLength;
|
||||
var configManager = collection.Resolve<IConfigurationManager>();
|
||||
|
||||
_maxLoadoutNameLength = configManager.GetCVar(CCVars.MaxLoadoutNameLength);
|
||||
RoleNameEdit.IsValid = text => text.Length <= _maxLoadoutNameLength;
|
||||
|
||||
// Hide if we can't edit the name.
|
||||
if (!proto.CanCustomizeName)
|
||||
@@ -45,7 +53,7 @@ public sealed partial class LoadoutWindow : FancyWindow
|
||||
|
||||
RoleNameEdit.ToolTip = Loc.GetString(
|
||||
"loadout-name-edit-tooltip",
|
||||
("max", HumanoidCharacterProfile.MaxLoadoutNameLength));
|
||||
("max", _maxLoadoutNameLength));
|
||||
RoleNameEdit.Text = name ?? string.Empty;
|
||||
RoleNameEdit.OnTextChanged += args => OnNameChanged?.Invoke(args.Text);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Pinpointer;
|
||||
using Content.Shared.Preferences;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Client.Pinpointer.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class NavMapBeaconWindow : FancyWindow
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
private string? _defaultLabel;
|
||||
private bool _defaultEnabled;
|
||||
private Color _defaultColor;
|
||||
|
||||
// CCVar.
|
||||
private int _maxNameLength;
|
||||
|
||||
public event Action<string?, bool, Color>? OnApplyButtonPressed;
|
||||
|
||||
public NavMapBeaconWindow()
|
||||
@@ -21,6 +27,7 @@ public sealed partial class NavMapBeaconWindow : FancyWindow
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
|
||||
|
||||
VisibleButton.OnPressed += args => UpdateVisibleButton(args.Button.Pressed);
|
||||
LabelLineEdit.OnTextChanged += OnTextChanged;
|
||||
@@ -53,8 +60,8 @@ public sealed partial class NavMapBeaconWindow : FancyWindow
|
||||
|
||||
private void OnTextChanged(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength)
|
||||
obj.Control.Text = obj.Text.Substring(0, HumanoidCharacterProfile.MaxNameLength);
|
||||
if (obj.Text.Length > _maxNameLength)
|
||||
obj.Control.Text = obj.Text.Substring(0, _maxNameLength);
|
||||
|
||||
TryEnableApplyButton();
|
||||
}
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
using Content.Client.Message;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Security.Components;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Client.Security.Ui;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class GenpopLockerMenu : FancyWindow
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
|
||||
public event Action<string, float, string>? OnConfigurationComplete;
|
||||
|
||||
// CCVar.
|
||||
private int _maxIdJobLength;
|
||||
|
||||
public GenpopLockerMenu(EntityUid owner, IEntityManager entMan)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
_maxIdJobLength = _cfgManager.GetCVar(CCVars.MaxIdJobLength);
|
||||
|
||||
Title = entMan.GetComponent<MetaDataComponent>(owner).EntityName;
|
||||
|
||||
NameLabel.SetMarkup(Loc.GetString("genpop-locker-ui-label-name"));
|
||||
@@ -25,7 +34,7 @@ public sealed partial class GenpopLockerMenu : FancyWindow
|
||||
SentenceEdit.Text = "5";
|
||||
CrimeEdit.Text = Loc.GetString("genpop-prisoner-id-crime-default");
|
||||
|
||||
NameEdit.IsValid = val => !string.IsNullOrWhiteSpace(val) && val.Length <= IdCardConsoleComponent.MaxFullNameLength;
|
||||
NameEdit.IsValid = val => !string.IsNullOrWhiteSpace(val) && val.Length <= _maxIdJobLength;
|
||||
SentenceEdit.IsValid = val => float.TryParse(val, out var f) && f >= 0;
|
||||
CrimeEdit.IsValid = val => !string.IsNullOrWhiteSpace(val) && val.Length <= GenpopLockerComponent.MaxCrimeLength;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.NameIdentifier;
|
||||
using Content.Shared.NameModifier.EntitySystems;
|
||||
using Content.Shared.Preferences;
|
||||
@@ -8,6 +9,7 @@ using Content.Shared.Silicons.Borgs.Components;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Silicons.Borgs;
|
||||
@@ -15,6 +17,7 @@ namespace Content.Client.Silicons.Borgs;
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BorgMenu : FancyWindow
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entity = default!;
|
||||
private readonly NameModifierSystem _nameModifier;
|
||||
|
||||
@@ -27,6 +30,9 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
private string _lastValidName;
|
||||
private List<EntityUid> _modules = new();
|
||||
|
||||
// CCVar.
|
||||
private int _maxNameLength;
|
||||
|
||||
public EntityUid Entity;
|
||||
|
||||
public BorgMenu()
|
||||
@@ -36,6 +42,8 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
|
||||
_nameModifier = _entity.System<NameModifierSystem>();
|
||||
|
||||
_maxNameLength = _cfgManager.GetCVar(CCVars.MaxNameLength);
|
||||
|
||||
_lastValidName = NameLineEdit.Text;
|
||||
|
||||
EjectBatteryButton.OnPressed += _ => EjectBatteryButtonPressed?.Invoke();
|
||||
@@ -153,9 +161,9 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength)
|
||||
if (obj.Text.Length > _maxNameLength)
|
||||
{
|
||||
obj.Control.Text = obj.Text.Substring(0, HumanoidCharacterProfile.MaxNameLength);
|
||||
obj.Control.Text = obj.Text.Substring(0, _maxNameLength);
|
||||
}
|
||||
|
||||
_lastValidName = obj.Control.Text;
|
||||
@@ -169,7 +177,7 @@ public sealed partial class BorgMenu : FancyWindow
|
||||
|
||||
private void OnNameFocusExit(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength ||
|
||||
if (obj.Text.Length > _maxNameLength ||
|
||||
obj.Text.Length == 0 ||
|
||||
string.IsNullOrWhiteSpace(obj.Text) ||
|
||||
string.IsNullOrEmpty(obj.Text))
|
||||
|
||||
@@ -2,7 +2,9 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
namespace Content.Server.Mind.Commands;
|
||||
@@ -10,6 +12,7 @@ namespace Content.Server.Mind.Commands;
|
||||
[AdminCommand(AdminFlags.VarEdit)]
|
||||
public sealed class RenameCommand : LocalizedEntityCommands
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
@@ -25,7 +28,7 @@ public sealed class RenameCommand : LocalizedEntityCommands
|
||||
}
|
||||
|
||||
var name = args[1];
|
||||
if (name.Length > IdCardConsoleComponent.MaxFullNameLength)
|
||||
if (name.Length > _cfgManager.GetCVar(CCVars.MaxNameLength))
|
||||
{
|
||||
shell.WriteLine(Loc.GetString("cmd-rename-too-long"));
|
||||
return;
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.UserInterface;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.NameIdentifier;
|
||||
using Content.Shared.PowerCell.Components;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Silicons.Borgs;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Server.Silicons.Borgs;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public sealed partial class BorgSystem
|
||||
{
|
||||
// CCvar.
|
||||
private int _maxNameLength;
|
||||
|
||||
public void InitializeUI()
|
||||
{
|
||||
SubscribeLocalEvent<BorgChassisComponent, BeforeActivatableUIOpenEvent>(OnBeforeBorgUiOpen);
|
||||
@@ -19,6 +24,8 @@ public sealed partial class BorgSystem
|
||||
SubscribeLocalEvent<BorgChassisComponent, BorgEjectBatteryBuiMessage>(OnEjectBatteryBuiMessage);
|
||||
SubscribeLocalEvent<BorgChassisComponent, BorgSetNameBuiMessage>(OnSetNameBuiMessage);
|
||||
SubscribeLocalEvent<BorgChassisComponent, BorgRemoveModuleBuiMessage>(OnRemoveModuleBuiMessage);
|
||||
|
||||
Subs.CVar(_cfgManager, CCVars.MaxNameLength, value => _maxNameLength = value, true);
|
||||
}
|
||||
|
||||
private void OnBeforeBorgUiOpen(EntityUid uid, BorgChassisComponent component, BeforeActivatableUIOpenEvent args)
|
||||
@@ -46,7 +53,7 @@ public sealed partial class BorgSystem
|
||||
|
||||
private void OnSetNameBuiMessage(EntityUid uid, BorgChassisComponent component, BorgSetNameBuiMessage args)
|
||||
{
|
||||
if (args.Name.Length > HumanoidCharacterProfile.MaxNameLength ||
|
||||
if (args.Name.Length > _maxNameLength ||
|
||||
args.Name.Length == 0 ||
|
||||
string.IsNullOrWhiteSpace(args.Name) ||
|
||||
string.IsNullOrEmpty(args.Name))
|
||||
|
||||
@@ -27,6 +27,7 @@ using Content.Shared.Throwing;
|
||||
using Content.Shared.Whitelist;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
@@ -41,6 +42,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLog = default!;
|
||||
[Dependency] private readonly IBanManager _banManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ActionsSystem _actions = default!;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Database;
|
||||
@@ -8,6 +9,7 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.VoiceMask;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.VoiceMask;
|
||||
@@ -16,10 +18,14 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
|
||||
// CCVar.
|
||||
private int _maxNameLength;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -28,6 +34,8 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
SubscribeLocalEvent<VoiceMaskComponent, VoiceMaskChangeVerbMessage>(OnChangeVerb);
|
||||
SubscribeLocalEvent<VoiceMaskComponent, ClothingGotEquippedEvent>(OnEquip);
|
||||
SubscribeLocalEvent<VoiceMaskSetNameEvent>(OpenUI);
|
||||
|
||||
Subs.CVar(_cfgManager, CCVars.MaxNameLength, value => _maxNameLength = value, true);
|
||||
}
|
||||
|
||||
private void OnTransformSpeakerName(Entity<VoiceMaskComponent> entity, ref InventoryRelayedEvent<TransformSpeakerNameEvent> args)
|
||||
@@ -52,7 +60,7 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
|
||||
private void OnChangeName(Entity<VoiceMaskComponent> entity, ref VoiceMaskChangeNameMessage message)
|
||||
{
|
||||
if (message.Name.Length > HumanoidCharacterProfile.MaxNameLength || message.Name.Length <= 0)
|
||||
if (message.Name.Length > _maxNameLength || message.Name.Length <= 0)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("voice-mask-popup-failure"), entity, message.Actor, PopupType.SmallCaution);
|
||||
return;
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Content.Shared.Access.Components;
|
||||
[Access(typeof(SharedIdCardConsoleSystem))]
|
||||
public sealed partial class IdCardConsoleComponent : Component
|
||||
{
|
||||
public const int MaxFullNameLength = 30;
|
||||
public const int MaxJobTitleLength = 30;
|
||||
|
||||
public static string PrivilegedIdCardSlotId = "IdCardConsole-privilegedId";
|
||||
public static string TargetIdCardSlotId = "IdCardConsole-targetId";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Globalization;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
@@ -8,6 +9,7 @@ using Content.Shared.Inventory;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.StatusIcon;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -15,6 +17,7 @@ namespace Content.Shared.Access.Systems;
|
||||
|
||||
public abstract class SharedIdCardSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedAccessSystem _access = default!;
|
||||
@@ -22,6 +25,10 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
// CCVar.
|
||||
private int _maxNameLength;
|
||||
private int _maxIdJobLength;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -29,6 +36,9 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
SubscribeLocalEvent<IdCardComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<TryGetIdentityShortInfoEvent>(OnTryGetIdentityShortInfo);
|
||||
SubscribeLocalEvent<EntityRenamedEvent>(OnRename);
|
||||
|
||||
Subs.CVar(_cfgManager, CCVars.MaxNameLength, value => _maxNameLength = value, true);
|
||||
Subs.CVar(_cfgManager, CCVars.MaxIdJobLength, value => _maxIdJobLength = value, true);
|
||||
}
|
||||
|
||||
private void OnRename(ref EntityRenamedEvent ev)
|
||||
@@ -131,8 +141,8 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
{
|
||||
jobTitle = jobTitle.Trim();
|
||||
|
||||
if (jobTitle.Length > IdCardConsoleComponent.MaxJobTitleLength)
|
||||
jobTitle = jobTitle[..IdCardConsoleComponent.MaxJobTitleLength];
|
||||
if (jobTitle.Length > _maxIdJobLength)
|
||||
jobTitle = jobTitle[.._maxIdJobLength];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -209,8 +219,8 @@ public abstract class SharedIdCardSystem : EntitySystem
|
||||
if (!string.IsNullOrWhiteSpace(fullName))
|
||||
{
|
||||
fullName = fullName.Trim();
|
||||
if (fullName.Length > IdCardConsoleComponent.MaxFullNameLength)
|
||||
fullName = fullName[..IdCardConsoleComponent.MaxFullNameLength];
|
||||
if (fullName.Length > _maxNameLength)
|
||||
fullName = fullName[.._maxNameLength];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,11 +11,35 @@ public sealed partial class CCVars
|
||||
CVarDef.Create("ic.restricted_names", true, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Allows flavor text (character descriptions)
|
||||
/// Sets the maximum IC name length.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> MaxNameLength =
|
||||
CVarDef.Create("ic.name_length", 32, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the maximum name length for a loadout name (e.g. cyborg name).
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> MaxLoadoutNameLength =
|
||||
CVarDef.Create("ic.loadout_name_length", 32, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Allows flavor text (character descriptions).
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> FlavorText =
|
||||
CVarDef.Create("ic.flavor_text", false, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the maximum length for flavor text (character descriptions).
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> MaxFlavorTextLength =
|
||||
CVarDef.Create("ic.flavor_text_length", 512, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the maximum character length of a job on an ID.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> MaxIdJobLength =
|
||||
CVarDef.Create("ic.id_job_length", 30, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a period at the end of a sentence if the sentence ends in a letter.
|
||||
/// </summary>
|
||||
|
||||
@@ -28,10 +28,6 @@ namespace Content.Shared.Preferences
|
||||
private static readonly Regex RestrictedNameRegex = new(@"[^A-Za-z0-9 '\-]");
|
||||
private static readonly Regex ICNameCaseRegex = new(@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)");
|
||||
|
||||
public const int MaxNameLength = 32;
|
||||
public const int MaxLoadoutNameLength = 32;
|
||||
public const int MaxDescLength = 512;
|
||||
|
||||
/// <summary>
|
||||
/// Job preferences for initial spawn.
|
||||
/// </summary>
|
||||
@@ -508,13 +504,14 @@ namespace Content.Shared.Preferences
|
||||
};
|
||||
|
||||
string name;
|
||||
var maxNameLength = configManager.GetCVar(CCVars.MaxNameLength);
|
||||
if (string.IsNullOrEmpty(Name))
|
||||
{
|
||||
name = GetName(Species, gender);
|
||||
}
|
||||
else if (Name.Length > MaxNameLength)
|
||||
else if (Name.Length > maxNameLength)
|
||||
{
|
||||
name = Name[..MaxNameLength];
|
||||
name = Name[..maxNameLength];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,9 +537,10 @@ namespace Content.Shared.Preferences
|
||||
}
|
||||
|
||||
string flavortext;
|
||||
if (FlavorText.Length > MaxDescLength)
|
||||
var maxFlavorTextLength = configManager.GetCVar(CCVars.MaxFlavorTextLength);
|
||||
if (FlavorText.Length > maxFlavorTextLength)
|
||||
{
|
||||
flavortext = FormattedMessage.RemoveMarkupOrThrow(FlavorText)[..MaxDescLength];
|
||||
flavortext = FormattedMessage.RemoveMarkupOrThrow(FlavorText)[..maxFlavorTextLength];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Humanoid.Prototypes;
|
||||
using Content.Shared.Random;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -59,6 +61,7 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
||||
{
|
||||
var groupRemove = new ValueList<string>();
|
||||
var protoManager = collection.Resolve<IPrototypeManager>();
|
||||
var configManager = collection.Resolve<IConfigurationManager>();
|
||||
|
||||
if (!protoManager.TryIndex(Role, out var roleProto))
|
||||
{
|
||||
@@ -78,10 +81,11 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
||||
if (EntityName != null)
|
||||
{
|
||||
var name = EntityName.Trim();
|
||||
var maxNameLength = configManager.GetCVar(CCVars.MaxNameLength);
|
||||
|
||||
if (name.Length > HumanoidCharacterProfile.MaxNameLength)
|
||||
if (name.Length > maxNameLength)
|
||||
{
|
||||
EntityName = name[..HumanoidCharacterProfile.MaxNameLength];
|
||||
EntityName = name[..maxNameLength];
|
||||
}
|
||||
|
||||
if (name.Length == 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Lock;
|
||||
@@ -8,12 +9,14 @@ using Content.Shared.Security.Components;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Security.Systems;
|
||||
|
||||
public abstract class SharedGenpopSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] protected readonly IGameTiming Timing = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||
[Dependency] private readonly SharedEntityStorageSystem _entityStorage = default!;
|
||||
@@ -23,6 +26,8 @@ public abstract class SharedGenpopSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedUserInterfaceSystem _userInterface = default!;
|
||||
|
||||
// CCvar.
|
||||
private int _maxIdJobLength;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -33,12 +38,14 @@ public abstract class SharedGenpopSystem : EntitySystem
|
||||
SubscribeLocalEvent<GenpopLockerComponent, LockToggledEvent>(OnLockToggled);
|
||||
SubscribeLocalEvent<GenpopLockerComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
|
||||
SubscribeLocalEvent<GenpopIdCardComponent, ExaminedEvent>(OnExamine);
|
||||
|
||||
Subs.CVar(_cfgManager, CCVars.MaxIdJobLength, value => _maxIdJobLength = value, true);
|
||||
}
|
||||
|
||||
private void OnIdConfigured(Entity<GenpopLockerComponent> ent, ref GenpopLockerIdConfiguredMessage args)
|
||||
{
|
||||
// validation.
|
||||
if (string.IsNullOrWhiteSpace(args.Name) || args.Name.Length > IdCardConsoleComponent.MaxFullNameLength ||
|
||||
if (string.IsNullOrWhiteSpace(args.Name) || args.Name.Length > _maxIdJobLength ||
|
||||
args.Sentence < 0 ||
|
||||
string.IsNullOrWhiteSpace(args.Crime) || args.Crime.Length > GenpopLockerComponent.MaxCrimeLength)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user