From 70ee7e4afdea9a442e4f197577f2de82f1a46af4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 2 Aug 2018 07:59:48 +0900 Subject: [PATCH] Scroll chat to end of buffer when posting a new message --- osu.Game/Overlays/Chat/DrawableChannel.cs | 6 +++--- osu.Game/Overlays/ChatOverlay.cs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index bcc8879902..acc145af68 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Chat protected override void LoadComplete() { base.LoadComplete(); - scrollToEnd(); + ScrollToEnd(); } protected override void Dispose(bool isDisposing) @@ -86,7 +86,7 @@ namespace osu.Game.Overlays.Chat if (!IsLoaded) return; if (scroll.IsScrolledToEnd(10) || !flow.Children.Any()) - scrollToEnd(); + ScrollToEnd(); var staleMessages = flow.Children.Where(c => c.LifetimeEnd == double.MaxValue).ToArray(); int count = staleMessages.Length - Channel.MAX_HISTORY; @@ -118,7 +118,7 @@ namespace osu.Game.Overlays.Chat flow.Children.FirstOrDefault(c => c.Message == removed)?.FadeColour(Color4.Red, 400).FadeOut(600).Expire(); } - private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd()); + public void ScrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd()); private class ChatLineContainer : FillFlowContainer { diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 8e20d76914..f86c5204bb 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -475,6 +475,8 @@ namespace osu.Game.Overlays if (target == null) return; + currentChannelContainer.Child.ScrollToEnd(); + if (!api.IsLoggedIn) { target.AddNewMessages(new ErrorMessage("Please sign in to participate in chat!"));