diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj
index cce7907c6c..3e0f0cb7f6 100644
--- a/osu.Desktop/osu.Desktop.csproj
+++ b/osu.Desktop/osu.Desktop.csproj
@@ -30,7 +30,7 @@
-
+
diff --git a/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs b/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs
index 492abdd88d..01e67b1681 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneStandAloneChatDisplay.cs
@@ -8,16 +8,16 @@ using osu.Game.Users;
using osuTK;
using System;
using System.Linq;
+using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Chat;
+using osuTK.Input;
namespace osu.Game.Tests.Visual.Online
{
- public class TestSceneStandAloneChatDisplay : OsuTestScene
+ public class TestSceneStandAloneChatDisplay : OsuManualInputManagerTestScene
{
- private readonly Channel testChannel = new Channel();
-
private readonly User admin = new User
{
Username = "HappyStick",
@@ -46,92 +46,97 @@ namespace osu.Game.Tests.Visual.Online
[Cached]
private ChannelManager channelManager = new ChannelManager();
- private readonly TestStandAloneChatDisplay chatDisplay;
- private readonly TestStandAloneChatDisplay chatDisplay2;
+ private TestStandAloneChatDisplay chatDisplay;
+ private int messageIdSequence;
+
+ private Channel testChannel;
public TestSceneStandAloneChatDisplay()
{
Add(channelManager);
-
- Add(chatDisplay = new TestStandAloneChatDisplay
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Margin = new MarginPadding(20),
- Size = new Vector2(400, 80)
- });
-
- Add(chatDisplay2 = new TestStandAloneChatDisplay(true)
- {
- Anchor = Anchor.CentreRight,
- Origin = Anchor.CentreRight,
- Margin = new MarginPadding(20),
- Size = new Vector2(400, 150)
- });
}
- protected override void LoadComplete()
+ [SetUp]
+ public void SetUp() => Schedule(() =>
{
- base.LoadComplete();
+ messageIdSequence = 0;
+ channelManager.CurrentChannel.Value = testChannel = new Channel();
- channelManager.CurrentChannel.Value = testChannel;
+ Children = new[]
+ {
+ chatDisplay = new TestStandAloneChatDisplay
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Margin = new MarginPadding(20),
+ Size = new Vector2(400, 80),
+ Channel = { Value = testChannel },
+ },
+ new TestStandAloneChatDisplay(true)
+ {
+ Anchor = Anchor.CentreRight,
+ Origin = Anchor.CentreRight,
+ Margin = new MarginPadding(20),
+ Size = new Vector2(400, 150),
+ Channel = { Value = testChannel },
+ }
+ };
+ });
- chatDisplay.Channel.Value = testChannel;
- chatDisplay2.Channel.Value = testChannel;
-
- int sequence = 0;
-
- AddStep("message from admin", () => testChannel.AddNewMessages(new Message(sequence++)
+ [Test]
+ public void TestManyMessages()
+ {
+ AddStep("message from admin", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = admin,
Content = "I am a wang!"
}));
- AddStep("message from team red", () => testChannel.AddNewMessages(new Message(sequence++)
+ AddStep("message from team red", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = redUser,
Content = "I am team red."
}));
- AddStep("message from team red", () => testChannel.AddNewMessages(new Message(sequence++)
+ AddStep("message from team red", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = redUser,
Content = "I plan to win!"
}));
- AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(sequence++)
+ AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = blueUser,
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
}));
- AddStep("message from admin", () => testChannel.AddNewMessages(new Message(sequence++)
+ AddStep("message from admin", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = admin,
Content = "Okay okay, calm down guys. Let's do this!"
}));
- AddStep("message from long username", () => testChannel.AddNewMessages(new Message(sequence++)
+ AddStep("message from long username", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = longUsernameUser,
Content = "Hi guys, my new username is lit!"
}));
- AddStep("message with new date", () => testChannel.AddNewMessages(new Message(sequence++)
+ AddStep("message with new date", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = longUsernameUser,
Content = "Message from the future!",
Timestamp = DateTimeOffset.Now
}));
- AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
+ checkScrolledToBottom();
const int messages_per_call = 10;
AddRepeatStep("add many messages", () =>
{
for (int i = 0; i < messages_per_call; i++)
{
- testChannel.AddNewMessages(new Message(sequence++)
+ testChannel.AddNewMessages(new Message(messageIdSequence++)
{
Sender = longUsernameUser,
Content = "Many messages! " + Guid.NewGuid(),
@@ -153,9 +158,133 @@ namespace osu.Game.Tests.Visual.Online
return true;
});
- AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
+ checkScrolledToBottom();
}
+ ///
+ /// Tests that when a message gets wrapped by the chat display getting contracted while scrolled to bottom, the chat will still keep scrolling down.
+ ///
+ [Test]
+ public void TestMessageWrappingKeepsAutoScrolling()
+ {
+ fillChat();
+
+ // send message with short words for text wrapping to occur when contracting chat.
+ sendMessage();
+
+ AddStep("contract chat", () => chatDisplay.Width -= 100);
+ checkScrolledToBottom();
+
+ AddStep("send another message", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
+ {
+ Sender = admin,
+ Content = "As we were saying...",
+ }));
+
+ checkScrolledToBottom();
+ }
+
+ [Test]
+ public void TestUserScrollOverride()
+ {
+ fillChat();
+
+ sendMessage();
+ checkScrolledToBottom();
+
+ AddStep("User scroll up", () =>
+ {
+ InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre);
+ InputManager.PressButton(MouseButton.Left);
+ InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre + new Vector2(0, chatDisplay.ScreenSpaceDrawQuad.Height));
+ InputManager.ReleaseButton(MouseButton.Left);
+ });
+
+ checkNotScrolledToBottom();
+ sendMessage();
+ checkNotScrolledToBottom();
+
+ AddRepeatStep("User scroll to bottom", () =>
+ {
+ InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre);
+ InputManager.PressButton(MouseButton.Left);
+ InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre - new Vector2(0, chatDisplay.ScreenSpaceDrawQuad.Height));
+ InputManager.ReleaseButton(MouseButton.Left);
+ }, 5);
+
+ checkScrolledToBottom();
+ sendMessage();
+ checkScrolledToBottom();
+ }
+
+ [Test]
+ public void TestLocalEchoMessageResetsScroll()
+ {
+ fillChat();
+
+ sendMessage();
+ checkScrolledToBottom();
+
+ AddStep("User scroll up", () =>
+ {
+ InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre);
+ InputManager.PressButton(MouseButton.Left);
+ InputManager.MoveMouseTo(chatDisplay.ScreenSpaceDrawQuad.Centre + new Vector2(0, chatDisplay.ScreenSpaceDrawQuad.Height));
+ InputManager.ReleaseButton(MouseButton.Left);
+ });
+
+ checkNotScrolledToBottom();
+ sendMessage();
+ checkNotScrolledToBottom();
+
+ sendLocalMessage();
+ checkScrolledToBottom();
+
+ sendMessage();
+ checkScrolledToBottom();
+ }
+
+ private void fillChat()
+ {
+ AddStep("fill chat", () =>
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ testChannel.AddNewMessages(new Message(messageIdSequence++)
+ {
+ Sender = longUsernameUser,
+ Content = $"some stuff {Guid.NewGuid()}",
+ });
+ }
+ });
+
+ checkScrolledToBottom();
+ }
+
+ private void sendMessage()
+ {
+ AddStep("send lorem ipsum", () => testChannel.AddNewMessages(new Message(messageIdSequence++)
+ {
+ Sender = longUsernameUser,
+ Content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce et bibendum velit.",
+ }));
+ }
+
+ private void sendLocalMessage()
+ {
+ AddStep("send local echo", () => testChannel.AddLocalEcho(new LocalEchoMessage
+ {
+ Sender = longUsernameUser,
+ Content = "This is a local echo message.",
+ }));
+ }
+
+ private void checkScrolledToBottom() =>
+ AddUntilStep("is scrolled to bottom", () => chatDisplay.ScrolledToBottom);
+
+ private void checkNotScrolledToBottom() =>
+ AddUntilStep("not scrolled to bottom", () => !chatDisplay.ScrolledToBottom);
+
private class TestStandAloneChatDisplay : StandAloneChatDisplay
{
public TestStandAloneChatDisplay(bool textbox = false)
@@ -165,7 +294,7 @@ namespace osu.Game.Tests.Visual.Online
protected DrawableChannel DrawableChannel => InternalChildren.OfType().First();
- protected OsuScrollContainer ScrollContainer => (OsuScrollContainer)((Container)DrawableChannel.Child).Child;
+ protected UserTrackingScrollContainer ScrollContainer => (UserTrackingScrollContainer)((Container)DrawableChannel.Child).Child;
public FillFlowContainer FillFlow => (FillFlowContainer)ScrollContainer.Child;
diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
index 008c862cc3..618447eae2 100644
--- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
+++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsLoungeSubScreen.cs
@@ -4,7 +4,6 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
-using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
@@ -28,12 +27,7 @@ namespace osu.Game.Tests.Visual.Playlists
{
base.SetUpSteps();
- AddStep("push screen", () => LoadScreen(loungeScreen = new PlaylistsLoungeSubScreen
- {
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
- Width = 0.5f,
- }));
+ AddStep("push screen", () => LoadScreen(loungeScreen = new PlaylistsLoungeSubScreen()));
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModIcon.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModIcon.cs
new file mode 100644
index 0000000000..e7fa7d9235
--- /dev/null
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModIcon.cs
@@ -0,0 +1,21 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Game.Rulesets.Osu.Mods;
+using osu.Game.Rulesets.UI;
+
+namespace osu.Game.Tests.Visual.UserInterface
+{
+ public class TestSceneModIcon : OsuTestScene
+ {
+ [Test]
+ public void TestChangeModType()
+ {
+ ModIcon icon = null;
+
+ AddStep("create mod icon", () => Child = icon = new ModIcon(new OsuModDoubleTime()));
+ AddStep("change mod", () => icon.Mod = new OsuModEasy());
+ }
+ }
+}
diff --git a/osu.Game/Graphics/Containers/UserTrackingScrollContainer.cs b/osu.Game/Graphics/Containers/UserTrackingScrollContainer.cs
index b8ce34b204..17506ce0f5 100644
--- a/osu.Game/Graphics/Containers/UserTrackingScrollContainer.cs
+++ b/osu.Game/Graphics/Containers/UserTrackingScrollContainer.cs
@@ -25,6 +25,8 @@ namespace osu.Game.Graphics.Containers
///
public bool UserScrolling { get; private set; }
+ public void CancelUserScroll() => UserScrolling = false;
+
public UserTrackingScrollContainer()
{
}
@@ -45,5 +47,11 @@ namespace osu.Game.Graphics.Containers
UserScrolling = false;
base.ScrollTo(value, animated, distanceDecay);
}
+
+ public new void ScrollToEnd(bool animated = true, bool allowDuringDrag = false)
+ {
+ UserScrolling = false;
+ base.ScrollToEnd(animated, allowDuringDrag);
+ }
}
}
diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs
index 5926d11c03..86ce724390 100644
--- a/osu.Game/Overlays/Chat/DrawableChannel.cs
+++ b/osu.Game/Overlays/Chat/DrawableChannel.cs
@@ -16,6 +16,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Sprites;
+using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Chat
@@ -24,7 +25,7 @@ namespace osu.Game.Overlays.Chat
{
public readonly Channel Channel;
protected FillFlowContainer ChatLineFlow;
- private OsuScrollContainer scroll;
+ private ChannelScrollContainer scroll;
private bool scrollbarVisible = true;
@@ -56,7 +57,7 @@ namespace osu.Game.Overlays.Chat
{
RelativeSizeAxes = Axes.Both,
Masking = true,
- Child = scroll = new OsuScrollContainer
+ Child = scroll = new ChannelScrollContainer
{
ScrollbarVisible = scrollbarVisible,
RelativeSizeAxes = Axes.Both,
@@ -80,12 +81,6 @@ namespace osu.Game.Overlays.Chat
Channel.PendingMessageResolved += pendingMessageResolved;
}
- protected override void LoadComplete()
- {
- base.LoadComplete();
- scrollToEnd();
- }
-
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
@@ -113,8 +108,6 @@ namespace osu.Game.Overlays.Chat
ChatLineFlow.Clear();
}
- bool shouldScrollToEnd = scroll.IsScrolledToEnd(10) || !chatLines.Any() || newMessages.Any(m => m is LocalMessage);
-
// Add up to last Channel.MAX_HISTORY messages
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
@@ -153,8 +146,10 @@ namespace osu.Game.Overlays.Chat
}
}
- if (shouldScrollToEnd)
- scrollToEnd();
+ // due to the scroll adjusts from old messages removal above, a scroll-to-end must be enforced,
+ // to avoid making the container think the user has scrolled back up and unwantedly disable auto-scrolling.
+ if (newMessages.Any(m => m is LocalMessage))
+ scroll.ScrollToEnd();
});
private void pendingMessageResolved(Message existing, Message updated) => Schedule(() =>
@@ -178,8 +173,6 @@ namespace osu.Game.Overlays.Chat
private IEnumerable chatLines => ChatLineFlow.Children.OfType();
- private void scrollToEnd() => ScheduleAfterChildren(() => scroll.ScrollToEnd());
-
public class DaySeparator : Container
{
public float TextSize
@@ -243,5 +236,51 @@ namespace osu.Game.Overlays.Chat
};
}
}
+
+ ///
+ /// An with functionality to automatically scroll whenever the maximum scrollable distance increases.
+ ///
+ private class ChannelScrollContainer : UserTrackingScrollContainer
+ {
+ ///
+ /// The chat will be automatically scrolled to end if and only if
+ /// the distance between the current scroll position and the end of the scroll
+ /// is less than this value.
+ ///
+ private const float auto_scroll_leniency = 10f;
+
+ private float? lastExtent;
+
+ protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
+ {
+ base.OnUserScroll(value, animated, distanceDecay);
+ lastExtent = null;
+ }
+
+ protected override void Update()
+ {
+ base.Update();
+
+ // If the user has scrolled to the bottom of the container, we should resume tracking new content.
+ if (UserScrolling && IsScrolledToEnd(auto_scroll_leniency))
+ CancelUserScroll();
+
+ // If the user hasn't overridden our behaviour and there has been new content added to the container, we should update our scroll position to track it.
+ bool requiresScrollUpdate = !UserScrolling && (lastExtent == null || Precision.AlmostBigger(ScrollableExtent, lastExtent.Value));
+
+ if (requiresScrollUpdate)
+ {
+ // Schedule required to allow FillFlow to be the correct size.
+ Schedule(() =>
+ {
+ if (!UserScrolling)
+ {
+ ScrollToEnd();
+ lastExtent = ScrollableExtent;
+ }
+ });
+ }
+ }
+ }
}
}
diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs
index 2ff59f4d1a..cae5da3d16 100644
--- a/osu.Game/Rulesets/UI/ModIcon.cs
+++ b/osu.Game/Rulesets/UI/ModIcon.cs
@@ -95,11 +95,6 @@ namespace osu.Game.Rulesets.UI
};
}
- [BackgroundDependencyLoader]
- private void load()
- {
- }
-
protected override void LoadComplete()
{
base.LoadComplete();
diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs
index 0e04d1ea12..0ba202b082 100644
--- a/osu.Game/Screens/Edit/Editor.cs
+++ b/osu.Game/Screens/Edit/Editor.cs
@@ -109,7 +109,16 @@ namespace osu.Game.Screens.Edit
if (Beatmap.Value is DummyWorkingBeatmap)
{
isNewBeatmap = true;
- Beatmap.Value = beatmapManager.CreateNew(Ruleset.Value, api.LocalUser.Value);
+
+ var newBeatmap = beatmapManager.CreateNew(Ruleset.Value, api.LocalUser.Value);
+
+ // this is a bit haphazard, but guards against setting the lease Beatmap bindable if
+ // the editor has already been exited.
+ if (!ValidForPush)
+ return;
+
+ // this probably shouldn't be set in the asynchronous load method, but everything following relies on it.
+ Beatmap.Value = newBeatmap;
}
beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs
index 01f9920609..ced6d1c5db 100644
--- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs
+++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs
@@ -200,7 +200,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
Child = new GridContainer
{
RelativeSizeAxes = Axes.X,
- Height = 300,
+ Height = 500,
Content = new[]
{
new Drawable[]
diff --git a/osu.Game/Utils/SentryLogger.cs b/osu.Game/Utils/SentryLogger.cs
index e8e41cdbbe..be9d01cde6 100644
--- a/osu.Game/Utils/SentryLogger.cs
+++ b/osu.Game/Utils/SentryLogger.cs
@@ -23,7 +23,7 @@ namespace osu.Game.Utils
var options = new SentryOptions
{
- Dsn = new Dsn("https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255"),
+ Dsn = "https://5e342cd55f294edebdc9ad604d28bbd3@sentry.io/1255255",
Release = game.Version
};
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index 1552dff17d..e2b506e187 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -29,8 +29,8 @@
-
-
+
+
diff --git a/osu.iOS.props b/osu.iOS.props
index 48dc01f5de..dc3527c687 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -89,10 +89,10 @@
-
+
-
+