]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
New Feature: Admin Only messages in AHelp (#35283)
authorWinkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Sat, 22 Feb 2025 17:45:50 +0000 (20:45 +0300)
committerGitHub <noreply@github.com>
Sat, 22 Feb 2025 17:45:50 +0000 (09:45 -0800)
* Feature

* Update

* Update

* Update

* Update Resources/Locale/en-US/administration/bwoink.ftl

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
* Yes

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Content.Client/Administration/Systems/BwoinkSystem.cs
Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs
Content.Server/Administration/Systems/BwoinkSystem.cs
Content.Shared/Administration/SharedBwoinkSystem.cs
Resources/Locale/en-US/administration/bwoink.ftl

index 5166dc8416babe485d6ef8fee4b674500867177f..7adf0069b21828166b46b106f8dbc6785b21d04b 100644 (file)
@@ -19,11 +19,11 @@ namespace Content.Client.Administration.Systems
             OnBwoinkTextMessageRecieved?.Invoke(this, message);
         }
 
-        public void Send(NetUserId channelId, string text, bool playSound)
+        public void Send(NetUserId channelId, string text, bool playSound, bool adminOnly)
         {
             // Reuse the channel ID as the 'true sender'.
             // Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
-            RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound));
+            RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound, adminOnly: adminOnly));
             SendInputTextUpdated(channelId, false);
         }
 
index 39ea50edbef02f818b1035dfdb2aef473952c868..42d6f4b3543fea79f661a06b4754b9828d3de52d 100644 (file)
@@ -7,7 +7,9 @@
             <BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2">
                 <BoxContainer Access="Public" Name="BwoinkArea" VerticalExpand="True" />
                 <BoxContainer Orientation="Horizontal" HorizontalExpand="True">
-                    <CheckBox Visible="True" Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
+                    <CheckBox Name="AdminOnly" Access="Public" Text="{Loc 'admin-ahelp-admin-only'}" ToolTip="{Loc 'admin-ahelp-admin-only-tooltip'}" />
+                    <Control HorizontalExpand="True" MinWidth="5" />
+                    <CheckBox Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
                     <Control HorizontalExpand="True" MinWidth="5" />
                     <Button Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}" StyleClasses="OpenBoth" HorizontalAlignment="Left" />
                     <Control HorizontalExpand="True" />
index b4e9a07ef88b7a5968b625315f50f3ec2eb8918d..3e05018c1085dda047a56c98256e8b3672b7f825 100644 (file)
@@ -45,6 +45,8 @@ namespace Content.Client.Administration.UI.Bwoink
             _adminManager.AdminStatusUpdated += UpdateButtons;
             UpdateButtons();
 
+            AdminOnly.OnToggled += args => PlaySound.Disabled = args.Pressed;
+
             ChannelSelector.OnSelectionChanged += sel =>
             {
                 _currentPlayer = sel;
index 445bcc8601a7b372f8d359e810a46c89da02f581..ebfec382757ab6707e0b98af8950992e457893ac 100644 (file)
@@ -175,7 +175,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
         UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId);
         UIHelper.DiscordRelayChanged(_discordRelayActive);
 
-        UIHelper.SendMessageAction = (userId, textMessage, playSound) => _bwoinkSystem?.Send(userId, textMessage, playSound);
+        UIHelper.SendMessageAction = (userId, textMessage, playSound, adminOnly) => _bwoinkSystem?.Send(userId, textMessage, playSound, adminOnly);
         UIHelper.InputTextChanged += (channel, text) => _bwoinkSystem?.SendInputTextUpdated(channel, text.Length > 0);
         UIHelper.OnClose += () => { SetAHelpPressed(false); };
         UIHelper.OnOpen +=  () => { SetAHelpPressed(true); };
@@ -324,7 +324,7 @@ public interface IAHelpUIHandler : IDisposable
     public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args);
     public event Action OnClose;
     public event Action OnOpen;
-    public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
+    public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
     public event Action<NetUserId, string>? InputTextChanged;
 }
 public sealed class AdminAHelpUIHandler : IAHelpUIHandler
@@ -408,7 +408,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
 
     public event Action? OnClose;
     public event Action? OnOpen;
-    public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
+    public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
     public event Action<NetUserId, string>? InputTextChanged;
 
     public void Open(NetUserId channelId, bool relayActive)
@@ -462,7 +462,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
         if (_activePanelMap.TryGetValue(channelId, out var existingPanel))
             return existingPanel;
 
-        _activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true));
+        _activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true, Window?.Bwoink.AdminOnly.Pressed ?? false));
         existingPanel.InputTextChanged += text => InputTextChanged?.Invoke(channelId, text);
         existingPanel.Visible = false;
         if (!Control!.BwoinkArea.Children.Contains(existingPanel))
