From a4c0ba502f21220353def6ad2523bf21f1f1620a Mon Sep 17 00:00:00 2001 From: eoineoineoin Date: Fri, 20 Jan 2023 15:21:42 +0000 Subject: [PATCH] Fix action callbacks when switching ui layout (#13366) Co-authored-by: Eoin Mcloughlin --- .../Systems/Alerts/AlertsUIController.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Content.Client/UserInterface/Systems/Alerts/AlertsUIController.cs b/Content.Client/UserInterface/Systems/Alerts/AlertsUIController.cs index 1026f8322a..53963195a1 100644 --- a/Content.Client/UserInterface/Systems/Alerts/AlertsUIController.cs +++ b/Content.Client/UserInterface/Systems/Alerts/AlertsUIController.cs @@ -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 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)