Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Content.Client/Chat/UI/SpeechBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public enum SpeechType : byte
/// </summary>
public const float SpeechMaxWidth = 256;

/// <summary>
/// White Dream;
/// Max amount of characters in a speech bubble
/// </summary>
public int SingleBubbleCharLimit => ConfigManager.GetCVar(WhiteCVars.SingleBubbleCharLimit);

private readonly EntityUid _senderEntity;

private float _timeLeft = TotalTime;
Expand Down Expand Up @@ -222,6 +228,21 @@ protected FormattedMessage ExtractAndFormatSpeechSubstring(ChatMessage message,
return FormatSpeech(SharedChatSystem.GetStringInsideTag(message, tag), fontColor);
}

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;
}
}

public sealed class TextSpeechBubble : SpeechBubble
Expand All @@ -238,6 +259,8 @@ protected override Control BuildBubble(ChatMessage message, string speechStyleCl
MaxWidth = SpeechMaxWidth,
};

message = TruncateWrappedMessage(message, SingleBubbleCharLimit); // White Dream

label.SetMessage(FormatSpeech(message.WrappedMessage, fontColor, "Bedstead")); // WWDP EDIT

var panel = new PanelContainer
Expand Down Expand Up @@ -268,6 +291,8 @@ protected override Control BuildBubble(ChatMessage message, string speechStyleCl
MaxWidth = SpeechMaxWidth
};

message = TruncateWrappedMessage(message, SingleBubbleCharLimit); // White Dream

label.SetMessage(FormatSpeech(SharedChatSystem.GetStringInsideTag(message, "BubbleContent"), fontColor, "Bedstead")); // WWDP EDIT // LESS USELESS ONE LINER FUNCS PLS

var unfanciedPanel = new PanelContainer
Expand Down
13 changes: 8 additions & 5 deletions Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -107,7 +108,7 @@ public sealed class ChatUIController : UIController
/// <summary>
/// The max amount of chars allowed to fit in a single speech bubble.
/// </summary>
private const int SingleBubbleCharLimit = 100;
private int SingleBubbleCharLimit => _config.GetCVar(WhiteCVars.SingleBubbleCharLimit); // White Dream moved to WhiteCvars

/// <summary>
/// Base queue delay each speech bubble has.
Expand All @@ -117,12 +118,12 @@ public sealed class ChatUIController : UIController
/// <summary>
/// Factor multiplied by speech bubble char length to add to delay.
/// </summary>
private const float BubbleDelayFactor = 0.8f / SingleBubbleCharLimit;
private const float BubbleDelayFactor = 0.8f / 100; // White Dream

/// <summary>
/// The max amount of speech bubbles over a single entity at once.
/// </summary>
private const int SpeechBubbleCap = 4;
private int SpeechBubbleCap => _config.GetCVar(WhiteCVars.SpeechBubbleCap); // White Dream moved to WhiteCvars

private LayoutContainer _speechBubbleRoot = default!;

Expand Down Expand Up @@ -461,8 +462,10 @@ private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData)
if (existing.Count > SpeechBubbleCap)
{
// Get the oldest to start fading fast.
var last = existing[0];
last.FadeNow();
// White Dream edit - Get all of the older ones
var lastBubbles = existing[..^SpeechBubbleCap];
foreach (var last in lastBubbles)
last.FadeNow();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/_White/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; // White dream moved to cvar
private bool _isEnabled;

public override void Initialize()
Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/Chat/SharedChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,22 @@ public static string GetStringInsideTag(ChatMessage message, string tag)
return rawmsg.Substring(tagStart, tagEnd - tagStart);
}

// White Dream 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;
}
// White Dream edit end

// WD EDIT START - Moved from ClatUIController
/// <summary>
/// Returns the chat name color for a mob
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/_White/CCVar/WhiteCVars.Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ public sealed partial class WhiteCVars

public static readonly CVarDef<bool> ColoredBubbleChat =
CVarDef.Create("chat.colored_bubble", true, CVar.CLIENTONLY | CVar.ARCHIVE);

public static readonly CVarDef<int> SingleBubbleCharLimit =
CVarDef.Create("chat.bubble_character_limit", 43, CVar.SERVER | CVar.REPLICATED);

public static readonly CVarDef<int> SpeechBubbleCap =
CVarDef.Create("chat.bubble_max_count", 1, CVar.SERVER | CVar.REPLICATED);
}
Loading