Add confirmation to kick and respawn in the admin player actions panel (#20542)
This commit is contained in:
@@ -4,8 +4,7 @@ using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
@@ -15,9 +14,12 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
public sealed partial class PlayerActionsWindow : DefaultWindow
|
||||
{
|
||||
private PlayerInfo? _selectedPlayer;
|
||||
private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
|
||||
|
||||
protected override void EnteredTree()
|
||||
public PlayerActionsWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
SubmitKickButton.OnPressed += SubmitKickButtonOnPressed;
|
||||
SubmitAHelpButton.OnPressed += SubmitAhelpButtonOnPressed;
|
||||
SubmitRespawnButton.OnPressed += SubmitRespawnButtonOnPressed;
|
||||
@@ -26,6 +28,9 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
|
||||
private void OnListOnOnSelectionChanged(PlayerInfo? obj)
|
||||
{
|
||||
if (_selectedPlayer != obj)
|
||||
AdminUIHelpers.RemoveAllConfirms(_confirmations);
|
||||
|
||||
_selectedPlayer = obj;
|
||||
var disableButtons = _selectedPlayer == null;
|
||||
SubmitKickButton.Disabled = disableButtons;
|
||||
@@ -37,6 +42,10 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
{
|
||||
if (_selectedPlayer == null)
|
||||
return;
|
||||
|
||||
if (!AdminUIHelpers.TryConfirm(SubmitKickButton, _confirmations))
|
||||
return;
|
||||
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"kick \"{_selectedPlayer.Username}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
||||
}
|
||||
@@ -54,6 +63,10 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
{
|
||||
if (_selectedPlayer == null)
|
||||
return;
|
||||
|
||||
if (!AdminUIHelpers.TryConfirm(SubmitRespawnButton, _confirmations))
|
||||
return;
|
||||
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"respawn \"{_selectedPlayer.Username}\"");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user