Fix mailing unit UI (#30174)

This commit is contained in:
themias
2024-07-19 22:31:26 -04:00
committed by GitHub
parent 3c7d14ad50
commit 5dfca4c2dc
2 changed files with 10 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ using Content.Shared.Disposal;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
namespace Content.Client.Disposal.UI namespace Content.Client.Disposal.UI
{ {
@@ -11,6 +12,8 @@ namespace Content.Client.Disposal.UI
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class MailingUnitWindow : DefaultWindow public sealed partial class MailingUnitWindow : DefaultWindow
{ {
public TimeSpan FullPressure;
public MailingUnitWindow() public MailingUnitWindow()
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
@@ -26,6 +29,7 @@ namespace Content.Client.Disposal.UI
Title = Loc.GetString("ui-mailing-unit-window-title", ("tag", state.Tag ?? " ")); Title = Loc.GetString("ui-mailing-unit-window-title", ("tag", state.Tag ?? " "));
UnitState.Text = disposalState.UnitState; UnitState.Text = disposalState.UnitState;
FullPressure = disposalState.FullPressureTime;
var pressureReached = PressureBar.UpdatePressure(disposalState.FullPressureTime); var pressureReached = PressureBar.UpdatePressure(disposalState.FullPressureTime);
Power.Pressed = disposalState.Powered; Power.Pressed = disposalState.Powered;
Engage.Pressed = disposalState.Engaged; Engage.Pressed = disposalState.Engaged;
@@ -42,9 +46,10 @@ namespace Content.Client.Disposal.UI
return !disposalState.Powered || pressureReached; return !disposalState.Powered || pressureReached;
} }
public bool UpdatePressure(TimeSpan stateFullPressureTime) protected override void FrameUpdate(FrameEventArgs args)
{ {
return PressureBar.UpdatePressure(stateFullPressureTime); base.FrameUpdate(args);
PressureBar.UpdatePressure(FullPressure);
} }
} }
} }

View File

@@ -9,6 +9,7 @@ using Content.Shared.Disposal;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.Disposal.Mailing; namespace Content.Server.Disposal.Mailing;
@@ -35,7 +36,7 @@ public sealed class MailingUnitSystem : EntitySystem
SubscribeLocalEvent<MailingUnitComponent, DeviceNetworkPacketEvent>(OnPacketReceived); SubscribeLocalEvent<MailingUnitComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
SubscribeLocalEvent<MailingUnitComponent, BeforeDisposalFlushEvent>(OnBeforeFlush); SubscribeLocalEvent<MailingUnitComponent, BeforeDisposalFlushEvent>(OnBeforeFlush);
SubscribeLocalEvent<MailingUnitComponent, ConfigurationSystem.ConfigurationUpdatedEvent>(OnConfigurationUpdated); SubscribeLocalEvent<MailingUnitComponent, ConfigurationSystem.ConfigurationUpdatedEvent>(OnConfigurationUpdated);
SubscribeLocalEvent<MailingUnitComponent, ActivateInWorldEvent>(HandleActivate); SubscribeLocalEvent<MailingUnitComponent, ActivateInWorldEvent>(HandleActivate, before: new[] { typeof(DisposalUnitSystem) });
SubscribeLocalEvent<MailingUnitComponent, DisposalUnitUIStateUpdatedEvent>(OnDisposalUnitUIStateChange); SubscribeLocalEvent<MailingUnitComponent, DisposalUnitUIStateUpdatedEvent>(OnDisposalUnitUIStateChange);
SubscribeLocalEvent<MailingUnitComponent, TargetSelectedMessage>(OnTargetSelected); SubscribeLocalEvent<MailingUnitComponent, TargetSelectedMessage>(OnTargetSelected);
} }
@@ -179,7 +180,7 @@ public sealed class MailingUnitSystem : EntitySystem
if (component.DisposalUnitInterfaceState == null) if (component.DisposalUnitInterfaceState == null)
return; return;
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag); var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList.ShallowClone(), component.Tag);
_userInterfaceSystem.SetUiState(uid, MailingUnitUiKey.Key, state); _userInterfaceSystem.SetUiState(uid, MailingUnitUiKey.Key, state);
} }