diff --git a/Robust.Client/UserInterface/Controls/OutputPanel.cs b/Robust.Client/UserInterface/Controls/OutputPanel.cs index 9800ad7ff7..d68cd9a368 100644 --- a/Robust.Client/UserInterface/Controls/OutputPanel.cs +++ b/Robust.Client/UserInterface/Controls/OutputPanel.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.Contracts; using System.Numerics; using Robust.Client.Graphics; using Robust.Client.UserInterface.RichText; @@ -154,6 +155,7 @@ namespace Robust.Client.UserInterface.Controls public void SetMessage(Index index, FormattedMessage message, Type[]? tagsAllowed = null, Color? defaultColor = null) { + var atBottom = !_scrollDownButton.Visible; var oldEntry = _entries[index]; var font = _getFont(); _totalContentHeight -= oldEntry.Height + font.GetLineSeparation(UIScale); @@ -164,6 +166,10 @@ namespace Robust.Client.UserInterface.Controls _entries[index] = entry; AddNewItemHeight(font, in entry); + + _scrollBar.MaxValue = Math.Max(_scrollBar.Page, _totalContentHeight); + if (atBottom) + _scrollBar.Value = _scrollBar.MaxValue; } private void AddNewItemHeight(Font font, in RichTextEntry entry) @@ -278,7 +284,7 @@ namespace Robust.Client.UserInterface.Controls } } - [System.Diagnostics.Contracts.Pure] + [Pure] private Font _getFont() { if (TryGetStyleProperty("font", out var font)) @@ -289,7 +295,7 @@ namespace Robust.Client.UserInterface.Controls return UserInterfaceManager.ThemeDefaults.DefaultFont; } - [System.Diagnostics.Contracts.Pure] + [Pure] private StyleBox? _getStyleBox() { if (StyleBoxOverride != null) @@ -301,14 +307,14 @@ namespace Robust.Client.UserInterface.Controls return box; } - [System.Diagnostics.Contracts.Pure] + [Pure] private float _getScrollSpeed() { // The scroll speed depends on the UI scale because the scroll bar is working with physical pixels. return GetScrollSpeed(_getFont(), UIScale); } - [System.Diagnostics.Contracts.Pure] + [Pure] private UIBox2 _getContentBox() { var style = _getStyleBox();