XAMLify ID card computer, Alerts and AME window (#4322)
* Refactor ID card computer to XAML UI * Alerts * XAMLify AME window * Use Control.SetButtonDisabledRecursive() instead
This commit is contained in:
10
Content.Client/Alerts/UI/AlertsUI.xaml
Normal file
10
Content.Client/Alerts/UI/AlertsUI.xaml
Normal file
@@ -0,0 +1,10 @@
|
||||
<Control xmlns="https://spacestation14.io"
|
||||
MinSize="64 64">
|
||||
<PanelContainer StyleClasses="TransparentBorderedWindowPanel"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top">
|
||||
<GridContainer Name="AlertContainer" MaxGridHeight="64" ExpandBackwards="True">
|
||||
|
||||
</GridContainer>
|
||||
</PanelContainer>
|
||||
</Control>
|
||||
@@ -1,8 +1,9 @@
|
||||
using Content.Client.Chat.Managers;
|
||||
using Content.Client.Chat.UI;
|
||||
using Content.Client.Stylesheets;
|
||||
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
|
||||
@@ -10,13 +11,20 @@ namespace Content.Client.Alerts.UI
|
||||
/// <summary>
|
||||
/// The status effects display on the right side of the screen.
|
||||
/// </summary>
|
||||
public sealed class AlertsUI : Control
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class AlertsUI : Control
|
||||
{
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
public const float ChatSeparation = 38f;
|
||||
public GridContainer Grid { get; }
|
||||
|
||||
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);
|
||||
@@ -25,28 +33,11 @@ namespace Content.Client.Alerts.UI
|
||||
LayoutContainer.SetMarginBottom(this, -180);
|
||||
LayoutContainer.SetMarginTop(this, 250);
|
||||
LayoutContainer.SetMarginRight(this, -10);
|
||||
var panelContainer = new PanelContainer
|
||||
{
|
||||
StyleClasses = {StyleNano.StyleClassTransparentBorderedWindowPanel},
|
||||
HorizontalAlignment = HAlignment.Right,
|
||||
VerticalAlignment = VAlignment.Top
|
||||
};
|
||||
AddChild(panelContainer);
|
||||
|
||||
Grid = new GridContainer
|
||||
{
|
||||
MaxGridHeight = 64,
|
||||
ExpandBackwards = true
|
||||
};
|
||||
panelContainer.AddChild(Grid);
|
||||
|
||||
MinSize = (64, 64);
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
base.EnteredTree();
|
||||
var _chatManager = IoCManager.Resolve<IChatManager>();
|
||||
_chatManager.OnChatBoxResized += OnChatResized;
|
||||
OnChatResized(new ChatResizedEventArgs(HudChatBox.InitialChatBottom));
|
||||
}
|
||||
@@ -54,15 +45,12 @@ namespace Content.Client.Alerts.UI
|
||||
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);
|
||||
@@ -81,12 +69,12 @@ namespace Content.Client.Alerts.UI
|
||||
// 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();
|
||||
Grid.MaxGridHeight = Height;
|
||||
AlertContainer.MaxGridHeight = Height;
|
||||
}
|
||||
|
||||
protected override void UIScaleChanged()
|
||||
{
|
||||
Grid.MaxGridHeight = Height;
|
||||
AlertContainer.MaxGridHeight = Height;
|
||||
base.UIScaleChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user