diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs
index 66db93a8269..0f6fca6798c 100644
--- a/Content.Client/Chat/UI/SpeechBubble.cs
+++ b/Content.Client/Chat/UI/SpeechBubble.cs
@@ -52,6 +52,26 @@ public enum SpeechType : byte
///
public const float SpeechMaxWidth = 256;
+ ///
+ /// White Dream;
+ /// Max amount of characters in a speech bubble
+ ///
+ public int SingleBubbleCharLimit
+ {
+ get
+ {
+ var cvar = ConfigManager.GetCVar(WhiteCVars.SingleBubbleCharLimit);
+
+ if (cvar <= 0)
+ {
+ Logger.Error("Local CVar chat.bubble_character_limit is set to 0 or lower");
+ cvar = 1;
+ }
+
+ return cvar;
+ }
+ }
+
private readonly EntityUid _senderEntity;
private float _timeLeft = TotalTime;
@@ -222,6 +242,23 @@ protected FormattedMessage ExtractAndFormatSpeechSubstring(ChatMessage message,
return FormatSpeech(SharedChatSystem.GetStringInsideTag(message, tag), fontColor);
}
+ // WWDP EDIT START
+ public ChatMessage TruncateWrappedMessage(ChatMessage message, int maxLength)
+ {
+ var text = SharedChatSystem.GetStringInsideTag(message, "BubbleContent");
+
+ if (text.Length <= maxLength)
+ return message;
+
+ text = text[..maxLength].TrimEnd(' ', '.', ',', ';', ':', '!', '?') + "...";
+
+ var newmsg = SharedChatSystem.SetStringInsideTag(message,"BubbleContent", text);
+
+ message.WrappedMessage = newmsg;
+
+ return message;
+ }
+ // WWDP EDIT END
}
public sealed class TextSpeechBubble : SpeechBubble
@@ -238,6 +275,8 @@ protected override Control BuildBubble(ChatMessage message, string speechStyleCl
MaxWidth = SpeechMaxWidth,
};
+ message = TruncateWrappedMessage(message, SingleBubbleCharLimit); // WWDP edit
+
label.SetMessage(FormatSpeech(message.WrappedMessage, fontColor, "Bedstead")); // WWDP EDIT
var panel = new PanelContainer
@@ -268,6 +307,8 @@ protected override Control BuildBubble(ChatMessage message, string speechStyleCl
MaxWidth = SpeechMaxWidth
};
+ message = TruncateWrappedMessage(message, SingleBubbleCharLimit); // WWDP edit
+
label.SetMessage(FormatSpeech(SharedChatSystem.GetStringInsideTag(message, "BubbleContent"), fontColor, "Bedstead")); // WWDP EDIT // LESS USELESS ONE LINER FUNCS PLS
var unfanciedPanel = new PanelContainer
diff --git a/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs b/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
index 6193ba339f0..182e9dd3bb9 100644
--- a/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
+++ b/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
@@ -15,6 +15,7 @@
using Content.Client.UserInterface.Screens;
using Content.Client.UserInterface.Systems.Chat.Widgets;
using Content.Client.UserInterface.Systems.Gameplay;
+using Content.Shared._White.CCVar;
using Content.Shared.Administration;
using Content.Shared.CCVar;
using Content.Shared.Chat;
@@ -107,7 +108,7 @@ public sealed class ChatUIController : UIController
///
/// The max amount of chars allowed to fit in a single speech bubble.
///
- private const int SingleBubbleCharLimit = 100;
+ private int SingleBubbleCharLimit => _config.GetCVar(WhiteCVars.SingleBubbleCharLimit); // WWDP moved to WhiteCvars
///
/// Base queue delay each speech bubble has.
@@ -117,12 +118,28 @@ public sealed class ChatUIController : UIController
///
/// Factor multiplied by speech bubble char length to add to delay.
///
- private const float BubbleDelayFactor = 0.8f / SingleBubbleCharLimit;
+ private const float BubbleDelayFactor = 0.8f / 100; // WWDP edit
+ // WWDP edit start
///
/// The max amount of speech bubbles over a single entity at once.
///
- private const int SpeechBubbleCap = 4;
+ private int SpeechBubbleCap
+ {
+ get
+ {
+ var cvar = _config.GetCVar(WhiteCVars.SpeechBubbleCap);
+
+ if (cvar <= 0)
+ {
+ Logger.Error("Local CVar chat.bubble_max_count is set to 0 or lower");
+ cvar = 1;
+ }
+
+ return cvar;
+ }
+ }
+ // WWDP edit end
private LayoutContainer _speechBubbleRoot = default!;
@@ -460,9 +477,12 @@ private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData)
if (existing.Count > SpeechBubbleCap)
{
- // Get the oldest to start fading fast.
- var last = existing[0];
- last.FadeNow();
+ // WWDP edit start
+ // Get all of the older ones
+ var lastBubbles = existing[..^SpeechBubbleCap];
+ foreach (var last in lastBubbles)
+ last.FadeNow();
+ // WWDP edit end
}
}
diff --git a/Content.Server/_White/TTS/TTSSystem.cs b/Content.Server/_White/TTS/TTSSystem.cs
index 11a50c89cc5..dc8140bafef 100644
--- a/Content.Server/_White/TTS/TTSSystem.cs
+++ b/Content.Server/_White/TTS/TTSSystem.cs
@@ -24,7 +24,7 @@ public sealed partial class TTSSystem : EntitySystem
[Dependency] private readonly SharedTransformSystem _xforms = default!;
[Dependency] private readonly LanguageSystem _language = default!;
- private const int MaxMessageChars = 100 * 2; // same as SingleBubbleCharLimit * 2
+ private int MaxMessageChars => _cfg.GetCVar(WhiteCVars.SingleBubbleCharLimit) * 2;
private bool _isEnabled;
public override void Initialize()
diff --git a/Content.Shared/Chat/SharedChatSystem.cs b/Content.Shared/Chat/SharedChatSystem.cs
index f0b09ba1b04..f72d582a35f 100644
--- a/Content.Shared/Chat/SharedChatSystem.cs
+++ b/Content.Shared/Chat/SharedChatSystem.cs
@@ -359,6 +359,22 @@ public static string GetStringInsideTag(ChatMessage message, string tag)
return rawmsg.Substring(tagStart, tagEnd - tagStart);
}
+ // WWDP edit start
+ // Returns a message with a string inside tag removed and replaced
+ public static string SetStringInsideTag(ChatMessage message, string tag, string strInsert)
+ {
+ var rawmsg = message.WrappedMessage;
+ var tagStart = rawmsg.IndexOf($"[{tag}]");
+ var tagEnd = rawmsg.IndexOf($"[/{tag}]");
+ if (tagStart < 0 || tagEnd < 0)
+ return rawmsg;
+ tagStart += tag.Length + 2;
+ rawmsg = rawmsg.Remove(tagStart, tagEnd - tagStart);
+ rawmsg = rawmsg.Insert(tagStart, $"{strInsert}");
+ return rawmsg;
+ }
+ // WWDP edit end
+
// WD EDIT START - Moved from ClatUIController
///
/// Returns the chat name color for a mob
diff --git a/Content.Shared/_White/CCVar/WhiteCVars.Chat.cs b/Content.Shared/_White/CCVar/WhiteCVars.Chat.cs
index bf326afddca..264f9189e30 100644
--- a/Content.Shared/_White/CCVar/WhiteCVars.Chat.cs
+++ b/Content.Shared/_White/CCVar/WhiteCVars.Chat.cs
@@ -12,4 +12,10 @@ public sealed partial class WhiteCVars
public static readonly CVarDef ColoredBubbleChat =
CVarDef.Create("chat.colored_bubble", true, CVar.CLIENTONLY | CVar.ARCHIVE);
+
+ public static readonly CVarDef SingleBubbleCharLimit =
+ CVarDef.Create("chat.bubble_character_limit", 43, CVar.CLIENT | CVar.ARCHIVE);
+
+ public static readonly CVarDef SpeechBubbleCap =
+ CVarDef.Create("chat.bubble_max_count", 1, CVar.CLIENT | CVar.ARCHIVE);
}