diff --git a/Resources/Locale/en-US/custom-controls.ftl b/Resources/Locale/en-US/custom-controls.ftl index abf04e79d6..4384dbd732 100644 --- a/Resources/Locale/en-US/custom-controls.ftl +++ b/Resources/Locale/en-US/custom-controls.ftl @@ -14,6 +14,10 @@ tile-spawn-window-title = Place Tiles console-line-edit-placeholder = Command Here +## OutputPanel + +output-panel-scroll-down-button-text = Scroll Down + ## Common Used window-erase-button-text = Erase Mode diff --git a/Robust.Client/UserInterface/Controls/OutputPanel.cs b/Robust.Client/UserInterface/Controls/OutputPanel.cs index 7149783854..a9cf67f6b6 100644 --- a/Robust.Client/UserInterface/Controls/OutputPanel.cs +++ b/Robust.Client/UserInterface/Controls/OutputPanel.cs @@ -4,6 +4,7 @@ using Robust.Client.Graphics; using Robust.Client.UserInterface.RichText; using Robust.Shared.Collections; using Robust.Shared.IoC; +using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Utility; @@ -15,10 +16,23 @@ namespace Robust.Client.UserInterface.Controls [Virtual] public class OutputPanel : Control { + public const string StyleClassOutputPanelScrollDownButton = "outputPanelScrollDownButton"; + [Dependency] private readonly MarkupTagManager _tagManager = default!; public const string StylePropertyStyleBox = "stylebox"; + public bool ShowScrollDownButton + { + get => _showScrollDownButton; + set + { + _showScrollDownButton = value; + _updateScrollButtonVisibility(); + } + } + private bool _showScrollDownButton; + private readonly RingBufferList _entries = new(); private bool _isAtBottom = true; @@ -26,6 +40,7 @@ namespace Robust.Client.UserInterface.Controls private bool _firstLine = true; private StyleBox? _styleBoxOverride; private VScrollBar _scrollBar; + private Button _scrollDownButton; public bool ScrollFollowing { get; set; } = true; @@ -43,7 +58,25 @@ namespace Robust.Client.UserInterface.Controls HorizontalAlignment = HAlignment.Right }; AddChild(_scrollBar); - _scrollBar.OnValueChanged += _ => _isAtBottom = _scrollBar.IsAtEnd; + + AddChild(_scrollDownButton = new Button() + { + Name = "scrollLiveBtn", + StyleClasses = { StyleClassOutputPanelScrollDownButton }, + VerticalAlignment = VAlignment.Bottom, + HorizontalAlignment = HAlignment.Center, + Text = String.Format("⬇ {0} ⬇", Loc.GetString("output-panel-scroll-down-button-text")), + MaxWidth = 300, + Visible = false, + }); + + _scrollDownButton.OnPressed += _ => ScrollToBottom(); + + _scrollBar.OnValueChanged += _ => + { + _isAtBottom = _scrollBar.IsAtEnd; + _updateScrollButtonVisibility(); + }; } public int EntryCount => _entries.Count; @@ -184,6 +217,7 @@ namespace Robust.Client.UserInterface.Controls var styleBoxSize = _getStyleBox()?.MinimumSize.Y ?? 0; _scrollBar.Page = UIScale * (Height - styleBoxSize); + _updateScrollButtonVisibility(); _invalidateEntries(); } @@ -284,5 +318,10 @@ namespace Robust.Client.UserInterface.Controls _invalidOnVisible = false; } } + + private void _updateScrollButtonVisibility() + { + _scrollDownButton.Visible = ShowScrollDownButton && !_isAtBottom; + } } } diff --git a/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml b/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml index 8dac92d033..8921f8b5f7 100644 --- a/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml +++ b/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml @@ -1,7 +1,7 @@ - +