From 77c94afcf182ff33a893ed3d3930f9cb04e3b344 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 7 Mar 2020 14:28:10 +0900 Subject: [PATCH 01/54] Add better flow logic to map pool layout when few beatmaps are present --- .../Screens/MapPool/MapPoolScreen.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index c42d0a6da3..d7aeac02cb 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -47,9 +47,10 @@ namespace osu.Game.Tournament.Screens.MapPool { Y = 100, Spacing = new Vector2(10, 10), - Padding = new MarginPadding(25), + Padding = new MarginPadding(5) { Horizontal = 100 }, Direction = FillDirection.Vertical, - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, }, new ControlPanel { @@ -90,6 +91,7 @@ namespace osu.Game.Tournament.Screens.MapPool Text = "Reset", Action = reset }, + new ControlPanel.Spacer(), } } }; @@ -206,11 +208,15 @@ namespace osu.Game.Tournament.Screens.MapPool { mapFlows.Clear(); + int totalRows = 0; + if (match.NewValue.Round.Value != null) { FillFlowContainer currentFlow = null; string currentMod = null; + int flowCount = 0; + foreach (var b in match.NewValue.Round.Value.Beatmaps) { if (currentFlow == null || currentMod != b.Mods) @@ -224,6 +230,15 @@ namespace osu.Game.Tournament.Screens.MapPool }); currentMod = b.Mods; + + totalRows++; + flowCount = 0; + } + + if (++flowCount > 2) + { + totalRows++; + flowCount = 0; } currentFlow.Add(new TournamentBeatmapPanel(b.BeatmapInfo, b.Mods) @@ -233,6 +248,10 @@ namespace osu.Game.Tournament.Screens.MapPool }); } } + + if (totalRows > 8) + // remove horizontal padding to increase flow width to 3 panels + mapFlows.Padding = new MarginPadding(5); } } } From ef0acde458c7b9bea5fa42fc60e951fa6e3581fb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 Mar 2020 14:12:56 +0900 Subject: [PATCH 02/54] Adjust to allow for extra row --- osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index 1ef2916ca1..fad9f00dc8 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -254,7 +254,7 @@ namespace osu.Game.Tournament.Screens.MapPool } } - if (totalRows > 8) + if (totalRows > 9) // remove horizontal padding to increase flow width to 3 panels mapFlows.Padding = new MarginPadding(5); } From fbb7e9f12a3971a6f3afb46138ba2f67b499d54b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 11 Mar 2020 15:34:52 +0900 Subject: [PATCH 03/54] Add tests (wip) --- osu.Game.Tournament.Tests/LadderTestScene.cs | 122 ++++++++++++++++++ .../Screens/TestSceneMapPoolScreen.cs | 83 +++++++++++- .../Screens/TestSceneSeedingEditorScreen.cs | 2 +- .../Screens/TestSceneSeedingScreen.cs | 101 --------------- .../Screens/MapPool/MapPoolScreen.cs | 4 +- 5 files changed, 201 insertions(+), 111 deletions(-) diff --git a/osu.Game.Tournament.Tests/LadderTestScene.cs b/osu.Game.Tournament.Tests/LadderTestScene.cs index dae0721023..4477ca8338 100644 --- a/osu.Game.Tournament.Tests/LadderTestScene.cs +++ b/osu.Game.Tournament.Tests/LadderTestScene.cs @@ -3,7 +3,10 @@ using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Utils; +using osu.Game.Beatmaps; using osu.Game.Tournament.Models; +using osu.Game.Users; namespace osu.Game.Tournament.Tests { @@ -12,5 +15,124 @@ namespace osu.Game.Tournament.Tests { [Resolved] protected LadderInfo Ladder { get; private set; } + + protected override void LoadComplete() + { + base.LoadComplete(); + + TournamentMatch match = CreateSampleMatch(); + + Ladder.Rounds.Clear(); + Ladder.Rounds.Add(match.Round.Value); + + Ladder.Matches.Clear(); + Ladder.Matches.Add(match); + + Ladder.Teams.Clear(); + Ladder.Teams.Add(match.Team1.Value); + Ladder.Teams.Add(match.Team2.Value); + + Ladder.CurrentMatch.Value = match; + } + + public static TournamentMatch CreateSampleMatch() => new TournamentMatch + { + Team1 = + { + Value = new TournamentTeam + { + FlagName = { Value = "JP" }, + FullName = { Value = "Japan" }, + LastYearPlacing = { Value = 10 }, + Seed = { Value = "Low" }, + SeedingResults = + { + new SeedingResult + { + Mod = { Value = "NM" }, + Seed = { Value = 10 }, + Beatmaps = + { + new SeedingBeatmap + { + BeatmapInfo = CreateSampleBeatmapInfo(), + Score = 12345672, + Seed = { Value = 24 }, + }, + new SeedingBeatmap + { + BeatmapInfo = CreateSampleBeatmapInfo(), + Score = 1234567, + Seed = { Value = 12 }, + }, + new SeedingBeatmap + { + BeatmapInfo = CreateSampleBeatmapInfo(), + Score = 1234567, + Seed = { Value = 16 }, + } + } + }, + new SeedingResult + { + Mod = { Value = "DT" }, + Seed = { Value = 5 }, + Beatmaps = + { + new SeedingBeatmap + { + BeatmapInfo = CreateSampleBeatmapInfo(), + Score = 234567, + Seed = { Value = 3 }, + }, + new SeedingBeatmap + { + BeatmapInfo = CreateSampleBeatmapInfo(), + Score = 234567, + Seed = { Value = 6 }, + }, + new SeedingBeatmap + { + BeatmapInfo = CreateSampleBeatmapInfo(), + Score = 234567, + Seed = { Value = 12 }, + } + } + } + }, + Players = + { + new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 12 } } }, + new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 16 } } }, + new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 20 } } }, + new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 24 } } }, + new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 30 } } }, + } + } + }, + Team2 = + { + Value = new TournamentTeam + { + FlagName = { Value = "US" }, + FullName = { Value = "United States" }, + Players = + { + new User { Username = "Hello" }, + new User { Username = "Hello" }, + new User { Username = "Hello" }, + new User { Username = "Hello" }, + new User { Username = "Hello" }, + } + } + }, + Round = + { + Value = new TournamentRound { Name = { Value = "Quarterfinals" } } + } + }; + + public static BeatmapInfo CreateSampleBeatmapInfo() => + new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } }; } } diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index a7011c6d3c..a73e4e53ba 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -1,24 +1,93 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; -using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Testing; +using osu.Game.Tournament.Components; +using osu.Game.Tournament.Models; using osu.Game.Tournament.Screens.MapPool; namespace osu.Game.Tournament.Tests.Screens { public class TestSceneMapPoolScreen : LadderTestScene { - public override IReadOnlyList RequiredTypes => new[] - { - typeof(MapPoolScreen) - }; + private MapPoolScreen screen; [BackgroundDependencyLoader] private void load() { - Add(new MapPoolScreen { Width = 0.7f }); + Add(screen = new MapPoolScreen { Width = 0.7f }); + } + + [Test] + public void TestFewMaps() + { + AddStep("load few maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 8; i++) + addBeatmap(); + }); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + + AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + } + + [Test] + public void TestManyMaps() + { + AddStep("load many maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 17; i++) + addBeatmap(); + }); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + + AddAssert("ensure layout width is 3", () => screen.ChildrenOfType().ElementAt(2).Y == 0); + } + + [Test] + public void TestManyMods() + { + AddStep("load many maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 13; i++) + addBeatmap(i < 4 ? $"M{i}" : "NM"); + }); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + + AddAssert("ensure layout width is 3", () => screen.ChildrenOfType().ElementAt(2).Y == 0); + } + + private void addBeatmap(string mods = "nm") + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Add(new RoundBeatmap + { + BeatmapInfo = CreateSampleBeatmapInfo(), + Mods = mods + }); } } } diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs index 014cd4663b..17cccd34b6 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingEditorScreen.cs @@ -14,7 +14,7 @@ namespace osu.Game.Tournament.Tests.Screens public TestSceneSeedingEditorScreen() { - var match = TestSceneSeedingScreen.CreateSampleSeededMatch(); + var match = CreateSampleMatch(); Add(new SeedingEditorScreen(match.Team1.Value) { diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs index 335a6c80a1..4269f8f56a 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneSeedingScreen.cs @@ -3,10 +3,8 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Game.Beatmaps; using osu.Game.Tournament.Models; using osu.Game.Tournament.Screens.TeamIntro; -using osu.Game.Users; namespace osu.Game.Tournament.Tests.Screens { @@ -18,110 +16,11 @@ namespace osu.Game.Tournament.Tests.Screens [BackgroundDependencyLoader] private void load() { - ladder.CurrentMatch.Value = CreateSampleSeededMatch(); - Add(new SeedingScreen { FillMode = FillMode.Fit, FillAspectRatio = 16 / 9f }); } - - public static TournamentMatch CreateSampleSeededMatch() => new TournamentMatch - { - Team1 = - { - Value = new TournamentTeam - { - FlagName = { Value = "JP" }, - FullName = { Value = "Japan" }, - LastYearPlacing = { Value = 10 }, - Seed = { Value = "Low" }, - SeedingResults = - { - new SeedingResult - { - Mod = { Value = "NM" }, - Seed = { Value = 10 }, - Beatmaps = - { - new SeedingBeatmap - { - BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist" } }, - Score = 12345672, - Seed = { Value = 24 }, - }, - new SeedingBeatmap - { - BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist" } }, - Score = 1234567, - Seed = { Value = 12 }, - }, - new SeedingBeatmap - { - BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist" } }, - Score = 1234567, - Seed = { Value = 16 }, - } - } - }, - new SeedingResult - { - Mod = { Value = "DT" }, - Seed = { Value = 5 }, - Beatmaps = - { - new SeedingBeatmap - { - BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist" } }, - Score = 234567, - Seed = { Value = 3 }, - }, - new SeedingBeatmap - { - BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist" } }, - Score = 234567, - Seed = { Value = 6 }, - }, - new SeedingBeatmap - { - BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist" } }, - Score = 234567, - Seed = { Value = 12 }, - } - } - } - }, - Players = - { - new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 12 } } }, - new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 16 } } }, - new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 20 } } }, - new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 24 } } }, - new User { Username = "Hello", Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 30 } } }, - } - } - }, - Team2 = - { - Value = new TournamentTeam - { - FlagName = { Value = "US" }, - FullName = { Value = "United States" }, - Players = - { - new User { Username = "Hello" }, - new User { Username = "Hello" }, - new User { Username = "Hello" }, - new User { Username = "Hello" }, - new User { Username = "Hello" }, - } - } - }, - Round = - { - Value = new TournamentRound { Name = { Value = "Quarterfinals" } } - } - }; } } diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index fad9f00dc8..a9e1d1f226 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -52,7 +52,6 @@ namespace osu.Game.Tournament.Screens.MapPool { Y = 100, Spacing = new Vector2(10, 10), - Padding = new MarginPadding(5) { Horizontal = 100 }, Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -212,6 +211,7 @@ namespace osu.Game.Tournament.Screens.MapPool private void matchChanged(ValueChangedEvent match) { mapFlows.Clear(); + mapFlows.Padding = new MarginPadding(5) { Horizontal = 100 }; int totalRows = 0; @@ -243,7 +243,7 @@ namespace osu.Game.Tournament.Screens.MapPool if (++flowCount > 2) { totalRows++; - flowCount = 0; + flowCount = 1; } currentFlow.Add(new TournamentBeatmapPanel(b.BeatmapInfo, b.Mods) From 00d7dc19cc4932ac1af3ca1c6da315dbcd8b5ee1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 Mar 2020 14:25:25 +0900 Subject: [PATCH 04/54] Update tests and logic --- .../Screens/TestSceneMapPoolScreen.cs | 46 +++++++++++++++++-- .../Screens/MapPool/MapPoolScreen.cs | 7 +-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index a73e4e53ba..cc5f66761e 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -41,6 +41,26 @@ namespace osu.Game.Tournament.Tests.Screens AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); } + [Test] + public void TestJustEnoughMaps() + { + AddStep("load just enough maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 18; i++) + addBeatmap(); + }); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + + AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + } + [Test] public void TestManyMaps() { @@ -48,7 +68,7 @@ namespace osu.Game.Tournament.Tests.Screens { Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); - for (int i = 0; i < 17; i++) + for (int i = 0; i < 19; i++) addBeatmap(); }); @@ -61,6 +81,26 @@ namespace osu.Game.Tournament.Tests.Screens AddAssert("ensure layout width is 3", () => screen.ChildrenOfType().ElementAt(2).Y == 0); } + [Test] + public void TestJustEnoughMods() + { + AddStep("load many maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 11; i++) + addBeatmap(i > 4 ? $"M{i}" : "NM"); + }); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + + AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + } + [Test] public void TestManyMods() { @@ -68,8 +108,8 @@ namespace osu.Game.Tournament.Tests.Screens { Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); - for (int i = 0; i < 13; i++) - addBeatmap(i < 4 ? $"M{i}" : "NM"); + for (int i = 0; i < 12; i++) + addBeatmap(i > 4 ? $"M{i}" : "NM"); }); AddStep("reset match", () => diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index a9e1d1f226..da7e226103 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -211,7 +211,6 @@ namespace osu.Game.Tournament.Screens.MapPool private void matchChanged(ValueChangedEvent match) { mapFlows.Clear(); - mapFlows.Padding = new MarginPadding(5) { Horizontal = 100 }; int totalRows = 0; @@ -254,9 +253,11 @@ namespace osu.Game.Tournament.Screens.MapPool } } - if (totalRows > 9) + mapFlows.Padding = new MarginPadding(5) + { // remove horizontal padding to increase flow width to 3 panels - mapFlows.Padding = new MarginPadding(5); + Horizontal = totalRows > 9 ? 0 : 100 + }; } } } From 30ad580993b60944d395a3650214f53a8e6b75fe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 Mar 2020 14:09:09 +0900 Subject: [PATCH 05/54] Fix map pool screen vertical layout --- osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index da7e226103..7217629860 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -50,7 +50,7 @@ namespace osu.Game.Tournament.Screens.MapPool new MatchHeader(), mapFlows = new FillFlowContainer> { - Y = 100, + Y = 160, Spacing = new Vector2(10, 10), Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.X, From 544dfe7dd39266a4e0c4906413fa3b26db161d10 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 16 Mar 2020 09:42:21 +0300 Subject: [PATCH 06/54] Implement FriendsLayout component --- .../Visual/Online/TestSceneFriendsLayout.cs | 80 ++++++ .../TestSceneFriendsOnlineStatusControl.cs | 12 +- .../UserInterface/TestSceneUserListToolbar.cs | 2 +- .../Online/API/Requests/GetFriendsRequest.cs | 4 +- .../API/Requests/Responses/APIFriend.cs | 14 + .../Friends/FriendsBundle.cs | 13 +- .../Dashboard/Friends/FriendsLayout.cs | 256 ++++++++++++++++++ .../Friends/FriendsOnlineStatusControl.cs | 15 +- .../Friends/FriendsOnlineStatusItem.cs | 2 +- .../Friends/UserListToolbar.cs | 2 +- .../Friends/UserSortTabControl.cs | 2 +- osu.Game/Overlays/SocialOverlay.cs | 2 +- 12 files changed, 379 insertions(+), 25 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs create mode 100644 osu.Game/Online/API/Requests/Responses/APIFriend.cs rename osu.Game/Overlays/{Home => Dashboard}/Friends/FriendsBundle.cs (55%) create mode 100644 osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs rename osu.Game/Overlays/{Home => Dashboard}/Friends/FriendsOnlineStatusControl.cs (70%) rename osu.Game/Overlays/{Home => Dashboard}/Friends/FriendsOnlineStatusItem.cs (96%) rename osu.Game/Overlays/{Home => Dashboard}/Friends/UserListToolbar.cs (96%) rename osu.Game/Overlays/{Home => Dashboard}/Friends/UserSortTabControl.cs (90%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs new file mode 100644 index 0000000000..0e9fafb1b6 --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -0,0 +1,80 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using osu.Framework.Graphics.Containers; +using osu.Game.Overlays.Dashboard.Friends; +using osu.Framework.Graphics; +using osu.Game.Users; +using osu.Game.Overlays; +using osu.Framework.Allocation; +using NUnit.Framework; +using osu.Game.Online.API.Requests.Responses; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneFriendsLayout : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(FriendsLayout), + typeof(FriendsOnlineStatusControl), + typeof(UserListToolbar) + }; + + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); + + private FriendsLayout layout; + + [SetUp] + public void Setup() => Schedule(() => + { + Child = new BasicScrollContainer + { + RelativeSizeAxes = Axes.Both, + Child = layout = new FriendsLayout() + }; + }); + + [Test] + public void TestPopulate() + { + AddStep("Populate", () => layout.Users = getUsers()); + } + + private List getUsers() => new List + { + new APIFriend + { + Username = @"flyte", + Id = 3103765, + IsOnline = true, + CurrentModeRank = 1111, + Country = new Country { FlagName = @"JP" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" + }, + new APIFriend + { + Username = @"peppy", + Id = 2, + IsOnline = false, + CurrentModeRank = 2222, + Country = new Country { FlagName = @"AU" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", + IsSupporter = true, + SupportLevel = 3, + }, + new APIFriend + { + Username = @"Evast", + Id = 8195163, + Country = new Country { FlagName = @"BY" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg", + IsOnline = false, + LastVisit = DateTimeOffset.Now + } + }; + } +} diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs index 0d841dfef1..8bdf3c5dc1 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs @@ -7,9 +7,9 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; -using osu.Game.Overlays.Home.Friends; -using osu.Game.Users; +using osu.Game.Overlays.Dashboard.Friends; namespace osu.Game.Tests.Visual.UserInterface { @@ -39,17 +39,17 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void Populate() { - AddStep("Populate", () => control.Populate(new List + AddStep("Populate", () => control.Populate(new List { - new User + new APIFriend { IsOnline = true }, - new User + new APIFriend { IsOnline = false }, - new User + new APIFriend { IsOnline = false } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUserListToolbar.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUserListToolbar.cs index 02b8839922..1546972580 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneUserListToolbar.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUserListToolbar.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; -using osu.Game.Overlays.Home.Friends; +using osu.Game.Overlays.Dashboard.Friends; using osuTK; namespace osu.Game.Tests.Visual.UserInterface diff --git a/osu.Game/Online/API/Requests/GetFriendsRequest.cs b/osu.Game/Online/API/Requests/GetFriendsRequest.cs index 46890aa889..321f675aae 100644 --- a/osu.Game/Online/API/Requests/GetFriendsRequest.cs +++ b/osu.Game/Online/API/Requests/GetFriendsRequest.cs @@ -2,11 +2,11 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; -using osu.Game.Users; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class GetFriendsRequest : APIRequest> + public class GetFriendsRequest : APIRequest> { protected override string Target => @"friends"; } diff --git a/osu.Game/Online/API/Requests/Responses/APIFriend.cs b/osu.Game/Online/API/Requests/Responses/APIFriend.cs new file mode 100644 index 0000000000..91fed28d44 --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIFriend.cs @@ -0,0 +1,14 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using Newtonsoft.Json; +using osu.Game.Users; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIFriend : User + { + [JsonProperty(@"current_mode_rank")] + public int? CurrentModeRank; + } +} diff --git a/osu.Game/Overlays/Home/Friends/FriendsBundle.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs similarity index 55% rename from osu.Game/Overlays/Home/Friends/FriendsBundle.cs rename to osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs index 75d00dfef8..0062c49c91 100644 --- a/osu.Game/Overlays/Home/Friends/FriendsBundle.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs @@ -1,18 +1,23 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -namespace osu.Game.Overlays.Home.Friends +using System.Collections.Generic; +using osu.Game.Online.API.Requests.Responses; + +namespace osu.Game.Overlays.Dashboard.Friends { public class FriendsBundle { public FriendsOnlineStatus Status { get; } - public int Count { get; } + public int Count => Users.Count; - public FriendsBundle(FriendsOnlineStatus status, int count) + public List Users { get; } + + public FriendsBundle(FriendsOnlineStatus status, List users) { Status = status; - Count = count; + Users = users; } } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs new file mode 100644 index 0000000000..55f394cb78 --- /dev/null +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -0,0 +1,256 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; +using osu.Game.Users; +using osuTK; + +namespace osu.Game.Overlays.Dashboard.Friends +{ + public class FriendsLayout : CompositeDrawable + { + private List users = new List(); + + public List Users + { + get => users; + set + { + users = value; + + usersLoaded = true; + + onlineStatusControl.Populate(value); + } + } + + [Resolved] + private IAPIProvider api { get; set; } + + private GetFriendsRequest request; + private CancellationTokenSource cancellationToken; + + private Drawable currentContent; + + private readonly Box background; + private readonly Box controlBackground; + private readonly FriendsOnlineStatusControl onlineStatusControl; + private readonly UserListToolbar userListToolbar; + private readonly Container itemsPlaceholder; + private readonly LoadingLayer loading; + + public FriendsLayout() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + InternalChild = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + controlBackground = new Box + { + RelativeSizeAxes = Axes.Both + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding + { + Top = 20, + Horizontal = 45 + }, + Child = onlineStatusControl = new FriendsOnlineStatusControl(), + } + } + }, + new Container + { + Name = "User List", + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Margin = new MarginPadding { Bottom = 20 }, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding + { + Horizontal = 40, + Vertical = 20 + }, + Child = userListToolbar = new UserListToolbar + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + } + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + itemsPlaceholder = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Horizontal = 50 } + }, + loading = new LoadingLayer(itemsPlaceholder) + } + } + } + } + } + } + } + }; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + background.Colour = colourProvider.Background4; + controlBackground.Colour = colourProvider.Background5; + } + + private bool usersLoaded; + + protected override void LoadComplete() + { + base.LoadComplete(); + + onlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); + userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels()); + userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels()); + + if (!api.IsLoggedIn) + return; + + request = new GetFriendsRequest(); + request.Success += response => Schedule(() => Users = response); + api.Queue(request); + } + + private void recreatePanels() + { + // Don't allow any changes until we have users loaded + if (!usersLoaded) + return; + + cancellationToken?.Cancel(); + + if (itemsPlaceholder.Any()) + loading.Show(); + + var groupedUsers = onlineStatusControl.Current.Value?.Users ?? new List(); + + var sortedUsers = sortUsers(groupedUsers); + + LoadComponentAsync(createTable(sortedUsers), addContentToPlaceholder, (cancellationToken = new CancellationTokenSource()).Token); + } + + private void addContentToPlaceholder(Drawable content) + { + loading.Hide(); + + var lastContent = currentContent; + + if (lastContent != null) + { + lastContent.FadeOut(100, Easing.OutQuint).Expire(); + lastContent.Delay(25).Schedule(() => lastContent.BypassAutoSizeAxes = Axes.Y); + } + + itemsPlaceholder.Add(currentContent = content); + currentContent.FadeIn(200, Easing.OutQuint); + } + + private FillFlowContainer createTable(List users) + { + var style = userListToolbar.DisplayStyle.Value; + + return new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(style == OverlayPanelDisplayStyle.Card ? 10 : 2), + Children = users.Select(u => createUserPanel(u, style)).ToList() + }; + } + + private UserPanel createUserPanel(User user, OverlayPanelDisplayStyle style) + { + switch (style) + { + default: + case OverlayPanelDisplayStyle.Card: + return new UserGridPanel(user).With(panel => + { + panel.Anchor = Anchor.TopCentre; + panel.Origin = Anchor.TopCentre; + panel.Width = 290; + }); + + case OverlayPanelDisplayStyle.List: + return new UserListPanel(user); + } + } + + private List sortUsers(List unsorted) + { + switch (userListToolbar.SortCriteria.Value) + { + default: + case UserSortCriteria.LastVisit: + return unsorted.OrderBy(u => u.LastVisit).Reverse().ToList(); + + case UserSortCriteria.Rank: + return unsorted.Where(u => u.CurrentModeRank.HasValue).OrderBy(u => u.CurrentModeRank).Concat(unsorted.Where(u => u.CurrentModeRank == null)).ToList(); + + case UserSortCriteria.Username: + return unsorted.OrderBy(u => u.Username).ToList(); + } + } + + protected override void Dispose(bool isDisposing) + { + request?.Cancel(); + cancellationToken?.Cancel(); + + base.Dispose(isDisposing); + } + } +} diff --git a/osu.Game/Overlays/Home/Friends/FriendsOnlineStatusControl.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs similarity index 70% rename from osu.Game/Overlays/Home/Friends/FriendsOnlineStatusControl.cs rename to osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs index 196f01ab4a..2b716f228d 100644 --- a/osu.Game/Overlays/Home/Friends/FriendsOnlineStatusControl.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs @@ -3,22 +3,21 @@ using System.Collections.Generic; using System.Linq; -using osu.Game.Users; +using osu.Game.Online.API.Requests.Responses; -namespace osu.Game.Overlays.Home.Friends +namespace osu.Game.Overlays.Dashboard.Friends { public class FriendsOnlineStatusControl : OverlayStreamControl { protected override OverlayStreamItem CreateStreamItem(FriendsBundle value) => new FriendsOnlineStatusItem(value); - public void Populate(List users) + public void Populate(List users) { - var userCount = users.Count; - var onlineUsersCount = users.Count(user => user.IsOnline); + Clear(); - AddItem(new FriendsBundle(FriendsOnlineStatus.All, userCount)); - AddItem(new FriendsBundle(FriendsOnlineStatus.Online, onlineUsersCount)); - AddItem(new FriendsBundle(FriendsOnlineStatus.Offline, userCount - onlineUsersCount)); + AddItem(new FriendsBundle(FriendsOnlineStatus.All, users)); + AddItem(new FriendsBundle(FriendsOnlineStatus.Online, users.Where(u => u.IsOnline).ToList())); + AddItem(new FriendsBundle(FriendsOnlineStatus.Offline, users.Where(u => !u.IsOnline).ToList())); Current.Value = Items.FirstOrDefault(); } diff --git a/osu.Game/Overlays/Home/Friends/FriendsOnlineStatusItem.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusItem.cs similarity index 96% rename from osu.Game/Overlays/Home/Friends/FriendsOnlineStatusItem.cs rename to osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusItem.cs index d9b780ce46..eada9420ea 100644 --- a/osu.Game/Overlays/Home/Friends/FriendsOnlineStatusItem.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusItem.cs @@ -5,7 +5,7 @@ using System; using osu.Game.Graphics; using osuTK.Graphics; -namespace osu.Game.Overlays.Home.Friends +namespace osu.Game.Overlays.Dashboard.Friends { public class FriendsOnlineStatusItem : OverlayStreamItem { diff --git a/osu.Game/Overlays/Home/Friends/UserListToolbar.cs b/osu.Game/Overlays/Dashboard/Friends/UserListToolbar.cs similarity index 96% rename from osu.Game/Overlays/Home/Friends/UserListToolbar.cs rename to osu.Game/Overlays/Dashboard/Friends/UserListToolbar.cs index f7c5e9f4fd..fb4b938183 100644 --- a/osu.Game/Overlays/Home/Friends/UserListToolbar.cs +++ b/osu.Game/Overlays/Dashboard/Friends/UserListToolbar.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics.Containers; using osuTK; using osu.Framework.Bindables; -namespace osu.Game.Overlays.Home.Friends +namespace osu.Game.Overlays.Dashboard.Friends { public class UserListToolbar : CompositeDrawable { diff --git a/osu.Game/Overlays/Home/Friends/UserSortTabControl.cs b/osu.Game/Overlays/Dashboard/Friends/UserSortTabControl.cs similarity index 90% rename from osu.Game/Overlays/Home/Friends/UserSortTabControl.cs rename to osu.Game/Overlays/Dashboard/Friends/UserSortTabControl.cs index 2479fa4638..3a5f65212d 100644 --- a/osu.Game/Overlays/Home/Friends/UserSortTabControl.cs +++ b/osu.Game/Overlays/Dashboard/Friends/UserSortTabControl.cs @@ -3,7 +3,7 @@ using System.ComponentModel; -namespace osu.Game.Overlays.Home.Friends +namespace osu.Game.Overlays.Dashboard.Friends { public class UserSortTabControl : OverlaySortTabControl { diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index 02f7c9b0d3..ba572b0e78 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -120,7 +120,7 @@ namespace osu.Game.Overlays { case SocialTab.Friends: var friendRequest = new GetFriendsRequest(); // TODO filter arguments? - friendRequest.Success += users => Users = users.ToArray(); + friendRequest.Success += users => Users = users.Select(u => (User)u).ToArray(); API.Queue(getUsersRequest = friendRequest); break; From cc5833db80568e8e300dd434f4ad636c9582f573 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 01:36:48 +0300 Subject: [PATCH 07/54] Remove string prefixes in the test scene --- .../Visual/Online/TestSceneFriendsLayout.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs index 0e9fafb1b6..46f22073f2 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -48,30 +48,30 @@ namespace osu.Game.Tests.Visual.Online { new APIFriend { - Username = @"flyte", + Username = "flyte", Id = 3103765, IsOnline = true, CurrentModeRank = 1111, - Country = new Country { FlagName = @"JP" }, - CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" + Country = new Country { FlagName = "JP" }, + CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" }, new APIFriend { - Username = @"peppy", + Username = "peppy", Id = 2, IsOnline = false, CurrentModeRank = 2222, - Country = new Country { FlagName = @"AU" }, - CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", + Country = new Country { FlagName = "AU" }, + CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", IsSupporter = true, SupportLevel = 3, }, new APIFriend { - Username = @"Evast", + Username = "Evast", Id = 8195163, - Country = new Country { FlagName = @"BY" }, - CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg", + Country = new Country { FlagName = "BY" }, + CoverUrl = "https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg", IsOnline = false, LastVisit = DateTimeOffset.Now } From 6ec01a67af0d3d3a7af3db542e00dd69e725b008 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 01:38:45 +0300 Subject: [PATCH 08/54] Use cast in SocialOverlay --- osu.Game/Overlays/SocialOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index ba572b0e78..ff6f7de436 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -120,7 +120,7 @@ namespace osu.Game.Overlays { case SocialTab.Friends: var friendRequest = new GetFriendsRequest(); // TODO filter arguments? - friendRequest.Success += users => Users = users.Select(u => (User)u).ToArray(); + friendRequest.Success += users => Users = users.Cast().ToArray(); API.Queue(getUsersRequest = friendRequest); break; From 6a151b8e75a4bcc3ed48d2dfd6c8f2f2ddd393b1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 01:50:19 +0300 Subject: [PATCH 09/54] Add online test --- .../Visual/Online/TestSceneFriendsLayout.cs | 18 ++++++++++++++++-- .../Dashboard/Friends/FriendsLayout.cs | 12 +++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs index 46f22073f2..90474e5178 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -11,6 +11,7 @@ using osu.Game.Overlays; using osu.Framework.Allocation; using NUnit.Framework; using osu.Game.Online.API.Requests.Responses; +using System.Linq; namespace osu.Game.Tests.Visual.Online { @@ -23,10 +24,12 @@ namespace osu.Game.Tests.Visual.Online typeof(UserListToolbar) }; + protected override bool UseOnlineAPI => true; + [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); - private FriendsLayout layout; + private TestFriendsLayout layout; [SetUp] public void Setup() => Schedule(() => @@ -34,10 +37,16 @@ namespace osu.Game.Tests.Visual.Online Child = new BasicScrollContainer { RelativeSizeAxes = Axes.Both, - Child = layout = new FriendsLayout() + Child = layout = new TestFriendsLayout() }; }); + [Test] + public void TestOnline() + { + AddUntilStep("Users loaded", () => layout?.StatusControl.Items.Any() ?? false); + } + [Test] public void TestPopulate() { @@ -76,5 +85,10 @@ namespace osu.Game.Tests.Visual.Online LastVisit = DateTimeOffset.Now } }; + + private class TestFriendsLayout : FriendsLayout + { + public FriendsOnlineStatusControl StatusControl => OnlineStatusControl; + } } } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index 55f394cb78..cd358bcf84 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -26,11 +26,13 @@ namespace osu.Game.Overlays.Dashboard.Friends get => users; set { + request?.Cancel(); + users = value; usersLoaded = true; - onlineStatusControl.Populate(value); + OnlineStatusControl.Populate(value); } } @@ -42,9 +44,9 @@ namespace osu.Game.Overlays.Dashboard.Friends private Drawable currentContent; + protected readonly FriendsOnlineStatusControl OnlineStatusControl; private readonly Box background; private readonly Box controlBackground; - private readonly FriendsOnlineStatusControl onlineStatusControl; private readonly UserListToolbar userListToolbar; private readonly Container itemsPlaceholder; private readonly LoadingLayer loading; @@ -78,7 +80,7 @@ namespace osu.Game.Overlays.Dashboard.Friends Top = 20, Horizontal = 45 }, - Child = onlineStatusControl = new FriendsOnlineStatusControl(), + Child = OnlineStatusControl = new FriendsOnlineStatusControl(), } } }, @@ -152,7 +154,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { base.LoadComplete(); - onlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); + OnlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels()); userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels()); @@ -175,7 +177,7 @@ namespace osu.Game.Overlays.Dashboard.Friends if (itemsPlaceholder.Any()) loading.Show(); - var groupedUsers = onlineStatusControl.Current.Value?.Users ?? new List(); + var groupedUsers = OnlineStatusControl.Current.Value?.Users ?? new List(); var sortedUsers = sortUsers(groupedUsers); From da97a02e6660ef516762d9f0c742df3eb39f7247 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 01:53:53 +0300 Subject: [PATCH 10/54] Remove pointless flag --- osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index cd358bcf84..1098fdee8f 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -30,8 +30,6 @@ namespace osu.Game.Overlays.Dashboard.Friends users = value; - usersLoaded = true; - OnlineStatusControl.Populate(value); } } @@ -148,8 +146,6 @@ namespace osu.Game.Overlays.Dashboard.Friends controlBackground.Colour = colourProvider.Background5; } - private bool usersLoaded; - protected override void LoadComplete() { base.LoadComplete(); @@ -168,8 +164,7 @@ namespace osu.Game.Overlays.Dashboard.Friends private void recreatePanels() { - // Don't allow any changes until we have users loaded - if (!usersLoaded) + if (!users.Any()) return; cancellationToken?.Cancel(); From bd84980aa61af03d6c398db2942d8d5998d049ab Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 01:56:10 +0300 Subject: [PATCH 11/54] Simplify order by last visit --- osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index 1098fdee8f..1c56227521 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -232,7 +232,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { default: case UserSortCriteria.LastVisit: - return unsorted.OrderBy(u => u.LastVisit).Reverse().ToList(); + return unsorted.OrderByDescending(u => u.LastVisit).ToList(); case UserSortCriteria.Rank: return unsorted.Where(u => u.CurrentModeRank.HasValue).OrderBy(u => u.CurrentModeRank).Concat(unsorted.Where(u => u.CurrentModeRank == null)).ToList(); From f816479ff8972c4e2fb139b55746b36432a05f34 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 02:03:57 +0300 Subject: [PATCH 12/54] Simplify order by rank --- osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index 1c56227521..f069d3f384 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -235,7 +235,7 @@ namespace osu.Game.Overlays.Dashboard.Friends return unsorted.OrderByDescending(u => u.LastVisit).ToList(); case UserSortCriteria.Rank: - return unsorted.Where(u => u.CurrentModeRank.HasValue).OrderBy(u => u.CurrentModeRank).Concat(unsorted.Where(u => u.CurrentModeRank == null)).ToList(); + return unsorted.OrderByDescending(u => u.CurrentModeRank.HasValue).ThenBy(u => u.CurrentModeRank ?? 0).ToList(); case UserSortCriteria.Username: return unsorted.OrderBy(u => u.Username).ToList(); From d9d812a8fe09d7006c0e64bd20a79dd9f049efec Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 02:10:20 +0300 Subject: [PATCH 13/54] Fix status icon flash on first status change --- osu.Game/Users/UserPanel.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 289244cdc3..d5e6d5f13e 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -99,6 +99,9 @@ namespace osu.Game.Users { base.LoadComplete(); Status.TriggerChange(); + + // Colour should be applied immediately on first load. + statusIcon.FinishTransforms(); } protected override bool OnHover(HoverEvent e) From bf9c6f8a3b0f36f1fb984ddc7894cb00d2ec0a8d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 02:19:03 +0300 Subject: [PATCH 14/54] Skip online test if user is not logged-in --- osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs index 90474e5178..788cbd82c9 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -12,6 +12,7 @@ using osu.Framework.Allocation; using NUnit.Framework; using osu.Game.Online.API.Requests.Responses; using System.Linq; +using osu.Game.Online.API; namespace osu.Game.Tests.Visual.Online { @@ -29,6 +30,9 @@ namespace osu.Game.Tests.Visual.Online [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); + [Resolved] + private IAPIProvider api { get; set; } + private TestFriendsLayout layout; [SetUp] @@ -44,7 +48,8 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestOnline() { - AddUntilStep("Users loaded", () => layout?.StatusControl.Items.Any() ?? false); + // Skip online test if user is not logged-in + AddUntilStep("Users loaded", () => !api.IsLoggedIn || (layout?.StatusControl.Items.Any() ?? false)); } [Test] From 4ac740b12baceb300e3c582e37804587568acb8c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 08:51:54 +0300 Subject: [PATCH 15/54] Remove APIFriend --- .../Visual/Online/TestSceneFriendsLayout.cs | 9 ++++----- .../TestSceneFriendsOnlineStatusControl.cs | 10 +++++----- osu.Game/Online/API/Requests/GetFriendsRequest.cs | 4 ++-- .../Online/API/Requests/Responses/APIFriend.cs | 14 -------------- .../Overlays/Dashboard/Friends/FriendsBundle.cs | 6 +++--- .../Overlays/Dashboard/Friends/FriendsLayout.cs | 11 +++++------ .../Friends/FriendsOnlineStatusControl.cs | 4 ++-- osu.Game/Overlays/SocialOverlay.cs | 2 +- osu.Game/Users/User.cs | 3 +++ 9 files changed, 25 insertions(+), 38 deletions(-) delete mode 100644 osu.Game/Online/API/Requests/Responses/APIFriend.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs index 788cbd82c9..c6971a971d 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -10,7 +10,6 @@ using osu.Game.Users; using osu.Game.Overlays; using osu.Framework.Allocation; using NUnit.Framework; -using osu.Game.Online.API.Requests.Responses; using System.Linq; using osu.Game.Online.API; @@ -58,9 +57,9 @@ namespace osu.Game.Tests.Visual.Online AddStep("Populate", () => layout.Users = getUsers()); } - private List getUsers() => new List + private List getUsers() => new List { - new APIFriend + new User { Username = "flyte", Id = 3103765, @@ -69,7 +68,7 @@ namespace osu.Game.Tests.Visual.Online Country = new Country { FlagName = "JP" }, CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" }, - new APIFriend + new User { Username = "peppy", Id = 2, @@ -80,7 +79,7 @@ namespace osu.Game.Tests.Visual.Online IsSupporter = true, SupportLevel = 3, }, - new APIFriend + new User { Username = "Evast", Id = 8195163, diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs index 8bdf3c5dc1..d72818ed89 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs @@ -7,9 +7,9 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.Dashboard.Friends; +using osu.Game.Users; namespace osu.Game.Tests.Visual.UserInterface { @@ -39,17 +39,17 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void Populate() { - AddStep("Populate", () => control.Populate(new List + AddStep("Populate", () => control.Populate(new List { - new APIFriend + new User { IsOnline = true }, - new APIFriend + new User { IsOnline = false }, - new APIFriend + new User { IsOnline = false } diff --git a/osu.Game/Online/API/Requests/GetFriendsRequest.cs b/osu.Game/Online/API/Requests/GetFriendsRequest.cs index 321f675aae..46890aa889 100644 --- a/osu.Game/Online/API/Requests/GetFriendsRequest.cs +++ b/osu.Game/Online/API/Requests/GetFriendsRequest.cs @@ -2,11 +2,11 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; -using osu.Game.Online.API.Requests.Responses; +using osu.Game.Users; namespace osu.Game.Online.API.Requests { - public class GetFriendsRequest : APIRequest> + public class GetFriendsRequest : APIRequest> { protected override string Target => @"friends"; } diff --git a/osu.Game/Online/API/Requests/Responses/APIFriend.cs b/osu.Game/Online/API/Requests/Responses/APIFriend.cs deleted file mode 100644 index 91fed28d44..0000000000 --- a/osu.Game/Online/API/Requests/Responses/APIFriend.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using Newtonsoft.Json; -using osu.Game.Users; - -namespace osu.Game.Online.API.Requests.Responses -{ - public class APIFriend : User - { - [JsonProperty(@"current_mode_rank")] - public int? CurrentModeRank; - } -} diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs index 0062c49c91..772d9c67a0 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs @@ -2,7 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; -using osu.Game.Online.API.Requests.Responses; +using osu.Game.Users; namespace osu.Game.Overlays.Dashboard.Friends { @@ -12,9 +12,9 @@ namespace osu.Game.Overlays.Dashboard.Friends public int Count => Users.Count; - public List Users { get; } + public List Users { get; } - public FriendsBundle(FriendsOnlineStatus status, List users) + public FriendsBundle(FriendsOnlineStatus status, List users) { Status = status; Users = users; diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index f069d3f384..c02f07fe4a 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Users; using osuTK; @@ -19,9 +18,9 @@ namespace osu.Game.Overlays.Dashboard.Friends { public class FriendsLayout : CompositeDrawable { - private List users = new List(); + private List users = new List(); - public List Users + public List Users { get => users; set @@ -172,7 +171,7 @@ namespace osu.Game.Overlays.Dashboard.Friends if (itemsPlaceholder.Any()) loading.Show(); - var groupedUsers = OnlineStatusControl.Current.Value?.Users ?? new List(); + var groupedUsers = OnlineStatusControl.Current.Value?.Users ?? new List(); var sortedUsers = sortUsers(groupedUsers); @@ -195,7 +194,7 @@ namespace osu.Game.Overlays.Dashboard.Friends currentContent.FadeIn(200, Easing.OutQuint); } - private FillFlowContainer createTable(List users) + private FillFlowContainer createTable(List users) { var style = userListToolbar.DisplayStyle.Value; @@ -226,7 +225,7 @@ namespace osu.Game.Overlays.Dashboard.Friends } } - private List sortUsers(List unsorted) + private List sortUsers(List unsorted) { switch (userListToolbar.SortCriteria.Value) { diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs index 2b716f228d..88035e0a34 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; -using osu.Game.Online.API.Requests.Responses; +using osu.Game.Users; namespace osu.Game.Overlays.Dashboard.Friends { @@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { protected override OverlayStreamItem CreateStreamItem(FriendsBundle value) => new FriendsOnlineStatusItem(value); - public void Populate(List users) + public void Populate(List users) { Clear(); diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index ff6f7de436..02f7c9b0d3 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -120,7 +120,7 @@ namespace osu.Game.Overlays { case SocialTab.Friends: var friendRequest = new GetFriendsRequest(); // TODO filter arguments? - friendRequest.Success += users => Users = users.Cast().ToArray(); + friendRequest.Success += users => Users = users.ToArray(); API.Queue(getUsersRequest = friendRequest); break; diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index d25c552160..2a6f7844a2 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -69,6 +69,9 @@ namespace osu.Game.Users [JsonProperty(@"support_level")] public int SupportLevel; + [JsonProperty(@"current_mode_rank")] + public int? CurrentModeRank; + [JsonProperty(@"is_gmt")] public bool IsGMT; From e951979a12ec05aadce4e4c0b68435d2a24f9f75 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 17 Mar 2020 22:34:46 +0300 Subject: [PATCH 16/54] Remove assert from online test --- .../Visual/Online/TestSceneFriendsLayout.cs | 18 +++++------------- .../Dashboard/Friends/FriendsLayout.cs | 10 +++++----- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs index c6971a971d..e6b2a41c1c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -10,7 +10,6 @@ using osu.Game.Users; using osu.Game.Overlays; using osu.Framework.Allocation; using NUnit.Framework; -using System.Linq; using osu.Game.Online.API; namespace osu.Game.Tests.Visual.Online @@ -32,7 +31,7 @@ namespace osu.Game.Tests.Visual.Online [Resolved] private IAPIProvider api { get; set; } - private TestFriendsLayout layout; + private FriendsLayout layout; [SetUp] public void Setup() => Schedule(() => @@ -40,21 +39,19 @@ namespace osu.Game.Tests.Visual.Online Child = new BasicScrollContainer { RelativeSizeAxes = Axes.Both, - Child = layout = new TestFriendsLayout() + Child = layout = new FriendsLayout() }; }); [Test] - public void TestOnline() + public void TestOffline() { - // Skip online test if user is not logged-in - AddUntilStep("Users loaded", () => !api.IsLoggedIn || (layout?.StatusControl.Items.Any() ?? false)); + AddStep("Populate", () => layout.Users = getUsers()); } [Test] - public void TestPopulate() + public void TestOnline() { - AddStep("Populate", () => layout.Users = getUsers()); } private List getUsers() => new List @@ -89,10 +86,5 @@ namespace osu.Game.Tests.Visual.Online LastVisit = DateTimeOffset.Now } }; - - private class TestFriendsLayout : FriendsLayout - { - public FriendsOnlineStatusControl StatusControl => OnlineStatusControl; - } } } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index c02f07fe4a..55a5081435 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Dashboard.Friends users = value; - OnlineStatusControl.Populate(value); + onlineStatusControl.Populate(value); } } @@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Dashboard.Friends private Drawable currentContent; - protected readonly FriendsOnlineStatusControl OnlineStatusControl; + private readonly FriendsOnlineStatusControl onlineStatusControl; private readonly Box background; private readonly Box controlBackground; private readonly UserListToolbar userListToolbar; @@ -77,7 +77,7 @@ namespace osu.Game.Overlays.Dashboard.Friends Top = 20, Horizontal = 45 }, - Child = OnlineStatusControl = new FriendsOnlineStatusControl(), + Child = onlineStatusControl = new FriendsOnlineStatusControl(), } } }, @@ -149,7 +149,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { base.LoadComplete(); - OnlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); + onlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels()); userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels()); @@ -171,7 +171,7 @@ namespace osu.Game.Overlays.Dashboard.Friends if (itemsPlaceholder.Any()) loading.Show(); - var groupedUsers = OnlineStatusControl.Current.Value?.Users ?? new List(); + var groupedUsers = onlineStatusControl.Current.Value?.Users ?? new List(); var sortedUsers = sortUsers(groupedUsers); From bee8e22d185e39abca1e54886fc3bb3998f3b8a4 Mon Sep 17 00:00:00 2001 From: Fuewburvpoa Date: Tue, 17 Mar 2020 22:27:11 +0200 Subject: [PATCH 17/54] Fix BeatDivisorControl allow to select value outside of VALID_DIVISORS --- .../Screens/Edit/Compose/Components/BeatDivisorControl.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs index 8201ec2710..626a12edcf 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs @@ -279,6 +279,10 @@ namespace osu.Game.Screens.Edit.Compose.Components handleMouseInput(e.ScreenSpaceMousePosition); } + protected override void OnDragEnd(DragEndEvent e) + { + } + private void handleMouseInput(Vector2 screenSpaceMousePosition) { // copied from SliderBar so we can do custom spacing logic. From 6c825eb74499799fe5dd7c07f56fbd0359862c9f Mon Sep 17 00:00:00 2001 From: Fuewburvpoa <44163588+Fuewburvpoa@users.noreply.github.com> Date: Wed, 18 Mar 2020 00:04:03 +0200 Subject: [PATCH 18/54] Update osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Bartłomiej Dach --- osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs index 626a12edcf..2dec3fd22e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs @@ -281,6 +281,7 @@ namespace osu.Game.Screens.Edit.Compose.Components protected override void OnDragEnd(DragEndEvent e) { + handleMouseInput(e.ScreenSpaceMousePosition); } private void handleMouseInput(Vector2 screenSpaceMousePosition) From 336d92715755320e33ab6c2f17095935a42b99c3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 18 Mar 2020 15:38:19 +0900 Subject: [PATCH 19/54] Update tests to not use positional data (nunit runs at an incompatible window size) --- .../Screens/TestSceneMapPoolScreen.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index cc5f66761e..a4538be384 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -4,6 +4,7 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Tournament.Components; using osu.Game.Tournament.Models; @@ -38,7 +39,7 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value = Ladder.Matches.First(); }); - AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + assertTwoWide(); } [Test] @@ -58,7 +59,7 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value = Ladder.Matches.First(); }); - AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + assertTwoWide(); } [Test] @@ -78,7 +79,7 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value = Ladder.Matches.First(); }); - AddAssert("ensure layout width is 3", () => screen.ChildrenOfType().ElementAt(2).Y == 0); + assertThreeWide(); } [Test] @@ -98,9 +99,15 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value = Ladder.Matches.First(); }); - AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + assertTwoWide(); } + private void assertTwoWide() => + AddAssert("ensure layout width is 2", () => screen.ChildrenOfType>>().First().Padding.Left > 0); + + private void assertThreeWide() => + AddAssert("ensure layout width is 3", () => screen.ChildrenOfType>>().First().Padding.Left == 0); + [Test] public void TestManyMods() { @@ -118,7 +125,7 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value = Ladder.Matches.First(); }); - AddAssert("ensure layout width is 3", () => screen.ChildrenOfType().ElementAt(2).Y == 0); + assertThreeWide(); } private void addBeatmap(string mods = "nm") From 463dde1fc40206a8e7ee3d59ebecdb6186a2f1e4 Mon Sep 17 00:00:00 2001 From: Fuewburvpoa Date: Wed, 18 Mar 2020 21:04:38 +0200 Subject: [PATCH 20/54] Tests for BeatDivisorControl --- .../Editor/TestSceneBeatDivisorControl.cs | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs index 7531a7be2c..2ee5e649a8 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Screens.Edit; @@ -11,19 +12,66 @@ using osuTK; namespace osu.Game.Tests.Visual.Editor { - public class TestSceneBeatDivisorControl : OsuTestScene + public class TestSceneBeatDivisorControl : ManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { typeof(BindableBeatDivisor) }; + private BeatDivisorControl beatDivisorControl; + private BindableBeatDivisor bindableBeatDivisor; [BackgroundDependencyLoader] private void load() { - Child = new BeatDivisorControl(new BindableBeatDivisor()) + Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor()) { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(90, 90) }; } + + [Test] + public void TestBindableBeatDivisor() + { + AddStep("Reset", () => reset()); + AddRepeatStep("Move previous", () => bindableBeatDivisor.Previous(), 4); + AddAssert("Position at 4", () => bindableBeatDivisor.Value == 4); + AddRepeatStep("Move next", () => bindableBeatDivisor.Next(), 3); + AddAssert("Position at 12", () => bindableBeatDivisor.Value == 12); + } + + [Test] + public void TestMouseInput() + { + AddStep("Reset", () => reset()); + AddStep("Move to marker", () => + { + InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18)); + InputManager.PressButton(osuTK.Input.MouseButton.Left); + }); + AddStep("Mote to divisor 8", () => + { + InputManager.MoveMouseTo(beatDivisorControl, new Vector2(0, -18)); + InputManager.ReleaseButton(osuTK.Input.MouseButton.Left); + }); + AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8); + AddStep("Prepare to move marker", () => { InputManager.PressButton(osuTK.Input.MouseButton.Left); }); + AddStep("Trigger marker jump", () => + { + InputManager.MoveMouseTo(beatDivisorControl, new Vector2(30, -18)); + }); + AddStep("Move to divisor ~10", () => + { + InputManager.MoveMouseTo(beatDivisorControl, new Vector2(10, -18)); + InputManager.ReleaseButton(osuTK.Input.MouseButton.Left); + }); + AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8); + + } + + private void reset() + { + bindableBeatDivisor.Value = 16; + InputManager.MoveMouseTo(beatDivisorControl, new Vector2(beatDivisorControl.Width, beatDivisorControl.Height)); + } } } From d5541dfc651635eecd650b4619000760f8f2fa97 Mon Sep 17 00:00:00 2001 From: Fuewburvpoa Date: Wed, 18 Mar 2020 21:06:14 +0200 Subject: [PATCH 21/54] Codefactor fix --- osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs index 2ee5e649a8..b8cefdb841 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs @@ -65,7 +65,6 @@ namespace osu.Game.Tests.Visual.Editor InputManager.ReleaseButton(osuTK.Input.MouseButton.Left); }); AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8); - } private void reset() From 4bda520695e37a5753a667289e6ac7f2c31147d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 18 Mar 2020 21:54:17 +0100 Subject: [PATCH 22/54] Use [SetUp] instead of reset method --- .../Editor/TestSceneBeatDivisorControl.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs index b8cefdb841..dc41f7d92b 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using NUnit.Framework; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Screens.Edit; using osu.Game.Screens.Edit.Compose.Components; @@ -18,21 +17,20 @@ namespace osu.Game.Tests.Visual.Editor private BeatDivisorControl beatDivisorControl; private BindableBeatDivisor bindableBeatDivisor; - [BackgroundDependencyLoader] - private void load() + [SetUp] + public void SetUp() => Schedule(() => { - Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor()) + Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor(16)) { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(90, 90) }; - } + }); [Test] public void TestBindableBeatDivisor() { - AddStep("Reset", () => reset()); AddRepeatStep("Move previous", () => bindableBeatDivisor.Previous(), 4); AddAssert("Position at 4", () => bindableBeatDivisor.Value == 4); AddRepeatStep("Move next", () => bindableBeatDivisor.Next(), 3); @@ -42,7 +40,6 @@ namespace osu.Game.Tests.Visual.Editor [Test] public void TestMouseInput() { - AddStep("Reset", () => reset()); AddStep("Move to marker", () => { InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18)); @@ -66,11 +63,5 @@ namespace osu.Game.Tests.Visual.Editor }); AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8); } - - private void reset() - { - bindableBeatDivisor.Value = 16; - InputManager.MoveMouseTo(beatDivisorControl, new Vector2(beatDivisorControl.Width, beatDivisorControl.Height)); - } } } From 1d3cac4cdc5e61e9148c69f5c567ad135c04d6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 18 Mar 2020 21:55:35 +0100 Subject: [PATCH 23/54] Eliminate osuTK.Input namespace qualifications --- .../Visual/Editor/TestSceneBeatDivisorControl.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs index dc41f7d92b..5a441f568a 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using osu.Game.Screens.Edit; using osu.Game.Screens.Edit.Compose.Components; using osuTK; +using osuTK.Input; namespace osu.Game.Tests.Visual.Editor { @@ -43,15 +44,15 @@ namespace osu.Game.Tests.Visual.Editor AddStep("Move to marker", () => { InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18)); - InputManager.PressButton(osuTK.Input.MouseButton.Left); + InputManager.PressButton(MouseButton.Left); }); AddStep("Mote to divisor 8", () => { InputManager.MoveMouseTo(beatDivisorControl, new Vector2(0, -18)); - InputManager.ReleaseButton(osuTK.Input.MouseButton.Left); + InputManager.ReleaseButton(MouseButton.Left); }); AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8); - AddStep("Prepare to move marker", () => { InputManager.PressButton(osuTK.Input.MouseButton.Left); }); + AddStep("Prepare to move marker", () => { InputManager.PressButton(MouseButton.Left); }); AddStep("Trigger marker jump", () => { InputManager.MoveMouseTo(beatDivisorControl, new Vector2(30, -18)); @@ -59,7 +60,7 @@ namespace osu.Game.Tests.Visual.Editor AddStep("Move to divisor ~10", () => { InputManager.MoveMouseTo(beatDivisorControl, new Vector2(10, -18)); - InputManager.ReleaseButton(osuTK.Input.MouseButton.Left); + InputManager.ReleaseButton(MouseButton.Left); }); AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8); } From 78bdf5cf9150c851c74433113ca433fa069830b2 Mon Sep 17 00:00:00 2001 From: Fuewburvpoa Date: Wed, 18 Mar 2020 23:03:58 +0200 Subject: [PATCH 24/54] InspectCode fixes --- osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs index b8cefdb841..38b33acc32 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs @@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.Editor [Test] public void TestBindableBeatDivisor() { - AddStep("Reset", () => reset()); + AddStep("Reset", reset); AddRepeatStep("Move previous", () => bindableBeatDivisor.Previous(), 4); AddAssert("Position at 4", () => bindableBeatDivisor.Value == 4); AddRepeatStep("Move next", () => bindableBeatDivisor.Next(), 3); @@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Editor [Test] public void TestMouseInput() { - AddStep("Reset", () => reset()); + AddStep("Reset", reset); AddStep("Move to marker", () => { InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18)); @@ -54,7 +54,7 @@ namespace osu.Game.Tests.Visual.Editor InputManager.ReleaseButton(osuTK.Input.MouseButton.Left); }); AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8); - AddStep("Prepare to move marker", () => { InputManager.PressButton(osuTK.Input.MouseButton.Left); }); + AddStep("Prepare to move marker", () => InputManager.PressButton(osuTK.Input.MouseButton.Left)); AddStep("Trigger marker jump", () => { InputManager.MoveMouseTo(beatDivisorControl, new Vector2(30, -18)); From 23338a6c82ed4f14b5e8e4cab0dafd96fb371deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 18 Mar 2020 22:23:06 +0100 Subject: [PATCH 25/54] Adjust test implementation * Use slider bar and slider marker coordinates in manual tests instead of hard-coded offsets. * Reword test steps slightly for greater clarity. --- .../Editor/TestSceneBeatDivisorControl.cs | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs index 5a441f568a..746b2c99aa 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs @@ -3,8 +3,12 @@ using System; using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Testing; using osu.Game.Screens.Edit; using osu.Game.Screens.Edit.Compose.Components; using osuTK; @@ -18,6 +22,9 @@ namespace osu.Game.Tests.Visual.Editor private BeatDivisorControl beatDivisorControl; private BindableBeatDivisor bindableBeatDivisor; + private SliderBar tickSliderBar; + private EquilateralTriangle tickMarkerHead; + [SetUp] public void SetUp() => Schedule(() => { @@ -27,42 +34,52 @@ namespace osu.Game.Tests.Visual.Editor Origin = Anchor.Centre, Size = new Vector2(90, 90) }; + + tickSliderBar = beatDivisorControl.ChildrenOfType>().Single(); + tickMarkerHead = tickSliderBar.ChildrenOfType().Single(); }); [Test] public void TestBindableBeatDivisor() { - AddRepeatStep("Move previous", () => bindableBeatDivisor.Previous(), 4); - AddAssert("Position at 4", () => bindableBeatDivisor.Value == 4); - AddRepeatStep("Move next", () => bindableBeatDivisor.Next(), 3); - AddAssert("Position at 12", () => bindableBeatDivisor.Value == 12); + AddRepeatStep("move previous", () => bindableBeatDivisor.Previous(), 4); + AddAssert("divisor is 4", () => bindableBeatDivisor.Value == 4); + AddRepeatStep("move next", () => bindableBeatDivisor.Next(), 3); + AddAssert("divisor is 12", () => bindableBeatDivisor.Value == 12); } [Test] public void TestMouseInput() { - AddStep("Move to marker", () => + AddStep("hold marker", () => { - InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18)); + InputManager.MoveMouseTo(tickMarkerHead.ScreenSpaceDrawQuad.Centre); InputManager.PressButton(MouseButton.Left); }); - AddStep("Mote to divisor 8", () => + AddStep("move to 8 and release", () => { - InputManager.MoveMouseTo(beatDivisorControl, new Vector2(0, -18)); + InputManager.MoveMouseTo(tickSliderBar.ScreenSpaceDrawQuad.Centre); InputManager.ReleaseButton(MouseButton.Left); }); - AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8); - AddStep("Prepare to move marker", () => { InputManager.PressButton(MouseButton.Left); }); - AddStep("Trigger marker jump", () => + AddAssert("divisor is 8", () => bindableBeatDivisor.Value == 8); + AddStep("hold marker", () => InputManager.PressButton(MouseButton.Left)); + AddStep("move to 16", () => InputManager.MoveMouseTo(getPositionForDivisor(16))); + AddStep("move to ~10 and release", () => { - InputManager.MoveMouseTo(beatDivisorControl, new Vector2(30, -18)); - }); - AddStep("Move to divisor ~10", () => - { - InputManager.MoveMouseTo(beatDivisorControl, new Vector2(10, -18)); + InputManager.MoveMouseTo(getPositionForDivisor(10)); InputManager.ReleaseButton(MouseButton.Left); }); - AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8); + AddAssert("divisor clamped to 8", () => bindableBeatDivisor.Value == 8); + } + + private Vector2 getPositionForDivisor(int divisor) + { + var relativePosition = (float)Math.Clamp(divisor, 0, 16) / 16; + var sliderDrawQuad = tickSliderBar.ScreenSpaceDrawQuad; + return new Vector2( + sliderDrawQuad.TopLeft.X + sliderDrawQuad.Width * relativePosition, + sliderDrawQuad.Centre.Y + ); } } } From 8f9e97b4ccbec6e9de72dba2fca7bfe29e1b7b88 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Mar 2020 18:07:39 +0900 Subject: [PATCH 26/54] Fix carousel not remembering last selection correctly --- osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs index 045c682dc3..6ce12f7b89 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs @@ -104,7 +104,8 @@ namespace osu.Game.Screens.Select.Carousel private void updateSelected(CarouselItem newSelection) { - LastSelected = newSelection; + if (newSelection != null) + LastSelected = newSelection; updateSelectedIndex(); } From 3a50c4bb51bf0377ad51e830656ef2a24c32417f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Mar 2020 18:58:22 +0900 Subject: [PATCH 27/54] Update tests --- .../SongSelect/TestSceneBeatmapCarousel.cs | 86 +++++++++++++++---- 1 file changed, 69 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 8df75c78f5..c2534e2cc7 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -419,7 +419,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] - public void TestCarouselRootIsRandom() + public void TestCarouselRemembersSelection() { List manySets = new List(); @@ -429,12 +429,74 @@ namespace osu.Game.Tests.Visual.SongSelect loadBeatmaps(manySets); advanceSelection(direction: 1, diff: false); - checkNonmatchingFilter(); - checkNonmatchingFilter(); - checkNonmatchingFilter(); - checkNonmatchingFilter(); - checkNonmatchingFilter(); - AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1); + + for (int i = 0; i < 5; i++) + { + AddStep("Toggle non-matching filter", () => + { + carousel.Filter(new FilterCriteria { SearchText = Guid.NewGuid().ToString() }, false); + }); + + AddStep("Restore no filter", () => + { + carousel.Filter(new FilterCriteria(), false); + eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); + }); + } + + // always returns to same selection as long as it's available. + AddAssert("Selection was remembered", () => eagerSelectedIDs.Count == 1); + } + + [Test] + public void TestRandomFallbackOnNonMatchingPrevious() + { + List manySets = new List(); + + AddStep("populate maps", () => + { + for (int i = 0; i < 10; i++) + { + var set = createTestBeatmapSet(i); + + foreach (var b in set.Beatmaps) + { + // all taiko except for first + int ruleset = i > 0 ? 1 : 0; + + b.Ruleset = rulesets.GetRuleset(ruleset); + b.RulesetID = ruleset; + } + + manySets.Add(set); + } + }); + + loadBeatmaps(manySets); + + for (int i = 0; i < 10; i++) + { + AddStep("Reset filter", () => carousel.Filter(new FilterCriteria(), false)); + + AddStep("select first beatmap", () => carousel.SelectBeatmap(manySets.First().Beatmaps.First())); + + AddStep("Toggle non-matching filter", () => + { + carousel.Filter(new FilterCriteria { SearchText = Guid.NewGuid().ToString() }, false); + }); + + AddAssert("selection lost", () => carousel.SelectedBeatmap == null); + + AddStep("Restore different ruleset filter", () => + { + carousel.Filter(new FilterCriteria { Ruleset = rulesets.GetRuleset(1) }, false); + eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); + }); + + AddAssert("selection changed", () => carousel.SelectedBeatmap != manySets.First().Beatmaps.First()); + } + + AddAssert("Selection was random", () => eagerSelectedIDs.Count > 2); } [Test] @@ -593,16 +655,6 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("Selection is visible", selectedBeatmapVisible); } - private void checkNonmatchingFilter() - { - AddStep("Toggle non-matching filter", () => - { - carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false); - carousel.Filter(new FilterCriteria(), false); - eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); - }); - } - private BeatmapSetInfo createTestBeatmapSet(int id) { return new BeatmapSetInfo From be4a97c2894282c794c763f269dcdb991aacf512 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Mar 2020 13:01:24 +0900 Subject: [PATCH 28/54] Correctly bypass last selected when it is filtered --- osu.Game/Screens/Select/BeatmapCarousel.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 9f8b201eff..389ae918b9 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -333,8 +333,7 @@ namespace osu.Game.Screens.Select else set = visibleSets.ElementAt(RNG.Next(visibleSets.Count)); - var visibleBeatmaps = set.Beatmaps.Where(s => !s.Filtered.Value).ToList(); - select(visibleBeatmaps[RNG.Next(visibleBeatmaps.Count)]); + select(set); return true; } @@ -756,7 +755,7 @@ namespace osu.Game.Screens.Select protected override void PerformSelection() { - if (LastSelected == null) + if (LastSelected == null || LastSelected.Filtered.Value) carousel.SelectNextRandom(); else base.PerformSelection(); From 9b60b535e596c051c353400f5feeb68e4562fa5c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Mar 2020 15:01:26 +0900 Subject: [PATCH 29/54] Fix selection not occurring when switching from empty ruleset on first load --- .../SongSelect/TestSceneBeatmapCarousel.cs | 32 +++++++++++++++++-- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 +++- osu.Game/Screens/Select/SongSelect.cs | 3 ++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 8df75c78f5..bd26120da9 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -227,6 +227,32 @@ namespace osu.Game.Tests.Visual.SongSelect waitForSelection(set_count); } + [Test] + public void TestSelectionEnteringFromEmptyRuleset() + { + var sets = new List(); + + AddStep("Create beatmaps for taiko only", () => + { + var rulesetBeatmapSet = createTestBeatmapSet(1); + var taikoRuleset = rulesets.AvailableRulesets.ElementAt(1); + rulesetBeatmapSet.Beatmaps.ForEach(b => + { + b.Ruleset = taikoRuleset; + b.RulesetID = 1; + }); + + sets.Add(rulesetBeatmapSet); + }); + + loadBeatmaps(sets, () => new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }); + + AddStep("Set non-empty mode filter", () => + carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(1) }, false)); + + AddAssert("Something is selected", () => carousel.SelectedBeatmap != null); + } + /// /// Test sorting /// @@ -399,7 +425,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("filter to ruleset 0", () => carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false)); AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false)); - AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmap == null); + AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmap.RulesetID == 0); AddStep("remove mixed set", () => { @@ -484,7 +510,7 @@ namespace osu.Game.Tests.Visual.SongSelect checkVisibleItemCount(true, 15); } - private void loadBeatmaps(List beatmapSets = null) + private void loadBeatmaps(List beatmapSets = null, Func initialCriteria = null) { createCarousel(); @@ -499,7 +525,7 @@ namespace osu.Game.Tests.Visual.SongSelect bool changed = false; AddStep($"Load {(beatmapSets.Count > 0 ? beatmapSets.Count.ToString() : "some")} beatmaps", () => { - carousel.Filter(new FilterCriteria()); + carousel.Filter(initialCriteria?.Invoke() ?? new FilterCriteria()); carousel.BeatmapSetsChanged = () => changed = true; carousel.BeatmapSets = beatmapSets; }); diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 9f8b201eff..6c6f9a0e79 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -751,13 +751,17 @@ namespace osu.Game.Screens.Select public CarouselRoot(BeatmapCarousel carousel) { + // root should always remaing selected. if not, PerformSelection will not be called. + State.Value = CarouselItemState.Selected; + State.ValueChanged += state => State.Value = CarouselItemState.Selected; + this.carousel = carousel; } protected override void PerformSelection() { if (LastSelected == null) - carousel.SelectNextRandom(); + carousel?.SelectNextRandom(); else base.PerformSelection(); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 11c680bdb0..b6ec40ab88 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -150,6 +150,7 @@ namespace osu.Game.Screens.Select }, Child = Carousel = new BeatmapCarousel { + AllowSelection = false, // delay any selection until our bindables are ready to make a good choice. Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, RelativeSizeAxes = Axes.Both, @@ -655,6 +656,8 @@ namespace osu.Game.Screens.Select { bindBindables(); + Carousel.AllowSelection = true; + // If a selection was already obtained, do not attempt to update the selected beatmap. if (Carousel.SelectedBeatmapSet != null) return; From 8136ea561e689786be2b5938fec47bdffc495d8c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Mar 2020 15:02:13 +0900 Subject: [PATCH 30/54] Fix a couple of broken tests --- .../Background/TestSceneUserDimBackgrounds.cs | 1 + .../Visual/SongSelect/TestSceneBeatmapCarousel.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index b51555db3e..1ddc1326d5 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -278,6 +278,7 @@ namespace osu.Game.Tests.Visual.Background private void setupUserSettings() { + AddUntilStep("Song select is current", () => songSelect.IsCurrentScreen()); AddUntilStep("Song select has selection", () => songSelect.Carousel?.SelectedBeatmap != null); AddStep("Set default user settings", () => { diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index bd26120da9..5b4c57e28f 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -432,13 +432,18 @@ namespace osu.Game.Tests.Visual.SongSelect carousel.RemoveBeatmapSet(testMixed); testMixed = null; }); - var testSingle = createTestBeatmapSet(set_count + 2); - testSingle.Beatmaps.ForEach(b => + BeatmapSetInfo testSingle = null; + AddStep("add single ruleset beatmapset", () => { - b.Ruleset = rulesets.AvailableRulesets.ElementAt(1); - b.RulesetID = b.Ruleset.ID ?? 1; + testSingle = createTestBeatmapSet(set_count + 2); + testSingle.Beatmaps.ForEach(b => + { + b.Ruleset = rulesets.AvailableRulesets.ElementAt(1); + b.RulesetID = b.Ruleset.ID ?? 1; + }); + + carousel.UpdateBeatmapSet(testSingle); }); - AddStep("add single ruleset beatmapset", () => carousel.UpdateBeatmapSet(testSingle)); AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testSingle.Beatmaps[0], false)); checkNoSelection(); AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle)); From 29009c85c01ad1729d54f25137e8ae6eb18b6d5b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Mar 2020 00:32:53 +0900 Subject: [PATCH 31/54] Fix typo in comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Bartłomiej Dach --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 6c6f9a0e79..739f99d72d 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -751,7 +751,7 @@ namespace osu.Game.Screens.Select public CarouselRoot(BeatmapCarousel carousel) { - // root should always remaing selected. if not, PerformSelection will not be called. + // root should always remain selected. if not, PerformSelection will not be called. State.Value = CarouselItemState.Selected; State.ValueChanged += state => State.Value = CarouselItemState.Selected; From d8041a0dcbfc5929c3244b686c959fa78a25857a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Mar 2020 02:16:28 +0900 Subject: [PATCH 32/54] Increase sample concurrency to better match stable --- osu.Game/OsuGameBase.cs | 4 ++++ osu.Game/Rulesets/UI/DrawableRuleset.cs | 1 + osu.Game/Skinning/LegacySkin.cs | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 3c7ab27651..5487bd9320 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -47,6 +47,8 @@ namespace osu.Game { public const string CLIENT_STREAM_NAME = "lazer"; + public const int SAMPLE_CONCURRENCY = 6; + protected OsuConfigManager LocalConfig; protected BeatmapManager BeatmapManager; @@ -153,6 +155,8 @@ namespace osu.Game AddFont(Resources, @"Fonts/Venera-Bold"); AddFont(Resources, @"Fonts/Venera-Black"); + Audio.Samples.PlaybackConcurrency = SAMPLE_CONCURRENCY; + runMigrations(); dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore(Resources, "Skins/Legacy"))); diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index e624fb80fa..d0a2722f58 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -158,6 +158,7 @@ namespace osu.Game.Rulesets.UI dependencies.Cache(textureStore); localSampleStore = dependencies.Get().GetSampleStore(new NamespacedResourceStore(resources, "Samples")); + localSampleStore.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY; dependencies.CacheAs(new FallbackSampleStore(localSampleStore, dependencies.Get())); } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 29bcd2e210..c71a321e74 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -52,7 +52,11 @@ namespace osu.Game.Skinning if (storage != null) { - Samples = audioManager?.GetSampleStore(storage); + var samples = audioManager?.GetSampleStore(storage); + if (samples != null) + samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY; + + Samples = samples; Textures = new TextureStore(new TextureLoaderStore(storage)); (storage as ResourceStore)?.AddExtension("ogg"); From d241f7c55fece40263c582e0dd6f89ceb3a60d2e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Mar 2020 20:32:55 +0300 Subject: [PATCH 33/54] Better variable naming --- osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index 55a5081435..c2f0917e29 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -171,9 +171,9 @@ namespace osu.Game.Overlays.Dashboard.Friends if (itemsPlaceholder.Any()) loading.Show(); - var groupedUsers = onlineStatusControl.Current.Value?.Users ?? new List(); + var usersInCurrentGroup = onlineStatusControl.Current.Value?.Users ?? new List(); - var sortedUsers = sortUsers(groupedUsers); + var sortedUsers = sortUsers(usersInCurrentGroup); LoadComponentAsync(createTable(sortedUsers), addContentToPlaceholder, (cancellationToken = new CancellationTokenSource()).Token); } From 2b0c267cb902a8c9667a7e6afba57fb351fb1deb Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 21 Mar 2020 20:37:21 +0300 Subject: [PATCH 34/54] Expose Fetch method --- osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs | 5 +---- osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs index e6b2a41c1c..1d8238dd40 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -10,7 +10,6 @@ using osu.Game.Users; using osu.Game.Overlays; using osu.Framework.Allocation; using NUnit.Framework; -using osu.Game.Online.API; namespace osu.Game.Tests.Visual.Online { @@ -28,9 +27,6 @@ namespace osu.Game.Tests.Visual.Online [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); - [Resolved] - private IAPIProvider api { get; set; } - private FriendsLayout layout; [SetUp] @@ -52,6 +48,7 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestOnline() { + AddStep("Fetch online", () => layout?.Fetch()); } private List getUsers() => new List diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index c2f0917e29..94c8230d8e 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -25,8 +25,6 @@ namespace osu.Game.Overlays.Dashboard.Friends get => users; set { - request?.Cancel(); - users = value; onlineStatusControl.Populate(value); @@ -152,7 +150,10 @@ namespace osu.Game.Overlays.Dashboard.Friends onlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels()); userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels()); + } + public void Fetch() + { if (!api.IsLoggedIn) return; From 19b6e496efbc0dddc8abb4af66a002e98a130512 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Mar 2020 04:17:04 +0900 Subject: [PATCH 35/54] Fix (very) long spinners degrading in performance due to high transform count --- osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs index e3dd2b1b4f..3de30d51d9 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -126,7 +126,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces .FadeTo(tracking_alpha, 250, Easing.OutQuint); } - this.RotateTo(currentRotation / 2, validAndTracking ? 500 : 1500, Easing.OutExpo); + Rotation = (float)Interpolation.Lerp(Rotation, currentRotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1)); } } } From 9482fc5b9990af7a53611539332e81cc1d5d79d5 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 22 Mar 2020 20:13:54 +0300 Subject: [PATCH 36/54] Refactor grouping logic --- .../Dashboard/Friends/FriendsBundle.cs | 11 +++------- .../Dashboard/Friends/FriendsLayout.cs | 20 ++++++++++++++++--- .../Friends/FriendsOnlineStatusControl.cs | 9 ++++++--- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs index 772d9c67a0..d5fad1ffd3 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs @@ -1,23 +1,18 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; -using osu.Game.Users; - namespace osu.Game.Overlays.Dashboard.Friends { public class FriendsBundle { public FriendsOnlineStatus Status { get; } - public int Count => Users.Count; + public int Count { get; } - public List Users { get; } - - public FriendsBundle(FriendsOnlineStatus status, List users) + public FriendsBundle(FriendsOnlineStatus status, int count) { Status = status; - Users = users; + Count = count; } } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs index 94c8230d8e..3514bf7ff7 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs @@ -172,13 +172,27 @@ namespace osu.Game.Overlays.Dashboard.Friends if (itemsPlaceholder.Any()) loading.Show(); - var usersInCurrentGroup = onlineStatusControl.Current.Value?.Users ?? new List(); - - var sortedUsers = sortUsers(usersInCurrentGroup); + var sortedUsers = sortUsers(getUsersInCurrentGroup()); LoadComponentAsync(createTable(sortedUsers), addContentToPlaceholder, (cancellationToken = new CancellationTokenSource()).Token); } + private List getUsersInCurrentGroup() + { + switch (onlineStatusControl.Current.Value?.Status) + { + default: + case FriendsOnlineStatus.All: + return users; + + case FriendsOnlineStatus.Offline: + return users.Where(u => !u.IsOnline).ToList(); + + case FriendsOnlineStatus.Online: + return users.Where(u => u.IsOnline).ToList(); + } + } + private void addContentToPlaceholder(Drawable content) { loading.Hide(); diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs index 88035e0a34..c54e9e2a06 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs @@ -15,9 +15,12 @@ namespace osu.Game.Overlays.Dashboard.Friends { Clear(); - AddItem(new FriendsBundle(FriendsOnlineStatus.All, users)); - AddItem(new FriendsBundle(FriendsOnlineStatus.Online, users.Where(u => u.IsOnline).ToList())); - AddItem(new FriendsBundle(FriendsOnlineStatus.Offline, users.Where(u => !u.IsOnline).ToList())); + var userCount = users.Count; + var onlineUsersCount = users.Count(user => user.IsOnline); + + AddItem(new FriendsBundle(FriendsOnlineStatus.All, userCount)); + AddItem(new FriendsBundle(FriendsOnlineStatus.Online, onlineUsersCount)); + AddItem(new FriendsBundle(FriendsOnlineStatus.Offline, userCount - onlineUsersCount)); Current.Value = Items.FirstOrDefault(); } From 97076325c46f8f734da5fa50cceaab7ea3747cf0 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 23 Mar 2020 01:45:13 +0300 Subject: [PATCH 37/54] Fix test scenes using framework-testing-specifc test scene --- .../TestSceneHitCircleArea.cs | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs index 67b6dac787..394d959d0a 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs @@ -4,13 +4,13 @@ using System; using NUnit.Framework; using osu.Framework.Graphics; -using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; +using osu.Game.Tests.Visual; using osuTK; namespace osu.Game.Rulesets.Osu.Tests @@ -22,30 +22,25 @@ namespace osu.Game.Rulesets.Osu.Tests private DrawableHitCircle.HitReceptor hitAreaReceptor => drawableHitCircle.HitArea; [SetUp] - public new void SetUp() + public void SetUp() => Schedule(() => { - base.SetUp(); - - Schedule(() => + hitCircle = new HitCircle { - hitCircle = new HitCircle - { - Position = new Vector2(100, 100), - StartTime = Time.Current + 500 - }; + Position = new Vector2(100, 100), + StartTime = Time.Current + 500 + }; - hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); + hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); - Child = new SkinProvidingContainer(new DefaultSkin()) + Child = new SkinProvidingContainer(new DefaultSkin()) + { + RelativeSizeAxes = Axes.Both, + Child = drawableHitCircle = new DrawableHitCircle(hitCircle) { - RelativeSizeAxes = Axes.Both, - Child = drawableHitCircle = new DrawableHitCircle(hitCircle) - { - Size = new Vector2(100) - } - }; - }); - } + Size = new Vector2(100) + } + }; + }); [Test] public void TestCircleHitCentre() From 0b728f483fb1d2934a629387fe936ff9fba84d8f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Mar 2020 10:01:33 +0900 Subject: [PATCH 38/54] Rename base test class to help avoid incorrect reference --- osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs | 2 +- osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs | 2 +- osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs | 2 +- .../Visual/Background/TestSceneUserDimBackgrounds.cs | 2 +- osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs | 2 +- osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs | 2 +- .../Visual/Editor/TestSceneZoomableScrollContainer.cs | 2 +- .../Visual/Gameplay/TestSceneGameplayMenuOverlay.cs | 2 +- osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs | 2 +- osu.Game.Tests/Visual/Gameplay/TestSceneHoldForMenuButton.cs | 2 +- osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs | 2 +- osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs | 2 +- osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs | 2 +- .../Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs | 2 +- osu.Game.Tests/Visual/Navigation/OsuGameTestScene.cs | 2 +- osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs | 2 +- osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs | 2 +- osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs | 2 +- .../Visual/UserInterface/TestSceneDeleteLocalScore.cs | 2 +- .../Visual/UserInterface/TestSceneOsuHoverContainer.cs | 2 +- .../Visual/UserInterface/TestSceneStatefulMenuItem.cs | 2 +- osu.Game.Tests/Visual/UserInterface/TestSceneSwitchButton.cs | 2 +- ...tManagerTestScene.cs => OsuManualInputManagerTestScene.cs} | 4 ++-- osu.Game/Tests/Visual/ScreenTestScene.cs | 2 +- osu.Game/Tests/Visual/SelectionBlueprintTestScene.cs | 2 +- 25 files changed, 26 insertions(+), 26 deletions(-) rename osu.Game/Tests/Visual/{ManualInputManagerTestScene.cs => OsuManualInputManagerTestScene.cs} (97%) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs index 394d959d0a..0649989dc0 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleArea.cs @@ -15,7 +15,7 @@ using osuTK; namespace osu.Game.Rulesets.Osu.Tests { - public class TestSceneHitCircleArea : ManualInputManagerTestScene + public class TestSceneHitCircleArea : OsuManualInputManagerTestScene { private HitCircle hitCircle; private DrawableHitCircle drawableHitCircle; diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs index 4af4d5f966..0ae49790cd 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuDistanceSnapGrid.cs @@ -23,7 +23,7 @@ using osuTK.Graphics; namespace osu.Game.Rulesets.Osu.Tests { - public class TestSceneOsuDistanceSnapGrid : ManualInputManagerTestScene + public class TestSceneOsuDistanceSnapGrid : OsuManualInputManagerTestScene { private const double beat_length = 100; private static readonly Vector2 grid_position = new Vector2(512, 384); diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs index 8e73d6152f..f4809b0c9b 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs @@ -12,7 +12,7 @@ using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Osu.Tests { - public class TestSceneResumeOverlay : ManualInputManagerTestScene + public class TestSceneResumeOverlay : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index b51555db3e..c906f21e22 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -37,7 +37,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.Background { [TestFixture] - public class TestSceneUserDimBackgrounds : ManualInputManagerTestScene + public class TestSceneUserDimBackgrounds : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs index 55aaeed8bf..4d64c7d35d 100644 --- a/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs +++ b/osu.Game.Tests/Visual/Components/TestSceneIdleTracker.cs @@ -12,7 +12,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.Components { [TestFixture] - public class TestSceneIdleTracker : ManualInputManagerTestScene + public class TestSceneIdleTracker : OsuManualInputManagerTestScene { private IdleTrackingBox box1; private IdleTrackingBox box2; diff --git a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs index 746b2c99aa..fd7a5980f3 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneBeatDivisorControl.cs @@ -16,7 +16,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Editor { - public class TestSceneBeatDivisorControl : ManualInputManagerTestScene + public class TestSceneBeatDivisorControl : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { typeof(BindableBeatDivisor) }; private BeatDivisorControl beatDivisorControl; diff --git a/osu.Game.Tests/Visual/Editor/TestSceneZoomableScrollContainer.cs b/osu.Game.Tests/Visual/Editor/TestSceneZoomableScrollContainer.cs index fd248abbc9..19d19c2759 100644 --- a/osu.Game.Tests/Visual/Editor/TestSceneZoomableScrollContainer.cs +++ b/osu.Game.Tests/Visual/Editor/TestSceneZoomableScrollContainer.cs @@ -17,7 +17,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.Editor { - public class TestSceneZoomableScrollContainer : ManualInputManagerTestScene + public class TestSceneZoomableScrollContainer : OsuManualInputManagerTestScene { private ZoomableScrollContainer scrollContainer; private Drawable innerBox; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs index c1635ffc83..ea3e0c2293 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs @@ -18,7 +18,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { [Description("player pause/fail screens")] - public class TestSceneGameplayMenuOverlay : ManualInputManagerTestScene + public class TestSceneGameplayMenuOverlay : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { typeof(FailOverlay), typeof(PauseOverlay) }; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs index fc03dc6ed3..c192a7b0e0 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs @@ -15,7 +15,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { - public class TestSceneHUDOverlay : ManualInputManagerTestScene + public class TestSceneHUDOverlay : OsuManualInputManagerTestScene { private HUDOverlay hudOverlay; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHoldForMenuButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHoldForMenuButton.cs index 0c5ead10cf..235842acc9 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHoldForMenuButton.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHoldForMenuButton.cs @@ -13,7 +13,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { [Description("'Hold to Quit' UI element")] - public class TestSceneHoldForMenuButton : ManualInputManagerTestScene + public class TestSceneHoldForMenuButton : OsuManualInputManagerTestScene { private bool exitAction; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs index 227ada70fe..593dcd245c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs @@ -13,7 +13,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { [TestFixture] - public class TestSceneKeyCounter : ManualInputManagerTestScene + public class TestSceneKeyCounter : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index 175f909a5a..4c73065087 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -29,7 +29,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { - public class TestScenePlayerLoader : ManualInputManagerTestScene + public class TestScenePlayerLoader : OsuManualInputManagerTestScene { private TestPlayerLoader loader; private TestPlayerLoaderContainer container; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs index 4c5c18f38a..6a0f86fe53 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkipOverlay.cs @@ -14,7 +14,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { [TestFixture] - public class TestSceneSkipOverlay : ManualInputManagerTestScene + public class TestSceneSkipOverlay : OsuManualInputManagerTestScene { private SkipOverlay skip; private int requestCount; diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs index 9fbe8f7ffe..713ba13439 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs @@ -20,7 +20,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Multiplayer { - public class TestSceneDrawableRoomPlaylist : ManualInputManagerTestScene + public class TestSceneDrawableRoomPlaylist : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/Navigation/OsuGameTestScene.cs b/osu.Game.Tests/Visual/Navigation/OsuGameTestScene.cs index 0d64eb651f..31afce86ae 100644 --- a/osu.Game.Tests/Visual/Navigation/OsuGameTestScene.cs +++ b/osu.Game.Tests/Visual/Navigation/OsuGameTestScene.cs @@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual.Navigation /// /// A scene which tests full game flow. /// - public abstract class OsuGameTestScene : ManualInputManagerTestScene + public abstract class OsuGameTestScene : OsuManualInputManagerTestScene { private GameHost host; diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs index 6665452d94..14924dda21 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs @@ -22,7 +22,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.Online { - public class TestSceneChatOverlay : ManualInputManagerTestScene + public class TestSceneChatOverlay : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs index 7b0b644dab..cef04a4c18 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneCommentEditor.cs @@ -15,7 +15,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneCommentEditor : ManualInputManagerTestScene + public class TestSceneCommentEditor : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs index d1dde4664a..5b74852259 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneCursors.cs @@ -17,7 +17,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface { [TestFixture] - public class TestSceneCursors : ManualInputManagerTestScene + public class TestSceneCursors : OsuManualInputManagerTestScene { private readonly MenuCursorContainer menuCursorContainer; private readonly CustomCursorBox[] cursorBoxes = new CustomCursorBox[6]; diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs index 1e5e26e4c5..a812b4dc79 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs @@ -27,7 +27,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneDeleteLocalScore : ManualInputManagerTestScene + public class TestSceneDeleteLocalScore : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs index dbef7d1686..396bec51b6 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuHoverContainer.cs @@ -12,7 +12,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.UserInterface { [TestFixture] - public class TestSceneOsuHoverContainer : ManualInputManagerTestScene + public class TestSceneOsuHoverContainer : OsuManualInputManagerTestScene { private OsuHoverTestContainer hoverContainer; private Box colourContainer; diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneStatefulMenuItem.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneStatefulMenuItem.cs index 2ada5b927b..85fea73bf5 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneStatefulMenuItem.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneStatefulMenuItem.cs @@ -12,7 +12,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneStatefulMenuItem : ManualInputManagerTestScene + public class TestSceneStatefulMenuItem : OsuManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneSwitchButton.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneSwitchButton.cs index 4a104b4a41..37fab75aee 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneSwitchButton.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneSwitchButton.cs @@ -9,7 +9,7 @@ using osuTK.Input; namespace osu.Game.Tests.Visual.UserInterface { - public class TestSceneSwitchButton : ManualInputManagerTestScene + public class TestSceneSwitchButton : OsuManualInputManagerTestScene { private SwitchButton switchButton; diff --git a/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs b/osu.Game/Tests/Visual/OsuManualInputManagerTestScene.cs similarity index 97% rename from osu.Game/Tests/Visual/ManualInputManagerTestScene.cs rename to osu.Game/Tests/Visual/OsuManualInputManagerTestScene.cs index a0af07013c..0da3ae7f87 100644 --- a/osu.Game/Tests/Visual/ManualInputManagerTestScene.cs +++ b/osu.Game/Tests/Visual/OsuManualInputManagerTestScene.cs @@ -14,7 +14,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual { - public abstract class ManualInputManagerTestScene : OsuTestScene + public abstract class OsuManualInputManagerTestScene : OsuTestScene { protected override Container Content => content; private readonly Container content; @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual private readonly TriangleButton buttonTest; private readonly TriangleButton buttonLocal; - protected ManualInputManagerTestScene() + protected OsuManualInputManagerTestScene() { base.Content.AddRange(new Drawable[] { diff --git a/osu.Game/Tests/Visual/ScreenTestScene.cs b/osu.Game/Tests/Visual/ScreenTestScene.cs index d26aacf2bc..33cc00e748 100644 --- a/osu.Game/Tests/Visual/ScreenTestScene.cs +++ b/osu.Game/Tests/Visual/ScreenTestScene.cs @@ -11,7 +11,7 @@ namespace osu.Game.Tests.Visual /// /// A test case which can be used to test a screen (that relies on OnEntering being called to execute startup instructions). /// - public abstract class ScreenTestScene : ManualInputManagerTestScene + public abstract class ScreenTestScene : OsuManualInputManagerTestScene { protected readonly OsuScreenStack Stack; diff --git a/osu.Game/Tests/Visual/SelectionBlueprintTestScene.cs b/osu.Game/Tests/Visual/SelectionBlueprintTestScene.cs index 6565f98666..1176361679 100644 --- a/osu.Game/Tests/Visual/SelectionBlueprintTestScene.cs +++ b/osu.Game/Tests/Visual/SelectionBlueprintTestScene.cs @@ -8,7 +8,7 @@ using osu.Game.Rulesets.Edit; namespace osu.Game.Tests.Visual { - public abstract class SelectionBlueprintTestScene : ManualInputManagerTestScene + public abstract class SelectionBlueprintTestScene : OsuManualInputManagerTestScene { protected override Container Content => content ?? base.Content; private readonly Container content; From 754d0ca14d43037c745c9a74a5ce8321bb0f195a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 23 Mar 2020 10:28:17 +0900 Subject: [PATCH 39/54] Fix crashes due to ladder re-use --- osu.Game.Tournament.Tests/LadderTestScene.cs | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tournament.Tests/LadderTestScene.cs b/osu.Game.Tournament.Tests/LadderTestScene.cs index 4477ca8338..b962d035ab 100644 --- a/osu.Game.Tournament.Tests/LadderTestScene.cs +++ b/osu.Game.Tournament.Tests/LadderTestScene.cs @@ -1,10 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Utils; using osu.Game.Beatmaps; +using osu.Game.Rulesets; using osu.Game.Tournament.Models; using osu.Game.Users; @@ -13,8 +15,20 @@ namespace osu.Game.Tournament.Tests [TestFixture] public abstract class LadderTestScene : TournamentTestScene { + [Cached] + protected LadderInfo Ladder { get; private set; } = new LadderInfo(); + [Resolved] - protected LadderInfo Ladder { get; private set; } + private RulesetStore rulesetStore { get; set; } + + [BackgroundDependencyLoader] + private void load() + { + if (Ladder.Ruleset.Value == null) + Ladder.Ruleset.Value = rulesetStore.AvailableRulesets.First(); + + Ruleset.BindTo(Ladder.Ruleset); + } protected override void LoadComplete() { @@ -22,13 +36,8 @@ namespace osu.Game.Tournament.Tests TournamentMatch match = CreateSampleMatch(); - Ladder.Rounds.Clear(); Ladder.Rounds.Add(match.Round.Value); - - Ladder.Matches.Clear(); Ladder.Matches.Add(match); - - Ladder.Teams.Clear(); Ladder.Teams.Add(match.Team1.Value); Ladder.Teams.Add(match.Team2.Value); From bfd643dd1659179186a5d26982b58bcbfcd3d5e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Mar 2020 10:47:27 +0900 Subject: [PATCH 40/54] Rename classes --- .../Visual/Online/TestSceneFriendsLayout.cs | 12 +++++------ .../TestSceneFriendsOnlineStatusControl.cs | 14 ++++++------- .../{FriendsLayout.cs => FriendDisplay.cs} | 20 +++++++++---------- ...ontrol.cs => FriendOnlineStreamControl.cs} | 10 +++++----- .../{FriendsBundle.cs => FriendStream.cs} | 13 +++--------- .../Friends/FriendsOnlineStatusItem.cs | 10 +++++----- .../Dashboard/Friends/OnlineStatus.cs | 12 +++++++++++ 7 files changed, 48 insertions(+), 43 deletions(-) rename osu.Game/Overlays/Dashboard/Friends/{FriendsLayout.cs => FriendDisplay.cs} (94%) rename osu.Game/Overlays/Dashboard/Friends/{FriendsOnlineStatusControl.cs => FriendOnlineStreamControl.cs} (53%) rename osu.Game/Overlays/Dashboard/Friends/{FriendsBundle.cs => FriendStream.cs} (57%) create mode 100644 osu.Game/Overlays/Dashboard/Friends/OnlineStatus.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs index 1d8238dd40..c0a617fe57 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs @@ -17,8 +17,8 @@ namespace osu.Game.Tests.Visual.Online { public override IReadOnlyList RequiredTypes => new[] { - typeof(FriendsLayout), - typeof(FriendsOnlineStatusControl), + typeof(FriendDisplay), + typeof(FriendOnlineStreamControl), typeof(UserListToolbar) }; @@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual.Online [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); - private FriendsLayout layout; + private FriendDisplay display; [SetUp] public void Setup() => Schedule(() => @@ -35,20 +35,20 @@ namespace osu.Game.Tests.Visual.Online Child = new BasicScrollContainer { RelativeSizeAxes = Axes.Both, - Child = layout = new FriendsLayout() + Child = display = new FriendDisplay() }; }); [Test] public void TestOffline() { - AddStep("Populate", () => layout.Users = getUsers()); + AddStep("Populate", () => display.Users = getUsers()); } [Test] public void TestOnline() { - AddStep("Fetch online", () => layout?.Fetch()); + AddStep("Fetch online", () => display?.Fetch()); } private List getUsers() => new List diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs index d72818ed89..f6dcf78d55 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneFriendsOnlineStatusControl.cs @@ -17,20 +17,20 @@ namespace osu.Game.Tests.Visual.UserInterface { public override IReadOnlyList RequiredTypes => new[] { - typeof(FriendsOnlineStatusControl), + typeof(FriendOnlineStreamControl), typeof(FriendsOnlineStatusItem), typeof(OverlayStreamControl<>), typeof(OverlayStreamItem<>), - typeof(FriendsBundle) + typeof(FriendStream) }; [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - private FriendsOnlineStatusControl control; + private FriendOnlineStreamControl control; [SetUp] - public void SetUp() => Schedule(() => Child = control = new FriendsOnlineStatusControl + public void SetUp() => Schedule(() => Child = control = new FriendOnlineStreamControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -55,9 +55,9 @@ namespace osu.Game.Tests.Visual.UserInterface } })); - AddAssert("3 users", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.All)?.Count == 3); - AddAssert("1 online user", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.Online)?.Count == 1); - AddAssert("2 offline users", () => control.Items.FirstOrDefault(item => item.Status == FriendsOnlineStatus.Offline)?.Count == 2); + AddAssert("3 users", () => control.Items.FirstOrDefault(item => item.Status == OnlineStatus.All)?.Count == 3); + AddAssert("1 online user", () => control.Items.FirstOrDefault(item => item.Status == OnlineStatus.Online)?.Count == 1); + AddAssert("2 offline users", () => control.Items.FirstOrDefault(item => item.Status == OnlineStatus.Offline)?.Count == 2); } } } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs b/osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs similarity index 94% rename from osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs rename to osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs index 3514bf7ff7..3c9b31daae 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsLayout.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendDisplay.cs @@ -16,7 +16,7 @@ using osuTK; namespace osu.Game.Overlays.Dashboard.Friends { - public class FriendsLayout : CompositeDrawable + public class FriendDisplay : CompositeDrawable { private List users = new List(); @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { users = value; - onlineStatusControl.Populate(value); + onlineStreamControl.Populate(value); } } @@ -39,14 +39,14 @@ namespace osu.Game.Overlays.Dashboard.Friends private Drawable currentContent; - private readonly FriendsOnlineStatusControl onlineStatusControl; + private readonly FriendOnlineStreamControl onlineStreamControl; private readonly Box background; private readonly Box controlBackground; private readonly UserListToolbar userListToolbar; private readonly Container itemsPlaceholder; private readonly LoadingLayer loading; - public FriendsLayout() + public FriendDisplay() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Dashboard.Friends Top = 20, Horizontal = 45 }, - Child = onlineStatusControl = new FriendsOnlineStatusControl(), + Child = onlineStreamControl = new FriendOnlineStreamControl(), } } }, @@ -147,7 +147,7 @@ namespace osu.Game.Overlays.Dashboard.Friends { base.LoadComplete(); - onlineStatusControl.Current.BindValueChanged(_ => recreatePanels()); + onlineStreamControl.Current.BindValueChanged(_ => recreatePanels()); userListToolbar.DisplayStyle.BindValueChanged(_ => recreatePanels()); userListToolbar.SortCriteria.BindValueChanged(_ => recreatePanels()); } @@ -179,16 +179,16 @@ namespace osu.Game.Overlays.Dashboard.Friends private List getUsersInCurrentGroup() { - switch (onlineStatusControl.Current.Value?.Status) + switch (onlineStreamControl.Current.Value?.Status) { default: - case FriendsOnlineStatus.All: + case OnlineStatus.All: return users; - case FriendsOnlineStatus.Offline: + case OnlineStatus.Offline: return users.Where(u => !u.IsOnline).ToList(); - case FriendsOnlineStatus.Online: + case OnlineStatus.Online: return users.Where(u => u.IsOnline).ToList(); } } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs b/osu.Game/Overlays/Dashboard/Friends/FriendOnlineStreamControl.cs similarity index 53% rename from osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs rename to osu.Game/Overlays/Dashboard/Friends/FriendOnlineStreamControl.cs index c54e9e2a06..28546ceab8 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendOnlineStreamControl.cs @@ -7,9 +7,9 @@ using osu.Game.Users; namespace osu.Game.Overlays.Dashboard.Friends { - public class FriendsOnlineStatusControl : OverlayStreamControl + public class FriendOnlineStreamControl : OverlayStreamControl { - protected override OverlayStreamItem CreateStreamItem(FriendsBundle value) => new FriendsOnlineStatusItem(value); + protected override OverlayStreamItem CreateStreamItem(FriendStream value) => new FriendsOnlineStatusItem(value); public void Populate(List users) { @@ -18,9 +18,9 @@ namespace osu.Game.Overlays.Dashboard.Friends var userCount = users.Count; var onlineUsersCount = users.Count(user => user.IsOnline); - AddItem(new FriendsBundle(FriendsOnlineStatus.All, userCount)); - AddItem(new FriendsBundle(FriendsOnlineStatus.Online, onlineUsersCount)); - AddItem(new FriendsBundle(FriendsOnlineStatus.Offline, userCount - onlineUsersCount)); + AddItem(new FriendStream(OnlineStatus.All, userCount)); + AddItem(new FriendStream(OnlineStatus.Online, onlineUsersCount)); + AddItem(new FriendStream(OnlineStatus.Offline, userCount - onlineUsersCount)); Current.Value = Items.FirstOrDefault(); } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs b/osu.Game/Overlays/Dashboard/Friends/FriendStream.cs similarity index 57% rename from osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs rename to osu.Game/Overlays/Dashboard/Friends/FriendStream.cs index d5fad1ffd3..4abece9a8d 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsBundle.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendStream.cs @@ -3,23 +3,16 @@ namespace osu.Game.Overlays.Dashboard.Friends { - public class FriendsBundle + public class FriendStream { - public FriendsOnlineStatus Status { get; } + public OnlineStatus Status { get; } public int Count { get; } - public FriendsBundle(FriendsOnlineStatus status, int count) + public FriendStream(OnlineStatus status, int count) { Status = status; Count = count; } } - - public enum FriendsOnlineStatus - { - All, - Online, - Offline - } } diff --git a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusItem.cs b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusItem.cs index eada9420ea..7e902203f8 100644 --- a/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusItem.cs +++ b/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusItem.cs @@ -7,9 +7,9 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Dashboard.Friends { - public class FriendsOnlineStatusItem : OverlayStreamItem + public class FriendsOnlineStatusItem : OverlayStreamItem { - public FriendsOnlineStatusItem(FriendsBundle value) + public FriendsOnlineStatusItem(FriendStream value) : base(value) { } @@ -22,13 +22,13 @@ namespace osu.Game.Overlays.Dashboard.Friends { switch (Value.Status) { - case FriendsOnlineStatus.All: + case OnlineStatus.All: return Color4.White; - case FriendsOnlineStatus.Online: + case OnlineStatus.Online: return colours.GreenLight; - case FriendsOnlineStatus.Offline: + case OnlineStatus.Offline: return Color4.Black; default: diff --git a/osu.Game/Overlays/Dashboard/Friends/OnlineStatus.cs b/osu.Game/Overlays/Dashboard/Friends/OnlineStatus.cs new file mode 100644 index 0000000000..6f2f55a6ed --- /dev/null +++ b/osu.Game/Overlays/Dashboard/Friends/OnlineStatus.cs @@ -0,0 +1,12 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Overlays.Dashboard.Friends +{ + public enum OnlineStatus + { + All, + Online, + Offline + } +} From bf70276496b072dad7009cb4b1c27848b7710edd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 23 Mar 2020 11:12:36 +0900 Subject: [PATCH 41/54] Fix test re-using the same beatmap sets --- osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 5b4c57e28f..6b4090ea58 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -234,6 +234,8 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("Create beatmaps for taiko only", () => { + sets.Clear(); + var rulesetBeatmapSet = createTestBeatmapSet(1); var taikoRuleset = rulesets.AvailableRulesets.ElementAt(1); rulesetBeatmapSet.Beatmaps.ForEach(b => From 27ae2d29aac6d10f13a696713d5a9de78b0056ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Mar 2020 11:47:24 +0900 Subject: [PATCH 42/54] Add ability to adjust (and save) chroma-key area width --- osu.Game.Tournament/Models/LadderInfo.cs | 8 +++++++- .../Screens/Gameplay/GameplayScreen.cs | 14 ++++++++++++-- osu.Game.Tournament/Screens/SetupScreen.cs | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tournament/Models/LadderInfo.cs b/osu.Game.Tournament/Models/LadderInfo.cs index 5db0b01547..c2e6da9ca5 100644 --- a/osu.Game.Tournament/Models/LadderInfo.cs +++ b/osu.Game.Tournament/Models/LadderInfo.cs @@ -24,7 +24,13 @@ namespace osu.Game.Tournament.Models // only used for serialisation public List Progressions = new List(); - [JsonIgnore] + [JsonIgnore] // updated manually in TournamentGameBase public Bindable CurrentMatch = new Bindable(); + + public Bindable ChromaKeyWidth = new BindableInt(1024) + { + MinValue = 640, + MaxValue = 1366, + }; } } diff --git a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs index 8920990d1b..64a5cd6dec 100644 --- a/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs +++ b/osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Platform; using osu.Framework.Threading; using osu.Game.Graphics.UserInterface; +using osu.Game.Overlays.Settings; using osu.Game.Tournament.Components; using osu.Game.Tournament.IPC; using osu.Game.Tournament.Models; @@ -35,6 +36,8 @@ namespace osu.Game.Tournament.Screens.Gameplay [Resolved] private TournamentMatchChatDisplay chat { get; set; } + private Box chroma; + [BackgroundDependencyLoader] private void load(LadderInfo ladder, MatchIPCInfo ipc, Storage storage) { @@ -60,11 +63,10 @@ namespace osu.Game.Tournament.Screens.Gameplay Origin = Anchor.TopCentre, Children = new Drawable[] { - new Box + chroma = new Box { // chroma key area for stable gameplay Name = "chroma", - RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Height = 512, @@ -93,6 +95,12 @@ namespace osu.Game.Tournament.Screens.Gameplay RelativeSizeAxes = Axes.X, Text = "Toggle chat", Action = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; } + }, + new SettingsSlider + { + LabelText = "Chroma Width", + Bindable = LadderInfo.ChromaKeyWidth, + KeyboardStep = 1, } } } @@ -101,6 +109,8 @@ namespace osu.Game.Tournament.Screens.Gameplay State.BindTo(ipc.State); State.BindValueChanged(stateChanged, true); + ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true); + currentMatch.BindValueChanged(m => { warmup.Value = m.NewValue.Team1Score.Value + m.NewValue.Team2Score.Value == 0; diff --git a/osu.Game.Tournament/Screens/SetupScreen.cs b/osu.Game.Tournament/Screens/SetupScreen.cs index b7f8b2bfd6..c91379b2d6 100644 --- a/osu.Game.Tournament/Screens/SetupScreen.cs +++ b/osu.Game.Tournament/Screens/SetupScreen.cs @@ -116,7 +116,7 @@ namespace osu.Game.Tournament.Screens { windowSize.Value = new Size((int)(1920 / TournamentSceneManager.STREAM_AREA_WIDTH * TournamentSceneManager.REQUIRED_WIDTH), 1080); } - } + }, }; } From 1b6342438f8cc54ff14dad811d54512c7e8af29b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Mar 2020 12:03:33 +0900 Subject: [PATCH 43/54] Hide scrollbars in tournament chat display --- .../Components/TournamentMatchChatDisplay.cs | 11 +++++++++++ osu.Game/Online/Chat/StandAloneChatDisplay.cs | 17 ++++++++++------- osu.Game/Overlays/Chat/DrawableChannel.cs | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs b/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs index 2a183d0d45..fe22d1e76d 100644 --- a/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs +++ b/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs @@ -70,6 +70,17 @@ namespace osu.Game.Tournament.Components protected override ChatLine CreateMessage(Message message) => new MatchMessage(message); + protected override StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => new MatchChannel(channel); + + public class MatchChannel : StandAloneDrawableChannel + { + public MatchChannel(Channel channel) + : base(channel) + { + ScrollbarVisible = false; + } + } + protected class MatchMessage : StandAloneMessage { public MatchMessage(Message message) diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs index 0914f688e9..4fbeac1db9 100644 --- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs +++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Online.Chat protected ChannelManager ChannelManager; - private DrawableChannel drawableChannel; + private StandAloneDrawableChannel drawableChannel; private readonly bool postingTextbox; @@ -77,6 +77,9 @@ namespace osu.Game.Online.Chat ChannelManager = manager; } + protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => + new StandAloneDrawableChannel(channel); + private void postMessage(TextBox sender, bool newtext) { var text = textbox.Text.Trim(); @@ -100,14 +103,14 @@ namespace osu.Game.Online.Chat if (e.NewValue == null) return; - AddInternal(drawableChannel = new StandAloneDrawableChannel(e.NewValue) - { - CreateChatLineAction = CreateMessage, - Padding = new MarginPadding { Bottom = postingTextbox ? textbox_height : 0 } - }); + drawableChannel = CreateDrawableChannel(e.NewValue); + drawableChannel.CreateChatLineAction = CreateMessage; + drawableChannel.Padding = new MarginPadding { Bottom = postingTextbox ? textbox_height : 0 }; + + AddInternal(drawableChannel); } - protected class StandAloneDrawableChannel : DrawableChannel + public class StandAloneDrawableChannel : DrawableChannel { public Func CreateChatLineAction; diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 443f2b7bf7..6019657cf0 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -26,6 +26,20 @@ namespace osu.Game.Overlays.Chat protected FillFlowContainer ChatLineFlow; private OsuScrollContainer scroll; + private bool scrollbarVisible = true; + + public bool ScrollbarVisible + { + set + { + if (scrollbarVisible == value) return; + + scrollbarVisible = value; + if (scroll != null) + scroll.ScrollbarVisible = value; + } + } + [Resolved] private OsuColour colours { get; set; } @@ -44,6 +58,7 @@ namespace osu.Game.Overlays.Chat Masking = true, Child = scroll = new OsuScrollContainer { + ScrollbarVisible = scrollbarVisible, RelativeSizeAxes = Axes.Both, // Some chat lines have effects that slightly protrude to the bottom, // which we do not want to mask away, hence the padding. From 5106d275ca1cf58f26897f1f962762fa8d6119c5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 23 Mar 2020 12:08:15 +0900 Subject: [PATCH 44/54] Remove CentreHit/RimHit hitobject abstraction --- .../Mods/TestSceneTaikoModPerfect.cs | 2 +- .../TaikoBeatmapConversionTest.cs | 4 +- .../TestSceneTaikoPlayfield.cs | 2 +- .../Beatmaps/TaikoBeatmapConverter.cs | 46 +++++-------------- .../Preprocessing/TaikoDifficultyHitObject.cs | 2 +- osu.Game.Rulesets.Taiko/Objects/CentreHit.cs | 9 ---- osu.Game.Rulesets.Taiko/Objects/Hit.cs | 4 ++ osu.Game.Rulesets.Taiko/Objects/HitType.cs | 21 +++++++++ osu.Game.Rulesets.Taiko/Objects/RimHit.cs | 9 ---- .../Replays/TaikoAutoGenerator.cs | 2 +- .../UI/DrawableTaikoRuleset.cs | 10 ++-- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 4 +- 12 files changed, 50 insertions(+), 65 deletions(-) delete mode 100644 osu.Game.Rulesets.Taiko/Objects/CentreHit.cs create mode 100644 osu.Game.Rulesets.Taiko/Objects/HitType.cs delete mode 100644 osu.Game.Rulesets.Taiko/Objects/RimHit.cs diff --git a/osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModPerfect.cs b/osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModPerfect.cs index d3be2cdf0d..26c90ad295 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModPerfect.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModPerfect.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods [TestCase(false)] [TestCase(true)] - public void TestHit(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new CentreHit { StartTime = 1000 }), shouldMiss); + public void TestHit(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Hit { StartTime = 1000, Type = HitType.Centre }), shouldMiss); [TestCase(false)] [TestCase(true)] diff --git a/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs b/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs index f23fd6d3f9..8c26ca70ac 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TaikoBeatmapConversionTest.cs @@ -27,8 +27,8 @@ namespace osu.Game.Rulesets.Taiko.Tests { StartTime = hitObject.StartTime, EndTime = hitObject.GetEndTime(), - IsRim = hitObject is RimHit, - IsCentre = hitObject is CentreHit, + IsRim = (hitObject as Hit)?.Type == HitType.Rim, + IsCentre = (hitObject as Hit)?.Type == HitType.Centre, IsDrumRoll = hitObject is DrumRoll, IsSwell = hitObject is Swell, IsStrong = ((TaikoHitObject)hitObject).IsStrong diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs index c01eef5252..0d9e813c60 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayfield.cs @@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Taiko.Tests WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap { - HitObjects = new List { new CentreHit() }, + HitObjects = new List { new Hit { Type = HitType.Centre } }, BeatmapInfo = new BeatmapInfo { BaseDifficulty = new BeatmapDifficulty(), diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index cc9d6e4470..695ada3a00 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -124,24 +124,13 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps bool isRim = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE); strong = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_FINISH); - if (isRim) + yield return new Hit { - yield return new RimHit - { - StartTime = j, - Samples = currentSamples, - IsStrong = strong - }; - } - else - { - yield return new CentreHit - { - StartTime = j, - Samples = currentSamples, - IsStrong = strong - }; - } + StartTime = j, + Type = isRim ? HitType.Rim : HitType.Centre, + Samples = currentSamples, + IsStrong = strong + }; i = (i + 1) % allSamples.Count; } @@ -180,24 +169,13 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps { bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE); - if (isRim) + yield return new Hit { - yield return new RimHit - { - StartTime = obj.StartTime, - Samples = obj.Samples, - IsStrong = strong - }; - } - else - { - yield return new CentreHit - { - StartTime = obj.StartTime, - Samples = obj.Samples, - IsStrong = strong - }; - } + StartTime = obj.StartTime, + Type = isRim ? HitType.Rim : HitType.Centre, + Samples = obj.Samples, + IsStrong = strong + }; break; } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs index 24345275c1..6807142327 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs @@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate) : base(hitObject, lastObject, clockRate) { - HasTypeChange = lastObject is RimHit != hitObject is RimHit; + HasTypeChange = (lastObject as Hit)?.Type != (hitObject as Hit)?.Type; } } } diff --git a/osu.Game.Rulesets.Taiko/Objects/CentreHit.cs b/osu.Game.Rulesets.Taiko/Objects/CentreHit.cs deleted file mode 100644 index a6354b16ed..0000000000 --- a/osu.Game.Rulesets.Taiko/Objects/CentreHit.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -namespace osu.Game.Rulesets.Taiko.Objects -{ - public class CentreHit : Hit - { - } -} diff --git a/osu.Game.Rulesets.Taiko/Objects/Hit.cs b/osu.Game.Rulesets.Taiko/Objects/Hit.cs index 6cc9357580..2aca701515 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Hit.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Hit.cs @@ -5,5 +5,9 @@ namespace osu.Game.Rulesets.Taiko.Objects { public class Hit : TaikoHitObject { + /// + /// The that actuates this . + /// + public HitType Type { get; set; } } } diff --git a/osu.Game.Rulesets.Taiko/Objects/HitType.cs b/osu.Game.Rulesets.Taiko/Objects/HitType.cs new file mode 100644 index 0000000000..17b3fdbd04 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Objects/HitType.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. + +namespace osu.Game.Rulesets.Taiko.Objects +{ + /// + /// The type of a . + /// + public enum HitType + { + /// + /// A that can be hit by the centre portion of the drum. + /// + Centre, + + /// + /// A that can be hit by the rim portion of the drum. + /// + Rim + } +} diff --git a/osu.Game.Rulesets.Taiko/Objects/RimHit.cs b/osu.Game.Rulesets.Taiko/Objects/RimHit.cs deleted file mode 100644 index 6f6b089e03..0000000000 --- a/osu.Game.Rulesets.Taiko/Objects/RimHit.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -namespace osu.Game.Rulesets.Taiko.Objects -{ - public class RimHit : Hit - { - } -} diff --git a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs index 48eb33976e..273f4e4105 100644 --- a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs +++ b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs @@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Taiko.Replays { TaikoAction[] actions; - if (hit is CentreHit) + if (hit.Type == HitType.Centre) { actions = h.IsStrong ? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre } diff --git a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs index 0c7495aa52..9196bbf13e 100644 --- a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs @@ -48,11 +48,11 @@ namespace osu.Game.Rulesets.Taiko.UI { switch (h) { - case CentreHit centreHit: - return new DrawableCentreHit(centreHit); - - case RimHit rimHit: - return new DrawableRimHit(rimHit); + case Hit hit: + if (hit.Type == HitType.Centre) + return new DrawableCentreHit(hit); + else + return new DrawableRimHit(hit); case DrumRoll drumRoll: return new DrawableDrumRoll(drumRoll); diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index a10f70a344..bde9085c23 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -14,9 +14,9 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; -using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Game.Rulesets.Taiko.Judgements; +using osu.Game.Rulesets.Taiko.Objects; using osuTK; using osuTK.Graphics; @@ -245,7 +245,7 @@ namespace osu.Game.Rulesets.Taiko.UI if (!result.IsHit) break; - bool isRim = judgedObject.HitObject is RimHit; + bool isRim = (judgedObject.HitObject as Hit)?.Type == HitType.Rim; hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim)); From e3a5be71cce01b6e42311a89772cc6fedbbb9c8f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 23 Mar 2020 12:09:30 +0900 Subject: [PATCH 45/54] Implement random mod for taiko --- .../Mods/ManiaModRandom.cs | 9 +------ .../Mods/TaikoModRandom.cs | 27 +++++++++++++++++++ osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 1 + osu.Game/Rulesets/Mods/ModRandom.cs | 17 ++++++++++++ 4 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 osu.Game.Rulesets.Taiko/Mods/TaikoModRandom.cs create mode 100644 osu.Game/Rulesets/Mods/ModRandom.cs diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs index 14b36fb765..699c58c373 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs @@ -3,24 +3,17 @@ using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Graphics.Sprites; using osu.Framework.Utils; using osu.Game.Beatmaps; -using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModRandom : Mod, IApplicableToBeatmap + public class ManiaModRandom : ModRandom, IApplicableToBeatmap { - public override string Name => "Random"; - public override string Acronym => "RD"; - public override ModType Type => ModType.Conversion; - public override IconUsage? Icon => OsuIcon.Dice; public override string Description => @"Shuffle around the keys!"; - public override double ScoreMultiplier => 1; public void ApplyToBeatmap(IBeatmap beatmap) { diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModRandom.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModRandom.cs new file mode 100644 index 0000000000..1cf19ac18e --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModRandom.cs @@ -0,0 +1,27 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Utils; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Taiko.Beatmaps; +using osu.Game.Rulesets.Taiko.Objects; + +namespace osu.Game.Rulesets.Taiko.Mods +{ + public class TaikoModRandom : ModRandom, IApplicableToBeatmap + { + public override string Description => @"Shuffle around the colours!"; + + public void ApplyToBeatmap(IBeatmap beatmap) + { + var taikoBeatmap = (TaikoBeatmap)beatmap; + + foreach (var obj in taikoBeatmap.HitObjects) + { + if (obj is Hit hit) + hit.Type = RNG.Next(2) == 0 ? HitType.Centre : HitType.Rim; + } + } + } +} diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index fc79e59864..4a841bf8c3 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -114,6 +114,7 @@ namespace osu.Game.Rulesets.Taiko case ModType.Conversion: return new Mod[] { + new TaikoModRandom(), new TaikoModDifficultyAdjust(), }; diff --git a/osu.Game/Rulesets/Mods/ModRandom.cs b/osu.Game/Rulesets/Mods/ModRandom.cs new file mode 100644 index 0000000000..da55ab3fbf --- /dev/null +++ b/osu.Game/Rulesets/Mods/ModRandom.cs @@ -0,0 +1,17 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Rulesets.Mods +{ + public abstract class ModRandom : Mod + { + public override string Name => "Random"; + public override string Acronym => "RD"; + public override ModType Type => ModType.Conversion; + public override IconUsage? Icon => OsuIcon.Dice; + public override double ScoreMultiplier => 1; + } +} From 3a3df06e0b2e0a38ab2c1591d012a78859b164cc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Mar 2020 13:11:40 +0900 Subject: [PATCH 46/54] Fix some pieces of SettingsItem getting dimmed twice when disabled --- .../Overlays/Settings/SettingsCheckbox.cs | 6 ++---- osu.Game/Overlays/Settings/SettingsItem.cs | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsCheckbox.cs b/osu.Game/Overlays/Settings/SettingsCheckbox.cs index a554159fd7..437b2e45b3 100644 --- a/osu.Game/Overlays/Settings/SettingsCheckbox.cs +++ b/osu.Game/Overlays/Settings/SettingsCheckbox.cs @@ -8,16 +8,14 @@ namespace osu.Game.Overlays.Settings { public class SettingsCheckbox : SettingsItem { - private OsuCheckbox checkbox; - private string labelText; - protected override Drawable CreateControl() => checkbox = new OsuCheckbox(); + protected override Drawable CreateControl() => new OsuCheckbox(); public override string LabelText { get => labelText; - set => checkbox.LabelText = labelText = value; + set => ((OsuCheckbox)Control).LabelText = labelText = value; } } } diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index e89f2adf0b..c2dd40d2a6 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -33,22 +33,24 @@ namespace osu.Game.Overlays.Settings protected readonly FillFlowContainer FlowContent; - private SpriteText text; + private SpriteText labelText; public bool ShowsDefaultIndicator = true; public virtual string LabelText { - get => text?.Text ?? string.Empty; + get => labelText?.Text ?? string.Empty; set { - if (text == null) + if (labelText == null) { // construct lazily for cases where the label is not needed (may be provided by the Control). - FlowContent.Insert(-1, text = new OsuSpriteText()); + FlowContent.Insert(-1, labelText = new OsuSpriteText()); + + updateDisabled(); } - text.Text = value; + labelText.Text = value; } } @@ -96,13 +98,19 @@ namespace osu.Game.Overlays.Settings if (controlWithCurrent != null) { controlWithCurrent.Current.ValueChanged += _ => SettingChanged?.Invoke(); - controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; + controlWithCurrent.Current.DisabledChanged += _ => updateDisabled(); if (ShowsDefaultIndicator) restoreDefaultButton.Bindable = controlWithCurrent.Current; } } + private void updateDisabled() + { + if (labelText != null) + labelText.Alpha = controlWithCurrent.Current.Disabled ? 0.3f : 1; + } + private class RestoreDefaultValueButton : Container, IHasTooltip { private Bindable bindable; From 98e6896e934d5aa0f88a3977c7edc0a6e8005d92 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Mar 2020 15:37:34 +0900 Subject: [PATCH 47/54] Rename test class --- .../{TestSceneFriendsLayout.cs => TestSceneFriendDisplay.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Tests/Visual/Online/{TestSceneFriendsLayout.cs => TestSceneFriendDisplay.cs} (97%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs similarity index 97% rename from osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs rename to osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs index c0a617fe57..cf365a7614 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFriendsLayout.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs @@ -13,7 +13,7 @@ using NUnit.Framework; namespace osu.Game.Tests.Visual.Online { - public class TestSceneFriendsLayout : OsuTestScene + public class TestSceneFriendDisplay : OsuTestScene { public override IReadOnlyList RequiredTypes => new[] { From 47c7673c9e7a855e02dd7d090830a7677657f64b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Mar 2020 17:04:54 +0900 Subject: [PATCH 48/54] Fix crash when holding a key down while entering player --- osu.Game/Screens/Select/FilterControl.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 6a03cfb68e..cad7672c71 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -136,6 +136,8 @@ namespace osu.Game.Screens.Select public void Deactivate() { + searchTextBox.ReadOnly = true; + searchTextBox.HoldFocus = false; if (searchTextBox.HasFocus) GetContainingInputManager().ChangeFocus(searchTextBox); @@ -143,6 +145,7 @@ namespace osu.Game.Screens.Select public void Activate() { + searchTextBox.ReadOnly = false; searchTextBox.HoldFocus = true; } From 66f2a52dd286693aa0aecd6b3e0f343acef23f12 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2020 08:59:47 +0000 Subject: [PATCH 49/54] Bump Sentry from 2.1.0 to 2.1.1 Bumps [Sentry](https://github.com/getsentry/sentry-dotnet) from 2.1.0 to 2.1.1. - [Release notes](https://github.com/getsentry/sentry-dotnet/releases) - [Commits](https://github.com/getsentry/sentry-dotnet/compare/2.1.0...2.1.1) Signed-off-by: dependabot-preview[bot] --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 46d17bcf05..3894c06994 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -24,7 +24,7 @@ - + From 96848405fd8df958850d4421c5eb31625416586f Mon Sep 17 00:00:00 2001 From: Joehu Date: Mon, 23 Mar 2020 10:54:45 -0700 Subject: [PATCH 50/54] Fix song select filter not absorbing input from carousel --- osu.Game/Screens/Select/FilterControl.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 6a03cfb68e..c831e1dcc4 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -16,6 +16,7 @@ using Container = osu.Framework.Graphics.Containers.Container; using osu.Framework.Graphics.Shapes; using osu.Game.Configuration; using osu.Game.Rulesets; +using osu.Framework.Input.Events; namespace osu.Game.Screens.Select { @@ -184,5 +185,7 @@ namespace osu.Game.Screens.Select } private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria()); + + protected override bool OnClick(ClickEvent e) => true; } } From 96d962ab307dfd6c6f7e5213ae5bead1ef241403 Mon Sep 17 00:00:00 2001 From: Joehu Date: Mon, 23 Mar 2020 11:25:40 -0700 Subject: [PATCH 51/54] Fix autoplay keyboard shortcut not working with keypad enter key --- osu.Game/Screens/Select/PlaySongSelect.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 9e2f5761dd..8b0547376d 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -56,6 +56,7 @@ namespace osu.Game.Screens.Select switch (e.Key) { case Key.Enter: + case Key.KeypadEnter: // this is a special hard-coded case; we can't rely on OnPressed (of SongSelect) as GlobalActionContainer is // matching with exact modifier consideration (so Ctrl+Enter would be ignored). FinaliseSelection(); From 5bc51193891766d39cd564a06d52383bacad3f7a Mon Sep 17 00:00:00 2001 From: Joehu Date: Mon, 23 Mar 2020 16:03:33 -0700 Subject: [PATCH 52/54] Handle OnHover on song select filter and footer --- osu.Game/Screens/Select/FilterControl.cs | 2 ++ osu.Game/Screens/Select/Footer.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index c831e1dcc4..a4a7ac5c9d 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -187,5 +187,7 @@ namespace osu.Game.Screens.Select private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria()); protected override bool OnClick(ClickEvent e) => true; + + protected override bool OnHover(HoverEvent e) => true; } } diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 1dc7081c1c..689a11166a 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -107,5 +107,7 @@ namespace osu.Game.Screens.Select protected override bool OnMouseDown(MouseDownEvent e) => true; protected override bool OnClick(ClickEvent e) => true; + + protected override bool OnHover(HoverEvent e) => true; } } From 4bb15a8b93e1290c6a1052005bf3c2bd47623f6c Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Mon, 23 Mar 2020 22:51:37 -0700 Subject: [PATCH 53/54] Allow individual storyboard layers to disable masking --- osu.Game/Screens/Play/DimmableStoryboard.cs | 1 - osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs | 1 + osu.Game/Storyboards/StoryboardLayer.cs | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/DimmableStoryboard.cs b/osu.Game/Screens/Play/DimmableStoryboard.cs index 0fe315fbab..eabdee95fb 100644 --- a/osu.Game/Screens/Play/DimmableStoryboard.cs +++ b/osu.Game/Screens/Play/DimmableStoryboard.cs @@ -44,7 +44,6 @@ namespace osu.Game.Screens.Play return; drawableStoryboard = storyboard.CreateDrawable(); - drawableStoryboard.Masking = true; if (async) LoadComponentAsync(drawableStoryboard, Add); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs index 39f5418902..69219fb038 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs @@ -22,6 +22,7 @@ namespace osu.Game.Storyboards.Drawables Anchor = Anchor.Centre; Origin = Anchor.Centre; Enabled = layer.EnabledWhenPassing; + Masking = layer.Masking; } [BackgroundDependencyLoader] diff --git a/osu.Game/Storyboards/StoryboardLayer.cs b/osu.Game/Storyboards/StoryboardLayer.cs index d15f771534..e3b74ca609 100644 --- a/osu.Game/Storyboards/StoryboardLayer.cs +++ b/osu.Game/Storyboards/StoryboardLayer.cs @@ -10,15 +10,17 @@ namespace osu.Game.Storyboards { public string Name; public int Depth; + public bool Masking; public bool EnabledWhenPassing = true; public bool EnabledWhenFailing = true; public List Elements = new List(); - public StoryboardLayer(string name, int depth) + public StoryboardLayer(string name, int depth, bool masking = true) { Name = name; Depth = depth; + Masking = masking; } public void Add(IStoryboardElement element) From 368bf585217409695bb4b336b97907b23834c560 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 25 Mar 2020 11:08:08 +0900 Subject: [PATCH 54/54] Rename and make fields readonly --- .../Formats/LegacyStoryboardDecoderTest.cs | 16 ++++++++-------- .../Storyboards/Drawables/DrawableStoryboard.cs | 2 +- .../Drawables/DrawableStoryboardLayer.cs | 2 +- osu.Game/Storyboards/Storyboard.cs | 4 ++-- osu.Game/Storyboards/StoryboardLayer.cs | 14 +++++++++----- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs index 76b76aa357..a6945dca90 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyStoryboardDecoderTest.cs @@ -31,29 +31,29 @@ namespace osu.Game.Tests.Beatmaps.Formats StoryboardLayer background = storyboard.Layers.FirstOrDefault(l => l.Depth == 3); Assert.IsNotNull(background); Assert.AreEqual(16, background.Elements.Count); - Assert.IsTrue(background.EnabledWhenFailing); - Assert.IsTrue(background.EnabledWhenPassing); + Assert.IsTrue(background.VisibleWhenFailing); + Assert.IsTrue(background.VisibleWhenPassing); Assert.AreEqual("Background", background.Name); StoryboardLayer fail = storyboard.Layers.FirstOrDefault(l => l.Depth == 2); Assert.IsNotNull(fail); Assert.AreEqual(0, fail.Elements.Count); - Assert.IsTrue(fail.EnabledWhenFailing); - Assert.IsFalse(fail.EnabledWhenPassing); + Assert.IsTrue(fail.VisibleWhenFailing); + Assert.IsFalse(fail.VisibleWhenPassing); Assert.AreEqual("Fail", fail.Name); StoryboardLayer pass = storyboard.Layers.FirstOrDefault(l => l.Depth == 1); Assert.IsNotNull(pass); Assert.AreEqual(0, pass.Elements.Count); - Assert.IsFalse(pass.EnabledWhenFailing); - Assert.IsTrue(pass.EnabledWhenPassing); + Assert.IsFalse(pass.VisibleWhenFailing); + Assert.IsTrue(pass.VisibleWhenPassing); Assert.AreEqual("Pass", pass.Name); StoryboardLayer foreground = storyboard.Layers.FirstOrDefault(l => l.Depth == 0); Assert.IsNotNull(foreground); Assert.AreEqual(151, foreground.Elements.Count); - Assert.IsTrue(foreground.EnabledWhenFailing); - Assert.IsTrue(foreground.EnabledWhenPassing); + Assert.IsTrue(foreground.VisibleWhenFailing); + Assert.IsTrue(foreground.VisibleWhenPassing); Assert.AreEqual("Foreground", foreground.Name); int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite)); diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs index 94d7395ecf..bc6e01a729 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs @@ -75,7 +75,7 @@ namespace osu.Game.Storyboards.Drawables private void updateLayerVisibility() { foreach (var layer in Children) - layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing; + layer.Enabled = passing ? layer.Layer.VisibleWhenPassing : layer.Layer.VisibleWhenFailing; } } } diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs index 69219fb038..def4eed2ca 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs @@ -21,7 +21,7 @@ namespace osu.Game.Storyboards.Drawables RelativeSizeAxes = Axes.Both; Anchor = Anchor.Centre; Origin = Anchor.Centre; - Enabled = layer.EnabledWhenPassing; + Enabled = layer.VisibleWhenPassing; Masking = layer.Masking; } diff --git a/osu.Game/Storyboards/Storyboard.cs b/osu.Game/Storyboards/Storyboard.cs index 35bfe8c229..2ba8563ba8 100644 --- a/osu.Game/Storyboards/Storyboard.cs +++ b/osu.Game/Storyboards/Storyboard.cs @@ -22,8 +22,8 @@ namespace osu.Game.Storyboards public Storyboard() { layers.Add("Background", new StoryboardLayer("Background", 3)); - layers.Add("Fail", new StoryboardLayer("Fail", 2) { EnabledWhenPassing = false, }); - layers.Add("Pass", new StoryboardLayer("Pass", 1) { EnabledWhenFailing = false, }); + layers.Add("Fail", new StoryboardLayer("Fail", 2) { VisibleWhenPassing = false, }); + layers.Add("Pass", new StoryboardLayer("Pass", 1) { VisibleWhenFailing = false, }); layers.Add("Foreground", new StoryboardLayer("Foreground", 0)); } diff --git a/osu.Game/Storyboards/StoryboardLayer.cs b/osu.Game/Storyboards/StoryboardLayer.cs index e3b74ca609..142bc60deb 100644 --- a/osu.Game/Storyboards/StoryboardLayer.cs +++ b/osu.Game/Storyboards/StoryboardLayer.cs @@ -8,11 +8,15 @@ namespace osu.Game.Storyboards { public class StoryboardLayer { - public string Name; - public int Depth; - public bool Masking; - public bool EnabledWhenPassing = true; - public bool EnabledWhenFailing = true; + public readonly string Name; + + public readonly int Depth; + + public readonly bool Masking; + + public bool VisibleWhenPassing = true; + + public bool VisibleWhenFailing = true; public List Elements = new List();