]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Disable Communication Console Announcement Button for Too Long Messages. (#27145)
authordffdff2423 <57052305+dffdff2423@users.noreply.github.com>
Sat, 20 Apr 2024 01:07:10 +0000 (20:07 -0500)
committerGitHub <noreply@github.com>
Sat, 20 Apr 2024 01:07:10 +0000 (11:07 +1000)
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.

Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs
Resources/Locale/en-US/communications/communications-console-component.ftl

index 90643e45cf7ff4e6dd612dee6520f46cd31ee363..4d8dd86a4dcce8e7dc5d464ea59bbc83102c8375 100644 (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;
 
index f7cc87cb8ba1b1fa40c2f02f9f789fb40f98f275..bead43df286ffa3ba8342935c0c6638f12fdd88a 100644 (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