@@ -548,7 +548,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
 
     public event Action? OnClose;
     public event Action? OnOpen;
-    public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
+    public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
     public event Action<NetUserId, string>? InputTextChanged;
 
     public void Open(NetUserId channelId, bool relayActive)
@@ -561,7 +561,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
     {
         if (_window is { Disposed: false })
             return;
-        _chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true));
+        _chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true, false));
         _chatPanel.InputTextChanged += text => InputTextChanged?.Invoke(_ownerId, text);
         _chatPanel.RelayedToDiscordLabel.Visible = relayActive;
         _window = new DefaultWindow()
index 4358b7e3876f3cde9df21069fa4a4c7df7a6bba3..b3039e92fff29acccf98e159ade0d03cc54c17e8 100644 (file)
@@ -640,7 +640,7 @@ namespace Content.Server.Administration.Systems
             var personalChannel = senderSession.UserId == message.UserId;
             var senderAdmin = _adminManager.GetAdminData(senderSession);
             var senderAHelpAdmin = senderAdmin?.HasFlag(AdminFlags.Adminhelp) ?? false;
-            var authorized = personalChannel || senderAHelpAdmin;
+            var authorized = personalChannel && !message.AdminOnly || senderAHelpAdmin;
             if (!authorized)
             {
                 // Unauthorized bwoink (log?)
@@ -676,11 +676,11 @@ namespace Content.Server.Administration.Systems
                 bwoinkText = $"{senderSession.Name}";
             }
 
-            bwoinkText = $"{(message.PlaySound ? "" : "(S) ")}{bwoinkText}: {escapedText}";
+            bwoinkText = $"{(message.AdminOnly ? Loc.GetString("bwoink-message-admin-only") : !message.PlaySound ? Loc.GetString("bwoink-message-silent") : "")} {bwoinkText}: {escapedText}";
 
-            // If it's not an admin / admin chooses to keep the sound then play it.
-            var playSound = !senderAHelpAdmin || message.PlaySound;
-            var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText, playSound: playSound);
+            // If it's not an admin / admin chooses to keep the sound and message is not an admin only message, then play it.
+            var playSound = (!senderAHelpAdmin || message.PlaySound) && !message.AdminOnly;
+            var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText, playSound: playSound, adminOnly: message.AdminOnly);
 
             LogBwoink(msg);
 
@@ -700,7 +700,7 @@ namespace Content.Server.Administration.Systems
             }
 
             // Notify player
-            if (_playerManager.TryGetSessionById(message.UserId, out var session))
+            if (_playerManager.TryGetSessionById(message.UserId, out var session) && !message.AdminOnly)
             {
                 if (!admins.Contains(session.Channel))
                 {
index e74375300e1d80a8e488764791c4e2df6765f059..26dc70021368acaa689030a7800e2f5262b7d6ce 100644 (file)
@@ -40,13 +40,16 @@ namespace Content.Shared.Administration
 
             public bool PlaySound { get; }
 
-            public BwoinkTextMessage(NetUserId userId, NetUserId trueSender, string text, DateTime? sentAt = default, bool playSound = true)
+            public readonly bool AdminOnly;
+
+            public BwoinkTextMessage(NetUserId userId, NetUserId trueSender, string text, DateTime? sentAt = default, bool playSound = true, bool adminOnly = false)
             {
                 SentAt = sentAt ?? DateTime.Now;
                 UserId = userId;
                 TrueSender = trueSender;
                 Text = text;
                 PlaySound = playSound;
+                AdminOnly = adminOnly;
             }
         }
     }
index 5e26f95735f2835fe91d99f10eda42fc60ab8cc8..9c305569e194fce957d681c34b2feb2987e33034 100644 (file)
@@ -17,6 +17,10 @@ bwoink-system-typing-indicator = {$players} {$count ->
 *[other] are
 } typing...
 
+admin-ahelp-admin-only = Admin Only
+admin-ahelp-admin-only-tooltip = If checked, then the message won't be visible for the player,
+    but will be visible for other admins and still will be Discord relayed.
+
 admin-bwoink-play-sound = Bwoink?
 
 bwoink-title-none-selected = None selected
@@ -25,3 +29,6 @@ bwoink-system-rate-limited = System: you are sending messages too quickly.
 bwoink-system-player-disconnecting = has disconnected.
 bwoink-system-player-reconnecting = has reconnected.
 bwoink-system-player-banned = has been banned for: {$banReason}
+
+bwoink-message-admin-only = (Admin Only)
+bwoink-message-silent = (S)