Store chat size (#14299)
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Content.Client.UserInterface.Systems.Chat.Widgets;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.UserInterface.Screens;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class DefaultGameScreen : UIScreen
|
||||
public sealed partial class DefaultGameScreen : InGameScreen
|
||||
{
|
||||
public DefaultGameScreen()
|
||||
{
|
||||
@@ -23,6 +25,14 @@ public sealed partial class DefaultGameScreen : UIScreen
|
||||
SetAnchorAndMarginPreset(Alerts, LayoutPreset.TopRight, margin: 10);
|
||||
|
||||
Chat.OnResized += ChatOnResized;
|
||||
Chat.OnChatResizeFinish += ChatOnResizeFinish;
|
||||
}
|
||||
|
||||
private void ChatOnResizeFinish(Vector2 _)
|
||||
{
|
||||
var marginBottom = Chat.GetValue<float>(MarginBottomProperty);
|
||||
var marginLeft = Chat.GetValue<float>(MarginLeftProperty);
|
||||
OnChatResized?.Invoke(new Vector2(marginBottom, marginLeft));
|
||||
}
|
||||
|
||||
private void ChatOnResized()
|
||||
@@ -30,4 +40,14 @@ public sealed partial class DefaultGameScreen : UIScreen
|
||||
var marginBottom = Chat.GetValue<float>(MarginBottomProperty);
|
||||
SetMarginTop(Alerts, marginBottom);
|
||||
}
|
||||
|
||||
public override ChatBox ChatBox => Chat;
|
||||
|
||||
//TODO: There's probably a better way to do this... but this is also the easiest way.
|
||||
public override void SetChatSize(Vector2 size)
|
||||
{
|
||||
SetMarginBottom(Chat, size.X);
|
||||
SetMarginLeft(Chat, size.Y);
|
||||
SetMarginTop(Alerts, Size.X);
|
||||
}
|
||||
}
|
||||
|
||||
17
Content.Client/UserInterface/Screens/InGameScreen.cs
Normal file
17
Content.Client/UserInterface/Screens/InGameScreen.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Content.Client.UserInterface.Systems.Chat.Widgets;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.UserInterface.Screens;
|
||||
|
||||
/// <summary>
|
||||
/// Screens that are considered to be 'in-game'.
|
||||
/// </summary>
|
||||
public abstract class InGameScreen : UIScreen
|
||||
{
|
||||
public Action<Vector2>? OnChatResized;
|
||||
|
||||
public abstract ChatBox ChatBox { get; }
|
||||
|
||||
public abstract void SetChatSize(Vector2 size);
|
||||
}
|
||||
@@ -13,10 +13,7 @@
|
||||
VerticalExpand="False"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Center">
|
||||
<SplitContainer Name="ScreenContainer"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True"
|
||||
SplitWidth="0">
|
||||
<controls:RecordedSplitContainer Name="ScreenContainer" HorizontalExpand="True" VerticalExpand="True" SplitWidth="0">
|
||||
<LayoutContainer Name="ViewportContainer" HorizontalExpand="True" VerticalExpand="True">
|
||||
<controls:MainViewport Name="MainViewport"/>
|
||||
<widgets:GhostGui Name="Ghost" Access="Protected" />
|
||||
@@ -24,15 +21,15 @@
|
||||
<actions:ActionsBar Name="Actions" Access="Protected" />
|
||||
<alerts:AlertsUI Name="Alerts" Access="Protected" />
|
||||
</LayoutContainer>
|
||||
<PanelContainer HorizontalExpand="True">
|
||||
<PanelContainer HorizontalExpand="True" MinWidth="300">
|
||||
<PanelContainer.PanelOverride>
|
||||
<graphics:StyleBoxFlat BackgroundColor="#2B2C3B" />
|
||||
</PanelContainer.PanelOverride>
|
||||
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" MinWidth="300" SeparationOverride="10" Margin="10">
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SeparationOverride="10" Margin="10">
|
||||
<menuBar:GameTopMenuBar Name="TopBar" HorizontalExpand="True" Access="Protected" />
|
||||
<chat:ChatBox VerticalExpand="True" HorizontalExpand="True" Name="Chat" Access="Protected" />
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</SplitContainer>
|
||||
</controls:RecordedSplitContainer>
|
||||
</screens:SeparatedChatGameScreen>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Content.Client.UserInterface.Systems.Chat.Widgets;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.UserInterface.Screens;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class SeparatedChatGameScreen : UIScreen
|
||||
public sealed partial class SeparatedChatGameScreen : InGameScreen
|
||||
{
|
||||
public SeparatedChatGameScreen()
|
||||
{
|
||||
@@ -20,5 +22,16 @@ public sealed partial class SeparatedChatGameScreen : UIScreen
|
||||
SetAnchorAndMarginPreset(Ghost, LayoutPreset.BottomWide, margin: 80);
|
||||
SetAnchorAndMarginPreset(Hotbar, LayoutPreset.BottomWide, margin: 5);
|
||||
SetAnchorAndMarginPreset(Alerts, LayoutPreset.CenterRight, margin: 10);
|
||||
|
||||
ScreenContainer.OnSplitResizeFinish += (first, second) =>
|
||||
OnChatResized?.Invoke(new Vector2(ScreenContainer.SplitFraction, 0));
|
||||
}
|
||||
|
||||
public override ChatBox ChatBox => GetWidget<ChatBox>()!;
|
||||
|
||||
public override void SetChatSize(Vector2 size)
|
||||
{
|
||||
ScreenContainer.DesiredSplitCenter = size.X;
|
||||
ScreenContainer.ResizeMode = SplitContainer.SplitResizeMode.RespectChildrenMinSize;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user