Fix action callbacks when switching ui layout (#13366)

Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
This commit is contained in:
eoineoineoin
2023-01-20 15:21:42 +00:00
committed by GitHub
parent 19bfa80a3f
commit a4c0ba502f

View File

@@ -1,4 +1,4 @@
using Content.Client.Alerts;
using Content.Client.Alerts;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Systems.Alerts.Widgets;
using Content.Shared.Alert;
@@ -26,7 +26,17 @@ public sealed class AlertsUIController : UIController, IOnStateEntered<GameplayS
private void SystemOnSyncAlerts(object? sender, IReadOnlyDictionary<AlertKey, AlertState> e)
{
if (sender is ClientAlertsSystem system)
{
UI?.SyncControls(system, system.AlertOrder, e);
}
// The UI can change underneath us if the user switches between HUD layouts
// So ensure we're subscribed to the AlertPressed callback.
if (UI != null)
{
UI.AlertPressed -= OnAlertPressed; // Ensure we don't hook into the callback twice
UI.AlertPressed += OnAlertPressed;
}
}
public void OnSystemLoaded(ClientAlertsSystem system)