diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 7a8446be8a..1b5c8b83fa 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -13,7 +13,9 @@ using Content.Shared.ActionBlocker; using Content.Shared.CCVar; using Content.Shared.Chat; using Content.Shared.Database; +using Content.Shared.Decals; using Content.Shared.Ghost; +using Content.Shared.Humanoid; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Mobs.Systems; @@ -25,6 +27,7 @@ using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Configuration; using Robust.Shared.Console; +using Robust.Shared.GameObjects.Components.Localization; using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -67,6 +70,10 @@ public sealed partial class ChatSystem : SharedChatSystem private bool _critLoocEnabled; private readonly bool _adminLoocEnabled = true; + [ValidatePrototypeId] + private const string _chatNamePalette = "Material"; + private string[] _chatNameColors = default!; + public override void Initialize() { base.Initialize(); @@ -76,6 +83,13 @@ public sealed partial class ChatSystem : SharedChatSystem _configurationManager.OnValueChanged(CCVars.CritLoocEnabled, OnCritLoocEnabledChanged, true); SubscribeLocalEvent(OnGameChange); + + var nameColors = _prototypeManager.Index(_chatNamePalette).Colors.Values.ToArray(); + _chatNameColors = new string[nameColors.Length]; + for (var i = 0; i < nameColors.Length; i++) + { + _chatNameColors[i] = nameColors[i].ToHex(); + } } public override void Shutdown() @@ -409,6 +423,11 @@ public sealed partial class ChatSystem : SharedChatSystem } name = FormattedMessage.EscapeText(name); + + // color the name unless it's something like "the old man" + if (!TryComp(source, out var grammar) || grammar.ProperNoun == true) + name = $"[color={GetNameColor(name)}]{name}[/color]"; + var wrappedMessage = Loc.GetString(speech.Bold ? "chat-manager-entity-say-bold-wrap-message" : "chat-manager-entity-say-wrap-message", ("entityName", name), ("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))), @@ -479,6 +498,10 @@ public sealed partial class ChatSystem : SharedChatSystem } name = FormattedMessage.EscapeText(name); + // color the name unless it's something like "the old man" + if (!TryComp(source, out var grammar) || grammar.ProperNoun == true) + name = $"[color={GetNameColor(name)}]{name}[/color]"; + var wrappedMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message", ("entityName", name), ("message", FormattedMessage.EscapeText(message))); @@ -619,6 +642,17 @@ public sealed partial class ChatSystem : SharedChatSystem #region Utility + /// + /// Returns the chat name color for a mob + /// + /// Name of the mob + /// Hex value of the color + public string GetNameColor(string name) + { + var colorIdx = Math.Abs(name.GetHashCode() % _chatNameColors.Length); + return _chatNameColors[colorIdx]; + } + private enum MessageRangeCheckResult { Disallowed, diff --git a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs index 02e29549d4..597afcbda2 100644 --- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs @@ -1,4 +1,5 @@ using System.Linq; +using Content.Shared.Decals; using Content.Shared.Humanoid.Markings; using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; diff --git a/Resources/Prototypes/Palettes/text.yml b/Resources/Prototypes/Palettes/text.yml new file mode 100644 index 0000000000..de0a9fb60d --- /dev/null +++ b/Resources/Prototypes/Palettes/text.yml @@ -0,0 +1,35 @@ +- type: palette + id: Material + name: Material + colors: + red: "#a91409" + red-darken-2: "#a72323" + red-accent-2: "#9b0000" + purple: "#7d1f8d" + purple-accent-2: "#8d03a5" + purple-accent-4: "#8800cc" + blue: "#0a6ab6" + blue-lighten-2: "#08528d" + blue-darken-2: "#145ea8" + cyan: "#0096aa" + cyan-lighten-2: "#198896" + cyan-darken-2: "#007986" + cyan-accent-2: "#00bebe" + cyan-accent-4: "#0093aa" + teal: "#00786d" + teal-lighten-2: "#3b8f89" + teal-accent-2: "#009076" + teal-accent-4: "#009984" + green: "#3d8c40" + green-darken-2: "#2d7230" + green-accent-2: "#0e885b" + green-accent-4: "#00a042" + lime: "#737a15" + lime-darken-2: "#8c9022" + lime-accent-2: "#737c00" + lime-accent-4: "#8bbb00" + amber: "#967000" + amber-lighten-2: "#755900" + amber-darken-2: "#cc8000" + amber-accent-2: "#7c6200" + amber-accent-4: "#996700" \ No newline at end of file