fix gateway destinations (#20172)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -16,12 +16,11 @@ namespace Content.Client.Gateway.UI;
|
||||
public sealed partial class GatewayWindow : FancyWindow,
|
||||
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
|
||||
{
|
||||
private readonly IEntityManager _entManager;
|
||||
private readonly IGameTiming _timing;
|
||||
|
||||
public event Action<EntityUid>? OpenPortal;
|
||||
public event Action<NetEntity>? OpenPortal;
|
||||
private List<(NetEntity, string, TimeSpan, bool)> _destinations = default!;
|
||||
private EntityUid? _current;
|
||||
private NetEntity? _current;
|
||||
private TimeSpan _nextClose;
|
||||
private TimeSpan _lastOpen;
|
||||
private List<Label> _readyLabels = default!;
|
||||
@@ -31,14 +30,13 @@ public sealed partial class GatewayWindow : FancyWindow,
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
var dependencies = IoCManager.Instance!;
|
||||
_entManager = dependencies.Resolve<IEntityManager>();
|
||||
_timing = dependencies.Resolve<IGameTiming>();
|
||||
}
|
||||
|
||||
public void UpdateState(GatewayBoundUserInterfaceState state)
|
||||
{
|
||||
_destinations = state.Destinations;
|
||||
_current = _entManager.GetEntity(state.Current);
|
||||
_current = state.Current;
|
||||
_nextClose = state.NextClose;
|
||||
_lastOpen = state.LastOpen;
|
||||
|
||||
@@ -67,7 +65,7 @@ public sealed partial class GatewayWindow : FancyWindow,
|
||||
var now = _timing.CurTime;
|
||||
foreach (var dest in _destinations)
|
||||
{
|
||||
var uid = _entManager.GetEntity(dest.Item1);
|
||||
var ent = dest.Item1;
|
||||
var name = dest.Item2;
|
||||
var nextReady = dest.Item3;
|
||||
var busy = dest.Item4;
|
||||
@@ -94,17 +92,17 @@ public sealed partial class GatewayWindow : FancyWindow,
|
||||
var openButton = new Button()
|
||||
{
|
||||
Text = Loc.GetString("gateway-window-open-portal"),
|
||||
Pressed = uid == _current,
|
||||
Pressed = ent == _current,
|
||||
ToggleMode = true,
|
||||
Disabled = _current != null || busy || now < nextReady
|
||||
};
|
||||
|
||||
openButton.OnPressed += args =>
|
||||
{
|
||||
OpenPortal?.Invoke(uid);
|
||||
OpenPortal?.Invoke(ent);
|
||||
};
|
||||
|
||||
if (uid == _entManager.GetEntity(state.Current))
|
||||
if (ent == _current)
|
||||
{
|
||||
openButton.AddStyleClass(StyleBase.ButtonCaution);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user