2021-11-10 20:38:18 +01:00
|
|
|
|
using Content.Shared.Administration;
|
|
|
|
|
|
using JetBrains.Annotations;
|
2021-02-17 09:39:31 -03:00
|
|
|
|
using Robust.Client.AutoGenerated;
|
|
|
|
|
|
using Robust.Client.Console;
|
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
2023-09-28 15:46:06 -07:00
|
|
|
|
using Robust.Client.UserInterface.XAML;
|
2021-02-17 09:39:31 -03:00
|
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Administration.UI.Tabs.AdminTab
|
2021-02-17 09:39:31 -03:00
|
|
|
|
{
|
|
|
|
|
|
[GenerateTypedNameReferences]
|
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed partial class PlayerActionsWindow : DefaultWindow
|
2021-02-17 09:39:31 -03:00
|
|
|
|
{
|
2021-11-10 20:38:18 +01:00
|
|
|
|
private PlayerInfo? _selectedPlayer;
|
2023-09-28 15:46:06 -07:00
|
|
|
|
private readonly Dictionary<Button, ConfirmationData> _confirmations = new();
|
2021-02-17 09:39:31 -03:00
|
|
|
|
|
2023-09-28 15:46:06 -07:00
|
|
|
|
public PlayerActionsWindow()
|
2021-02-17 09:39:31 -03:00
|
|
|
|
{
|
2023-09-28 15:46:06 -07:00
|
|
|
|
RobustXamlLoader.Load(this);
|
|
|
|
|
|
|
2021-10-07 16:48:47 -05:00
|
|
|
|
SubmitKickButton.OnPressed += SubmitKickButtonOnPressed;
|
|
|
|
|
|
SubmitAHelpButton.OnPressed += SubmitAhelpButtonOnPressed;
|
|
|
|
|
|
SubmitRespawnButton.OnPressed += SubmitRespawnButtonOnPressed;
|
2021-02-19 15:26:34 -03:00
|
|
|
|
PlayerList.OnSelectionChanged += OnListOnOnSelectionChanged;
|
2021-02-17 09:39:31 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-10 20:38:18 +01:00
|
|
|
|
private void OnListOnOnSelectionChanged(PlayerInfo? obj)
|
2021-02-17 09:39:31 -03:00
|
|
|
|
{
|
2023-09-28 15:46:06 -07:00
|
|
|
|
if (_selectedPlayer != obj)
|
|
|
|
|
|
AdminUIHelpers.RemoveAllConfirms(_confirmations);
|
|
|
|
|
|
|
2021-11-10 20:38:18 +01:00
|
|
|
|
_selectedPlayer = obj;
|
|
|
|
|
|
var disableButtons = _selectedPlayer == null;
|
2021-10-07 16:48:47 -05:00
|
|
|
|
SubmitKickButton.Disabled = disableButtons;
|
|
|
|
|
|
SubmitAHelpButton.Disabled = disableButtons;
|
|
|
|
|
|
SubmitRespawnButton.Disabled = disableButtons;
|
2021-02-17 09:39:31 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-10-07 16:48:47 -05:00
|
|
|
|
private void SubmitKickButtonOnPressed(BaseButton.ButtonEventArgs obj)
|
2021-02-17 09:39:31 -03:00
|
|
|
|
{
|
2021-11-10 20:38:18 +01:00
|
|
|
|
if (_selectedPlayer == null)
|
2021-02-17 09:39:31 -03:00
|
|
|
|
return;
|
2023-09-28 15:46:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (!AdminUIHelpers.TryConfirm(SubmitKickButton, _confirmations))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2021-02-17 09:39:31 -03:00
|
|
|
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
2021-11-10 20:38:18 +01:00
|
|
|
|
$"kick \"{_selectedPlayer.Username}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
2021-02-17 09:39:31 -03:00
|
|
|
|
}
|
2021-10-06 16:25:27 +01:00
|
|
|
|
|
2021-10-07 16:48:47 -05:00
|
|
|
|
private void SubmitAhelpButtonOnPressed(BaseButton.ButtonEventArgs obj)
|
2021-10-06 16:25:27 +01:00
|
|
|
|
{
|
2021-11-10 20:38:18 +01:00
|
|
|
|
if (_selectedPlayer == null)
|
2021-10-06 16:25:27 +01:00
|
|
|
|
return;
|
2021-11-10 20:38:18 +01:00
|
|
|
|
|
2021-10-06 16:25:27 +01:00
|
|
|
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
2021-11-10 20:38:18 +01:00
|
|
|
|
$"openahelp \"{_selectedPlayer.SessionId}\"");
|
2021-10-06 16:25:27 +01:00
|
|
|
|
}
|
2021-10-07 16:48:47 -05:00
|
|
|
|
|
|
|
|
|
|
private void SubmitRespawnButtonOnPressed(BaseButton.ButtonEventArgs obj)
|
|
|
|
|
|
{
|
2021-11-10 20:38:18 +01:00
|
|
|
|
if (_selectedPlayer == null)
|
2021-10-07 16:48:47 -05:00
|
|
|
|
return;
|
2023-09-28 15:46:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (!AdminUIHelpers.TryConfirm(SubmitRespawnButton, _confirmations))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2021-10-07 16:48:47 -05:00
|
|
|
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
2021-11-10 20:38:18 +01:00
|
|
|
|
$"respawn \"{_selectedPlayer.Username}\"");
|
2021-10-07 16:48:47 -05:00
|
|
|
|
}
|
2021-02-17 09:39:31 -03:00
|
|
|
|
}
|
|
|
|
|
|
}
|