From: dffdff2423 <57052305+dffdff2423@users.noreply.github.com> Date: Sat, 20 Apr 2024 01:07:10 +0000 (-0500) Subject: Disable Communication Console Announcement Button for Too Long Messages. (#27145) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=cff80836503c8d7bd3ed0b018d9feff904114128;p=space-station-14.git 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. --- diff --git a/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs b/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs index 90643e45cf..4d8dd86a4d 100644 --- a/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs +++ b/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs @@ -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(); 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; diff --git a/Resources/Locale/en-US/communications/communications-console-component.ftl b/Resources/Locale/en-US/communications/communications-console-component.ftl index f7cc87cb8b..bead43df28 100644 --- a/Resources/Locale/en-US/communications/communications-console-component.ftl +++ b/Resources/Locale/en-US/communications/communications-console-component.ftl @@ -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