2021-04-20 18:39:39 -05:00
|
|
|
|
using Content.Client.Chat;
|
|
|
|
|
|
using Content.Client.Interfaces.Chat;
|
|
|
|
|
|
using Content.Client.UserInterface.Stylesheets;
|
2020-11-09 20:22:19 -08:00
|
|
|
|
using Robust.Client.UserInterface;
|
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
2021-04-20 18:39:39 -05:00
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Maths;
|
2020-11-09 20:22:19 -08:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.UserInterface
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The status effects display on the right side of the screen.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class AlertsUI : Control
|
|
|
|
|
|
{
|
2021-04-20 18:39:39 -05:00
|
|
|
|
public const float ChatSeparation = 38f;
|
2020-11-09 20:22:19 -08:00
|
|
|
|
public GridContainer Grid { get; }
|
|
|
|
|
|
|
2020-12-13 14:28:20 -08:00
|
|
|
|
public AlertsUI()
|
2020-11-09 20:22:19 -08:00
|
|
|
|
{
|
2020-12-13 14:28:20 -08:00
|
|
|
|
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);
|
2020-11-09 20:22:19 -08:00
|
|
|
|
var panelContainer = new PanelContainer
|
|
|
|
|
|
{
|
|
|
|
|
|
StyleClasses = {StyleNano.StyleClassTransparentBorderedWindowPanel},
|
2021-02-21 12:38:56 +01:00
|
|
|
|
HorizontalAlignment = HAlignment.Right,
|
|
|
|
|
|
VerticalAlignment = VAlignment.Top
|
2020-11-09 20:22:19 -08:00
|
|
|
|
};
|
|
|
|
|
|
AddChild(panelContainer);
|
|
|
|
|
|
|
|
|
|
|
|
Grid = new GridContainer
|
|
|
|
|
|
{
|
2021-02-21 12:38:56 +01:00
|
|
|
|
MaxGridHeight = 64,
|
2020-11-09 20:22:19 -08:00
|
|
|
|
ExpandBackwards = true
|
|
|
|
|
|
};
|
|
|
|
|
|
panelContainer.AddChild(Grid);
|
2021-02-21 12:38:56 +01:00
|
|
|
|
|
|
|
|
|
|
MinSize = (64, 64);
|
2020-11-09 20:22:19 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-20 18:39:39 -05:00
|
|
|
|
protected override void EnteredTree()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.EnteredTree();
|
|
|
|
|
|
var _chatManager = IoCManager.Resolve<IChatManager>();
|
|
|
|
|
|
_chatManager.OnChatBoxResized += OnChatResized;
|
|
|
|
|
|
OnChatResized(new ChatResizedEventArgs(ChatBox.InitialChatBottom));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ExitedTree()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.ExitedTree();
|
|
|
|
|
|
var _chatManager = IoCManager.Resolve<IChatManager>();
|
|
|
|
|
|
_chatManager.OnChatBoxResized -= OnChatResized;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnChatResized(ChatResizedEventArgs chatResizedEventArgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
// resize us to fit just below the chatbox
|
|
|
|
|
|
var _chatManager = IoCManager.Resolve<IChatManager>();
|
|
|
|
|
|
if (_chatManager.CurrentChatBox != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
LayoutContainer.SetMarginTop(this, chatResizedEventArgs.NewBottom + ChatSeparation);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
LayoutContainer.SetMarginTop(this, 250);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-02-21 12:38:56 +01:00
|
|
|
|
// This makes no sense but I'm leaving it in place in case I break anything by removing it.
|
|
|
|
|
|
|
2020-12-13 14:28:20 -08:00
|
|
|
|
protected override void Resized()
|
2020-11-09 20:22:19 -08:00
|
|
|
|
{
|
|
|
|
|
|
// 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
|
2020-12-13 14:28:20 -08:00
|
|
|
|
base.Resized();
|
2021-02-21 12:38:56 +01:00
|
|
|
|
Grid.MaxGridHeight = Height;
|
2020-11-09 20:22:19 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-13 14:28:20 -08:00
|
|
|
|
protected override void UIScaleChanged()
|
2020-11-09 20:22:19 -08:00
|
|
|
|
{
|
2021-02-21 12:38:56 +01:00
|
|
|
|
Grid.MaxGridHeight = Height;
|
2020-12-13 14:28:20 -08:00
|
|
|
|
base.UIScaleChanged();
|
2020-11-09 20:22:19 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|