diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index 8362fb37417..68c937a7885 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -66,10 +66,10 @@ public static SpeechBubble CreateSpeechBubble(SpeechType type, ChatMessage messa return new TextSpeechBubble(message, senderEntity, "emoteBox"); case SpeechType.Say: - return new FancyTextSpeechBubble(message, senderEntity, "sayBox", message.MessageColorOverride); + return new FancyTextSpeechBubble(message, senderEntity, "sayBox"); case SpeechType.Whisper: - return new FancyTextSpeechBubble(message, senderEntity, "whisperBox", message.MessageColorOverride); + return new FancyTextSpeechBubble(message, senderEntity, "whisperBox"); case SpeechType.Looc: return new TextSpeechBubble(message, senderEntity, "emoteBox", Color.FromHex("#48d1cc")); diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 599d215d0b8..c16159e06f4 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -435,6 +435,11 @@ private void SendEntitySpeak( ("fontSize", speech.FontSize), ("message", FormattedMessage.EscapeText(msg.OriginalMessage))); + var color = LanguageSystem.GetLanguageColor(msg); + + if (color is not null) + wrappedMessage = InjectTagInsideTag(wrappedMessage, "Message", "color", color.Value.ToHex()); + var wrappedLanguageMessage = 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))), @@ -451,9 +456,7 @@ private void SendEntitySpeak( var understand = _language.IsUnderstandLanguage(session, msg); - var color = understand ? LanguageSystem.GetLanguageColor(msg) : null; - - _chatManager.ChatMessageToOne(ChatChannel.Local, understand ? msg.OriginalMessage : msg.Message, understand ? wrappedMessage : wrappedLanguageMessage, source, entRange == MessageRangeCheckResult.HideChat, session.Channel, color); + _chatManager.ChatMessageToOne(ChatChannel.Local, understand ? msg.OriginalMessage : msg.Message, understand ? wrappedMessage : wrappedLanguageMessage, source, entRange == MessageRangeCheckResult.HideChat, session.Channel); } _replay.RecordServerMessage(new ChatMessage(ChatChannel.Local, msg.OriginalMessage, wrappedMessage, GetNetEntity(source), null, MessageRangeHideChatForReplay(range))); @@ -534,6 +537,15 @@ private void SendEntityWhisper( var wrappedUnknownMessage = Loc.GetString("chat-manager-entity-whisper-unknown-wrap-message", ("message", FormattedMessage.EscapeText(obfuscatedMessage))); + var color = LanguageSystem.GetLanguageColor(msg); + + if (color is not null) + { + wrappedMessage = InjectTagInsideTag(wrappedMessage, "Message", "color", color.Value.ToHex()); + wrappedObfuscatedMessage = InjectTagInsideTag(wrappedObfuscatedMessage, "Message", "color", color.Value.ToHex()); + wrappedUnknownMessage = InjectTagInsideTag(wrappedUnknownMessage, "Message", "color", color.Value.ToHex()); + } + var wrappedLanguageMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message", ("entityName", name), ("message", FormattedMessage.EscapeText(msg.Message))); @@ -557,17 +569,15 @@ private void SendEntityWhisper( var understand = _language.IsUnderstandLanguage(session, msg); - var color = understand ? LanguageSystem.GetLanguageColor(msg) : null; - if (data.Range <= WhisperClearRange) - _chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? msg.OriginalMessage : msg.Message, understand ? wrappedMessage : wrappedLanguageMessage, source, false, session.Channel, color); + _chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? msg.OriginalMessage : msg.Message, understand ? wrappedMessage : wrappedLanguageMessage, source, false, session.Channel); //If listener is too far, they only hear fragments of the message //Collisiongroup.Opaque is not ideal for this use. Preferably, there should be a check specifically with "Can Ent1 see Ent2" in mind else if (_interactionSystem.InRangeUnobstructed(source, listener, WhisperMuffledRange, Shared.Physics.CollisionGroup.Opaque)) //Shared.Physics.CollisionGroup.Opaque - _chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? obfuscatedMessage : obfuscatedLanguageMessage, understand ? wrappedObfuscatedMessage : wrappedObfuscatedLanguageMessage, source, false, session.Channel, color); + _chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? obfuscatedMessage : obfuscatedLanguageMessage, understand ? wrappedObfuscatedMessage : wrappedObfuscatedLanguageMessage, source, false, session.Channel); //If listener is too far and has no line of sight, they can't identify the whisperer's identity else - _chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? obfuscatedMessage : obfuscatedLanguageMessage, understand ? wrappedUnknownMessage : wrappedUnknownLanguageMessage, source, false, session.Channel, color); + _chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? obfuscatedMessage : obfuscatedLanguageMessage, understand ? wrappedUnknownMessage : wrappedUnknownLanguageMessage, source, false, session.Channel); } _replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, msg.OriginalMessage, wrappedMessage, GetNetEntity(source), null, MessageRangeHideChatForReplay(range))); diff --git a/Content.Server/Radio/EntitySystems/RadioSystem.cs b/Content.Server/Radio/EntitySystems/RadioSystem.cs index 67e7dfdd7aa..0d0e9c545d4 100644 --- a/Content.Server/Radio/EntitySystems/RadioSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioSystem.cs @@ -140,6 +140,11 @@ public void SendRadioMessage(EntityUid messageSource, LanguageMessage message, R ("name", name), ("message", content)); + var color = LanguageSystem.GetLanguageColor(message); + + if (color is not null) + wrappedMessage = SharedChatSystem.InjectTagInsideTag(wrappedMessage, "Message", "color", color.Value.ToHex()); + var wrappedLanguageMessage = languageContent is not null ? Loc.GetString(speech!.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap", ("color", channel.Color), ("fontType", speech.FontId), diff --git a/Content.Shared/Chat/SharedChatSystem.cs b/Content.Shared/Chat/SharedChatSystem.cs index a20d649d238..7326eeb0b8b 100644 --- a/Content.Shared/Chat/SharedChatSystem.cs +++ b/Content.Shared/Chat/SharedChatSystem.cs @@ -217,20 +217,25 @@ public static string SanitizeAnnouncement(string message, int maxLength = 0, int public static string InjectTagInsideTag(ChatMessage message, string outerTag, string innerTag, string? tagParameter) { - var rawmsg = message.WrappedMessage; - var tagStart = rawmsg.IndexOf($"[{outerTag}]"); - var tagEnd = rawmsg.IndexOf($"[/{outerTag}]"); + return InjectTagInsideTag(message.WrappedMessage, outerTag, innerTag, tagParameter); + } + + public static string InjectTagInsideTag(string message, string outerTag, string innerTag, string? tagParameter) + { + var tagStart = message.IndexOf($"[{outerTag}]"); + var tagEnd = message.IndexOf($"[/{outerTag}]"); if (tagStart < 0 || tagEnd < 0) //If the outer tag is not found, the injection is not performed - return rawmsg; + return message; tagStart += outerTag.Length + 2; - string innerTagProcessed = tagParameter != null ? $"[{innerTag}={tagParameter}]" : $"[{innerTag}]"; + var innerTagProcessed = tagParameter != null ? $"[{innerTag}={tagParameter}]" : $"[{innerTag}]"; - rawmsg = rawmsg.Insert(tagEnd, $"[/{innerTag}]"); - rawmsg = rawmsg.Insert(tagStart, innerTagProcessed); + message = message.Insert(tagEnd, $"[/{innerTag}]"); + message = message.Insert(tagStart, innerTagProcessed); - return rawmsg; + return message; } + public static string GetStringInsideTag(ChatMessage message, string tag) { var rawmsg = message.WrappedMessage; diff --git a/Resources/Locale/en-US/chat/managers/chat-manager.ftl b/Resources/Locale/en-US/chat/managers/chat-manager.ftl index 38b12251bec..2d31cd658cf 100644 --- a/Resources/Locale/en-US/chat/managers/chat-manager.ftl +++ b/Resources/Locale/en-US/chat/managers/chat-manager.ftl @@ -21,8 +21,8 @@ chat-manager-whisper-headset-on-message = You can't whisper on the radio! chat-manager-server-wrap-message = [bold]{$message}[/bold] chat-manager-sender-announcement-wrap-message = [font size=14][bold]{$sender} Announcement:[/font][font size=12] {$message}[/bold][/font] -chat-manager-entity-say-wrap-message = [BubbleHeader][bold][Name]{$entityName}[/Name][/bold][/BubbleHeader] {$verb}, [font={$fontType} size={$fontSize}]"[BubbleContent]{$message}[/BubbleContent]"[/font] -chat-manager-entity-say-bold-wrap-message = [BubbleHeader][bold][Name]{$entityName}[/Name][/bold][/BubbleHeader] {$verb}, [font={$fontType} size={$fontSize}]"[BubbleContent][bold]{$message}[/bold][/BubbleContent]"[/font] +chat-manager-entity-say-wrap-message = [BubbleHeader][bold][Name]{$entityName}[/Name][/bold][/BubbleHeader] {$verb}, [font={$fontType} size={$fontSize}]"[BubbleContent][Message]{$message}[/Message][/BubbleContent]"[/font] +chat-manager-entity-say-bold-wrap-message = [BubbleHeader][bold][Name]{$entityName}[/Name][/bold][/BubbleHeader] {$verb}, [font={$fontType} size={$fontSize}]"[BubbleContent][bold][Message]{$message}[/Message][/bold][/BubbleContent]"[/font] chat-manager-entity-whisper-wrap-message = [font size=11][italic][BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] whispers,"[BubbleContent]{$message}[/BubbleContent]"[/italic][/font] chat-manager-entity-whisper-unknown-wrap-message = [font size=11][italic][BubbleHeader]Someone[/BubbleHeader] whispers, "[BubbleContent]{$message}[/BubbleContent]"[/italic][/font] diff --git a/Resources/Locale/en-US/headset/headset-component.ftl b/Resources/Locale/en-US/headset/headset-component.ftl index dcd758ddd02..c32ce7fb02c 100644 --- a/Resources/Locale/en-US/headset/headset-component.ftl +++ b/Resources/Locale/en-US/headset/headset-component.ftl @@ -1,6 +1,6 @@ # Chat window radio wrap (prefix and postfix) -chat-radio-message-wrap = [color={$color}]{$channel} [bold]{$name}[/bold] {$verb}, [font={$fontType} size={$fontSize}]"{$message}"[/font][/color] -chat-radio-message-wrap-bold = [color={$color}]{$channel} [bold]{$name}[/bold] {$verb}, [font={$fontType} size={$fontSize}][bold]"{$message}"[/bold][/font][/color] +chat-radio-message-wrap = [color={$color}]{$channel} [bold]{$name}[/bold] {$verb}, [font={$fontType} size={$fontSize}]"[Message]{$message}[/Message]"[/font][/color] +chat-radio-message-wrap-bold = [color={$color}]{$channel} [bold]{$name}[/bold] {$verb}, [font={$fontType} size={$fontSize}][bold]"[Message]{$message}[/Message]"[/bold][/font][/color] examine-headset-default-channel = Use {$prefix} for the default channel ([color={$color}]{$channel}[/color]). diff --git a/Resources/Locale/ru-RU/chat/managers/chat-manager.ftl b/Resources/Locale/ru-RU/chat/managers/chat-manager.ftl index 1b2449af6f9..db52f6fcf46 100644 --- a/Resources/Locale/ru-RU/chat/managers/chat-manager.ftl +++ b/Resources/Locale/ru-RU/chat/managers/chat-manager.ftl @@ -19,8 +19,8 @@ chat-manager-whisper-headset-on-message = Вы не можете шептать chat-manager-server-wrap-message = [bold]{ $message }[/bold] chat-manager-sender-announcement-wrap-message = [font size=14][bold]Объявление { $sender }:[/font][font size=12] { $message }[/bold][/font] -chat-manager-entity-say-wrap-message = [BubbleHeader][bold][Name]{ $entityName }[/Name][/bold][/BubbleHeader] { $verb }, [font={ $fontType } size={ $fontSize } ]"[BubbleContent]{ $message }[/BubbleContent]"[/font] -chat-manager-entity-say-bold-wrap-message = [BubbleHeader][bold][Name]{ $entityName }[/Name][/bold][/BubbleHeader] { $verb }, [font={ $fontType } size={ $fontSize }]"[BubbleContent][bold]{ $message }[/bold][/BubbleContent]"[/font] +chat-manager-entity-say-wrap-message = [BubbleHeader][bold][Name]{ $entityName }[/Name][/bold][/BubbleHeader] { $verb }, [font={ $fontType } size={ $fontSize } ]"[BubbleContent][Message]{ $message }[/Message][/BubbleContent]"[/font] +chat-manager-entity-say-bold-wrap-message = [BubbleHeader][bold][Name]{ $entityName }[/Name][/bold][/BubbleHeader] { $verb }, [font={ $fontType } size={ $fontSize }]"[BubbleContent][bold][Message]{ $message }[/Message][/bold][/BubbleContent]"[/font] chat-manager-entity-whisper-wrap-message = [font size=11][italic][BubbleHeader][Name]{ $entityName }[/Name][/BubbleHeader] шепчет,"[BubbleContent]{ $message }[/BubbleContent]"[/italic][/font] chat-manager-entity-whisper-unknown-wrap-message = [font size=11][italic][BubbleHeader]Кто-то[/BubbleHeader] шепчет, "[BubbleContent]{ $message }[/BubbleContent]"[/italic][/font] chat-manager-entity-me-wrap-message = [italic]{ $entityName } { $message }[/italic] diff --git a/Resources/Locale/ru-RU/headset/headset-component.ftl b/Resources/Locale/ru-RU/headset/headset-component.ftl index 21d1da37fe3..22717503451 100644 --- a/Resources/Locale/ru-RU/headset/headset-component.ftl +++ b/Resources/Locale/ru-RU/headset/headset-component.ftl @@ -1,6 +1,6 @@ # Chat window radio wrap (prefix and postfix) -chat-radio-message-wrap = [color={ $color }]{ $channel } [bold]{ $name }[/bold] { $verb }, [font={ $fontType } size={ $fontSize }]"{ $message }"[/font][/color] -chat-radio-message-wrap-bold = [color={ $color }]{ $channel } [bold]{ $name }[/bold] { $verb }, [font={ $fontType } size={ $fontSize }][bold]"{ $message }"[/bold][/font][/color] +chat-radio-message-wrap = [color={ $color }]{ $channel } [bold]{ $name }[/bold] { $verb }, [font={ $fontType } size={ $fontSize }]"[Message]{ $message }[/Message]"[/font][/color] +chat-radio-message-wrap-bold = [color={ $color }]{ $channel } [bold]{ $name }[/bold] { $verb }, [font={ $fontType } size={ $fontSize }]"[bold][Message]{ $message }[/Message][/bold]"[/font][/color] examine-headset-default-channel = Отображается, что каналом по умолчанию этой гарнитуры является [color={ $color }]{ $channel }[/color]. chat-radio-common = Общий chat-radio-centcom = Центком