]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Command to open chatbox in a new window (#33548)
authoreoineoineoin <helloworld@eoinrul.es>
Mon, 14 Apr 2025 15:37:58 +0000 (16:37 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Apr 2025 15:37:58 +0000 (17:37 +0200)
* Command to open chatbox in a new window

* Add command for users with AdminChat permission

* Add command button to admin tools window

Content.Client/Administration/UI/Tabs/AdminTab/AdminTab.xaml
Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml [new file with mode: 0644]
Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml.cs [new file with mode: 0644]
Content.Client/UserInterface/Systems/Chat/ChatWindowCommand.cs [new file with mode: 0644]
Content.Client/UserInterface/Systems/Chat/Controls/ChannelFilterPopup.xaml.cs
Resources/Locale/en-US/administration/ui/tabs/admin-tab/player-actions-window.ftl
Resources/Locale/en-US/chat/ui/chat-window.ftl [new file with mode: 0644]
Resources/clientCommandPerms.yml

index 8b68487547f95d1703759f4db712e7deb9371ccf..0d4668d5bfd7d86a0dced59e57e230897e862cd7 100644 (file)
@@ -16,6 +16,7 @@
             <cc:UICommandButton Command="callshuttle" Text="{Loc admin-player-actions-window-shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
             <cc:CommandButton Command="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}"/>
             <cc:CommandButton Command="faxui" Text="{Loc admin-player-actions-window-admin-fax}"/>
+            <cc:CommandButton Command="achatwindow" Text="{Loc admin-player-actions-window-admin-chat}"/>
         </GridContainer>
     </BoxContainer>
 </Control>
diff --git a/Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml b/Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml
new file mode 100644 (file)
index 0000000..4977785
--- /dev/null
@@ -0,0 +1,7 @@
+<controls:FancyWindow xmlns="https://spacestation14.io"
+                      xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
+                      xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets"
+                      Title="{Loc chat-window-title}"
+                      MinSize="465 265">
+    <widgets:ChatBox Name="Chatbox"/>
+</controls:FancyWindow>
diff --git a/Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml.cs b/Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml.cs
new file mode 100644 (file)
index 0000000..abf421c
--- /dev/null
@@ -0,0 +1,44 @@
+using Content.Client.UserInterface.Controls;
+using Content.Shared.Chat;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client.UserInterface.Systems.Chat;
+
+/// <summary>
+/// Window which only holds a single chatbox, useful for monitoring multiple chats simultaneously.
+/// </summary>
+[GenerateTypedNameReferences]
+public sealed partial class ChatWindow : FancyWindow
+{
+    public ChatWindow()
+    {
+        RobustXamlLoader.Load(this);
+        IoCManager.InjectDependencies(this);
+
+        // These are necessary for the controls inside the chatbox to initialize correctly:
+        Chatbox.Repopulate();
+        var controller = UserInterfaceManager.GetUIController<ChatUIController>();
+        controller.UpdateSelectedChannel(Chatbox);
+    }
+
+    /// <summary>
+    /// Helper method to configure this window to be useful for admins.
+    /// Sets incoming filters to only admin chats and output to admin channel
+    /// </summary>
+    public void ConfigureForAdminChat()
+    {
+        Chatbox.ChatInput.ChannelSelector.Select(ChatSelectChannel.Admin);
+
+        var filter = Chatbox.ChatInput.FilterButton.Popup;
+        foreach (var c in Enum.GetValues(typeof(ChatChannel)))
+        {
+            var channel = (ChatChannel)c;
+            var isAdminInterest = channel == ChatChannel.Admin
+                                  || channel == ChatChannel.AdminChat
+                                  || channel == ChatChannel.AdminAlert
+                                  || channel == ChatChannel.AdminRelated;
+            filter.SetActive(channel, isAdminInterest);
+        }
+    }
+}
diff --git a/Content.Client/UserInterface/Systems/Chat/ChatWindowCommand.cs b/Content.Client/UserInterface/Systems/Chat/ChatWindowCommand.cs
new file mode 100644 (file)
index 0000000..8c3aea8
--- /dev/null
@@ -0,0 +1,35 @@
+using JetBrains.Annotations;
+using Robust.Shared.Console;
+
+namespace Content.Client.UserInterface.Systems.Chat;
+
+/// <summary>
+/// Command which creates a window containing a chatbox
+/// </summary>
+[UsedImplicitly]
+public sealed class ChatWindowCommand : LocalizedCommands
+{
+    public override string Command => "chatwindow";
+
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        var window = new ChatWindow();
+        window.OpenCentered();
+    }
+}
+
+/// <summary>
+/// Command which creates a window containing a chatbox configured for admin use
+/// </summary>
+[UsedImplicitly]
+public sealed class AdminChatWindowCommand : LocalizedCommands
+{
+    public override string Command => "achatwindow";
+
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        var window = new ChatWindow();
+        window.ConfigureForAdminChat();
+        window.OpenCentered();
+    }
+}
index df4f56cb27cee1baa454cb56d83b3f21019ca082..33a82db335a0b72df15b44f994252892cffa4eb0 100644 (file)
@@ -1,4 +1,4 @@
-using Content.Shared.Chat;
+using Content.Shared.Chat;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.XAML;
@@ -40,6 +40,15 @@ public sealed partial class ChannelFilterPopup : Popup
         return _filterStates.TryGetValue(channel, out var checkbox) && checkbox.Pressed;
     }
 
+    public void SetActive(ChatChannel channel, bool isActive)
+    {
+        if (_filterStates.TryGetValue(channel, out var checkbox) && checkbox.Pressed != isActive)
+        {
+            checkbox.Pressed = isActive;
+            OnChannelFilter?.Invoke(checkbox.Channel, checkbox.Pressed);
+        }
+    }
+
     public ChatChannel GetActive()
     {
         ChatChannel active = 0;
index 6af6a3ae206824f5722316d5b42ea36889f9d37a..62b253e3f5744471bca95df8fe63d3993bec2255 100644 (file)
@@ -8,3 +8,4 @@ admin-player-actions-window-shuttle = (Re)call Shuttle
 admin-player-actions-window-admin-logs = Admin Logs
 admin-player-actions-window-admin-notes = Admin Notes
 admin-player-actions-window-admin-fax = Admin Fax
+admin-player-actions-window-admin-chat = Admin Chat
diff --git a/Resources/Locale/en-US/chat/ui/chat-window.ftl b/Resources/Locale/en-US/chat/ui/chat-window.ftl
new file mode 100644 (file)
index 0000000..024bed6
--- /dev/null
@@ -0,0 +1,7 @@
+chat-window-title = Chat
+
+cmd-chatwindow-desc = Additional Chat Window
+cmd-chatwindow-help = Usage: chatwindow
+
+cmd-achatwindow-desc = Admin Chat Window
+cmd-achatwindow-help = Usage: achatwindow
index cbe654e557eb2f08d4d297ba87721061ba5568fe..9d183a3f8c5dc0ff6e287582cff7224447549ff6 100644 (file)
@@ -38,6 +38,7 @@
     - replay_stop
     - replay_load
     - saveconfig
+    - chatwindow
 
 - Flags: DEBUG
   Commands:
@@ -84,3 +85,7 @@
     - uploadfile
     - loadprototype
     - uploadfolder
+
+- Flags: ADMINCHAT
+  Commands:
+    - achatwindow