From b28a1d38a6b66f0c678bfb1150a29dcdf82a2cfe Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 17:09:18 +0100 Subject: [PATCH 01/65] Simplify GradientLine and fix colour changing --- .../UserInterface/GradientLineTabControl.cs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/GradientLineTabControl.cs b/osu.Game/Graphics/UserInterface/GradientLineTabControl.cs index baca57ea89..1d67c4e033 100644 --- a/osu.Game/Graphics/UserInterface/GradientLineTabControl.cs +++ b/osu.Game/Graphics/UserInterface/GradientLineTabControl.cs @@ -49,14 +49,7 @@ namespace osu.Game.Graphics.UserInterface public GradientLine() { RelativeSizeAxes = Axes.X; - Size = new Vector2(0.8f, 1.5f); - - ColumnDimensions = new[] - { - new Dimension(), - new Dimension(mode: GridSizeMode.Relative, size: 0.4f), - new Dimension(), - }; + Size = new Vector2(0.8f, 1f); Content = new[] { @@ -65,16 +58,12 @@ namespace osu.Game.Graphics.UserInterface new Box { RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientHorizontal(Color4.Transparent, Color4.White) + Colour = ColourInfo.GradientHorizontal(Color4.Transparent, Colour) }, new Box { RelativeSizeAxes = Axes.Both, - }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.Transparent) + Colour = ColourInfo.GradientHorizontal(Colour, Color4.Transparent) }, } }; From 9bc45d21f13e2a048d991e9144cf773e2592389b Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 17:11:28 +0100 Subject: [PATCH 02/65] Recolour LeaderboardScopeSelector --- osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs index e2a725ec46..20a3b09db4 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs @@ -26,10 +26,10 @@ namespace osu.Game.Overlays.BeatmapSet } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - AccentColour = colours.Blue; - LineColour = Color4.Gray; + AccentColour = colourProvider.Highlight1; + LineColour = colourProvider.Background1; } private class ScopeSelectorTabItem : PageTabItem From 5eb1619e24ca180b99de8b762a30b9986dc4da75 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 18:02:49 +0100 Subject: [PATCH 03/65] Adjust title / artist font weight --- osu.Game/Overlays/BeatmapSet/Header.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 7c5c5a9d55..b62a5d46f0 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// 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; @@ -134,7 +134,7 @@ namespace osu.Game.Overlays.BeatmapSet { title = new OsuSpriteText { - Font = OsuFont.GetFont(size: 37, weight: FontWeight.Bold, italics: true) + Font = OsuFont.GetFont(size: 37, weight: FontWeight.SemiBold, italics: true) }, externalLink = new ExternalLinkButton { @@ -144,7 +144,7 @@ namespace osu.Game.Overlays.BeatmapSet }, } }, - artist = new OsuSpriteText { Font = OsuFont.GetFont(size: 25, weight: FontWeight.SemiBold, italics: true) }, + artist = new OsuSpriteText { Font = OsuFont.GetFont(size: 25, weight: FontWeight.Medium, italics: true) }, new Container { RelativeSizeAxes = Axes.X, From 5b881568db688d501f8464963ac85d87b751981a Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 19:15:02 +0100 Subject: [PATCH 04/65] Adjust header gradient colours --- osu.Game/Overlays/BeatmapSet/Header.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index b62a5d46f0..5cfbd2ef83 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -93,10 +93,9 @@ namespace osu.Game.Overlays.BeatmapSet RelativeSizeAxes = Axes.Both, Masking = true, }, - new Box + coverGradient = new Box { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.3f), Color4.Black.Opacity(0.8f)), + RelativeSizeAxes = Axes.Both }, }, }, @@ -215,8 +214,10 @@ namespace osu.Game.Overlays.BeatmapSet } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { + coverGradient.Colour = ColourInfo.GradientVertical(colourProvider.Background6.Opacity(0.3f), colourProvider.Background6.Opacity(0.8f)); + State.BindValueChanged(_ => updateDownloadButtons()); BeatmapSet.BindValueChanged(setInfo => From b6301f6537753fa7ad6597dbb8b7a2135cdb2e7a Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 19:52:32 +0100 Subject: [PATCH 05/65] Adjust PreviewButton alpha and animation --- osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs index 8c884e0950..80b287f6c6 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs @@ -22,7 +22,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { private const float transition_duration = 500; - private readonly Box bg, progress; + private readonly Box background, progress; private readonly PlayButton playButton; private PreviewTrack preview => playButton.Preview; @@ -40,10 +40,11 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons Children = new Drawable[] { - bg = new Box + background = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.25f), + Colour = Color4.Black, + Alpha = 0.5f }, new Container { @@ -91,13 +92,13 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons protected override bool OnHover(HoverEvent e) { - bg.FadeColour(Color4.Black.Opacity(0.5f), 100); + background.FadeTo(0.75f, 80); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - bg.FadeColour(Color4.Black.Opacity(0.25f), 100); + background.FadeTo(0.5f, 80); base.OnHoverLost(e); } } From a366a92d4c93001a0af58566ff68448d20f88e96 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 19:54:51 +0100 Subject: [PATCH 06/65] Use alpha instead of colour opacity --- osu.Game/Overlays/BeatmapSet/Details.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index d76f6a43db..627f3d04c9 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -119,7 +118,8 @@ namespace osu.Game.Overlays.BeatmapSet new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.5f), + Colour = Color4.Black, + Alpha = 0.5f }, content = new Container { From 86283cc422654e7babbb54a67cab8f8ccc8dc151 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 19:55:19 +0100 Subject: [PATCH 07/65] Recolour SuccessRate background --- osu.Game/Overlays/BeatmapSet/SuccessRate.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs index 1dcc847760..dac750dacf 100644 --- a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs @@ -105,10 +105,10 @@ namespace osu.Game.Overlays.BeatmapSet } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, OverlayColourProvider colourProvider) { successRate.AccentColour = colours.Green; - successRate.BackgroundColour = colours.GrayD; + successRate.BackgroundColour = colourProvider.Background6; updateDisplay(); } From d0eb4e44719b20621362dc721cedfc18f17ab051 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 20:08:54 +0100 Subject: [PATCH 08/65] Add necessary variable --- osu.Game/Overlays/BeatmapSet/Header.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 5cfbd2ef83..f2d1077844 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -30,6 +30,7 @@ namespace osu.Game.Overlays.BeatmapSet private const float buttons_spacing = 5; private readonly UpdateableBeatmapSetCover cover; + private readonly Box coverGradient; private readonly OsuSpriteText title, artist; private readonly AuthorInfo author; private readonly FillFlowContainer downloadButtonsContainer; From 2cc1255035d5f84aad41dd5cc21a38db0a837229 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 20:09:52 +0100 Subject: [PATCH 09/65] Adjust online status pill font and padding --- osu.Game/Overlays/BeatmapSet/Header.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index f2d1077844..dccebe5bad 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -196,8 +196,8 @@ namespace osu.Game.Overlays.BeatmapSet { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - TextSize = 14, - TextPadding = new MarginPadding { Horizontal = 25, Vertical = 8 } + TextSize = 17, + TextPadding = new MarginPadding { Horizontal = 35, Vertical = 10 } }, Details = new Details(), }, From 268bb73ac668f927f936b5c72798fc6cdf5fc270 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 20:14:50 +0100 Subject: [PATCH 10/65] Adjust header padding --- osu.Game/Overlays/BeatmapSet/Header.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index dccebe5bad..c620ae2bca 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -106,8 +106,7 @@ namespace osu.Game.Overlays.BeatmapSet AutoSizeAxes = Axes.Y, Padding = new MarginPadding { - Top = 20, - Bottom = 30, + Vertical = BeatmapSetOverlay.Y_PADDING, Left = BeatmapSetOverlay.X_PADDING, Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH, }, @@ -187,7 +186,7 @@ namespace osu.Game.Overlays.BeatmapSet Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Top = BeatmapSetOverlay.TOP_PADDING, Right = BeatmapSetOverlay.X_PADDING }, + Margin = new MarginPadding { Top = BeatmapSetOverlay.Y_PADDING, Right = BeatmapSetOverlay.X_PADDING }, Direction = FillDirection.Vertical, Spacing = new Vector2(10), Children = new Drawable[] From cbfb90983bfe8b146bcf1df5883c6b7b06a109d6 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 20:17:27 +0100 Subject: [PATCH 11/65] Rename variable --- osu.Game/Overlays/BeatmapSetOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index f747cfff16..7624351e41 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays public class BeatmapSetOverlay : FullscreenOverlay { public const float X_PADDING = 40; - public const float TOP_PADDING = 25; + public const float Y_PADDING = 25; public const float RIGHT_WIDTH = 275; protected readonly Header Header; From 85fb4b4a18eb79ccd7b65786a3f99f83b67838f7 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:00:00 +0100 Subject: [PATCH 12/65] Recolour DetailBox --- osu.Game/Overlays/BeatmapSet/Details.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index 627f3d04c9..d24ad58a74 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// 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.Allocation; @@ -106,6 +106,8 @@ namespace osu.Game.Overlays.BeatmapSet private class DetailBox : Container { private readonly Container content; + private readonly Box background; + protected override Container Content => content; public DetailBox() @@ -115,10 +117,9 @@ namespace osu.Game.Overlays.BeatmapSet InternalChildren = new Drawable[] { - new Box + background = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, Alpha = 0.5f }, content = new Container @@ -129,6 +130,12 @@ namespace osu.Game.Overlays.BeatmapSet }, }; } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + background.Colour = colourProvider.Background6; + } } } } From 88e79dfa78031b474fdb1ba341a4c8acb9c4ae13 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:00:27 +0100 Subject: [PATCH 13/65] Hide ratings if beatmap has no leaderboard --- osu.Game/Overlays/BeatmapSet/Details.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index d24ad58a74..85341e6f1c 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// 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.Allocation; @@ -20,6 +20,7 @@ namespace osu.Game.Overlays.BeatmapSet private readonly PreviewButton preview; private readonly BasicStats basic; private readonly AdvancedStats advanced; + private readonly DetailBox ratingBox; private BeatmapSetInfo beatmapSet; @@ -53,6 +54,7 @@ namespace osu.Game.Overlays.BeatmapSet private void updateDisplay() { Ratings.Metrics = BeatmapSet?.Metrics; + ratingBox.Alpha = (BeatmapSet?.OnlineInfo?.Status ?? 0) > 0 ? 1 : 0; } public Details() @@ -85,7 +87,7 @@ namespace osu.Game.Overlays.BeatmapSet Margin = new MarginPadding { Vertical = 7.5f }, }, }, - new DetailBox + ratingBox = new DetailBox { Child = Ratings = new UserRatings { From 48beb9fd6d45688911e18f08f81137bde53b03ee Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:01:02 +0100 Subject: [PATCH 14/65] Recolour PreviewButton --- osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs index 80b287f6c6..5ce283d0d8 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs @@ -43,7 +43,6 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons background = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, Alpha = 0.5f }, new Container @@ -72,9 +71,10 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, OverlayColourProvider colourProvider) { progress.Colour = colours.Yellow; + background.Colour = colourProvider.Background6; } protected override void Update() From 3ef6027d5718a11bd2a4ef8154c949d2911452f5 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:02:02 +0100 Subject: [PATCH 15/65] Show placeholder instead of success rate when beatmap unranked --- osu.Game/Overlays/BeatmapSet/Info.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index d7392b31e1..516eee43ce 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -26,6 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet private readonly Box successRateBackground; private readonly Box background; private readonly SuccessRate successRate; + private readonly OsuSpriteText unrankedPlaceholder; public readonly Bindable BeatmapSet = new Bindable(); @@ -110,6 +111,14 @@ namespace osu.Game.Overlays.BeatmapSet RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = 20, Horizontal = 15 }, }, + unrankedPlaceholder = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Alpha = 0, + Text = "Unranked beatmap", + Font = OsuFont.GetFont(size: 13) + }, }, }, }, @@ -122,6 +131,9 @@ namespace osu.Game.Overlays.BeatmapSet tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty; genre.Text = b.NewValue?.OnlineInfo?.Genre?.Name ?? string.Empty; language.Text = b.NewValue?.OnlineInfo?.Language?.Name ?? string.Empty; + var setHasLeaderboard = (b.NewValue?.OnlineInfo?.Status ?? 0) > 0; + successRate.Alpha = setHasLeaderboard ? 1 : 0; + unrankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1; }; } From 54580858499cb36326ef0a8beade69f5c568702c Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:11:35 +0100 Subject: [PATCH 16/65] Adjust TopScoreUserSection font and spacing --- osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index 72a7efd777..1923c5a48f 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -96,13 +96,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold) + Font = OsuFont.GetFont(size: 10) }, flag = new UpdateableFlag { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Size = new Vector2(19, 13), + Margin = new MarginPadding { Top = 2 }, // makes spacing look more even ShowPlaceholderOnNull = false, }, } From d23e4a1fa1cc649a7242b356298c081474ccdc35 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:27:51 +0100 Subject: [PATCH 17/65] Change scoreboard text size --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 7a17412722..c124f7b262 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// 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; @@ -23,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const float horizontal_inset = 20; private const float row_height = 25; - private const int text_size = 12; + private const int text_size = 14; private readonly FillFlowContainer backgroundFlow; From 979589704534c0592bb249b9f42084aadb929e77 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:28:31 +0100 Subject: [PATCH 18/65] Enforce correct column order in ScoreTable --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index c124f7b262..7820323171 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// 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; @@ -65,6 +65,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores for (int i = 0; i < value.Count; i++) backgroundFlow.Add(new ScoreTableRowBackground(i, value[i])); + // Ensure correct column order + foreach (ScoreInfo score in value) + score.Statistics = score.Statistics.OrderByDescending(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value); + Columns = createHeaders(value[0]); Content = value.Select((s, i) => createContent(i, s)).ToArray().ToRectangular(); } From 82914b5d6e6f852f9d21ab65277b3889f3d19468 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:41:33 +0100 Subject: [PATCH 19/65] Adjust ScoreTable spacing --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 7820323171..f04477d911 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -81,9 +81,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores new TableColumn("rank", Anchor.CentreRight, new Dimension(GridSizeMode.AutoSize)), new TableColumn("", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 70)), // grade new TableColumn("score", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)), - new TableColumn("accuracy", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)), + new TableColumn("accuracy", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 60, maxSize: 70)), new TableColumn("player", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 150)), - new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 90)) + new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 110)) }; foreach (var statistic in score.Statistics) @@ -194,7 +194,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public HeaderText(string text) { Text = text.ToUpper(); - Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold); + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold); } [BackgroundDependencyLoader] From d7af96a2e51817fbffa8d872d500f25081cc628b Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:42:01 +0100 Subject: [PATCH 20/65] Adjust corner radius --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs index 14ea3e6b38..83271efe09 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableRowBackground.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores RelativeSizeAxes = Axes.X; Height = 25; - CornerRadius = 3; + CornerRadius = 5; Masking = true; InternalChildren = new Drawable[] From 86c0b509835eae73a680c72f41bb6bc59124c9fd Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:45:45 +0100 Subject: [PATCH 21/65] Adjust font once again for readibility --- osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index 1923c5a48f..9913493617 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -96,14 +96,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: 10) + Font = OsuFont.GetFont(size: 12) }, flag = new UpdateableFlag { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Size = new Vector2(19, 13), - Margin = new MarginPadding { Top = 2 }, // makes spacing look more even + Margin = new MarginPadding { Top = 3 }, // makes spacing look more even ShowPlaceholderOnNull = false, }, } From c1b8445b006fd22243a4235a7da14c458220b53f Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 21:53:23 +0100 Subject: [PATCH 22/65] Add spacing to match osu-web Note: due to osu-web using flex to even out the spacing and me not being able to implement the same behaviour here, I added a static margin to separate the title from the diffname above. This looks better than the previous state in most cases, the only scenario where this differs somehow visibly from web is on mapsets with large numbers of difficulties. --- osu.Game/Overlays/BeatmapSet/Header.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index c620ae2bca..9f79b92cb6 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -129,6 +129,7 @@ namespace osu.Game.Overlays.BeatmapSet { Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Top = 15 }, Children = new Drawable[] { title = new OsuSpriteText From ae467538d3bf0ff1b3483ba201d8f19d7b7f46c9 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Tue, 4 Feb 2020 22:39:51 +0100 Subject: [PATCH 23/65] Fix tests --- .../Online/TestSceneBeatmapSetOverlayDetails.cs | 11 ++++++++++- .../Online/TestSceneBeatmapSetOverlaySuccessRate.cs | 5 +++++ .../Online/TestSceneLeaderboardScopeSelector.cs | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs index 990e0a166b..dea1e710b5 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs @@ -5,9 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Utils; using osu.Game.Beatmaps; +using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet; using osu.Game.Screens.Select.Details; @@ -22,6 +24,9 @@ namespace osu.Game.Tests.Visual.Online private RatingsExposingDetails details; + [Cached] + private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + [SetUp] public void Setup() => Schedule(() => { @@ -55,8 +60,12 @@ namespace osu.Game.Tests.Visual.Online { Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(), Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(), - } + }, } + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Status = BeatmapSetOnlineStatus.Ranked } }; } diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs index 2b572c1f6c..03003daf81 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs @@ -5,11 +5,13 @@ using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Utils; using osu.Game.Beatmaps; +using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet; using osu.Game.Screens.Select.Details; using osuTK; @@ -26,6 +28,9 @@ namespace osu.Game.Tests.Visual.Online private GraphExposingSuccessRate successRate; + [Cached] + private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + [SetUp] public void Setup() => Schedule(() => { diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardScopeSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardScopeSelector.cs index cc3b2ac68b..f9a7bc99c3 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardScopeSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardScopeSelector.cs @@ -7,11 +7,16 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Bindables; using osu.Game.Screens.Select.Leaderboards; +using osu.Framework.Allocation; +using osu.Game.Overlays; namespace osu.Game.Tests.Visual.Online { public class TestSceneLeaderboardScopeSelector : OsuTestScene { + [Cached] + private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + public override IReadOnlyList RequiredTypes => new[] { typeof(LeaderboardScopeSelector), From b606408667e842dd0326bf071fa551a2e1de7452 Mon Sep 17 00:00:00 2001 From: Tree Date: Tue, 4 Feb 2020 23:02:28 +0100 Subject: [PATCH 24/65] Remove space --- osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index 9913493617..00171e1170 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -103,7 +103,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Size = new Vector2(19, 13), - Margin = new MarginPadding { Top = 3 }, // makes spacing look more even + Margin = new MarginPadding { Top = 3 }, // makes spacing look more even ShowPlaceholderOnNull = false, }, } From 23d1d3fdf11bb9cf23e416cd0478dd8ba8ab4644 Mon Sep 17 00:00:00 2001 From: Tree Date: Tue, 4 Feb 2020 23:09:10 +0100 Subject: [PATCH 25/65] Convert field to local variable --- osu.Game/Overlays/BeatmapSet/Info.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 516eee43ce..a71409a05f 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -26,7 +26,6 @@ namespace osu.Game.Overlays.BeatmapSet private readonly Box successRateBackground; private readonly Box background; private readonly SuccessRate successRate; - private readonly OsuSpriteText unrankedPlaceholder; public readonly Bindable BeatmapSet = new Bindable(); @@ -39,6 +38,8 @@ namespace osu.Game.Overlays.BeatmapSet public Info() { MetadataSection source, tags, genre, language; + OsuSpriteText unrankedPlaceholder; + RelativeSizeAxes = Axes.X; Height = 220; Masking = true; From c2a80119ca4cf9c65755abecfc9000dd234cc446 Mon Sep 17 00:00:00 2001 From: Tree Date: Tue, 4 Feb 2020 23:23:57 +0100 Subject: [PATCH 26/65] Remove using directives --- osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs index 5ce283d0d8..7eae05e4a9 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -14,7 +13,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Overlays.Direct; using osuTK; -using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Buttons { From 447f31ccfc21f96f3795c6e4f121e3a1f82aded0 Mon Sep 17 00:00:00 2001 From: Tree Date: Tue, 4 Feb 2020 23:25:21 +0100 Subject: [PATCH 27/65] Remove using directive --- osu.Game/Overlays/BeatmapSet/Details.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index 85341e6f1c..bd13b4371e 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -9,7 +9,6 @@ using osu.Game.Beatmaps; using osu.Game.Overlays.BeatmapSet.Buttons; using osu.Game.Screens.Select.Details; using osuTK; -using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet { From a3fd952f74bf6693a576f3db4b8261e399db037c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 11:21:23 +0300 Subject: [PATCH 28/65] Use new SpotlightSelector in RankingsHeader --- .../Visual/Online/TestSceneRankingsHeader.cs | 13 ++-- .../Rankings/RankingsOverlayHeader.cs | 61 +++---------------- osu.Game/Overlays/Rankings/Spotlight.cs | 18 ------ 3 files changed, 16 insertions(+), 76 deletions(-) delete mode 100644 osu.Game/Overlays/Rankings/Spotlight.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs index 898e461bde..bc0ae3d264 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.Rankings; using osu.Game.Rulesets; @@ -37,20 +38,20 @@ namespace osu.Game.Tests.Visual.Online Ruleset = { BindTarget = ruleset }, Spotlights = new[] { - new Spotlight + new APISpotlight { Id = 1, - Text = "Spotlight 1" + Name = "Spotlight 1" }, - new Spotlight + new APISpotlight { Id = 2, - Text = "Spotlight 2" + Name = "Spotlight 2" }, - new Spotlight + new APISpotlight { Id = 3, - Text = "Spotlight 3" + Name = "Spotlight 3" } } }); diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index 94afe4e5a5..41722034b6 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -8,21 +8,20 @@ using osu.Game.Rulesets; using osu.Game.Users; using System.Collections.Generic; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Allocation; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Rankings { public class RankingsOverlayHeader : TabControlOverlayHeader { public readonly Bindable Ruleset = new Bindable(); - public readonly Bindable Spotlight = new Bindable(); + public readonly Bindable Spotlight = new Bindable(); public readonly Bindable Country = new Bindable(); - public IEnumerable Spotlights + public IEnumerable Spotlights { - get => spotlightsContainer.Spotlights; - set => spotlightsContainer.Spotlights = value; + get => spotlightSelector.Spotlights; + set => spotlightSelector.Spotlights = value; } protected override ScreenTitle CreateTitle() => new RankingsTitle @@ -35,7 +34,7 @@ namespace osu.Game.Overlays.Rankings Current = Ruleset }; - private SpotlightsContainer spotlightsContainer; + private SpotlightSelector spotlightSelector; protected override Drawable CreateContent() => new FillFlowContainer { @@ -48,9 +47,9 @@ namespace osu.Game.Overlays.Rankings { Current = Country }, - spotlightsContainer = new SpotlightsContainer + spotlightSelector = new SpotlightSelector { - Spotlight = { BindTarget = Spotlight } + Current = { BindTarget = Spotlight } } } }; @@ -62,7 +61,7 @@ namespace osu.Game.Overlays.Rankings } private void onCurrentChanged(ValueChangedEvent scope) => - spotlightsContainer.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint); + spotlightSelector.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint); private class RankingsTitle : ScreenTitle { @@ -81,48 +80,6 @@ namespace osu.Game.Overlays.Rankings protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/rankings"); } - - private class SpotlightsContainer : CompositeDrawable - { - public readonly Bindable Spotlight = new Bindable(); - - public IEnumerable Spotlights - { - get => dropdown.Items; - set => dropdown.Items = value; - } - - private readonly OsuDropdown dropdown; - private readonly Box background; - - public SpotlightsContainer() - { - Height = 100; - RelativeSizeAxes = Axes.X; - InternalChildren = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - }, - dropdown = new OsuDropdown - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - Width = 0.8f, - Current = Spotlight, - Y = 20, - } - }; - } - - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - background.Colour = colourProvider.Dark3; - } - } } public enum RankingsScope diff --git a/osu.Game/Overlays/Rankings/Spotlight.cs b/osu.Game/Overlays/Rankings/Spotlight.cs deleted file mode 100644 index e956b4f449..0000000000 --- a/osu.Game/Overlays/Rankings/Spotlight.cs +++ /dev/null @@ -1,18 +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; - -namespace osu.Game.Overlays.Rankings -{ - public class Spotlight - { - [JsonProperty("id")] - public int Id; - - [JsonProperty("text")] - public string Text; - - public override string ToString() => Text; - } -} From fa65e3a5bb51db63dc33f74189607e5d8dcb0487 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 12:09:32 +0300 Subject: [PATCH 29/65] Make spotlight selector work --- osu.Game/Overlays/RankingsOverlay.cs | 32 +++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 84470d9caa..36f5a3155a 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -14,6 +14,8 @@ using osu.Game.Online.API; using System.Threading; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Rankings.Tables; +using osu.Game.Online.API.Requests.Responses; +using System.Linq; namespace osu.Game.Overlays { @@ -22,11 +24,13 @@ namespace osu.Game.Overlays protected readonly Bindable Country = new Bindable(); protected readonly Bindable Scope = new Bindable(); private readonly Bindable ruleset = new Bindable(); + private readonly Bindable spotlight = new Bindable(); private readonly BasicScrollContainer scrollFlow; private readonly Container tableContainer; private readonly DimmedLoadingLayer loading; private readonly Box background; + private readonly RankingsOverlayHeader header; private APIRequest lastRequest; private CancellationTokenSource cancellationToken; @@ -54,14 +58,15 @@ namespace osu.Game.Overlays Direction = FillDirection.Vertical, Children = new Drawable[] { - new RankingsOverlayHeader + header = new RankingsOverlayHeader { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Depth = -float.MaxValue, Country = { BindTarget = Country }, Current = { BindTarget = Scope }, - Ruleset = { BindTarget = ruleset } + Ruleset = { BindTarget = ruleset }, + Spotlight = { BindTarget = spotlight } }, new Container { @@ -109,11 +114,19 @@ namespace osu.Game.Overlays if (Scope.Value != RankingsScope.Performance) Country.Value = null; + if (Scope.Value == RankingsScope.Spotlights && !header.Spotlights.Any()) + { + getSpotlights(); + return; + } + Scheduler.AddOnce(loadNewContent); }, true); ruleset.BindValueChanged(_ => Scheduler.AddOnce(loadNewContent), true); + spotlight.BindValueChanged(_ => Scheduler.AddOnce(loadNewContent), true); + base.LoadComplete(); } @@ -127,6 +140,14 @@ namespace osu.Game.Overlays Country.Value = requested; } + private void getSpotlights() + { + loading.Show(); + var request = new GetSpotlightsRequest(); + request.Success += response => header.Spotlights = response.Spotlights; + api.Queue(request); + } + private void loadNewContent() { loading.Show(); @@ -145,7 +166,6 @@ namespace osu.Game.Overlays request.Success += () => loadTable(createTableFromResponse(request)); request.Failure += _ => loadTable(null); - api.Queue(request); } @@ -161,6 +181,9 @@ namespace osu.Game.Overlays case RankingsScope.Score: return new GetUserRankingsRequest(ruleset.Value, UserRankingsType.Score); + + case RankingsScope.Spotlights: + return new GetSpotlightRankingsRequest(ruleset.Value, header.Spotlight.Value.Id); } return null; @@ -184,6 +207,9 @@ namespace osu.Game.Overlays case GetCountryRankingsRequest countryRequest: return new CountriesTable(1, countryRequest.Result.Countries); + + case GetSpotlightRankingsRequest spotlightRequest: + return new ScoresTable(1, spotlightRequest.Result.Users); } return null; From 2b0b789980a0c7a099bc4ae88a5cf11a2229b70e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 12:14:24 +0300 Subject: [PATCH 30/65] Naming adjustments --- osu.Game/Overlays/RankingsOverlay.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 36f5a3155a..39f106a24e 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays private readonly Bindable spotlight = new Bindable(); private readonly BasicScrollContainer scrollFlow; - private readonly Container tableContainer; + private readonly Container contentContainer; private readonly DimmedLoadingLayer loading; private readonly Box background; private readonly RankingsOverlayHeader header; @@ -74,7 +74,7 @@ namespace osu.Game.Overlays AutoSizeAxes = Axes.Y, Children = new Drawable[] { - tableContainer = new Container + contentContainer = new Container { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -160,12 +160,12 @@ namespace osu.Game.Overlays if (request == null) { - loadTable(null); + loadContent(null); return; } - request.Success += () => loadTable(createTableFromResponse(request)); - request.Failure += _ => loadTable(null); + request.Success += () => loadContent(createContentFromResponse(request)); + request.Failure += _ => loadContent(null); api.Queue(request); } @@ -189,7 +189,7 @@ namespace osu.Game.Overlays return null; } - private Drawable createTableFromResponse(APIRequest request) + private Drawable createContentFromResponse(APIRequest request) { switch (request) { @@ -215,21 +215,21 @@ namespace osu.Game.Overlays return null; } - private void loadTable(Drawable table) + private void loadContent(Drawable content) { scrollFlow.ScrollToStart(); - if (table == null) + if (content == null) { - tableContainer.Clear(); + contentContainer.Clear(); loading.Hide(); return; } - LoadComponentAsync(table, t => + LoadComponentAsync(content, t => { loading.Hide(); - tableContainer.Child = table; + contentContainer.Child = content; }, (cancellationToken = new CancellationTokenSource()).Token); } } From b83ee6dabf45a4baf1ceebd4204ad56affe1245b Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 12:22:42 +0300 Subject: [PATCH 31/65] Show beatmap panels for selected spotlight --- osu.Game/Overlays/RankingsOverlay.cs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 39f106a24e..2a4bc28b18 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -16,6 +16,8 @@ using osu.Game.Online.API.Requests; using osu.Game.Overlays.Rankings.Tables; using osu.Game.Online.API.Requests.Responses; using System.Linq; +using osuTK; +using osu.Game.Overlays.Direct; namespace osu.Game.Overlays { @@ -38,6 +40,9 @@ namespace osu.Game.Overlays [Resolved] private IAPIProvider api { get; set; } + [Resolved] + private RulesetStore rulesets { get; set; } + public RankingsOverlay() : base(OverlayColourScheme.Green) { @@ -209,7 +214,28 @@ namespace osu.Game.Overlays return new CountriesTable(1, countryRequest.Result.Countries); case GetSpotlightRankingsRequest spotlightRequest: - return new ScoresTable(1, spotlightRequest.Result.Users); + return new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 20), + Children = new Drawable[] + { + new ScoresTable(1, spotlightRequest.Result.Users), + new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Spacing = new Vector2(10), + Children = spotlightRequest.Result.BeatmapSets.Select(b => new DirectGridPanel(b.ToBeatmapSet(rulesets)) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }).ToList() + } + } + }; } return null; From cb30f463fb670d801a54044c6326f7b96e8a73ac Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 12:48:29 +0300 Subject: [PATCH 32/65] Update spotlight info based on selected one --- .../API/Requests/Responses/APISpotlight.cs | 3 +++ .../Rankings/RankingsOverlayHeader.cs | 10 +++++----- .../Overlays/Rankings/SpotlightSelector.cs | 19 +++++++++---------- osu.Game/Overlays/RankingsOverlay.cs | 10 +++++++--- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APISpotlight.cs b/osu.Game/Online/API/Requests/Responses/APISpotlight.cs index 3a002e57b2..4f63ebe3df 100644 --- a/osu.Game/Online/API/Requests/Responses/APISpotlight.cs +++ b/osu.Game/Online/API/Requests/Responses/APISpotlight.cs @@ -26,6 +26,9 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"end_date")] public DateTimeOffset EndDate; + [JsonProperty(@"participant_count")] + public int? Participants; + public override string ToString() => Name; } } diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index 41722034b6..5c78879b26 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -20,8 +20,8 @@ namespace osu.Game.Overlays.Rankings public IEnumerable Spotlights { - get => spotlightSelector.Spotlights; - set => spotlightSelector.Spotlights = value; + get => SpotlightSelector.Spotlights; + set => SpotlightSelector.Spotlights = value; } protected override ScreenTitle CreateTitle() => new RankingsTitle @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Rankings Current = Ruleset }; - private SpotlightSelector spotlightSelector; + public SpotlightSelector SpotlightSelector; protected override Drawable CreateContent() => new FillFlowContainer { @@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Rankings { Current = Country }, - spotlightSelector = new SpotlightSelector + SpotlightSelector = new SpotlightSelector { Current = { BindTarget = Spotlight } } @@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Rankings } private void onCurrentChanged(ValueChangedEvent scope) => - spotlightSelector.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint); + SpotlightSelector.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint); private class RankingsTitle : ScreenTitle { diff --git a/osu.Game/Overlays/Rankings/SpotlightSelector.cs b/osu.Game/Overlays/Rankings/SpotlightSelector.cs index e34c01113e..bd2b7d9b21 100644 --- a/osu.Game/Overlays/Rankings/SpotlightSelector.cs +++ b/osu.Game/Overlays/Rankings/SpotlightSelector.cs @@ -38,6 +38,8 @@ namespace osu.Game.Overlays.Rankings private readonly InfoColumn startDateColumn; private readonly InfoColumn endDateColumn; + private readonly InfoColumn mapCountColumn; + private readonly InfoColumn participantsColumn; public SpotlightSelector() { @@ -75,6 +77,8 @@ namespace osu.Game.Overlays.Rankings { startDateColumn = new InfoColumn(@"Start Date"), endDateColumn = new InfoColumn(@"End Date"), + mapCountColumn = new InfoColumn(@"Map Count"), + participantsColumn = new InfoColumn(@"Participants") } } } @@ -88,17 +92,12 @@ namespace osu.Game.Overlays.Rankings background.Colour = colourProvider.Dark3; } - protected override void LoadComplete() + public void ShowInfo(APISpotlight spotlight, int mapCount) { - base.LoadComplete(); - - Current.BindValueChanged(onCurrentChanged); - } - - private void onCurrentChanged(ValueChangedEvent spotlight) - { - startDateColumn.Value = dateToString(spotlight.NewValue.StartDate); - endDateColumn.Value = dateToString(spotlight.NewValue.EndDate); + startDateColumn.Value = dateToString(spotlight.StartDate); + endDateColumn.Value = dateToString(spotlight.EndDate); + mapCountColumn.Value = mapCount.ToString(); + participantsColumn.Value = spotlight.Participants?.ToString("N0"); } private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd"); diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 2a4bc28b18..ba0cc29d6d 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -36,6 +36,7 @@ namespace osu.Game.Overlays private APIRequest lastRequest; private CancellationTokenSource cancellationToken; + private GetSpotlightsRequest spotlightsRequest; [Resolved] private IAPIProvider api { get; set; } @@ -115,6 +116,8 @@ namespace osu.Game.Overlays Scope.BindValueChanged(_ => { + spotlightsRequest?.Cancel(); + // country filtering is only valid for performance scope. if (Scope.Value != RankingsScope.Performance) Country.Value = null; @@ -148,9 +151,9 @@ namespace osu.Game.Overlays private void getSpotlights() { loading.Show(); - var request = new GetSpotlightsRequest(); - request.Success += response => header.Spotlights = response.Spotlights; - api.Queue(request); + spotlightsRequest = new GetSpotlightsRequest(); + spotlightsRequest.Success += response => header.Spotlights = response.Spotlights; + api.Queue(spotlightsRequest); } private void loadNewContent() @@ -214,6 +217,7 @@ namespace osu.Game.Overlays return new CountriesTable(1, countryRequest.Result.Countries); case GetSpotlightRankingsRequest spotlightRequest: + header.SpotlightSelector.ShowInfo(spotlightRequest.Result.Spotlight, spotlightRequest.Result.BeatmapSets.Count); return new FillFlowContainer { AutoSizeAxes = Axes.Y, From 6708e271acd04336255c8c3aefa3e3ea8c2f17e7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 13:01:50 +0300 Subject: [PATCH 33/65] Adjust SpotlightSelector animations --- .../Rankings/RankingsOverlayHeader.cs | 2 +- .../Overlays/Rankings/SpotlightSelector.cs | 89 ++++++++++++------- 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index 5c78879b26..538ae112b5 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Rankings } private void onCurrentChanged(ValueChangedEvent scope) => - SpotlightSelector.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint); + SpotlightSelector.State.Value = scope.NewValue == RankingsScope.Spotlights ? Visibility.Visible : Visibility.Hidden; private class RankingsTitle : ScreenTitle { diff --git a/osu.Game/Overlays/Rankings/SpotlightSelector.cs b/osu.Game/Overlays/Rankings/SpotlightSelector.cs index bd2b7d9b21..8af6c0bb3b 100644 --- a/osu.Game/Overlays/Rankings/SpotlightSelector.cs +++ b/osu.Game/Overlays/Rankings/SpotlightSelector.cs @@ -17,8 +17,11 @@ using osu.Framework.Graphics.UserInterface; namespace osu.Game.Overlays.Rankings { - public class SpotlightSelector : CompositeDrawable, IHasCurrentValue + public class SpotlightSelector : VisibilityContainer, IHasCurrentValue { + private const int height = 100; + private const int duration = 200; + private readonly Box background; private readonly SpotlightsDropdown dropdown; @@ -36,54 +39,60 @@ namespace osu.Game.Overlays.Rankings set => dropdown.Items = value; } + protected override bool StartHidden => true; + private readonly InfoColumn startDateColumn; private readonly InfoColumn endDateColumn; private readonly InfoColumn mapCountColumn; private readonly InfoColumn participantsColumn; + private readonly Container content; public SpotlightSelector() { RelativeSizeAxes = Axes.X; - Height = 100; - - InternalChildren = new Drawable[] + Add(content = new Container { - background = new Box + Height = height, + RelativeSizeAxes = Axes.X, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, - Children = new Drawable[] + background = new Box { - dropdown = new SpotlightsDropdown + RelativeSizeAxes = Axes.Both, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, + Children = new Drawable[] { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - Current = Current, - Depth = -float.MaxValue - }, - new FillFlowContainer - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(15, 0), - Children = new Drawable[] + dropdown = new SpotlightsDropdown { - startDateColumn = new InfoColumn(@"Start Date"), - endDateColumn = new InfoColumn(@"End Date"), - mapCountColumn = new InfoColumn(@"Map Count"), - participantsColumn = new InfoColumn(@"Participants") + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + Current = Current, + Depth = -float.MaxValue + }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(15, 0), + Children = new Drawable[] + { + startDateColumn = new InfoColumn(@"Start Date"), + endDateColumn = new InfoColumn(@"End Date"), + mapCountColumn = new InfoColumn(@"Map Count"), + participantsColumn = new InfoColumn(@"Participants") + } } } - } - }, - }; + }, + } + }); } [BackgroundDependencyLoader] @@ -100,6 +109,18 @@ namespace osu.Game.Overlays.Rankings participantsColumn.Value = spotlight.Participants?.ToString("N0"); } + protected override void PopIn() + { + this.ResizeHeightTo(height, duration, Easing.OutQuint); + content.FadeIn(duration, Easing.OutQuint); + } + + protected override void PopOut() + { + this.ResizeHeightTo(0, duration, Easing.OutQuint); + content.FadeOut(duration, Easing.OutQuint); + } + private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd"); private class InfoColumn : FillFlowContainer From 00e010a06151a085636dcdfa5fbae2167470780e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 13:11:02 +0300 Subject: [PATCH 34/65] Add visibility test for SpotlightSelector --- .../Visual/Online/TestSceneRankingsSpotlightSelector.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs index e46c8a4a71..f27ab1e775 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs @@ -35,6 +35,12 @@ namespace osu.Game.Tests.Visual.Online Add(selector = new SpotlightSelector()); } + [Test] + public void TestVisibility() + { + AddStep("Toggle Visibility", selector.ToggleVisibility); + } + [Test] public void TestLocalSpotlights() { From f4ee281dd6474552d935bda91234daf6c575d5ba Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 16:15:55 +0100 Subject: [PATCH 35/65] Add optional decimal place --- osu.Game/Overlays/BeatmapSet/SuccessRate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs index dac750dacf..15216b6e69 100644 --- a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs @@ -42,7 +42,7 @@ namespace osu.Game.Overlays.BeatmapSet int playCount = beatmap?.OnlineInfo?.PlayCount ?? 0; var rate = playCount != 0 ? (float)passCount / playCount : 0; - successPercent.Text = rate.ToString("0%"); + successPercent.Text = rate.ToString("0.#%"); successRate.Length = rate; percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic); From 76037e4ffddab6a219219b8a909209dcb06a002f Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 16:31:14 +0100 Subject: [PATCH 36/65] Recolour ranked status pill --- .../Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs | 9 ++++++++- osu.Game/Overlays/BeatmapSet/Header.cs | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs index 351e5df17a..f6e03d40ff 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs @@ -13,6 +13,7 @@ namespace osu.Game.Beatmaps.Drawables public class BeatmapSetOnlineStatusPill : CircularContainer { private readonly OsuSpriteText statusText; + private readonly Box background; private BeatmapSetOnlineStatus status; @@ -43,6 +44,12 @@ namespace osu.Game.Beatmaps.Drawables set => statusText.Padding = value; } + public Color4 BackgroundColour + { + get => background.Colour; + set => background.Colour = value; + } + public BeatmapSetOnlineStatusPill() { AutoSizeAxes = Axes.Both; @@ -50,7 +57,7 @@ namespace osu.Game.Beatmaps.Drawables Children = new Drawable[] { - new Box + background = new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 9f79b92cb6..1b111ced1f 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -218,6 +218,7 @@ namespace osu.Game.Overlays.BeatmapSet private void load(OverlayColourProvider colourProvider) { coverGradient.Colour = ColourInfo.GradientVertical(colourProvider.Background6.Opacity(0.3f), colourProvider.Background6.Opacity(0.8f)); + onlineStatusPill.BackgroundColour = colourProvider.Background6; State.BindValueChanged(_ => updateDownloadButtons()); From e1e1c1a11af6a8397b43d250d0fba0edcb0268b2 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 16:34:39 +0100 Subject: [PATCH 37/65] Match osu-web display accuracy Decided to change this only locally instead of modifying FormatAccuracy which would affect everywhere else in the game as well. --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index f04477d911..9c71cabfa6 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -120,7 +120,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores new OsuSpriteText { Margin = new MarginPadding { Right = horizontal_inset }, - Text = score.DisplayAccuracy, + Text = $@"{score.Accuracy:0.00%}", Font = OsuFont.GetFont(size: text_size), Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White }, From fa3934ddb474b605b3147a364f43ce968984f7b5 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 17:16:20 +0100 Subject: [PATCH 38/65] Match osu-web button description --- osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs index e0360c6312..5ed15cecd5 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs @@ -150,7 +150,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, new OsuSpriteText { - Text = BeatmapSet.Value.OnlineInfo.HasVideo && noVideo ? "without Video" : string.Empty, + Text = BeatmapSet.Value.OnlineInfo.HasVideo ? (noVideo ? "without Video" : "with Video") : string.Empty, Font = OsuFont.GetFont(size: 11, weight: FontWeight.Bold) }, }; From e79ba9a1299fc54728d9762af30e5e38a02f0e4b Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 17:41:57 +0100 Subject: [PATCH 39/65] Add alwaysShowDecimals param to FormatAccuracy This allows us to specify whether we want it to show decimal places if accuracy is 100%. --- osu.Game/Utils/FormatUtils.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Utils/FormatUtils.cs b/osu.Game/Utils/FormatUtils.cs index b3758b3375..f0b8b470f1 100644 --- a/osu.Game/Utils/FormatUtils.cs +++ b/osu.Game/Utils/FormatUtils.cs @@ -7,18 +7,18 @@ namespace osu.Game.Utils { /// /// Turns the provided accuracy into a percentage with 2 decimal places. - /// Omits all decimal places when equals 1d. /// /// The accuracy to be formatted + /// Whether to show decimal places if equals 1d /// formatted accuracy in percentage - public static string FormatAccuracy(this double accuracy) => accuracy == 1 ? "100%" : $"{accuracy:0.00%}"; + public static string FormatAccuracy(this double accuracy, bool alwaysShowDecimals = false) => accuracy == 1 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00%}"; /// /// Turns the provided accuracy into a percentage with 2 decimal places. - /// Omits all decimal places when equals 100m. /// /// The accuracy to be formatted + /// Whether to show decimal places if equals 100m /// formatted accuracy in percentage - public static string FormatAccuracy(this decimal accuracy) => accuracy == 100 ? "100%" : $"{accuracy:0.00}%"; + public static string FormatAccuracy(this decimal accuracy, bool alwaysShowDecimals = false) => accuracy == 100 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00}%"; } } From 63df6b8da6255116b7c6fe25df8c5d09fe797cc3 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 17:42:14 +0100 Subject: [PATCH 40/65] Change accuracy formatting method --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 9c71cabfa6..4d5bd84090 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -16,6 +16,7 @@ using osu.Game.Scoring; using osu.Game.Users.Drawables; using osuTK; using osuTK.Graphics; +using osu.Game.Utils; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -120,7 +121,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores new OsuSpriteText { Margin = new MarginPadding { Right = horizontal_inset }, - Text = $@"{score.Accuracy:0.00%}", + Text = score.Accuracy.FormatAccuracy(alwaysShowDecimals: true), Font = OsuFont.GetFont(size: text_size), Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White }, From c93d2c7f00240ec8126732e801c66389f041457b Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Wed, 5 Feb 2020 18:26:01 +0100 Subject: [PATCH 41/65] Adjust loading container corner radius --- osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 0a3b5d9457..8560232209 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -164,7 +164,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { RelativeSizeAxes = Axes.Both, Masking = true, - CornerRadius = 10, + CornerRadius = 5, Child = loading = new DimmedLoadingLayer(iconScale: 0.8f) { Alpha = 0, From 24e8a2bd6920cae69a957c807c60648bd9c7ea86 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 22:59:01 +0300 Subject: [PATCH 42/65] Make SpotlightSelector.ShowInfo use the full rankings response --- osu.Game/Overlays/Rankings/SpotlightSelector.cs | 11 ++++++----- osu.Game/Overlays/RankingsOverlay.cs | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Rankings/SpotlightSelector.cs b/osu.Game/Overlays/Rankings/SpotlightSelector.cs index 8af6c0bb3b..8bf75b2357 100644 --- a/osu.Game/Overlays/Rankings/SpotlightSelector.cs +++ b/osu.Game/Overlays/Rankings/SpotlightSelector.cs @@ -14,6 +14,7 @@ using osuTK; using System; using System.Collections.Generic; using osu.Framework.Graphics.UserInterface; +using osu.Game.Online.API.Requests; namespace osu.Game.Overlays.Rankings { @@ -101,12 +102,12 @@ namespace osu.Game.Overlays.Rankings background.Colour = colourProvider.Dark3; } - public void ShowInfo(APISpotlight spotlight, int mapCount) + public void ShowInfo(GetSpotlightRankingsResponse response) { - startDateColumn.Value = dateToString(spotlight.StartDate); - endDateColumn.Value = dateToString(spotlight.EndDate); - mapCountColumn.Value = mapCount.ToString(); - participantsColumn.Value = spotlight.Participants?.ToString("N0"); + startDateColumn.Value = dateToString(response.Spotlight.StartDate); + endDateColumn.Value = dateToString(response.Spotlight.EndDate); + mapCountColumn.Value = response.BeatmapSets.Count.ToString(); + participantsColumn.Value = response.Spotlight.Participants?.ToString("N0"); } protected override void PopIn() diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index ba0cc29d6d..99e81eef15 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -217,7 +217,7 @@ namespace osu.Game.Overlays return new CountriesTable(1, countryRequest.Result.Countries); case GetSpotlightRankingsRequest spotlightRequest: - header.SpotlightSelector.ShowInfo(spotlightRequest.Result.Spotlight, spotlightRequest.Result.BeatmapSets.Count); + header.SpotlightSelector.ShowInfo(spotlightRequest.Result); return new FillFlowContainer { AutoSizeAxes = Axes.Y, From 4dd25b42aeee0fb158dcdb05ab128733332842f5 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 23:00:42 +0300 Subject: [PATCH 43/65] Move spotlightsRequest to another place --- osu.Game/Overlays/RankingsOverlay.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 99e81eef15..084c8b6e5a 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -36,7 +36,6 @@ namespace osu.Game.Overlays private APIRequest lastRequest; private CancellationTokenSource cancellationToken; - private GetSpotlightsRequest spotlightsRequest; [Resolved] private IAPIProvider api { get; set; } @@ -148,6 +147,8 @@ namespace osu.Game.Overlays Country.Value = requested; } + private GetSpotlightsRequest spotlightsRequest; + private void getSpotlights() { loading.Show(); From 7757a3a30bb7cfe33c0def5fe4489cddf7949796 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 5 Feb 2020 23:06:13 +0300 Subject: [PATCH 44/65] Move spotlight layout to it's own method --- osu.Game/Overlays/RankingsOverlay.cs | 52 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 084c8b6e5a..4fc94420a4 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -218,34 +218,40 @@ namespace osu.Game.Overlays return new CountriesTable(1, countryRequest.Result.Countries); case GetSpotlightRankingsRequest spotlightRequest: - header.SpotlightSelector.ShowInfo(spotlightRequest.Result); - return new FillFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 20), - Children = new Drawable[] - { - new ScoresTable(1, spotlightRequest.Result.Users), - new FillFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Spacing = new Vector2(10), - Children = spotlightRequest.Result.BeatmapSets.Select(b => new DirectGridPanel(b.ToBeatmapSet(rulesets)) - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - }).ToList() - } - } - }; + return getSpotlightContent(spotlightRequest.Result); } return null; } + private Drawable getSpotlightContent(GetSpotlightRankingsResponse response) + { + header.SpotlightSelector.ShowInfo(response); + + return new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 20), + Children = new Drawable[] + { + new ScoresTable(1, response.Users), + new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Spacing = new Vector2(10), + Children = response.BeatmapSets.Select(b => new DirectGridPanel(b.ToBeatmapSet(rulesets)) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }).ToList() + } + } + }; + } + private void loadContent(Drawable content) { scrollFlow.ScrollToStart(); From c09af0052bf3f2e1a2e4809b12aeeb166f0501af Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Thu, 6 Feb 2020 20:21:47 +0100 Subject: [PATCH 45/65] Revert accuracy display and column sorting changes --- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 7 +------ osu.Game/Utils/FormatUtils.cs | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 4d5bd84090..2310b2a0f5 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -16,7 +16,6 @@ using osu.Game.Scoring; using osu.Game.Users.Drawables; using osuTK; using osuTK.Graphics; -using osu.Game.Utils; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -66,10 +65,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores for (int i = 0; i < value.Count; i++) backgroundFlow.Add(new ScoreTableRowBackground(i, value[i])); - // Ensure correct column order - foreach (ScoreInfo score in value) - score.Statistics = score.Statistics.OrderByDescending(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value); - Columns = createHeaders(value[0]); Content = value.Select((s, i) => createContent(i, s)).ToArray().ToRectangular(); } @@ -121,7 +116,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores new OsuSpriteText { Margin = new MarginPadding { Right = horizontal_inset }, - Text = score.Accuracy.FormatAccuracy(alwaysShowDecimals: true), + Text = score.DisplayAccuracy, Font = OsuFont.GetFont(size: text_size), Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White }, diff --git a/osu.Game/Utils/FormatUtils.cs b/osu.Game/Utils/FormatUtils.cs index f0b8b470f1..b3758b3375 100644 --- a/osu.Game/Utils/FormatUtils.cs +++ b/osu.Game/Utils/FormatUtils.cs @@ -7,18 +7,18 @@ namespace osu.Game.Utils { /// /// Turns the provided accuracy into a percentage with 2 decimal places. + /// Omits all decimal places when equals 1d. /// /// The accuracy to be formatted - /// Whether to show decimal places if equals 1d /// formatted accuracy in percentage - public static string FormatAccuracy(this double accuracy, bool alwaysShowDecimals = false) => accuracy == 1 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00%}"; + public static string FormatAccuracy(this double accuracy) => accuracy == 1 ? "100%" : $"{accuracy:0.00%}"; /// /// Turns the provided accuracy into a percentage with 2 decimal places. + /// Omits all decimal places when equals 100m. /// /// The accuracy to be formatted - /// Whether to show decimal places if equals 100m /// formatted accuracy in percentage - public static string FormatAccuracy(this decimal accuracy, bool alwaysShowDecimals = false) => accuracy == 100 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00}%"; + public static string FormatAccuracy(this decimal accuracy) => accuracy == 100 ? "100%" : $"{accuracy:0.00}%"; } } From 881d192af3ecdc9cc9f950bd4e607b70bb3c969d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 7 Feb 2020 12:07:16 +0300 Subject: [PATCH 46/65] Fix crash when selecting spotlight tab with not-null country --- osu.Game/Overlays/RankingsOverlay.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index 4fc94420a4..a0aeff082e 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -110,7 +110,8 @@ namespace osu.Game.Overlays if (Country.Value != null) Scope.Value = RankingsScope.Performance; - Scheduler.AddOnce(loadNewContent); + if (Scope.Value != RankingsScope.Spotlights) + Scheduler.AddOnce(loadNewContent); }, true); Scope.BindValueChanged(_ => From 7395f01919a6710fda4127676b6482e06d882676 Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Fri, 7 Feb 2020 20:28:02 +0100 Subject: [PATCH 47/65] Use osu-web font sizes --- osu.Game/Overlays/BeatmapSet/Header.cs | 2 +- osu.Game/Overlays/BeatmapSet/Info.cs | 2 +- osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs | 4 ++-- osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 1b111ced1f..ab7b2d82ed 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -196,7 +196,7 @@ namespace osu.Game.Overlays.BeatmapSet { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, - TextSize = 17, + TextSize = 14, TextPadding = new MarginPadding { Horizontal = 35, Vertical = 10 } }, Details = new Details(), diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index a71409a05f..0a5415124e 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -118,7 +118,7 @@ namespace osu.Game.Overlays.BeatmapSet Origin = Anchor.Centre, Alpha = 0, Text = "Unranked beatmap", - Font = OsuFont.GetFont(size: 13) + Font = OsuFont.GetFont(size: 12) }, }, }, diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 2310b2a0f5..7f55aecaf0 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -23,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const float horizontal_inset = 20; private const float row_height = 25; - private const int text_size = 14; + private const int text_size = 12; private readonly FillFlowContainer backgroundFlow; @@ -190,7 +190,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public HeaderText(string text) { Text = text.ToUpper(); - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold); + Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index 00171e1170..8a368aa535 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -96,7 +96,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: 12) + Font = OsuFont.GetFont(size: 10) }, flag = new UpdateableFlag { From 88a56d00bfde67ba143e7b1d87a90d5b4ba0b5c4 Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Sun, 9 Feb 2020 20:11:37 -0800 Subject: [PATCH 48/65] Allow specifying order to SettingSource --- .../Mods/CatchModDifficultyAdjust.cs | 4 +-- .../Mods/OsuModDifficultyAdjust.cs | 4 +-- .../Configuration/SettingSourceAttribute.cs | 28 +++++++++++++++++-- osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs | 4 +-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs index 8377b3786a..802802c155 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch.Mods { public class CatchModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Fruit Size", "Override a beatmap's set CS.")] + [SettingSource("Fruit Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.")] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", SettingSourceAttribute.LAST)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs index 7eee71be81..5326e36282 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Mods { public class OsuModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Circle Size", "Override a beatmap's set CS.")] + [SettingSource("Circle Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.")] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", SettingSourceAttribute.LAST)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game/Configuration/SettingSourceAttribute.cs b/osu.Game/Configuration/SettingSourceAttribute.cs index a3788e4582..79232b70dc 100644 --- a/osu.Game/Configuration/SettingSourceAttribute.cs +++ b/osu.Game/Configuration/SettingSourceAttribute.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using JetBrains.Annotations; using osu.Framework.Bindables; @@ -20,14 +21,25 @@ namespace osu.Game.Configuration [AttributeUsage(AttributeTargets.Property)] public class SettingSourceAttribute : Attribute { + public const int FIRST = 0; + public const int ORDERED_RELATIVE = 1; + public const int UNORDERED = 2; + public const int LAST = 3; + public string Label { get; } public string Description { get; } - public SettingSourceAttribute(string label, string description = null) + public int OrderMode { get; } + + public int OrderPosition { get; } + + public SettingSourceAttribute(string label, string description = null, int order = UNORDERED, int orderPosition = 0) { Label = label ?? string.Empty; Description = description ?? string.Empty; + OrderMode = order; + OrderPosition = orderPosition; } } @@ -35,7 +47,7 @@ namespace osu.Game.Configuration { public static IEnumerable CreateSettingsControls(this object obj) { - foreach (var (attr, property) in obj.GetSettingsSourceProperties()) + foreach (var (attr, property) in obj.GetOrderedSettingsSourceProperties()) { object value = property.GetValue(obj); @@ -116,5 +128,17 @@ namespace osu.Game.Configuration yield return (attr, property); } } + + public static IEnumerable<(SettingSourceAttribute, PropertyInfo)> GetOrderedSettingsSourceProperties(this object obj) + { + var original = obj.GetSettingsSourceProperties(); + + var first = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.FIRST); + var orderedRelative = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.ORDERED_RELATIVE).OrderBy(attr => attr.Item1.OrderPosition); + var unordered = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.UNORDERED); + var last = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.LAST); + + return first.Concat(orderedRelative).Concat(unordered).Concat(last); + } } } diff --git a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs index d74e2ce2bc..8c6b9658b0 100644 --- a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs +++ b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mods public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) }; - [SettingSource("Drain Rate", "Override a beatmap's set HP.")] + [SettingSource("Drain Rate", "Override a beatmap's set HP.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] public BindableNumber DrainRate { get; } = new BindableFloat { Precision = 0.1f, @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Mods Value = 5, }; - [SettingSource("Overall Difficulty", "Override a beatmap's set OD.")] + [SettingSource("Overall Difficulty", "Override a beatmap's set OD.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] public BindableNumber OverallDifficulty { get; } = new BindableFloat { Precision = 0.1f, From 137181017b96ae3c7f786295c42023da197691ed Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Sun, 9 Feb 2020 20:36:54 -0800 Subject: [PATCH 49/65] Naming consistency with osu!web --- osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs | 2 +- osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs index 802802c155..f4754696ff 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch.Mods { public class CatchModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Fruit Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)] + [SettingSource("Circle Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs index 8c6b9658b0..fae04dd13e 100644 --- a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs +++ b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mods public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) }; - [SettingSource("Drain Rate", "Override a beatmap's set HP.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] + [SettingSource("HP Drain", "Override a beatmap's set HP.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] public BindableNumber DrainRate { get; } = new BindableFloat { Precision = 0.1f, @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Mods Value = 5, }; - [SettingSource("Overall Difficulty", "Override a beatmap's set OD.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] + [SettingSource("Accuracy", "Override a beatmap's set OD.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] public BindableNumber OverallDifficulty { get; } = new BindableFloat { Precision = 0.1f, From ea521b466fdaa28dda69d8388f3f19a6183f040b Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Sun, 9 Feb 2020 21:37:40 -0800 Subject: [PATCH 50/65] Switch numerical consts to an enum --- .../Mods/CatchModDifficultyAdjust.cs | 5 ++-- .../Mods/OsuModDifficultyAdjust.cs | 5 ++-- .../Configuration/SettingSourceAttribute.cs | 25 +++++++++++-------- osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs | 5 ++-- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs index f4754696ff..17a2847fd1 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs @@ -5,12 +5,13 @@ using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Rulesets.Mods; +using static osu.Game.Configuration.SettingSourceAttribute; namespace osu.Game.Rulesets.Catch.Mods { public class CatchModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Circle Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)] + [SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -20,7 +21,7 @@ namespace osu.Game.Rulesets.Catch.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.", SettingSourceAttribute.LAST)] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs index 5326e36282..2b56042ead 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs @@ -5,12 +5,13 @@ using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Rulesets.Mods; +using static osu.Game.Configuration.SettingSourceAttribute; namespace osu.Game.Rulesets.Osu.Mods { public class OsuModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Circle Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)] + [SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -20,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.", SettingSourceAttribute.LAST)] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game/Configuration/SettingSourceAttribute.cs b/osu.Game/Configuration/SettingSourceAttribute.cs index 79232b70dc..06e01bb042 100644 --- a/osu.Game/Configuration/SettingSourceAttribute.cs +++ b/osu.Game/Configuration/SettingSourceAttribute.cs @@ -21,24 +21,27 @@ namespace osu.Game.Configuration [AttributeUsage(AttributeTargets.Property)] public class SettingSourceAttribute : Attribute { - public const int FIRST = 0; - public const int ORDERED_RELATIVE = 1; - public const int UNORDERED = 2; - public const int LAST = 3; + public enum OrderMode + { + FIRST, + ORDERED_RELATIVE, + UNORDERED, + LAST + } public string Label { get; } public string Description { get; } - public int OrderMode { get; } + public OrderMode OrderingMode { get; } public int OrderPosition { get; } - public SettingSourceAttribute(string label, string description = null, int order = UNORDERED, int orderPosition = 0) + public SettingSourceAttribute(string label, string description = null, OrderMode order = OrderMode.UNORDERED, int orderPosition = 0) { Label = label ?? string.Empty; Description = description ?? string.Empty; - OrderMode = order; + OrderingMode = order; OrderPosition = orderPosition; } } @@ -133,10 +136,10 @@ namespace osu.Game.Configuration { var original = obj.GetSettingsSourceProperties(); - var first = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.FIRST); - var orderedRelative = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.ORDERED_RELATIVE).OrderBy(attr => attr.Item1.OrderPosition); - var unordered = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.UNORDERED); - var last = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.LAST); + var first = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.FIRST); + var orderedRelative = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.ORDERED_RELATIVE).OrderBy(attr => attr.Item1.OrderPosition); + var unordered = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.UNORDERED); + var last = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.LAST); return first.Concat(orderedRelative).Concat(unordered).Concat(last); } diff --git a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs index fae04dd13e..958a0353ea 100644 --- a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs +++ b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites; using System; using System.Collections.Generic; using osu.Game.Configuration; +using static osu.Game.Configuration.SettingSourceAttribute; namespace osu.Game.Rulesets.Mods { @@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Mods public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) }; - [SettingSource("HP Drain", "Override a beatmap's set HP.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] + [SettingSource("HP Drain", "Override a beatmap's set HP.", OrderMode.ORDERED_RELATIVE, 1)] public BindableNumber DrainRate { get; } = new BindableFloat { Precision = 0.1f, @@ -38,7 +39,7 @@ namespace osu.Game.Rulesets.Mods Value = 5, }; - [SettingSource("Accuracy", "Override a beatmap's set OD.", SettingSourceAttribute.ORDERED_RELATIVE, 1)] + [SettingSource("Accuracy", "Override a beatmap's set OD.", OrderMode.ORDERED_RELATIVE, 1)] public BindableNumber OverallDifficulty { get; } = new BindableFloat { Precision = 0.1f, From d61516e10c342a02ee20350bb49c7cd69a1eec05 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Feb 2020 16:59:49 +0900 Subject: [PATCH 51/65] Add failing tests --- .../SongSelect/TestScenePlaySongSelect.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 80192b9ebc..a5145f420d 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -17,6 +17,7 @@ using osu.Framework.Screens; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; @@ -426,6 +427,40 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("start not requested", () => !startRequested); } + [TestCase(false)] + [TestCase(true)] + public void TestExternalBeatmapChangeWhileFiltered(bool differentRuleset) + { + createSongSelect(); + addManyTestMaps(); + + changeRuleset(0); + + AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null); + + AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType().First().Text = "nonono"); + + AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap); + + BeatmapInfo target = null; + + AddStep("select beatmap externally", () => + { + target = manager.QueryBeatmapSets(b => b.Beatmaps.Any(bi => bi.RulesetID == (differentRuleset ? 1 : 0))) + .ElementAt(5).Beatmaps.First(); + + Beatmap.Value = manager.GetWorkingBeatmap(target); + }); + + AddUntilStep("correct beatmap selected", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID); + AddAssert("carousel also correct", () => songSelect.Carousel.SelectedBeatmap.OnlineBeatmapID == target.OnlineBeatmapID); + + AddStep("reset filter text", () => songSelect.FilterControl.ChildrenOfType().First().Text = string.Empty); + + AddAssert("still selected", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID); + AddAssert("carousel also correct", () => songSelect.Carousel.SelectedBeatmap.OnlineBeatmapID == target.OnlineBeatmapID); + } + [Test] public void TestAutoplayViaCtrlEnter() { @@ -468,6 +503,7 @@ namespace osu.Game.Tests.Visual.SongSelect private void importForRuleset(int id) => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())).Wait(); private static int importId; + private int getImportId() => ++importId; private void checkMusicPlaying(bool playing) => @@ -551,6 +587,8 @@ namespace osu.Game.Tests.Visual.SongSelect public new Bindable Ruleset => base.Ruleset; + public new FilterControl FilterControl => base.FilterControl; + public WorkingBeatmap CurrentBeatmap => Beatmap.Value; public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap; public new BeatmapCarousel Carousel => base.Carousel; From 66fb72cd8a476f33f07f408d0c0220d23233d950 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Feb 2020 16:31:52 +0900 Subject: [PATCH 52/65] Fix song select not showing active beatmap if it is filtered by local criteria --- osu.Game/Screens/Select/BeatmapCarousel.cs | 12 ++++++++++++ .../Select/Carousel/CarouselBeatmapSet.cs | 2 +- osu.Game/Screens/Select/Carousel/CarouselItem.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 16 +++++++++++----- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 592e26adc2..5be4d24b2b 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -17,6 +17,7 @@ using osu.Framework.Caching; using osu.Framework.Threading; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Input.Events; +using osu.Framework.Logging; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; @@ -229,6 +230,17 @@ namespace osu.Game.Screens.Select if (item != null) { select(item); + + // if we got here and the set is filtered, it means we were bypassing filters. + // in this case, reapplying the filter is necessary to ensure the panel is in the correct place + // (since it is forcefully being included in the carousel). + if (set.Filtered.Value) + { + Debug.Assert(bypassFilters); + + applyActiveCriteria(false, true); + } + return true; } } diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index 301d0d4dae..8e323c66e2 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Select.Carousel /// /// All beatmaps which are not filtered and valid for display. /// - protected IEnumerable ValidBeatmaps => Beatmaps.Where(b => !b.Filtered.Value).Select(b => b.Beatmap); + protected IEnumerable ValidBeatmaps => Beatmaps.Where(b => !b.Filtered.Value || b.State.Value == CarouselItemState.Selected).Select(b => b.Beatmap); private int compareUsingAggregateMax(CarouselBeatmapSet other, Func func) { diff --git a/osu.Game/Screens/Select/Carousel/CarouselItem.cs b/osu.Game/Screens/Select/Carousel/CarouselItem.cs index 79c1a4cb6b..1108b72bd2 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselItem.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselItem.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Select.Carousel /// /// This item is not in a hidden state. /// - public bool Visible => State.Value != CarouselItemState.Collapsed && !Filtered.Value; + public bool Visible => State.Value == CarouselItemState.Selected || (State.Value != CarouselItemState.Collapsed && !Filtered.Value); public virtual List Drawables { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 5037081b5e..0da260d752 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -376,16 +376,22 @@ namespace osu.Game.Screens.Select private void workingBeatmapChanged(ValueChangedEvent e) { - if (e.NewValue is DummyWorkingBeatmap) return; + if (e.NewValue is DummyWorkingBeatmap || !this.IsCurrentScreen()) return; - if (this.IsCurrentScreen() && !Carousel.SelectBeatmap(e.NewValue?.BeatmapInfo, false)) + if (!Carousel.SelectBeatmap(e.NewValue.BeatmapInfo, false)) { - // If selecting new beatmap without bypassing filters failed, there's possibly a ruleset mismatch - if (e.NewValue?.BeatmapInfo?.Ruleset != null && !e.NewValue.BeatmapInfo.Ruleset.Equals(decoupledRuleset.Value)) + // A selection may not have been possible with filters applied. + + // There was possibly a ruleset mismatch. This is a case we can help things along by updating the game-wide ruleset to match. + if (e.NewValue.BeatmapInfo.Ruleset != null && !e.NewValue.BeatmapInfo.Ruleset.Equals(decoupledRuleset.Value)) { Ruleset.Value = e.NewValue.BeatmapInfo.Ruleset; - Carousel.SelectBeatmap(e.NewValue.BeatmapInfo); + transferRulesetValue(); } + + // Even if a ruleset mismatch was not the cause (ie. a text filter is applied), + // we still want to forcefully show the new beatmap, bypassing filters. + Carousel.SelectBeatmap(e.NewValue.BeatmapInfo); } } From 8186f7250725472fd54039e91f44df57135a2f8d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Feb 2020 17:12:45 +0900 Subject: [PATCH 53/65] Remove unused using --- osu.Game/Screens/Select/BeatmapCarousel.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 5be4d24b2b..7f36a23a86 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -17,7 +17,6 @@ using osu.Framework.Caching; using osu.Framework.Threading; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Input.Events; -using osu.Framework.Logging; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; From 926cde9afc14ecbd3c75b043b22b1383cec4e3f2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Feb 2020 18:17:27 +0900 Subject: [PATCH 54/65] Fix potential test failures --- .../Visual/SongSelect/TestScenePlaySongSelect.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index a5145f420d..bd06089514 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -452,13 +452,13 @@ namespace osu.Game.Tests.Visual.SongSelect Beatmap.Value = manager.GetWorkingBeatmap(target); }); - AddUntilStep("correct beatmap selected", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID); - AddAssert("carousel also correct", () => songSelect.Carousel.SelectedBeatmap.OnlineBeatmapID == target.OnlineBeatmapID); + AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmap?.OnlineBeatmapID == target.OnlineBeatmapID); + AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID); AddStep("reset filter text", () => songSelect.FilterControl.ChildrenOfType().First().Text = string.Empty); - AddAssert("still selected", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID); - AddAssert("carousel also correct", () => songSelect.Carousel.SelectedBeatmap.OnlineBeatmapID == target.OnlineBeatmapID); + AddAssert("game still correct", () => Beatmap.Value?.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID); + AddAssert("carousel still correct", () => songSelect.Carousel.SelectedBeatmap.OnlineBeatmapID == target.OnlineBeatmapID); } [Test] From e2950d7027003db5f9f1327cefae551a9a745117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 10 Feb 2020 20:27:46 +0100 Subject: [PATCH 55/65] Extract method to avoid nested ternaries --- .../BeatmapSet/Buttons/HeaderDownloadButton.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs index 5ed15cecd5..53003b0488 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs @@ -150,7 +150,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons }, new OsuSpriteText { - Text = BeatmapSet.Value.OnlineInfo.HasVideo ? (noVideo ? "without Video" : "with Video") : string.Empty, + Text = getVideoSuffixText(), Font = OsuFont.GetFont(size: 11, weight: FontWeight.Bold) }, }; @@ -163,5 +163,13 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons private void userChanged(ValueChangedEvent e) => button.Enabled.Value = !(e.NewValue is GuestUser); private void enabledChanged(ValueChangedEvent e) => this.FadeColour(e.NewValue ? Color4.White : Color4.Gray, 200, Easing.OutQuint); + + private string getVideoSuffixText() + { + if (!BeatmapSet.Value.OnlineInfo.HasVideo) + return string.Empty; + + return noVideo ? "without Video" : "with Video"; + } } } From 811553cd60e47cca3d86386dc9b9c5c561255e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 10 Feb 2020 20:37:34 +0100 Subject: [PATCH 56/65] Remove unnecessary coercions Comparisons to null of nullable numbers are always false. --- osu.Game/Overlays/BeatmapSet/Details.cs | 2 +- osu.Game/Overlays/BeatmapSet/Info.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index bd13b4371e..488e181fa2 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet private void updateDisplay() { Ratings.Metrics = BeatmapSet?.Metrics; - ratingBox.Alpha = (BeatmapSet?.OnlineInfo?.Status ?? 0) > 0 ? 1 : 0; + ratingBox.Alpha = BeatmapSet?.OnlineInfo?.Status > 0 ? 1 : 0; } public Details() diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 0a5415124e..85e871baca 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -132,7 +132,7 @@ namespace osu.Game.Overlays.BeatmapSet tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty; genre.Text = b.NewValue?.OnlineInfo?.Genre?.Name ?? string.Empty; language.Text = b.NewValue?.OnlineInfo?.Language?.Name ?? string.Empty; - var setHasLeaderboard = (b.NewValue?.OnlineInfo?.Status ?? 0) > 0; + var setHasLeaderboard = b.NewValue?.OnlineInfo?.Status > 0; successRate.Alpha = setHasLeaderboard ? 1 : 0; unrankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1; }; From 35d5237dddf677dee02c7d2fc622e1d78abcacc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 10 Feb 2020 20:40:39 +0100 Subject: [PATCH 57/65] Adjust font sizes --- osu.Game/Overlays/BeatmapSet/Header.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index ab7b2d82ed..5f4782573d 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -134,7 +134,7 @@ namespace osu.Game.Overlays.BeatmapSet { title = new OsuSpriteText { - Font = OsuFont.GetFont(size: 37, weight: FontWeight.SemiBold, italics: true) + Font = OsuFont.GetFont(size: 37.5f, weight: FontWeight.SemiBold, italics: true) }, externalLink = new ExternalLinkButton { @@ -144,7 +144,7 @@ namespace osu.Game.Overlays.BeatmapSet }, } }, - artist = new OsuSpriteText { Font = OsuFont.GetFont(size: 25, weight: FontWeight.Medium, italics: true) }, + artist = new OsuSpriteText { Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true) }, new Container { RelativeSizeAxes = Axes.X, From e072042d4ecfd8e81517b34a845ebff5114e582c Mon Sep 17 00:00:00 2001 From: TheWildTree Date: Mon, 10 Feb 2020 21:11:49 +0100 Subject: [PATCH 58/65] Match osu-web font size --- osu.Game/Overlays/BeatmapSet/Header.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 5f4782573d..29f09a1ad8 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -134,7 +134,7 @@ namespace osu.Game.Overlays.BeatmapSet { title = new OsuSpriteText { - Font = OsuFont.GetFont(size: 37.5f, weight: FontWeight.SemiBold, italics: true) + Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true) }, externalLink = new ExternalLinkButton { From b04a4b5c8ac28f3eb70150efee23f6085395854d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 11 Feb 2020 01:44:56 +0300 Subject: [PATCH 59/65] Implement SpotlightsLayout --- .../TestSceneRankingsSpotlightSelector.cs | 6 - .../Online/TestSceneSpotlightsLayout.cs | 55 ++++++ .../Rankings/RankingsOverlayHeader.cs | 6 +- .../Overlays/Rankings/SpotlightSelector.cs | 86 ++++------ .../Overlays/Rankings/SpotlightsLayout.cs | 158 ++++++++++++++++++ 5 files changed, 249 insertions(+), 62 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneSpotlightsLayout.cs create mode 100644 osu.Game/Overlays/Rankings/SpotlightsLayout.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs index f27ab1e775..e46c8a4a71 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs @@ -35,12 +35,6 @@ namespace osu.Game.Tests.Visual.Online Add(selector = new SpotlightSelector()); } - [Test] - public void TestVisibility() - { - AddStep("Toggle Visibility", selector.ToggleVisibility); - } - [Test] public void TestLocalSpotlights() { diff --git a/osu.Game.Tests/Visual/Online/TestSceneSpotlightsLayout.cs b/osu.Game.Tests/Visual/Online/TestSceneSpotlightsLayout.cs new file mode 100644 index 0000000000..d025a8d7c2 --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneSpotlightsLayout.cs @@ -0,0 +1,55 @@ +// 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.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Overlays; +using osu.Game.Overlays.Rankings; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Catch; +using osu.Game.Rulesets.Mania; +using osu.Game.Rulesets.Osu; +using osu.Game.Rulesets.Taiko; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneSpotlightsLayout : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(SpotlightsLayout), + typeof(SpotlightSelector), + }; + + protected override bool UseOnlineAPI => true; + + [Cached] + private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Green); + + public TestSceneSpotlightsLayout() + { + var ruleset = new Bindable(new OsuRuleset().RulesetInfo); + + Add(new BasicScrollContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Width = 0.8f, + Child = new SpotlightsLayout + { + Ruleset = { BindTarget = ruleset } + } + }); + + AddStep("Osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo); + AddStep("Mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo); + AddStep("Taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo); + AddStep("Catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo); + } + } +} diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index 538ae112b5..5b3744cf7f 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -60,8 +60,10 @@ namespace osu.Game.Overlays.Rankings base.LoadComplete(); } - private void onCurrentChanged(ValueChangedEvent scope) => - SpotlightSelector.State.Value = scope.NewValue == RankingsScope.Spotlights ? Visibility.Visible : Visibility.Hidden; + private void onCurrentChanged(ValueChangedEvent scope) + { + + } private class RankingsTitle : ScreenTitle { diff --git a/osu.Game/Overlays/Rankings/SpotlightSelector.cs b/osu.Game/Overlays/Rankings/SpotlightSelector.cs index 8bf75b2357..bc2d731772 100644 --- a/osu.Game/Overlays/Rankings/SpotlightSelector.cs +++ b/osu.Game/Overlays/Rankings/SpotlightSelector.cs @@ -18,11 +18,8 @@ using osu.Game.Online.API.Requests; namespace osu.Game.Overlays.Rankings { - public class SpotlightSelector : VisibilityContainer, IHasCurrentValue + public class SpotlightSelector : CompositeDrawable, IHasCurrentValue { - private const int height = 100; - private const int duration = 200; - private readonly Box background; private readonly SpotlightsDropdown dropdown; @@ -40,59 +37,52 @@ namespace osu.Game.Overlays.Rankings set => dropdown.Items = value; } - protected override bool StartHidden => true; - private readonly InfoColumn startDateColumn; private readonly InfoColumn endDateColumn; private readonly InfoColumn mapCountColumn; private readonly InfoColumn participantsColumn; - private readonly Container content; public SpotlightSelector() { RelativeSizeAxes = Axes.X; - Add(content = new Container + Height = 100; + AddRangeInternal(new Drawable[] { - Height = height, - RelativeSizeAxes = Axes.X, - Children = new Drawable[] + background = new Box { - background = new Box + RelativeSizeAxes = Axes.Both, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, - Children = new Drawable[] + dropdown = new SpotlightsDropdown { - dropdown = new SpotlightsDropdown + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + Current = Current, + Depth = -float.MaxValue + }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(15, 0), + Children = new Drawable[] { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - Current = Current, - Depth = -float.MaxValue - }, - new FillFlowContainer - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(15, 0), - Children = new Drawable[] - { - startDateColumn = new InfoColumn(@"Start Date"), - endDateColumn = new InfoColumn(@"End Date"), - mapCountColumn = new InfoColumn(@"Map Count"), - participantsColumn = new InfoColumn(@"Participants") - } + startDateColumn = new InfoColumn(@"Start Date"), + endDateColumn = new InfoColumn(@"End Date"), + mapCountColumn = new InfoColumn(@"Map Count"), + participantsColumn = new InfoColumn(@"Participants") } } - }, - } + } + }, }); } @@ -110,18 +100,6 @@ namespace osu.Game.Overlays.Rankings participantsColumn.Value = response.Spotlight.Participants?.ToString("N0"); } - protected override void PopIn() - { - this.ResizeHeightTo(height, duration, Easing.OutQuint); - content.FadeIn(duration, Easing.OutQuint); - } - - protected override void PopOut() - { - this.ResizeHeightTo(0, duration, Easing.OutQuint); - content.FadeOut(duration, Easing.OutQuint); - } - private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd"); private class InfoColumn : FillFlowContainer diff --git a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs new file mode 100644 index 0000000000..fd1b73c4cd --- /dev/null +++ b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs @@ -0,0 +1,158 @@ +// 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; +using osu.Framework.Bindables; +using osu.Game.Rulesets; +using osu.Framework.Graphics.Containers; +using osu.Game.Online.API.Requests.Responses; +using osuTK; +using osu.Framework.Allocation; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; +using osu.Game.Overlays.Rankings.Tables; +using System.Linq; +using osu.Game.Overlays.Direct; +using System.Threading; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Rankings +{ + public class SpotlightsLayout : CompositeDrawable + { + public readonly Bindable Ruleset = new Bindable(); + + private readonly Bindable selectedSpotlight = new Bindable(); + + [Resolved] + private IAPIProvider api { get; set; } + + [Resolved] + private RulesetStore rulesets { get; set; } + + private CancellationTokenSource cancellationToken; + private GetSpotlightRankingsRequest getRankingsRequest; + private GetSpotlightsRequest spotlightsRequest; + + private readonly SpotlightSelector selector; + private readonly Container content; + private readonly DimmedLoadingLayer loading; + + public SpotlightsLayout() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + InternalChild = new ReverseChildIDFillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 20), + Children = new Drawable[] + { + selector = new SpotlightSelector + { + Current = selectedSpotlight, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + content = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + loading = new DimmedLoadingLayer(), + } + } + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + selectedSpotlight.BindValueChanged(onSpotlightChanged); + Ruleset.BindValueChanged(onRulesetChanged); + + getSpotlights(); + } + + private void getSpotlights() + { + spotlightsRequest = new GetSpotlightsRequest(); + spotlightsRequest.Success += response => selector.Spotlights = response.Spotlights; + api.Queue(spotlightsRequest); + } + + private void onRulesetChanged(ValueChangedEvent ruleset) + { + if (!selector.Spotlights.Any()) + return; + + selectedSpotlight.TriggerChange(); + } + + private void onSpotlightChanged(ValueChangedEvent spotlight) + { + loading.Show(); + + cancellationToken?.Cancel(); + getRankingsRequest?.Cancel(); + + getRankingsRequest = new GetSpotlightRankingsRequest(Ruleset.Value, spotlight.NewValue.Id); + getRankingsRequest.Success += onSuccess; + api.Queue(getRankingsRequest); + } + + private void onSuccess(GetSpotlightRankingsResponse response) + { + LoadComponentAsync(createContent(response), loaded => + { + selector.ShowInfo(response); + + content.Clear(); + content.Add(loaded); + + loading.Hide(); + }, (cancellationToken = new CancellationTokenSource()).Token); + } + + private Drawable createContent(GetSpotlightRankingsResponse response) => new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 20), + Children = new Drawable[] + { + new ScoresTable(1, response.Users), + new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Spacing = new Vector2(10), + Children = response.BeatmapSets.Select(b => new DirectGridPanel(b.ToBeatmapSet(rulesets)) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }).ToList() + } + } + }; + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + spotlightsRequest?.Cancel(); + getRankingsRequest?.Cancel(); + cancellationToken?.Cancel(); + } + } +} From 0b6558dc40e9813712c0e6c0bfc28e354d62da42 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 11 Feb 2020 02:35:23 +0300 Subject: [PATCH 60/65] Add SpotlightsLayout to RankingsOverlay --- .../Visual/Online/TestSceneRankingsHeader.cs | 21 +--- .../TestSceneRankingsSpotlightSelector.cs | 6 ++ .../Rankings/RankingsOverlayHeader.cs | 40 +------- .../Overlays/Rankings/SpotlightSelector.cs | 73 ++++++++------ .../Overlays/Rankings/SpotlightsLayout.cs | 15 +-- osu.Game/Overlays/RankingsOverlay.cs | 97 +++++-------------- 6 files changed, 85 insertions(+), 167 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs index bc0ae3d264..1e711b3cd7 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.Rankings; using osu.Game.Rulesets; @@ -35,25 +34,7 @@ namespace osu.Game.Tests.Visual.Online { Current = { BindTarget = scope }, Country = { BindTarget = countryBindable }, - Ruleset = { BindTarget = ruleset }, - Spotlights = new[] - { - new APISpotlight - { - Id = 1, - Name = "Spotlight 1" - }, - new APISpotlight - { - Id = 2, - Name = "Spotlight 2" - }, - new APISpotlight - { - Id = 3, - Name = "Spotlight 3" - } - } + Ruleset = { BindTarget = ruleset } }); var country = new Country diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs index e46c8a4a71..f27ab1e775 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsSpotlightSelector.cs @@ -35,6 +35,12 @@ namespace osu.Game.Tests.Visual.Online Add(selector = new SpotlightSelector()); } + [Test] + public void TestVisibility() + { + AddStep("Toggle Visibility", selector.ToggleVisibility); + } + [Test] public void TestLocalSpotlights() { diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index 5b3744cf7f..2674b3a81e 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -6,24 +6,14 @@ using osu.Framework.Bindables; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osu.Game.Users; -using System.Collections.Generic; -using osu.Framework.Graphics.Containers; -using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.Rankings { public class RankingsOverlayHeader : TabControlOverlayHeader { public readonly Bindable Ruleset = new Bindable(); - public readonly Bindable Spotlight = new Bindable(); public readonly Bindable Country = new Bindable(); - public IEnumerable Spotlights - { - get => SpotlightSelector.Spotlights; - set => SpotlightSelector.Spotlights = value; - } - protected override ScreenTitle CreateTitle() => new RankingsTitle { Scope = { BindTarget = Current } @@ -34,37 +24,11 @@ namespace osu.Game.Overlays.Rankings Current = Ruleset }; - public SpotlightSelector SpotlightSelector; - - protected override Drawable CreateContent() => new FillFlowContainer + protected override Drawable CreateContent() => new CountryFilter { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - new CountryFilter - { - Current = Country - }, - SpotlightSelector = new SpotlightSelector - { - Current = { BindTarget = Spotlight } - } - } + Current = Country }; - protected override void LoadComplete() - { - Current.BindValueChanged(onCurrentChanged, true); - base.LoadComplete(); - } - - private void onCurrentChanged(ValueChangedEvent scope) - { - - } - private class RankingsTitle : ScreenTitle { public readonly Bindable Scope = new Bindable(); diff --git a/osu.Game/Overlays/Rankings/SpotlightSelector.cs b/osu.Game/Overlays/Rankings/SpotlightSelector.cs index bc2d731772..f019b50ae8 100644 --- a/osu.Game/Overlays/Rankings/SpotlightSelector.cs +++ b/osu.Game/Overlays/Rankings/SpotlightSelector.cs @@ -18,8 +18,10 @@ using osu.Game.Online.API.Requests; namespace osu.Game.Overlays.Rankings { - public class SpotlightSelector : CompositeDrawable, IHasCurrentValue + public class SpotlightSelector : VisibilityContainer, IHasCurrentValue { + private const int duration = 300; + private readonly Box background; private readonly SpotlightsDropdown dropdown; @@ -37,52 +39,59 @@ namespace osu.Game.Overlays.Rankings set => dropdown.Items = value; } + protected override bool StartHidden => true; + private readonly InfoColumn startDateColumn; private readonly InfoColumn endDateColumn; private readonly InfoColumn mapCountColumn; private readonly InfoColumn participantsColumn; + private readonly Container content; public SpotlightSelector() { RelativeSizeAxes = Axes.X; Height = 100; - AddRangeInternal(new Drawable[] + Add(content = new Container { - background = new Box + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, - Children = new Drawable[] + background = new Box { - dropdown = new SpotlightsDropdown + RelativeSizeAxes = Axes.Both, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, + Children = new Drawable[] { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, - Current = Current, - Depth = -float.MaxValue - }, - new FillFlowContainer - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(15, 0), - Children = new Drawable[] + dropdown = new SpotlightsDropdown { - startDateColumn = new InfoColumn(@"Start Date"), - endDateColumn = new InfoColumn(@"End Date"), - mapCountColumn = new InfoColumn(@"Map Count"), - participantsColumn = new InfoColumn(@"Participants") + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + Current = Current, + Depth = -float.MaxValue + }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(15, 0), + Children = new Drawable[] + { + startDateColumn = new InfoColumn(@"Start Date"), + endDateColumn = new InfoColumn(@"End Date"), + mapCountColumn = new InfoColumn(@"Map Count"), + participantsColumn = new InfoColumn(@"Participants") + } } } } - }, + } }); } @@ -100,6 +109,10 @@ namespace osu.Game.Overlays.Rankings participantsColumn.Value = response.Spotlight.Participants?.ToString("N0"); } + protected override void PopIn() => content.FadeIn(duration, Easing.OutQuint); + + protected override void PopOut() => content.FadeOut(duration, Easing.OutQuint); + private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd"); private class InfoColumn : FillFlowContainer diff --git a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs index fd1b73c4cd..33811cc982 100644 --- a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs +++ b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs @@ -35,11 +35,12 @@ namespace osu.Game.Overlays.Rankings private GetSpotlightRankingsRequest getRankingsRequest; private GetSpotlightsRequest spotlightsRequest; - private readonly SpotlightSelector selector; - private readonly Container content; - private readonly DimmedLoadingLayer loading; + private SpotlightSelector selector; + private Container content; + private DimmedLoadingLayer loading; - public SpotlightsLayout() + [BackgroundDependencyLoader] + private void load() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -48,7 +49,6 @@ namespace osu.Game.Overlays.Rankings RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 20), Children = new Drawable[] { selector = new SpotlightSelector @@ -65,8 +65,9 @@ namespace osu.Game.Overlays.Rankings { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Vertical = 10 } }, - loading = new DimmedLoadingLayer(), + loading = new DimmedLoadingLayer() } } } @@ -77,6 +78,8 @@ namespace osu.Game.Overlays.Rankings { base.LoadComplete(); + selector.Show(); + selectedSpotlight.BindValueChanged(onSpotlightChanged); Ruleset.BindValueChanged(onRulesetChanged); diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index a0aeff082e..f3215d07fa 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -14,10 +14,6 @@ using osu.Game.Online.API; using System.Threading; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Rankings.Tables; -using osu.Game.Online.API.Requests.Responses; -using System.Linq; -using osuTK; -using osu.Game.Overlays.Direct; namespace osu.Game.Overlays { @@ -26,13 +22,11 @@ namespace osu.Game.Overlays protected readonly Bindable Country = new Bindable(); protected readonly Bindable Scope = new Bindable(); private readonly Bindable ruleset = new Bindable(); - private readonly Bindable spotlight = new Bindable(); private readonly BasicScrollContainer scrollFlow; private readonly Container contentContainer; private readonly DimmedLoadingLayer loading; private readonly Box background; - private readonly RankingsOverlayHeader header; private APIRequest lastRequest; private CancellationTokenSource cancellationToken; @@ -40,9 +34,6 @@ namespace osu.Game.Overlays [Resolved] private IAPIProvider api { get; set; } - [Resolved] - private RulesetStore rulesets { get; set; } - public RankingsOverlay() : base(OverlayColourScheme.Green) { @@ -63,15 +54,14 @@ namespace osu.Game.Overlays Direction = FillDirection.Vertical, Children = new Drawable[] { - header = new RankingsOverlayHeader + new RankingsOverlayHeader { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Depth = -float.MaxValue, Country = { BindTarget = Country }, Current = { BindTarget = Scope }, - Ruleset = { BindTarget = ruleset }, - Spotlight = { BindTarget = spotlight } + Ruleset = { BindTarget = ruleset } }, new Container { @@ -85,7 +75,7 @@ namespace osu.Game.Overlays Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Vertical = 10 } + Margin = new MarginPadding { Bottom = 10 } }, loading = new DimmedLoadingLayer(), } @@ -110,30 +100,25 @@ namespace osu.Game.Overlays if (Country.Value != null) Scope.Value = RankingsScope.Performance; - if (Scope.Value != RankingsScope.Spotlights) - Scheduler.AddOnce(loadNewContent); + Scheduler.AddOnce(loadNewContent); }, true); Scope.BindValueChanged(_ => { - spotlightsRequest?.Cancel(); - // country filtering is only valid for performance scope. if (Scope.Value != RankingsScope.Performance) Country.Value = null; - if (Scope.Value == RankingsScope.Spotlights && !header.Spotlights.Any()) - { - getSpotlights(); - return; - } - Scheduler.AddOnce(loadNewContent); }, true); - ruleset.BindValueChanged(_ => Scheduler.AddOnce(loadNewContent), true); + ruleset.BindValueChanged(_ => + { + if (Scope.Value == RankingsScope.Spotlights) + return; - spotlight.BindValueChanged(_ => Scheduler.AddOnce(loadNewContent), true); + Scheduler.AddOnce(loadNewContent); + }, true); base.LoadComplete(); } @@ -148,16 +133,6 @@ namespace osu.Game.Overlays Country.Value = requested; } - private GetSpotlightsRequest spotlightsRequest; - - private void getSpotlights() - { - loading.Show(); - spotlightsRequest = new GetSpotlightsRequest(); - spotlightsRequest.Success += response => header.Spotlights = response.Spotlights; - api.Queue(spotlightsRequest); - } - private void loadNewContent() { loading.Show(); @@ -165,6 +140,15 @@ namespace osu.Game.Overlays cancellationToken?.Cancel(); lastRequest?.Cancel(); + if (Scope.Value == RankingsScope.Spotlights) + { + loadContent(new SpotlightsLayout + { + Ruleset = { BindTarget = ruleset } + }); + return; + } + var request = createScopedRequest(); lastRequest = request; @@ -174,8 +158,9 @@ namespace osu.Game.Overlays return; } - request.Success += () => loadContent(createContentFromResponse(request)); + request.Success += () => loadContent(createTableFromResponse(request)); request.Failure += _ => loadContent(null); + api.Queue(request); } @@ -191,15 +176,12 @@ namespace osu.Game.Overlays case RankingsScope.Score: return new GetUserRankingsRequest(ruleset.Value, UserRankingsType.Score); - - case RankingsScope.Spotlights: - return new GetSpotlightRankingsRequest(ruleset.Value, header.Spotlight.Value.Id); } return null; } - private Drawable createContentFromResponse(APIRequest request) + private Drawable createTableFromResponse(APIRequest request) { switch (request) { @@ -217,42 +199,11 @@ namespace osu.Game.Overlays case GetCountryRankingsRequest countryRequest: return new CountriesTable(1, countryRequest.Result.Countries); - - case GetSpotlightRankingsRequest spotlightRequest: - return getSpotlightContent(spotlightRequest.Result); } return null; } - private Drawable getSpotlightContent(GetSpotlightRankingsResponse response) - { - header.SpotlightSelector.ShowInfo(response); - - return new FillFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 20), - Children = new Drawable[] - { - new ScoresTable(1, response.Users), - new FillFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Spacing = new Vector2(10), - Children = response.BeatmapSets.Select(b => new DirectGridPanel(b.ToBeatmapSet(rulesets)) - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - }).ToList() - } - } - }; - } - private void loadContent(Drawable content) { scrollFlow.ScrollToStart(); @@ -264,10 +215,10 @@ namespace osu.Game.Overlays return; } - LoadComponentAsync(content, t => + LoadComponentAsync(content, loaded => { loading.Hide(); - contentContainer.Child = content; + contentContainer.Child = loaded; }, (cancellationToken = new CancellationTokenSource()).Token); } } From ca237fd987cc677f7bbda1923a421836763f884d Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Mon, 10 Feb 2020 16:21:49 -0800 Subject: [PATCH 61/65] Simplify ordering by using only numbers, add xmldoc --- .../Mods/CatchModDifficultyAdjust.cs | 5 ++-- .../Mods/OsuModDifficultyAdjust.cs | 5 ++-- .../Configuration/SettingSourceAttribute.cs | 25 ++++++------------- osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs | 5 ++-- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs index 17a2847fd1..de7adaa261 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs @@ -5,13 +5,12 @@ using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Rulesets.Mods; -using static osu.Game.Configuration.SettingSourceAttribute; namespace osu.Game.Rulesets.Catch.Mods { public class CatchModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)] + [SettingSource("Circle Size", "Override a beatmap's set CS.", 0)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", 3)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs index 2b56042ead..2c6eb19f3d 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs @@ -5,13 +5,12 @@ using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Rulesets.Mods; -using static osu.Game.Configuration.SettingSourceAttribute; namespace osu.Game.Rulesets.Osu.Mods { public class OsuModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)] + [SettingSource("Circle Size", "Override a beatmap's set CS.", 0)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", 3)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game/Configuration/SettingSourceAttribute.cs b/osu.Game/Configuration/SettingSourceAttribute.cs index 06e01bb042..4dcd2c6122 100644 --- a/osu.Game/Configuration/SettingSourceAttribute.cs +++ b/osu.Game/Configuration/SettingSourceAttribute.cs @@ -17,31 +17,24 @@ namespace osu.Game.Configuration /// An attribute to mark a bindable as being exposed to the user via settings controls. /// Can be used in conjunction with to automatically create UI controls. /// + /// + /// All controls with OrderPosition set to an int greater than 0 will be placed first in ascending order. + /// All controls with no OrderPosition will come afterward in default order. + /// [MeansImplicitUse] [AttributeUsage(AttributeTargets.Property)] public class SettingSourceAttribute : Attribute { - public enum OrderMode - { - FIRST, - ORDERED_RELATIVE, - UNORDERED, - LAST - } - public string Label { get; } public string Description { get; } - public OrderMode OrderingMode { get; } - public int OrderPosition { get; } - public SettingSourceAttribute(string label, string description = null, OrderMode order = OrderMode.UNORDERED, int orderPosition = 0) + public SettingSourceAttribute(string label, string description = null, int orderPosition = -1) { Label = label ?? string.Empty; Description = description ?? string.Empty; - OrderingMode = order; OrderPosition = orderPosition; } } @@ -136,12 +129,10 @@ namespace osu.Game.Configuration { var original = obj.GetSettingsSourceProperties(); - var first = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.FIRST); - var orderedRelative = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.ORDERED_RELATIVE).OrderBy(attr => attr.Item1.OrderPosition); - var unordered = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.UNORDERED); - var last = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.LAST); + var orderedRelative = original.Where(attr => attr.Item1.OrderPosition > -1).OrderBy(attr => attr.Item1.OrderPosition); + var unordered = original.Except(orderedRelative); - return first.Concat(orderedRelative).Concat(unordered).Concat(last); + return orderedRelative.Concat(unordered); } } } diff --git a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs index 958a0353ea..6ba54ff8fb 100644 --- a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs +++ b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Sprites; using System; using System.Collections.Generic; using osu.Game.Configuration; -using static osu.Game.Configuration.SettingSourceAttribute; namespace osu.Game.Rulesets.Mods { @@ -29,7 +28,7 @@ namespace osu.Game.Rulesets.Mods public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) }; - [SettingSource("HP Drain", "Override a beatmap's set HP.", OrderMode.ORDERED_RELATIVE, 1)] + [SettingSource("HP Drain", "Override a beatmap's set HP.", 1)] public BindableNumber DrainRate { get; } = new BindableFloat { Precision = 0.1f, @@ -39,7 +38,7 @@ namespace osu.Game.Rulesets.Mods Value = 5, }; - [SettingSource("Accuracy", "Override a beatmap's set OD.", OrderMode.ORDERED_RELATIVE, 1)] + [SettingSource("Accuracy", "Override a beatmap's set OD.", 2)] public BindableNumber OverallDifficulty { get; } = new BindableFloat { Precision = 0.1f, From 333f976580cc8e159b09e268bef438f09200e3d9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 Feb 2020 17:41:48 +0900 Subject: [PATCH 62/65] Fix test finding deleted beatmaps under dotnet-test --- osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index bd06089514..9474c08c5a 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -442,16 +442,20 @@ namespace osu.Game.Tests.Visual.SongSelect AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap); + AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmap == null); + BeatmapInfo target = null; AddStep("select beatmap externally", () => { - target = manager.QueryBeatmapSets(b => b.Beatmaps.Any(bi => bi.RulesetID == (differentRuleset ? 1 : 0))) + target = manager.GetAllUsableBeatmapSets().Where(b => b.Beatmaps.Any(bi => bi.RulesetID == (differentRuleset ? 1 : 0))) .ElementAt(5).Beatmaps.First(); Beatmap.Value = manager.GetWorkingBeatmap(target); }); + AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null); + AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmap?.OnlineBeatmapID == target.OnlineBeatmapID); AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID); From e9b51371476ca3adb6a00e9aca26ff5b600dae51 Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Tue, 11 Feb 2020 21:52:22 -0800 Subject: [PATCH 63/65] Remove >-1 limitation by using a separate constructor --- osu.Game/Configuration/SettingSourceAttribute.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Configuration/SettingSourceAttribute.cs b/osu.Game/Configuration/SettingSourceAttribute.cs index 4dcd2c6122..013621d7b7 100644 --- a/osu.Game/Configuration/SettingSourceAttribute.cs +++ b/osu.Game/Configuration/SettingSourceAttribute.cs @@ -29,12 +29,17 @@ namespace osu.Game.Configuration public string Description { get; } - public int OrderPosition { get; } + public int? OrderPosition { get; } - public SettingSourceAttribute(string label, string description = null, int orderPosition = -1) + public SettingSourceAttribute(string label, string description = null) { Label = label ?? string.Empty; Description = description ?? string.Empty; + } + + public SettingSourceAttribute(string label, string description, int orderPosition) + : this(label, description) + { OrderPosition = orderPosition; } } @@ -129,7 +134,7 @@ namespace osu.Game.Configuration { var original = obj.GetSettingsSourceProperties(); - var orderedRelative = original.Where(attr => attr.Item1.OrderPosition > -1).OrderBy(attr => attr.Item1.OrderPosition); + var orderedRelative = original.Where(attr => attr.Item1.OrderPosition != null).OrderBy(attr => attr.Item1.OrderPosition); var unordered = original.Except(orderedRelative); return orderedRelative.Concat(unordered); From a8eb9ba45c71fe67fce625c74776919dea430d82 Mon Sep 17 00:00:00 2001 From: voidedWarranties Date: Wed, 12 Feb 2020 15:55:16 -0800 Subject: [PATCH 64/65] Update xmldoc --- osu.Game/Configuration/SettingSourceAttribute.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Configuration/SettingSourceAttribute.cs b/osu.Game/Configuration/SettingSourceAttribute.cs index 013621d7b7..4bdbb5fc24 100644 --- a/osu.Game/Configuration/SettingSourceAttribute.cs +++ b/osu.Game/Configuration/SettingSourceAttribute.cs @@ -18,8 +18,8 @@ namespace osu.Game.Configuration /// Can be used in conjunction with to automatically create UI controls. /// /// - /// All controls with OrderPosition set to an int greater than 0 will be placed first in ascending order. - /// All controls with no OrderPosition will come afterward in default order. + /// All controls with set will be placed first in ascending order. + /// All controls with no will come afterward in default order. /// [MeansImplicitUse] [AttributeUsage(AttributeTargets.Property)] From 53b62816f8db94b3aa90fe0be77ceca296a4feab Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Feb 2020 14:07:37 +0900 Subject: [PATCH 65/65] Add index constants for cross-class safety --- osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs | 4 ++-- osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs | 4 ++-- osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs index de7adaa261..e2465d727e 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModDifficultyAdjust.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch.Mods { public class CatchModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Circle Size", "Override a beatmap's set CS.", 0)] + [SettingSource("Circle Size", "Override a beatmap's set CS.", FIRST_SETTING_ORDER - 1)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.", 3)] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs index 2c6eb19f3d..75de6896a3 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifficultyAdjust.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Mods { public class OsuModDifficultyAdjust : ModDifficultyAdjust { - [SettingSource("Circle Size", "Override a beatmap's set CS.", 0)] + [SettingSource("Circle Size", "Override a beatmap's set CS.", FIRST_SETTING_ORDER - 1)] public BindableNumber CircleSize { get; } = new BindableFloat { Precision = 0.1f, @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods Value = 5, }; - [SettingSource("Approach Rate", "Override a beatmap's set AR.", 3)] + [SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1)] public BindableNumber ApproachRate { get; } = new BindableFloat { Precision = 0.1f, diff --git a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs index 6ba54ff8fb..2083671072 100644 --- a/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs +++ b/osu.Game/Rulesets/Mods/ModDifficultyAdjust.cs @@ -28,7 +28,11 @@ namespace osu.Game.Rulesets.Mods public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) }; - [SettingSource("HP Drain", "Override a beatmap's set HP.", 1)] + protected const int FIRST_SETTING_ORDER = 1; + + protected const int LAST_SETTING_ORDER = 2; + + [SettingSource("HP Drain", "Override a beatmap's set HP.", FIRST_SETTING_ORDER)] public BindableNumber DrainRate { get; } = new BindableFloat { Precision = 0.1f, @@ -38,7 +42,7 @@ namespace osu.Game.Rulesets.Mods Value = 5, }; - [SettingSource("Accuracy", "Override a beatmap's set OD.", 2)] + [SettingSource("Accuracy", "Override a beatmap's set OD.", LAST_SETTING_ORDER)] public BindableNumber OverallDifficulty { get; } = new BindableFloat { Precision = 0.1f,