Improves kick, teleport and ban menus (#3312)
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -16,33 +13,23 @@ namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab
|
||||
[UsedImplicitly]
|
||||
public partial class BanWindow : SS14Window
|
||||
{
|
||||
private IEnumerable<IPlayerSession>? _data;
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
// Fill the Option data
|
||||
_data = IoCManager.Resolve<IPlayerManager>().Sessions;
|
||||
foreach (var session in _data)
|
||||
{
|
||||
PlayerOptions.AddItem(GetDisplayName(session));
|
||||
}
|
||||
PlayerOptions.OnItemSelected += eventArgs => PlayerOptions.SelectId(eventArgs.Id);
|
||||
PlayerNameLine.OnTextChanged += PlayerNameLineOnOnTextChanged;
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
}
|
||||
|
||||
private static string GetDisplayName(IPlayerSession session)
|
||||
private void PlayerNameLineOnOnTextChanged(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
return $"{session.Name} ({session.AttachedEntity?.Name})";
|
||||
SubmitButton.Disabled = string.IsNullOrEmpty(PlayerNameLine.Text);
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
var dataList = _data.ToList();
|
||||
var session = dataList[PlayerOptions.SelectedId];
|
||||
// Small verification if Player Name exists
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"ban \"{session.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\" {MinutesLine.Text}");
|
||||
$"ban \"{PlayerNameLine.Text}\" \"{CommandParsing.Escape(ReasonLine.Text)}\" {MinutesLine.Text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user