48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using Content.Shared.Administration;
|
|
using JetBrains.Annotations;
|
|
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.Utility;
|
|
using static Robust.Client.UserInterface.Controls.LineEdit;
|
|
|
|
namespace Content.Client.Administration.UI.Tabs.AdminTab
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
[UsedImplicitly]
|
|
public partial class BanWindow : SS14Window
|
|
{
|
|
protected override void EnteredTree()
|
|
{
|
|
PlayerNameLine.OnTextChanged += PlayerNameLineOnOnTextChanged;
|
|
PlayerList.OnSelectionChanged += OnPlayerSelectionChanged;
|
|
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
|
}
|
|
|
|
private void OnPlayerNameChanged()
|
|
{
|
|
SubmitButton.Disabled = string.IsNullOrEmpty(PlayerNameLine.Text);
|
|
}
|
|
|
|
private void PlayerNameLineOnOnTextChanged(LineEditEventArgs obj)
|
|
{
|
|
OnPlayerNameChanged();
|
|
}
|
|
|
|
private void OnPlayerSelectionChanged(PlayerInfo? player)
|
|
{
|
|
PlayerNameLine.Text = player?.Username ?? string.Empty;
|
|
OnPlayerNameChanged();
|
|
}
|
|
|
|
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
// Small verification if Player Name exists
|
|
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
|
$"ban \"{PlayerNameLine.Text}\" \"{CommandParsing.Escape(ReasonLine.Text)}\" {MinutesLine.Text}");
|
|
}
|
|
}
|
|
}
|