Command to open chatbox in a new window (#33548)
* Command to open chatbox in a new window * Add command for users with AdminChat permission * Add command button to admin tools window
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
<cc:UICommandButton Command="callshuttle" Text="{Loc admin-player-actions-window-shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
|
<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="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}"/>
|
||||||
<cc:CommandButton Command="faxui" Text="{Loc admin-player-actions-window-admin-fax}"/>
|
<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>
|
</GridContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</Control>
|
</Control>
|
||||||
|
|||||||
@@ -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>
|
||||||
44
Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml.cs
Normal file
44
Content.Client/UserInterface/Systems/Chat/ChatWindow.xaml.cs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
@@ -40,6 +40,15 @@ public sealed partial class ChannelFilterPopup : Popup
|
|||||||
return _filterStates.TryGetValue(channel, out var checkbox) && checkbox.Pressed;
|
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()
|
public ChatChannel GetActive()
|
||||||
{
|
{
|
||||||
ChatChannel active = 0;
|
ChatChannel active = 0;
|
||||||
|
|||||||
@@ -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-logs = Admin Logs
|
||||||
admin-player-actions-window-admin-notes = Admin Notes
|
admin-player-actions-window-admin-notes = Admin Notes
|
||||||
admin-player-actions-window-admin-fax = Admin Fax
|
admin-player-actions-window-admin-fax = Admin Fax
|
||||||
|
admin-player-actions-window-admin-chat = Admin Chat
|
||||||
|
|||||||
7
Resources/Locale/en-US/chat/ui/chat-window.ftl
Normal file
7
Resources/Locale/en-US/chat/ui/chat-window.ftl
Normal file
@@ -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
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
- replay_stop
|
- replay_stop
|
||||||
- replay_load
|
- replay_load
|
||||||
- saveconfig
|
- saveconfig
|
||||||
|
- chatwindow
|
||||||
|
|
||||||
- Flags: DEBUG
|
- Flags: DEBUG
|
||||||
Commands:
|
Commands:
|
||||||
@@ -84,3 +85,7 @@
|
|||||||
- uploadfile
|
- uploadfile
|
||||||
- loadprototype
|
- loadprototype
|
||||||
- uploadfolder
|
- uploadfolder
|
||||||
|
|
||||||
|
- Flags: ADMINCHAT
|
||||||
|
Commands:
|
||||||
|
- achatwindow
|
||||||
|
|||||||
Reference in New Issue
Block a user