diff --git a/Content.Server/Chat/Managers/ChatSanitizationManager.cs b/Content.Server/Chat/Managers/ChatSanitizationManager.cs index 7cfd6051a82ae..9f13a259536d7 100644 --- a/Content.Server/Chat/Managers/ChatSanitizationManager.cs +++ b/Content.Server/Chat/Managers/ChatSanitizationManager.cs @@ -2,6 +2,8 @@ using System.Text.RegularExpressions; using Content.Shared.CCVar; using Robust.Shared.Configuration; +using Content.Shared.Humanoid; //DS14 +using Content.Shared.Humanoid.Prototypes; //DS14 namespace Content.Server.Chat.Managers; @@ -117,8 +119,24 @@ private static readonly (Regex regex, string emoteKey)[] ShorthandToEmote = Entry("['=", "chatsan-tearfully-smiles"), ]; + // DS14-Start + // Эмоции, для которых мы и юзаем половые варианты(Пополнить список, если я чтот забыл) + private static readonly HashSet GenderedEmotes = new() + { + "chatsan-surprised", + "chatsan-uncertain", + "chatsan-annoyed", + "chatsan-unimpressed", + "chatsan-wide-eyed", + "chatsan-confused" + }; + // DS14-End + [Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly ILocalizationManager _loc = default!; + // DS14-Start + [Dependency] private readonly IEntityManager _entityManager = default!; + // DS14-End private bool _doSanitize; @@ -146,6 +164,15 @@ public bool TrySanitizeEmoteShorthands(string message, if (!_doSanitize) return false; + // DS14-Start + // Определение пола + Sex sex = Sex.Unsexed; + if (_entityManager.TryGetComponent(speaker, out var humanoid)) + { + sex = humanoid.Sex; + } + // DS14-End + // -1 is just a canary for nothing found yet var lastEmoteIndex = -1; @@ -161,7 +188,26 @@ public bool TrySanitizeEmoteShorthands(string message, if (lastMatch.Index > lastEmoteIndex) { lastEmoteIndex = lastMatch.Index; - emote = _loc.GetString(emoteKey, ("ent", speaker)); + + // DS14-Start + // Суффиксы, да + string finalEmoteKey; + if (GenderedEmotes.Contains(emoteKey)) + { + finalEmoteKey = sex switch + { + Sex.Female => $"{emoteKey}-female", + Sex.Male => $"{emoteKey}-male", + _ => $"{emoteKey}-unsexed" + }; + } + else + { + finalEmoteKey = emoteKey; + } + + emote = _loc.GetString(finalEmoteKey); + // DS14-End } message = r.Replace(message, string.Empty); @@ -187,4 +233,4 @@ private static (Regex regex, string emoteKey) Entry(string shorthand, string emo return (pattern, emoteKey); } -} +} \ No newline at end of file diff --git a/Resources/Locale/ru-RU/chat/sanitizer-replacements.ftl b/Resources/Locale/ru-RU/chat/sanitizer-replacements.ftl index a5cf837de7909..f7cb0d109788c 100644 --- a/Resources/Locale/ru-RU/chat/sanitizer-replacements.ftl +++ b/Resources/Locale/ru-RU/chat/sanitizer-replacements.ftl @@ -2,19 +2,13 @@ chatsan-smiles = улыбается chatsan-frowns = грустит chatsan-smiles-widely = широко улыбается chatsan-frowns-deeply = сильно грустит -chatsan-surprised = выглядит удивлённым -chatsan-uncertain = выглядит растерянным chatsan-grins = ухмыляется chatsan-pouts = дуется chatsan-laughs = смеётся chatsan-cries = плачет chatsan-smiles-smugly = самодовольно улыбается -chatsan-annoyed = выглядит раздражённым chatsan-sighs = вздыхает chatsan-stick-out-tongue = показывает язык -chatsan-wide-eyed = выглядит шокированным -chatsan-confused = выглядит смущённым -chatsan-unimpressed = кажется не впечатлённым chatsan-waves = машет chatsan-salutes = отдаёт честь chatsan-tearfully-salutes = отдаёт честь со слезами на глазах @@ -23,3 +17,32 @@ chatsan-winks = подмигивает chatsan-shrugs = пожимает плечами chatsan-claps = хлопает chatsan-snaps = щёлкает +# surprised +chatsan-surprised-female = выглядит удивлённой +chatsan-surprised-male = выглядит удивлённым +chatsan-surprised-unsexed = выглядят удивлёнными + +# uncertain +chatsan-uncertain-female = выглядит растерянной +chatsan-uncertain-male = выглядит растерянным +chatsan-uncertain-unsexed = выглядят растерянными + +# annoyed +chatsan-annoyed-female = выглядит раздражённой +chatsan-annoyed-male = выглядит раздражённым +chatsan-annoyed-unsexed = выглядят раздражёнными + +# unimpressed +chatsan-unimpressed-female = кажется невпечатлённой +chatsan-unimpressed-male = кажется невпечатлённым +chatsan-unimpressed-unsexed = кажутся невпечатлёнными + +# wide-eyed +chatsan-wide-eyed-female = выглядит шокированной +chatsan-wide-eyed-male = выглядит шокированным +chatsan-wide-eyed-unsexed = выглядят шокированными + +# confused +chatsan-confused-female = выглядит смущённой +chatsan-confused-male = выглядит смущённым +chatsan-confused-unsexed = выглядят смущёнными \ No newline at end of file