diff --git a/Content.Client/Disposal/Systems/DisposalUnitSystem.cs b/Content.Client/Disposal/Systems/DisposalUnitSystem.cs index 6c649888c1..cc866db8d9 100644 --- a/Content.Client/Disposal/Systems/DisposalUnitSystem.cs +++ b/Content.Client/Disposal/Systems/DisposalUnitSystem.cs @@ -47,9 +47,9 @@ namespace Content.Client.Disposal.Systems foreach (var inter in userInterface.Interfaces) { - if (inter is DisposalUnitBoundUserInterface disposals) + if (inter is DisposalUnitBoundUserInterface boundInterface) { - return disposals.Window?.UpdateState(state) != false; + return boundInterface.UpdateWindowState(state) != false; } } diff --git a/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs b/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs index dd4965210b..d9a31c534f 100644 --- a/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs +++ b/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs @@ -1,7 +1,10 @@ using Content.Client.Disposal.Components; using Content.Client.Disposal.Systems; +using Content.Shared.Disposal; using JetBrains.Annotations; using Robust.Client.GameObjects; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.CustomControls; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using static Content.Shared.Disposal.Components.SharedDisposalUnitComponent; @@ -9,12 +12,13 @@ using static Content.Shared.Disposal.Components.SharedDisposalUnitComponent; namespace Content.Client.Disposal.UI { /// - /// Initializes a and updates it when new server messages are received. + /// Initializes a or a and updates it when new server messages are received. /// [UsedImplicitly] public sealed class DisposalUnitBoundUserInterface : BoundUserInterface { - public DisposalUnitWindow? Window; + public MailingUnitWindow? MailingUnitWindow; + public DisposalUnitWindow? DisposalUnitWindow; public DisposalUnitBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { @@ -27,35 +31,66 @@ namespace Content.Client.Disposal.UI // the pressure lerp up. } + private void TargetSelected(ItemList.ItemListSelectedEventArgs args) + { + var item = args.ItemList[args.ItemIndex]; + SendMessage(new TargetSelectedMessage(item.Text)); + } + protected override void Open() { base.Open(); - Window = new DisposalUnitWindow(); + if (UiKey is MailingUnitUiKey) + { + MailingUnitWindow = new MailingUnitWindow(); - Window.OpenCentered(); - Window.OnClose += Close; + MailingUnitWindow.OpenCenteredRight(); + MailingUnitWindow.OnClose += Close; - Window.Eject.OnPressed += _ => ButtonPressed(UiButton.Eject); - Window.Engage.OnPressed += _ => ButtonPressed(UiButton.Engage); - Window.Power.OnPressed += _ => ButtonPressed(UiButton.Power); + MailingUnitWindow.Eject.OnPressed += _ => ButtonPressed(UiButton.Eject); + MailingUnitWindow.Engage.OnPressed += _ => ButtonPressed(UiButton.Engage); + MailingUnitWindow.Power.OnPressed += _ => ButtonPressed(UiButton.Power); + + MailingUnitWindow.TargetListContainer.OnItemSelected += TargetSelected; + } + else if(UiKey is DisposalUnitUiKey) + { + DisposalUnitWindow = new DisposalUnitWindow(); + + DisposalUnitWindow.OpenCenteredRight(); + DisposalUnitWindow.OnClose += Close; + + DisposalUnitWindow.Eject.OnPressed += _ => ButtonPressed(UiButton.Eject); + DisposalUnitWindow.Engage.OnPressed += _ => ButtonPressed(UiButton.Engage); + DisposalUnitWindow.Power.OnPressed += _ => ButtonPressed(UiButton.Power); + } } protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); - if (state is not DisposalUnitBoundUserInterfaceState cast) + if (state is not MailingUnitBoundUserInterfaceState && state is not DisposalUnitBoundUserInterfaceState) { return; } - Window?.UpdateState(cast); - - // Kinda icky but we just want client to handle its own lerping and not flood bandwidth for it. if (!IoCManager.Resolve().TryGetComponent(Owner.Owner, out DisposalUnitComponent? component)) return; - component.UiState = cast; + switch (state) + { + case MailingUnitBoundUserInterfaceState mailingUnitState: + MailingUnitWindow?.UpdateState(mailingUnitState); + component.UiState = mailingUnitState.DisposalState; + break; + + case DisposalUnitBoundUserInterfaceState disposalUnitState: + DisposalUnitWindow?.UpdateState(disposalUnitState); + component.UiState = disposalUnitState; + break; + } + EntitySystem.Get().UpdateActive(component, true); } @@ -63,10 +98,17 @@ namespace Content.Client.Disposal.UI { base.Dispose(disposing); - if (disposing) - { - Window?.Dispose(); - } + if (!disposing) return; + + MailingUnitWindow?.Dispose(); + DisposalUnitWindow?.Dispose(); + } + + public bool? UpdateWindowState(DisposalUnitBoundUserInterfaceState state) + { + return UiKey is DisposalUnitUiKey + ? DisposalUnitWindow?.UpdateState(state) + : MailingUnitWindow?.UpdatePressure(state.FullPressureTime); } } } diff --git a/Content.Client/Disposal/UI/DisposalUnitWindow.xaml b/Content.Client/Disposal/UI/DisposalUnitWindow.xaml index 56a1dc89c3..c8acef98ea 100644 --- a/Content.Client/Disposal/UI/DisposalUnitWindow.xaml +++ b/Content.Client/Disposal/UI/DisposalUnitWindow.xaml @@ -1,5 +1,6 @@  @@ -13,7 +14,7 @@