#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; namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminTab { [GenerateTypedNameReferences] [UsedImplicitly] public partial class TeleportWindow : SS14Window { private IEnumerable? _data; protected override void EnteredTree() { // Fill the Option data _data = IoCManager.Resolve().Sessions; foreach (var session in _data) { PlayerOptions.AddItem(GetDisplayName(session)); } PlayerOptions.OnItemSelected += eventArgs => PlayerOptions.SelectId(eventArgs.Id); SubmitButton.OnPressed += SubmitButtonOnOnPressed; } private static string GetDisplayName(IPlayerSession session) { return $"{session.Name} ({session.AttachedEntity?.Name})"; } private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj) { // Find the value if (_data == null) return; var dataList = _data.ToList(); var session = dataList[PlayerOptions.SelectedId]; // Execute command IoCManager.Resolve().ExecuteCommand( $"tpto \"{session.Name}\""); } } }