using Content.Shared.Access; using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; using Content.Shared.CrewManifest; using Content.Shared.Roles; using Robust.Shared.Prototypes; using static Content.Shared.Access.Components.IdCardConsoleComponent; namespace Content.Client.Access.UI { public sealed partial class IdCardConsoleBoundUserInterface : BoundUserInterface { [Dependency] private IPrototypeManager _prototypeManager = default!; private readonly SharedIdCardConsoleSystem _idCardConsoleSystem = default!; private IdCardConsoleWindow? _window; public IdCardConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { _idCardConsoleSystem = EntMan.System(); } protected override void Open() { base.Open(); List> accessLevels; if (EntMan.TryGetComponent(Owner, out var idCard)) { accessLevels = idCard.AccessLevels; } else { accessLevels = new List>(); _idCardConsoleSystem.Log.Error($"No IdCardConsole component found for {EntMan.ToPrettyString(Owner)}!"); } _window = new IdCardConsoleWindow(this, _prototypeManager, accessLevels) { Title = EntMan.GetComponent(Owner).EntityName }; _window.CrewManifestButton.OnPressed += _ => SendMessage(new CrewManifestOpenUiMessage()); _window.PrivilegedIdButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(PrivilegedIdCardSlotId)); _window.TargetIdButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(TargetIdCardSlotId)); _window.OnClose += Close; _window.OpenCentered(); } protected override void Dispose(bool disposing) { base.Dispose(disposing); if (!disposing) return; _window?.Dispose(); } protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); var castState = (IdCardConsoleBoundUserInterfaceState) state; _window?.UpdateState(castState); } public void SubmitData(string newFullName, string newJobTitle, List> newAccessList, ProtoId? newJobPrototype) { SendMessage(new WriteToTargetIdMessage( newFullName, newJobTitle, newAccessList, newJobPrototype)); } } }