Disable Communication Console Announcement Button for Too Long Messages. (#27145)

Disable comms console announce for long messages

Disable the "announce" button on the communications console for messages
above the cap. I did not touch broadcasting because I could not identify
an easy way to check the maximum length for it.

(cherry picked from commit cff80836503c8d7bd3ed0b018d9feff904114128)
This commit is contained in:
dffdff2423 2024-04-19 20:07:10 -05:00 committed by NullWanderer
parent df3d2bb453
commit 107fc0ff25
No known key found for this signature in database
GPG Key ID: 212F05528FD678BE
2 changed files with 22 additions and 1 deletions

View File

@ -1,7 +1,9 @@
using Content.Client.UserInterface.Controls;
using System.Threading;
using Content.Shared.CCVar;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Utility;
using Timer = Robust.Shared.Timing.Timer;
@ -13,6 +15,8 @@ namespace Content.Client.Communications.UI
private CommunicationsConsoleBoundUserInterface Owner { get; set; }
private readonly CancellationTokenSource _timerCancelTokenSource = new();
[Dependency] private readonly IConfigurationManager _cfg = default!;
public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner)
{
IoCManager.InjectDependencies(this);
@ -23,6 +27,22 @@ namespace Content.Client.Communications.UI
var loc = IoCManager.Resolve<ILocalizationManager>();
MessageInput.Placeholder = new Rope.Leaf(loc.GetString("comms-console-menu-announcement-placeholder"));
var maxAnnounceLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
MessageInput.OnTextChanged += (args) =>
{
if (args.Control.TextLength > maxAnnounceLength)
{
AnnounceButton.Disabled = true;
AnnounceButton.ToolTip = Loc.GetString("comms-console-message-too-long");
}
else
{
AnnounceButton.Disabled = !owner.CanAnnounce;
AnnounceButton.ToolTip = null;
}
};
AnnounceButton.OnPressed += (_) => Owner.AnnounceButtonPressed(Rope.Collapse(MessageInput.TextRope));
AnnounceButton.Disabled = !owner.CanAnnounce;

View File

@ -1,4 +1,4 @@
# User interface
# User interface
comms-console-menu-title = Communications Console
comms-console-menu-announcement-placeholder = Announcement text...
comms-console-menu-announcement-button = Announce
@ -9,6 +9,7 @@ comms-console-menu-recall-shuttle = Recall emergency shuttle
# Popup
comms-console-permission-denied = Permission denied
comms-console-shuttle-unavailable = Shuttle is currently unavailable
comms-console-message-too-long = Message is too long
# Placeholder values
comms-console-announcement-sent-by = Sent by