using Content.Client.Chat.Managers; using Content.Client.Chat.UI; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.IoC; namespace Content.Client.Alerts.UI { /// /// The status effects display on the right side of the screen. /// [GenerateTypedNameReferences] public sealed partial class AlertsUI : Control { [Dependency] private readonly IChatManager _chatManager = default!; public const float ChatSeparation = 38f; public GridContainer Grid => AlertContainer; public AlertsUI() { IoCManager.InjectDependencies(this); RobustXamlLoader.Load(this); LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin); LayoutContainer.SetGrowVertical(this, LayoutContainer.GrowDirection.End); LayoutContainer.SetAnchorTop(this, 0f); LayoutContainer.SetAnchorRight(this, 1f); LayoutContainer.SetAnchorBottom(this, 1f); LayoutContainer.SetMarginBottom(this, -180); LayoutContainer.SetMarginTop(this, 250); LayoutContainer.SetMarginRight(this, -10); } protected override void EnteredTree() { base.EnteredTree(); _chatManager.OnChatBoxResized += OnChatResized; OnChatResized(new ChatResizedEventArgs(HudChatBox.InitialChatBottom)); } protected override void ExitedTree() { base.ExitedTree(); _chatManager.OnChatBoxResized -= OnChatResized; } private void OnChatResized(ChatResizedEventArgs chatResizedEventArgs) { // resize us to fit just below the chatbox if (_chatManager.CurrentChatBox != null) { LayoutContainer.SetMarginTop(this, chatResizedEventArgs.NewBottom + ChatSeparation); } else { LayoutContainer.SetMarginTop(this, 250); } } // This makes no sense but I'm leaving it in place in case I break anything by removing it. protected override void Resized() { // TODO: Can rework this once https://github.com/space-wizards/RobustToolbox/issues/1392 is done, // this is here because there isn't currently a good way to allow the grid to adjust its height based // on constraints, otherwise we would use anchors to lay it out base.Resized(); AlertContainer.MaxGridHeight = Height; } protected override void UIScaleChanged() { AlertContainer.MaxGridHeight = Height; base.UIScaleChanged(); } } }