Add admin teleport button (#2435)

Co-authored-by: zionnBE <zionn@tfwno.gf>
This commit is contained in:
zionnBE
2020-10-30 01:05:49 +01:00
committed by GitHub
parent cb0937c8b6
commit 14b0a6eae4
2 changed files with 27 additions and 1 deletions

View File

@@ -37,7 +37,7 @@ namespace Content.Client.UserInterface.AdminMenu
{
new KickCommandButton(),
new DirectCommandButton("Admin Ghost", "aghost"),
//TODO: teleport
new TeleportCommandButton(),
};
private readonly List<CommandButton> _adminbusButtons = new List<CommandButton>
{
@@ -534,6 +534,30 @@ namespace Content.Client.UserInterface.AdminMenu
}
}
private class TeleportCommandButton : UICommandButton
{
public override string Name => "Teleport";
public override string RequiredCommand => "tpto";
private readonly CommandUIDropDown _playerDropDown = new CommandUIDropDown
{
Name = "Player",
GetData = () => IoCManager.Resolve<IPlayerManager>().Sessions.ToList<object>(),
GetDisplayName = (obj) => $"{((IPlayerSession) obj).Name} ({((IPlayerSession) obj).AttachedEntity?.Name})",
GetValueFromData = (obj) => ((IPlayerSession) obj).Name,
};
public override List<CommandUIControl> UI => new List<CommandUIControl>
{
_playerDropDown
};
public override void Submit()
{
IoCManager.Resolve<IClientConsole>().ProcessCommand($"tpto \"{_playerDropDown.GetValue()}\"");
}
}
private class AddAtmosCommandButton : UICommandButton
{
public override string Name => "Add Atmos";