From f561120295d392678a19d5a8a578da272a082bc0 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sat, 7 Jan 2023 23:40:02 +0100 Subject: [PATCH 001/157] Remove info labels, since they are no longer present in this component in thew new design --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 356 ++++++++++++++++++ 1 file changed, 356 insertions(+) create mode 100644 osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs new file mode 100644 index 0000000000..4d1a2133fd --- /dev/null +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -0,0 +1,356 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +#nullable disable + +using System.Collections.Generic; +using System.Threading; +using osuTK; +using osuTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Effects; +using osu.Framework.Localisation; +using osu.Game.Configuration; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Screens.Select +{ + public partial class BeatmapInfoWedgeV2 : VisibilityContainer + { + public const float BORDER_THICKNESS = 2.5f; + private const float shear_width = 36.75f; + + private const float transition_duration = 250; + + private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / SongSelect.WEDGE_HEIGHT, 0); + + [Resolved] + private IBindable ruleset { get; set; } + + protected Container DisplayedContent { get; private set; } + + protected WedgeInfoText Info { get; private set; } + + public BeatmapInfoWedgeV2() + { + Shear = wedged_container_shear; + Masking = true; + BorderColour = new Color4(221, 255, 255, 255); + BorderThickness = BORDER_THICKNESS; + Alpha = 0; + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Glow, + Colour = new Color4(130, 204, 255, 150), + Radius = 20, + Roundness = 15, + }; + } + + [BackgroundDependencyLoader] + private void load() + { + ruleset.BindValueChanged(_ => updateDisplay()); + } + + private const double animation_duration = 800; + + protected override void PopIn() + { + this.MoveToX(0, animation_duration, Easing.OutQuint); + this.RotateTo(0, animation_duration, Easing.OutQuint); + this.FadeIn(transition_duration); + } + + protected override void PopOut() + { + this.MoveToX(-100, animation_duration, Easing.In); + this.RotateTo(10, animation_duration, Easing.In); + this.FadeOut(transition_duration * 2, Easing.In); + } + + private WorkingBeatmap beatmap; + + public WorkingBeatmap Beatmap + { + get => beatmap; + set + { + if (beatmap == value) return; + + beatmap = value; + + updateDisplay(); + } + } + + public override bool IsPresent => base.IsPresent || DisplayedContent == null; // Visibility is updated in the LoadComponentAsync callback + + private Container loadingInfo; + + private void updateDisplay() + { + Scheduler.AddOnce(perform); + + void perform() + { + void removeOldInfo() + { + State.Value = beatmap == null ? Visibility.Hidden : Visibility.Visible; + + DisplayedContent?.FadeOut(transition_duration); + DisplayedContent?.Expire(); + DisplayedContent = null; + } + + if (beatmap == null) + { + removeOldInfo(); + return; + } + + LoadComponentAsync(loadingInfo = new Container + { + RelativeSizeAxes = Axes.Both, + Shear = -Shear, + Depth = DisplayedContent?.Depth + 1 ?? 0, + Children = new Drawable[] + { + new BeatmapInfoWedgeBackground(beatmap), + Info = new WedgeInfoText(beatmap), + } + }, loaded => + { + // ensure we are the most recent loaded wedge. + if (loaded != loadingInfo) return; + + removeOldInfo(); + Add(DisplayedContent = loaded); + }); + } + } + + public partial class WedgeInfoText : Container + { + public OsuSpriteText VersionLabel { get; private set; } + public OsuSpriteText TitleLabel { get; private set; } + public OsuSpriteText ArtistLabel { get; private set; } + public FillFlowContainer MapperContainer { get; private set; } + + private Container difficultyColourBar; + private StarRatingDisplay starRatingDisplay; + + private ILocalisedBindableString titleBinding; + private ILocalisedBindableString artistBinding; + + private readonly WorkingBeatmap working; + + [Resolved] + private IBindable> mods { get; set; } + + [Resolved] + private BeatmapDifficultyCache difficultyCache { get; set; } + + [Resolved] + private OsuColour colours { get; set; } + + private ModSettingChangeTracker settingChangeTracker; + + public WedgeInfoText(WorkingBeatmap working) + { + this.working = working; + } + + private CancellationTokenSource cancellationSource; + private IBindable starDifficulty; + + [BackgroundDependencyLoader] + private void load(LocalisationManager localisation) + { + var beatmapInfo = working.BeatmapInfo; + var metadata = beatmapInfo.Metadata; + + RelativeSizeAxes = Axes.Both; + + titleBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.TitleUnicode, metadata.Title)); + artistBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.ArtistUnicode, metadata.Artist)); + + const float top_height = 0.7f; + + Children = new Drawable[] + { + difficultyColourBar = new Container + { + RelativeSizeAxes = Axes.Y, + Width = 20f, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Width = top_height, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + RelativePositionAxes = Axes.Both, + Alpha = 0.5f, + X = top_height, + Width = 1 - top_height, + } + } + }, + new FillFlowContainer + { + Name = "Topleft-aligned metadata", + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Top = 10, Left = 25, Right = shear_width * 2.5f }, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Children = new Drawable[] + { + VersionLabel = new OsuSpriteText + { + Text = beatmapInfo.DifficultyName, + Font = OsuFont.GetFont(size: 24, italics: true), + RelativeSizeAxes = Axes.X, + Truncate = true, + }, + } + }, + new FillFlowContainer + { + Name = "Topright-aligned metadata", + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Top = 14, Right = shear_width / 2 }, + AutoSizeAxes = Axes.Both, + Shear = wedged_container_shear, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] + { + starRatingDisplay = new StarRatingDisplay(default, animated: true) + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Shear = -wedged_container_shear, + Alpha = 0f, + }, + new BeatmapSetOnlineStatusPill + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Shear = -wedged_container_shear, + TextSize = 11, + TextPadding = new MarginPadding { Horizontal = 8, Vertical = 2 }, + Status = beatmapInfo.Status, + Alpha = string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? 0 : 1 + } + } + }, + new FillFlowContainer + { + Name = "Centre-aligned metadata", + Anchor = Anchor.CentreLeft, + Origin = Anchor.TopLeft, + Y = -7, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Left = 25, Right = shear_width }, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Children = new Drawable[] + { + TitleLabel = new OsuSpriteText + { + Current = { BindTarget = titleBinding }, + Font = OsuFont.GetFont(size: 28, italics: true), + RelativeSizeAxes = Axes.X, + Truncate = true, + }, + ArtistLabel = new OsuSpriteText + { + Current = { BindTarget = artistBinding }, + Font = OsuFont.GetFont(size: 17, italics: true), + RelativeSizeAxes = Axes.X, + Truncate = true, + }, + MapperContainer = new FillFlowContainer + { + Margin = new MarginPadding { Top = 10 }, + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + Child = getMapper(metadata), + } + } + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + starRatingDisplay.DisplayedStars.BindValueChanged(s => + { + difficultyColourBar.Colour = colours.ForStarDifficulty(s.NewValue); + }, true); + + starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); + starDifficulty.BindValueChanged(s => + { + starRatingDisplay.Current.Value = s.NewValue ?? default; + + // Don't roll the counter on initial display (but still allow it to roll on applying mods etc.) + if (!starRatingDisplay.IsPresent) + starRatingDisplay.FinishTransforms(true); + + starRatingDisplay.FadeIn(transition_duration); + }); + + mods.BindValueChanged(m => + { + settingChangeTracker?.Dispose(); + + settingChangeTracker = new ModSettingChangeTracker(m.NewValue); + }, true); + } + + private Drawable getMapper(BeatmapMetadata metadata) + { + if (string.IsNullOrEmpty(metadata.Author.Username)) + return Empty(); + + return new LinkFlowContainer(s => + { + s.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 15); + }).With(d => + { + d.AutoSizeAxes = Axes.Both; + d.AddText("mapped by "); + d.AddUserLink(metadata.Author); + }); + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + settingChangeTracker?.Dispose(); + cancellationSource?.Cancel(); + } + } + } +} From c646f8479b35cc7d66b1075ad5c5ba8ab46434ad Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sat, 7 Jan 2023 23:53:19 +0100 Subject: [PATCH 002/157] Move stardifficulty logic to main BeatmapInfoWedge class instead of text subclass ( for use by background star rating colour bar ) --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 4d1a2133fd..104fa8787b 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -37,10 +37,16 @@ namespace osu.Game.Screens.Select [Resolved] private IBindable ruleset { get; set; } + [Resolved] + private BeatmapDifficultyCache difficultyCache { get; set; } + protected Container DisplayedContent { get; private set; } protected WedgeInfoText Info { get; private set; } + private IBindable starDifficulty; + private CancellationTokenSource cancellationSource; + public BeatmapInfoWedgeV2() { Shear = wedged_container_shear; @@ -98,6 +104,19 @@ namespace osu.Game.Screens.Select private Container loadingInfo; + protected override void LoadComplete() + { + base.LoadComplete(); + starDifficulty = difficultyCache.GetBindableDifficulty(beatmap.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + cancellationSource?.Cancel(); + } + private void updateDisplay() { Scheduler.AddOnce(perform); @@ -127,7 +146,7 @@ namespace osu.Game.Screens.Select Children = new Drawable[] { new BeatmapInfoWedgeBackground(beatmap), - Info = new WedgeInfoText(beatmap), + Info = new WedgeInfoText(beatmap, starDifficulty), } }, loaded => { @@ -154,26 +173,22 @@ namespace osu.Game.Screens.Select private ILocalisedBindableString artistBinding; private readonly WorkingBeatmap working; + private readonly IBindable starDifficulty; [Resolved] private IBindable> mods { get; set; } - [Resolved] - private BeatmapDifficultyCache difficultyCache { get; set; } - [Resolved] private OsuColour colours { get; set; } private ModSettingChangeTracker settingChangeTracker; - public WedgeInfoText(WorkingBeatmap working) + public WedgeInfoText(WorkingBeatmap working, IBindable starDifficulty) { this.working = working; + this.starDifficulty = starDifficulty; } - private CancellationTokenSource cancellationSource; - private IBindable starDifficulty; - [BackgroundDependencyLoader] private void load(LocalisationManager localisation) { @@ -309,7 +324,6 @@ namespace osu.Game.Screens.Select difficultyColourBar.Colour = colours.ForStarDifficulty(s.NewValue); }, true); - starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); starDifficulty.BindValueChanged(s => { starRatingDisplay.Current.Value = s.NewValue ?? default; @@ -349,7 +363,6 @@ namespace osu.Game.Screens.Select { base.Dispose(isDisposing); settingChangeTracker?.Dispose(); - cancellationSource?.Cancel(); } } } From 0199c19f74705c2d5c0dd10f3c61c0c8325ef224 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sun, 8 Jan 2023 01:24:47 +0100 Subject: [PATCH 003/157] Add a test scene and move colour bar to back and adjust positioning of it --- .../SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 187 ++++++++++++++++++ osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 131 +++--------- 2 files changed, 217 insertions(+), 101 deletions(-) create mode 100644 osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs new file mode 100644 index 0000000000..98e9d803ca --- /dev/null +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -0,0 +1,187 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +#nullable disable + +using System.Collections.Generic; +using JetBrains.Annotations; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Testing; +using osu.Game.Beatmaps; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Legacy; +using osu.Game.Rulesets.Objects.Types; +using osu.Game.Screens.Select; +using osuTK; + +namespace osu.Game.Tests.Visual.SongSelect +{ + [TestFixture] + public partial class TestSceneBeatmapInfoWedgeV2 : OsuTestScene + { + private RulesetStore rulesets; + private TestBeatmapInfoWedgeV2 infoWedge; + private readonly List beatmaps = new List(); + + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + this.rulesets = rulesets; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + Add(infoWedge = new TestBeatmapInfoWedgeV2 + { + Size = new Vector2(0.6f, 120), + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = 20 } + }); + + AddStep("show", () => infoWedge.Show()); + + selectBeatmap(Beatmap.Value.Beatmap); + + AddWaitStep("wait for select", 3); + + AddStep("hide", () => { infoWedge.Hide(); }); + + AddWaitStep("wait for hide", 3); + + AddStep("show", () => { infoWedge.Show(); }); + + AddSliderStep("change star difficulty", 0, 11.9, 5.55, v => + { + foreach (var hasCurrentValue in infoWedge.Info.ChildrenOfType>()) + hasCurrentValue.Current.Value = new StarDifficulty(v, 0); + }); + + foreach (var rulesetInfo in rulesets.AvailableRulesets) + { + var instance = rulesetInfo.CreateInstance(); + var testBeatmap = createTestBeatmap(rulesetInfo); + + beatmaps.Add(testBeatmap); + + setRuleset(rulesetInfo); + + selectBeatmap(testBeatmap); + + testBeatmapLabels(instance); + } + } + + private void testBeatmapLabels(Ruleset ruleset) + { + AddAssert("check title", () => infoWedge.Info.TitleLabel.Current.Value == $"{ruleset.ShortName}Title"); + AddAssert("check artist", () => infoWedge.Info.ArtistLabel.Current.Value == $"{ruleset.ShortName}Artist"); + } + + [SetUpSteps] + public void SetUpSteps() + { + AddStep("reset mods", () => SelectedMods.SetDefault()); + } + + [Test] + public void TestTruncation() + { + selectBeatmap(createLongMetadata()); + } + + private void setRuleset(RulesetInfo rulesetInfo) + { + Container containerBefore = null; + + AddStep("set ruleset", () => + { + // wedge content is only refreshed if the ruleset changes, so only wait for load in that case. + if (!rulesetInfo.Equals(Ruleset.Value)) + containerBefore = infoWedge.DisplayedContent; + + Ruleset.Value = rulesetInfo; + }); + + AddUntilStep("wait for async load", () => infoWedge.DisplayedContent != containerBefore); + } + + private void selectBeatmap([CanBeNull] IBeatmap b) + { + Container containerBefore = null; + + AddStep($"select {b?.Metadata.Title ?? "null"} beatmap", () => + { + containerBefore = infoWedge.DisplayedContent; + infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : CreateWorkingBeatmap(b); + }); + + AddUntilStep("wait for async load", () => infoWedge.DisplayedContent != containerBefore); + } + + private IBeatmap createTestBeatmap(RulesetInfo ruleset) + { + List objects = new List(); + for (double i = 0; i < 50000; i += 1000) + objects.Add(new TestHitObject { StartTime = i }); + + return new Beatmap + { + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Author = { Username = $"{ruleset.ShortName}Author" }, + Artist = $"{ruleset.ShortName}Artist", + Source = $"{ruleset.ShortName}Source", + Title = $"{ruleset.ShortName}Title" + }, + Ruleset = ruleset, + StarRating = 6, + DifficultyName = $"{ruleset.ShortName}Version", + Difficulty = new BeatmapDifficulty() + }, + HitObjects = objects + }; + } + + private IBeatmap createLongMetadata() + { + return new Beatmap + { + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Author = { Username = "WWWWWWWWWWWWWWW" }, + Artist = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Artist", + Source = "Verrrrry long Source", + Title = "Verrrrry long Title" + }, + DifficultyName = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Version", + Status = BeatmapOnlineStatus.Graveyard, + }, + }; + } + + private partial class TestBeatmapInfoWedgeV2 : BeatmapInfoWedgeV2 + { + public new Container DisplayedContent => base.DisplayedContent; + + public new WedgeInfoText Info => base.Info; + } + + private class TestHitObject : ConvertHitObject, IHasPosition + { + public float X => 0; + public float Y => 0; + public Vector2 Position { get; } = Vector2.Zero; + } + } +} diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 104fa8787b..5583ad11f7 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Threading; using osuTK; -using osuTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -16,18 +15,16 @@ using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Effects; using osu.Framework.Localisation; using osu.Game.Configuration; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; -using osu.Game.Graphics.Containers; namespace osu.Game.Screens.Select { + [Cached] public partial class BeatmapInfoWedgeV2 : VisibilityContainer { - public const float BORDER_THICKNESS = 2.5f; private const float shear_width = 36.75f; private const float transition_duration = 250; @@ -44,22 +41,25 @@ namespace osu.Game.Screens.Select protected WedgeInfoText Info { get; private set; } - private IBindable starDifficulty; + private IBindable starDifficulty = new Bindable(); private CancellationTokenSource cancellationSource; + private readonly Container difficultyColourBar; + public BeatmapInfoWedgeV2() { + CornerRadius = 10; Shear = wedged_container_shear; Masking = true; - BorderColour = new Color4(221, 255, 255, 255); - BorderThickness = BORDER_THICKNESS; Alpha = 0; - EdgeEffect = new EdgeEffectParameters + Child = difficultyColourBar = new Container { - Type = EdgeEffectType.Glow, - Colour = new Color4(130, 204, 255, 150), - Radius = 20, - Roundness = 15, + Depth = float.MaxValue, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Y, + Width = 40, + Child = new Box { RelativeSizeAxes = Axes.Both } }; } @@ -95,6 +95,7 @@ namespace osu.Game.Screens.Select if (beatmap == value) return; beatmap = value; + starDifficulty = difficultyCache.GetBindableDifficulty(value.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); updateDisplay(); } @@ -104,12 +105,6 @@ namespace osu.Game.Screens.Select private Container loadingInfo; - protected override void LoadComplete() - { - base.LoadComplete(); - starDifficulty = difficultyCache.GetBindableDifficulty(beatmap.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); - } - protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); @@ -140,13 +135,15 @@ namespace osu.Game.Screens.Select LoadComponentAsync(loadingInfo = new Container { + Masking = true, + X = -30, + CornerRadius = 10, RelativeSizeAxes = Axes.Both, - Shear = -Shear, Depth = DisplayedContent?.Depth + 1 ?? 0, Children = new Drawable[] { - new BeatmapInfoWedgeBackground(beatmap), - Info = new WedgeInfoText(beatmap, starDifficulty), + new BeatmapInfoWedgeBackground(beatmap) { Shear = -Shear }, + Info = new WedgeInfoText(beatmap, starDifficulty) { Shear = -Shear } } }, loaded => { @@ -161,12 +158,9 @@ namespace osu.Game.Screens.Select public partial class WedgeInfoText : Container { - public OsuSpriteText VersionLabel { get; private set; } public OsuSpriteText TitleLabel { get; private set; } public OsuSpriteText ArtistLabel { get; private set; } - public FillFlowContainer MapperContainer { get; private set; } - private Container difficultyColourBar; private StarRatingDisplay starRatingDisplay; private ILocalisedBindableString titleBinding; @@ -178,6 +172,9 @@ namespace osu.Game.Screens.Select [Resolved] private IBindable> mods { get; set; } + [Resolved] + private BeatmapInfoWedgeV2 wedge { get; set; } + [Resolved] private OsuColour colours { get; set; } @@ -200,51 +197,8 @@ namespace osu.Game.Screens.Select titleBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.TitleUnicode, metadata.Title)); artistBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.ArtistUnicode, metadata.Artist)); - const float top_height = 0.7f; - Children = new Drawable[] { - difficultyColourBar = new Container - { - RelativeSizeAxes = Axes.Y, - Width = 20f, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Width = top_height, - }, - new Box - { - RelativeSizeAxes = Axes.Both, - RelativePositionAxes = Axes.Both, - Alpha = 0.5f, - X = top_height, - Width = 1 - top_height, - } - } - }, - new FillFlowContainer - { - Name = "Topleft-aligned metadata", - Anchor = Anchor.TopLeft, - Origin = Anchor.TopLeft, - Direction = FillDirection.Vertical, - Padding = new MarginPadding { Top = 10, Left = 25, Right = shear_width * 2.5f }, - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Children = new Drawable[] - { - VersionLabel = new OsuSpriteText - { - Text = beatmapInfo.DifficultyName, - Font = OsuFont.GetFont(size: 24, italics: true), - RelativeSizeAxes = Axes.X, - Truncate = true, - }, - } - }, new FillFlowContainer { Name = "Topright-aligned metadata", @@ -279,12 +233,10 @@ namespace osu.Game.Screens.Select }, new FillFlowContainer { - Name = "Centre-aligned metadata", - Anchor = Anchor.CentreLeft, - Origin = Anchor.TopLeft, - Y = -7, + Name = "Top-left aligned metadata", Direction = FillDirection.Vertical, - Padding = new MarginPadding { Left = 25, Right = shear_width }, + Position = new Vector2(50, 12), + Width = .8f, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Children = new Drawable[] @@ -292,23 +244,17 @@ namespace osu.Game.Screens.Select TitleLabel = new OsuSpriteText { Current = { BindTarget = titleBinding }, - Font = OsuFont.GetFont(size: 28, italics: true), + Font = OsuFont.TorusAlternate.With(size: 40, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, - Truncate = true, + Truncate = true }, ArtistLabel = new OsuSpriteText { Current = { BindTarget = artistBinding }, - Font = OsuFont.GetFont(size: 17, italics: true), + //Not sure if this should be semi bold or medium + Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, - Truncate = true, - }, - MapperContainer = new FillFlowContainer - { - Margin = new MarginPadding { Top = 10 }, - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - Child = getMapper(metadata), + Truncate = true } } } @@ -321,9 +267,8 @@ namespace osu.Game.Screens.Select starRatingDisplay.DisplayedStars.BindValueChanged(s => { - difficultyColourBar.Colour = colours.ForStarDifficulty(s.NewValue); + wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); }, true); - starDifficulty.BindValueChanged(s => { starRatingDisplay.Current.Value = s.NewValue ?? default; @@ -343,22 +288,6 @@ namespace osu.Game.Screens.Select }, true); } - private Drawable getMapper(BeatmapMetadata metadata) - { - if (string.IsNullOrEmpty(metadata.Author.Username)) - return Empty(); - - return new LinkFlowContainer(s => - { - s.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 15); - }).With(d => - { - d.AutoSizeAxes = Axes.Both; - d.AddText("mapped by "); - d.AddUserLink(metadata.Author); - }); - } - protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); From 61caabaa8ee4002c7d96859f0937b3fb8b997c82 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sun, 8 Jan 2023 01:47:22 +0100 Subject: [PATCH 004/157] Add coloured star counter --- .../Graphics/UserInterface/StarCounter.cs | 6 ++- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 51 +++++++++++++++---- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index d7d088d798..7adb482188 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -32,6 +32,11 @@ namespace osu.Game.Graphics.UserInterface private const float star_spacing = 4; + public virtual FillDirection Direction + { + set => stars.Direction = value; + } + private float current; /// @@ -66,7 +71,6 @@ namespace osu.Game.Graphics.UserInterface stars = new FillFlowContainer { AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, Spacing = new Vector2(star_spacing), ChildrenEnumerable = Enumerable.Range(0, StarCount).Select(_ => CreateStar()) } diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 5583ad11f7..07fcb42fff 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -3,7 +3,9 @@ #nullable disable +using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using osuTK; using osu.Framework.Allocation; @@ -17,6 +19,7 @@ using osu.Game.Graphics.Sprites; using osu.Framework.Graphics.Shapes; using osu.Framework.Localisation; using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; @@ -25,11 +28,12 @@ namespace osu.Game.Screens.Select [Cached] public partial class BeatmapInfoWedgeV2 : VisibilityContainer { - private const float shear_width = 36.75f; + private const float shear_width = 21; + private const int wedge_height = 120; private const float transition_duration = 250; - private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / SongSelect.WEDGE_HEIGHT, 0); + private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / wedge_height, 0); [Resolved] private IBindable ruleset { get; set; } @@ -45,6 +49,7 @@ namespace osu.Game.Screens.Select private CancellationTokenSource cancellationSource; private readonly Container difficultyColourBar; + private readonly StarCounter starCounter; public BeatmapInfoWedgeV2() { @@ -52,14 +57,27 @@ namespace osu.Game.Screens.Select Shear = wedged_container_shear; Masking = true; Alpha = 0; - Child = difficultyColourBar = new Container + + Children = new Drawable[] { - Depth = float.MaxValue, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - RelativeSizeAxes = Axes.Y, - Width = 40, - Child = new Box { RelativeSizeAxes = Axes.Both } + difficultyColourBar = new Container + { + Depth = float.MaxValue, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Y, + Width = 40, + Child = new Box { RelativeSizeAxes = Axes.Both } + }, + starCounter = new StarCounter + { + Anchor = Anchor.CentreRight, + Origin = Anchor.Centre, + Scale = new Vector2(0.4f), + Shear = -wedged_container_shear, + X = -15, + Direction = FillDirection.Vertical + } }; } @@ -67,6 +85,15 @@ namespace osu.Game.Screens.Select private void load() { ruleset.BindValueChanged(_ => updateDisplay()); + + float starAngle = (float)(Math.Atan(shear_width / wedge_height) * (180 / Math.PI)); + + //Applying the rotation directly to the StarCounter distorts the stars, hence it is applied to the child container + starCounter.Children.First().Rotation = starAngle; + + //Makes sure the stars center themselves properly in the colour bar + starCounter.Children.First().Anchor = Anchor.Centre; + starCounter.Children.First().Origin = Anchor.Centre; } private const double animation_duration = 800; @@ -267,8 +294,12 @@ namespace osu.Game.Screens.Select starRatingDisplay.DisplayedStars.BindValueChanged(s => { - wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); + wedge.starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); + wedge.starCounter.Current = (float)s.NewValue; + + wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue), 750, Easing.OutQuint); }, true); + starDifficulty.BindValueChanged(s => { starRatingDisplay.Current.Value = s.NewValue ?? default; From 1698272eb88b3937228783d3df8d04db993d5da5 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sun, 8 Jan 2023 12:03:02 +0100 Subject: [PATCH 005/157] Simplify passing data from BeatmapInfoWedgeV2.cs to subclass wedgeinfotext --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 07fcb42fff..1056d9478b 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -60,17 +60,22 @@ namespace osu.Game.Screens.Select Children = new Drawable[] { + //These elements can't be grouped with the rest of the content, due to being present either outside or under the backgrounds area difficultyColourBar = new Container { + Colour = Colour4.Transparent, Depth = float.MaxValue, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, + + //By limiting the width we avoid this box showing up as an outline around the drawables that are on top of it. Width = 40, Child = new Box { RelativeSizeAxes = Axes.Both } }, starCounter = new StarCounter { + Colour = Colour4.Transparent, Anchor = Anchor.CentreRight, Origin = Anchor.Centre, Scale = new Vector2(0.4f), @@ -170,7 +175,7 @@ namespace osu.Game.Screens.Select Children = new Drawable[] { new BeatmapInfoWedgeBackground(beatmap) { Shear = -Shear }, - Info = new WedgeInfoText(beatmap, starDifficulty) { Shear = -Shear } + Info = new WedgeInfoText { Shear = -Shear } } }, loaded => { @@ -193,9 +198,6 @@ namespace osu.Game.Screens.Select private ILocalisedBindableString titleBinding; private ILocalisedBindableString artistBinding; - private readonly WorkingBeatmap working; - private readonly IBindable starDifficulty; - [Resolved] private IBindable> mods { get; set; } @@ -207,17 +209,11 @@ namespace osu.Game.Screens.Select private ModSettingChangeTracker settingChangeTracker; - public WedgeInfoText(WorkingBeatmap working, IBindable starDifficulty) - { - this.working = working; - this.starDifficulty = starDifficulty; - } - [BackgroundDependencyLoader] private void load(LocalisationManager localisation) { - var beatmapInfo = working.BeatmapInfo; - var metadata = beatmapInfo.Metadata; + var beatmapInfo = wedge.Beatmap.BeatmapInfo; + var metadata = wedge.beatmap.Metadata; RelativeSizeAxes = Axes.Both; @@ -262,7 +258,7 @@ namespace osu.Game.Screens.Select { Name = "Top-left aligned metadata", Direction = FillDirection.Vertical, - Position = new Vector2(50, 12), + Position = new Vector2(80, 12), Width = .8f, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, @@ -270,6 +266,7 @@ namespace osu.Game.Screens.Select { TitleLabel = new OsuSpriteText { + Shadow = true, Current = { BindTarget = titleBinding }, Font = OsuFont.TorusAlternate.With(size: 40, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, @@ -277,6 +274,7 @@ namespace osu.Game.Screens.Select }, ArtistLabel = new OsuSpriteText { + Shadow = true, Current = { BindTarget = artistBinding }, //Not sure if this should be semi bold or medium Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold), @@ -297,10 +295,10 @@ namespace osu.Game.Screens.Select wedge.starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); wedge.starCounter.Current = (float)s.NewValue; - wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue), 750, Easing.OutQuint); + wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); }, true); - starDifficulty.BindValueChanged(s => + wedge.starDifficulty.BindValueChanged(s => { starRatingDisplay.Current.Value = s.NewValue ?? default; From 65c30d2c2e0a322d0d75003905fd44b4e5969d32 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sun, 8 Jan 2023 12:56:32 +0100 Subject: [PATCH 006/157] Remove nullability disabling --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 1056d9478b..da7cfc6613 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using System.Linq; @@ -36,17 +34,11 @@ namespace osu.Game.Screens.Select private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / wedge_height, 0); [Resolved] - private IBindable ruleset { get; set; } + private IBindable ruleset { get; set; } = null!; - [Resolved] - private BeatmapDifficultyCache difficultyCache { get; set; } + protected Container? DisplayedContent { get; private set; } - protected Container DisplayedContent { get; private set; } - - protected WedgeInfoText Info { get; private set; } - - private IBindable starDifficulty = new Bindable(); - private CancellationTokenSource cancellationSource; + protected WedgeInfoText? Info { get; private set; } private readonly Container difficultyColourBar; private readonly StarCounter starCounter; @@ -117,9 +109,9 @@ namespace osu.Game.Screens.Select this.FadeOut(transition_duration * 2, Easing.In); } - private WorkingBeatmap beatmap; + private WorkingBeatmap? beatmap; - public WorkingBeatmap Beatmap + public WorkingBeatmap? Beatmap { get => beatmap; set @@ -127,7 +119,6 @@ namespace osu.Game.Screens.Select if (beatmap == value) return; beatmap = value; - starDifficulty = difficultyCache.GetBindableDifficulty(value.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); updateDisplay(); } @@ -135,14 +126,7 @@ namespace osu.Game.Screens.Select public override bool IsPresent => base.IsPresent || DisplayedContent == null; // Visibility is updated in the LoadComponentAsync callback - private Container loadingInfo; - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - - cancellationSource?.Cancel(); - } + private Container? loadingInfo; private void updateDisplay() { @@ -190,30 +174,36 @@ namespace osu.Game.Screens.Select public partial class WedgeInfoText : Container { - public OsuSpriteText TitleLabel { get; private set; } - public OsuSpriteText ArtistLabel { get; private set; } + public OsuSpriteText TitleLabel { get; private set; } = null!; + public OsuSpriteText ArtistLabel { get; private set; } = null!; - private StarRatingDisplay starRatingDisplay; + private StarRatingDisplay starRatingDisplay = null!; - private ILocalisedBindableString titleBinding; - private ILocalisedBindableString artistBinding; + private ILocalisedBindableString titleBinding = null!; + private ILocalisedBindableString artistBinding = null!; [Resolved] - private IBindable> mods { get; set; } + private IBindable> mods { get; set; } = null!; [Resolved] - private BeatmapInfoWedgeV2 wedge { get; set; } + private BeatmapInfoWedgeV2 wedge { get; set; } = null!; [Resolved] - private OsuColour colours { get; set; } + private OsuColour colours { get; set; } = null!; - private ModSettingChangeTracker settingChangeTracker; + [Resolved] + private BeatmapDifficultyCache difficultyCache { get; set; } = null!; + + private ModSettingChangeTracker? settingChangeTracker; + + private IBindable? starDifficulty; + private CancellationTokenSource? cancellationSource; [BackgroundDependencyLoader] private void load(LocalisationManager localisation) { - var beatmapInfo = wedge.Beatmap.BeatmapInfo; - var metadata = wedge.beatmap.Metadata; + var beatmapInfo = wedge.Beatmap!.BeatmapInfo; + var metadata = wedge.beatmap!.Metadata; RelativeSizeAxes = Axes.Both; @@ -274,6 +264,7 @@ namespace osu.Game.Screens.Select }, ArtistLabel = new OsuSpriteText { + //figma design has a diffused shadow, instead of the solid one present here. Shadow = true, Current = { BindTarget = artistBinding }, //Not sure if this should be semi bold or medium @@ -298,7 +289,8 @@ namespace osu.Game.Screens.Select wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); }, true); - wedge.starDifficulty.BindValueChanged(s => + starDifficulty = difficultyCache.GetBindableDifficulty(wedge.beatmap!.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); + starDifficulty.BindValueChanged(s => { starRatingDisplay.Current.Value = s.NewValue ?? default; @@ -320,6 +312,8 @@ namespace osu.Game.Screens.Select protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); + + cancellationSource?.Cancel(); settingChangeTracker?.Dispose(); } } From 9afdfd7f067c786f236748c84e7028e0c294ff76 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sun, 8 Jan 2023 15:42:42 +0100 Subject: [PATCH 007/157] small tweaks, container edge - effect addition.. --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index da7cfc6613..ced6931e1f 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -10,6 +10,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; @@ -27,9 +28,9 @@ namespace osu.Game.Screens.Select public partial class BeatmapInfoWedgeV2 : VisibilityContainer { private const float shear_width = 21; - private const int wedge_height = 120; - + private const float wedge_height = 120; private const float transition_duration = 250; + private const float corner_radius = 10; private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / wedge_height, 0); @@ -45,14 +46,20 @@ namespace osu.Game.Screens.Select public BeatmapInfoWedgeV2() { - CornerRadius = 10; Shear = wedged_container_shear; Masking = true; - Alpha = 0; + EdgeEffect = new EdgeEffectParameters + { + Colour = Colour4.Black.Opacity(.25f), + Type = EdgeEffectType.Shadow, + Radius = corner_radius, + Roundness = corner_radius + }; + CornerRadius = corner_radius; Children = new Drawable[] { - //These elements can't be grouped with the rest of the content, due to being present either outside or under the backgrounds area + // These elements can't be grouped with the rest of the content, due to being present either outside or under the backgrounds area difficultyColourBar = new Container { Colour = Colour4.Transparent, @@ -61,7 +68,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, - //By limiting the width we avoid this box showing up as an outline around the drawables that are on top of it. + // By limiting the width we avoid this box showing up as an outline around the drawables that are on top of it. Width = 40, Child = new Box { RelativeSizeAxes = Axes.Both } }, @@ -70,7 +77,7 @@ namespace osu.Game.Screens.Select Colour = Colour4.Transparent, Anchor = Anchor.CentreRight, Origin = Anchor.Centre, - Scale = new Vector2(0.4f), + Scale = new Vector2(0.35f), Shear = -wedged_container_shear, X = -15, Direction = FillDirection.Vertical @@ -85,10 +92,10 @@ namespace osu.Game.Screens.Select float starAngle = (float)(Math.Atan(shear_width / wedge_height) * (180 / Math.PI)); - //Applying the rotation directly to the StarCounter distorts the stars, hence it is applied to the child container + // Applying the rotation directly to the StarCounter distorts the stars, hence it is applied to the child container starCounter.Children.First().Rotation = starAngle; - //Makes sure the stars center themselves properly in the colour bar + // Makes sure the stars center themselves properly in the colour bar starCounter.Children.First().Anchor = Anchor.Centre; starCounter.Children.First().Origin = Anchor.Centre; } @@ -153,13 +160,13 @@ namespace osu.Game.Screens.Select { Masking = true, X = -30, - CornerRadius = 10, + CornerRadius = corner_radius, RelativeSizeAxes = Axes.Both, Depth = DisplayedContent?.Depth + 1 ?? 0, Children = new Drawable[] { new BeatmapInfoWedgeBackground(beatmap) { Shear = -Shear }, - Info = new WedgeInfoText { Shear = -Shear } + Info = new WedgeInfoText(beatmap) { Shear = -Shear } } }, loaded => { @@ -182,11 +189,10 @@ namespace osu.Game.Screens.Select private ILocalisedBindableString titleBinding = null!; private ILocalisedBindableString artistBinding = null!; - [Resolved] - private IBindable> mods { get; set; } = null!; + private readonly WorkingBeatmap working; [Resolved] - private BeatmapInfoWedgeV2 wedge { get; set; } = null!; + private IBindable> mods { get; set; } = null!; [Resolved] private OsuColour colours { get; set; } = null!; @@ -194,16 +200,24 @@ namespace osu.Game.Screens.Select [Resolved] private BeatmapDifficultyCache difficultyCache { get; set; } = null!; + [Resolved] + private BeatmapInfoWedgeV2 wedge { get; set; } = null!; + private ModSettingChangeTracker? settingChangeTracker; private IBindable? starDifficulty; private CancellationTokenSource? cancellationSource; + public WedgeInfoText(WorkingBeatmap working) + { + this.working = working; + } + [BackgroundDependencyLoader] private void load(LocalisationManager localisation) { - var beatmapInfo = wedge.Beatmap!.BeatmapInfo; - var metadata = wedge.beatmap!.Metadata; + var beatmapInfo = working.BeatmapInfo; + var metadata = working.Metadata; RelativeSizeAxes = Axes.Both; @@ -249,7 +263,7 @@ namespace osu.Game.Screens.Select Name = "Top-left aligned metadata", Direction = FillDirection.Vertical, Position = new Vector2(80, 12), - Width = .8f, + Width = .7f, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Children = new Drawable[] @@ -289,7 +303,7 @@ namespace osu.Game.Screens.Select wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); }, true); - starDifficulty = difficultyCache.GetBindableDifficulty(wedge.beatmap!.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); + starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); starDifficulty.BindValueChanged(s => { starRatingDisplay.Current.Value = s.NewValue ?? default; From 2a82f618ed9a69dd28613dfc8f04189ceecd702f Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Tue, 10 Jan 2023 17:34:47 +0100 Subject: [PATCH 008/157] Add TODO for text margin const, added pertinent comments to known "issues" --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index ced6931e1f..ce07a59a0c 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -32,6 +32,9 @@ namespace osu.Game.Screens.Select private const float transition_duration = 250; private const float corner_radius = 10; + /// Todo: move this const out to song select when more new design elements are implemented for the beatmap details area, since it applies to text alignment of various elements + private const float text_margin = 62; + private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / wedge_height, 0); [Resolved] @@ -159,18 +162,21 @@ namespace osu.Game.Screens.Select LoadComponentAsync(loadingInfo = new Container { Masking = true, + // We offset this by the portion of the colour bar underneath we wish to show X = -30, CornerRadius = corner_radius, RelativeSizeAxes = Axes.Both, Depth = DisplayedContent?.Depth + 1 ?? 0, Children = new Drawable[] { + // TODO: New wedge design uses a coloured horizontal gradient for its background, however this lacks implementation information in the figma draft. + // pending https://www.figma.com/file/DXKwqZhD5yyb1igc3mKo1P?node-id=2980:3361#340801912 being answered. new BeatmapInfoWedgeBackground(beatmap) { Shear = -Shear }, Info = new WedgeInfoText(beatmap) { Shear = -Shear } } }, loaded => { - // ensure we are the most recent loaded wedge. + // Ensure we are the most recent loaded wedge. if (loaded != loadingInfo) return; removeOldInfo(); @@ -262,7 +268,7 @@ namespace osu.Game.Screens.Select { Name = "Top-left aligned metadata", Direction = FillDirection.Vertical, - Position = new Vector2(80, 12), + Position = new Vector2(text_margin + shear_width, 12), Width = .7f, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, @@ -278,10 +284,10 @@ namespace osu.Game.Screens.Select }, ArtistLabel = new OsuSpriteText { - //figma design has a diffused shadow, instead of the solid one present here. + // TODO : figma design has a diffused shadow, instead of the solid one present here, not possible currently as far as i'm aware. Shadow = true, Current = { BindTarget = artistBinding }, - //Not sure if this should be semi bold or medium + // Not sure if this should be semi bold or medium Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, Truncate = true @@ -297,8 +303,8 @@ namespace osu.Game.Screens.Select starRatingDisplay.DisplayedStars.BindValueChanged(s => { - wedge.starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); wedge.starCounter.Current = (float)s.NewValue; + wedge.starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); }, true); From 8bfe24ced0c9163c1e1017b76d1f1669d57a160c Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Tue, 10 Jan 2023 17:49:33 +0100 Subject: [PATCH 009/157] Remove nullable disable in test. --- .../SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index 98e9d803ca..193acc8a7b 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -1,10 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Collections.Generic; -using JetBrains.Annotations; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -24,8 +21,8 @@ namespace osu.Game.Tests.Visual.SongSelect [TestFixture] public partial class TestSceneBeatmapInfoWedgeV2 : OsuTestScene { - private RulesetStore rulesets; - private TestBeatmapInfoWedgeV2 infoWedge; + private RulesetStore rulesets = null!; + private TestBeatmapInfoWedgeV2 infoWedge = null!; private readonly List beatmaps = new List(); [BackgroundDependencyLoader] @@ -80,8 +77,8 @@ namespace osu.Game.Tests.Visual.SongSelect private void testBeatmapLabels(Ruleset ruleset) { - AddAssert("check title", () => infoWedge.Info.TitleLabel.Current.Value == $"{ruleset.ShortName}Title"); - AddAssert("check artist", () => infoWedge.Info.ArtistLabel.Current.Value == $"{ruleset.ShortName}Artist"); + AddAssert("check title", () => infoWedge.Info!.TitleLabel.Current.Value == $"{ruleset.ShortName}Title"); + AddAssert("check artist", () => infoWedge.Info!.ArtistLabel.Current.Value == $"{ruleset.ShortName}Artist"); } [SetUpSteps] @@ -98,7 +95,7 @@ namespace osu.Game.Tests.Visual.SongSelect private void setRuleset(RulesetInfo rulesetInfo) { - Container containerBefore = null; + Container? containerBefore = null; AddStep("set ruleset", () => { @@ -112,9 +109,9 @@ namespace osu.Game.Tests.Visual.SongSelect AddUntilStep("wait for async load", () => infoWedge.DisplayedContent != containerBefore); } - private void selectBeatmap([CanBeNull] IBeatmap b) + private void selectBeatmap(IBeatmap? b) { - Container containerBefore = null; + Container? containerBefore = null; AddStep($"select {b?.Metadata.Title ?? "null"} beatmap", () => { @@ -172,9 +169,9 @@ namespace osu.Game.Tests.Visual.SongSelect private partial class TestBeatmapInfoWedgeV2 : BeatmapInfoWedgeV2 { - public new Container DisplayedContent => base.DisplayedContent; + public new Container? DisplayedContent => base.DisplayedContent; - public new WedgeInfoText Info => base.Info; + public new WedgeInfoText? Info => base.Info; } private class TestHitObject : ConvertHitObject, IHasPosition From 880428046a17606b200750c6f8bdec254fd7e4e1 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Tue, 10 Jan 2023 18:03:28 +0100 Subject: [PATCH 010/157] Fix margins on top right aligned elements. --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index ce07a59a0c..1497bed121 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -238,7 +238,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Direction = FillDirection.Vertical, - Padding = new MarginPadding { Top = 14, Right = shear_width / 2 }, + Padding = new MarginPadding { Top = 3, Right = 8 }, AutoSizeAxes = Axes.Both, Shear = wedged_container_shear, Spacing = new Vector2(0f, 5f), From 7510201804aab33e90d805b8a34b9883f9ff390f Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 16 Jan 2023 22:24:21 +0100 Subject: [PATCH 011/157] Add back null beatmap test --- .../Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index 193acc8a7b..a2935fb218 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -93,6 +94,15 @@ namespace osu.Game.Tests.Visual.SongSelect selectBeatmap(createLongMetadata()); } + [Test] + public void TestNullBeatmap() + { + selectBeatmap(null); + AddAssert("check default title", () => infoWedge.Info!.TitleLabel.Current.Value == Beatmap.Default.BeatmapInfo.Metadata.Title); + AddAssert("check default artist", () => infoWedge.Info!.ArtistLabel.Current.Value == Beatmap.Default.BeatmapInfo.Metadata.Artist); + AddAssert("check no info labels", () => !infoWedge.Info.ChildrenOfType().Any()); + } + private void setRuleset(RulesetInfo rulesetInfo) { Container? containerBefore = null; From 74b72e4ac0d6c34df51bf8d27c24d4625a9f8039 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 16 Jan 2023 22:46:18 +0100 Subject: [PATCH 012/157] Address issues that joehuu brought up --- .../Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 2 +- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index a2935fb218..4904e2a723 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -38,7 +38,7 @@ namespace osu.Game.Tests.Visual.SongSelect Add(infoWedge = new TestBeatmapInfoWedgeV2 { - Size = new Vector2(0.6f, 120), + Width = 0.6f, RelativeSizeAxes = Axes.X, Margin = new MarginPadding { Top = 20 } }); diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 1497bed121..02d640fc0d 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -31,6 +31,7 @@ namespace osu.Game.Screens.Select private const float wedge_height = 120; private const float transition_duration = 250; private const float corner_radius = 10; + private const float colour_bar_width = 30; /// Todo: move this const out to song select when more new design elements are implemented for the beatmap details area, since it applies to text alignment of various elements private const float text_margin = 62; @@ -49,6 +50,7 @@ namespace osu.Game.Screens.Select public BeatmapInfoWedgeV2() { + Height = wedge_height; Shear = wedged_container_shear; Masking = true; EdgeEffect = new EdgeEffectParameters @@ -72,7 +74,7 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.Y, // By limiting the width we avoid this box showing up as an outline around the drawables that are on top of it. - Width = 40, + Width = colour_bar_width + corner_radius, Child = new Box { RelativeSizeAxes = Axes.Both } }, starCounter = new StarCounter @@ -82,7 +84,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.Centre, Scale = new Vector2(0.35f), Shear = -wedged_container_shear, - X = -15, + X = -colour_bar_width / 2, Direction = FillDirection.Vertical } }; @@ -163,7 +165,7 @@ namespace osu.Game.Screens.Select { Masking = true, // We offset this by the portion of the colour bar underneath we wish to show - X = -30, + X = -colour_bar_width, CornerRadius = corner_radius, RelativeSizeAxes = Axes.Both, Depth = DisplayedContent?.Depth + 1 ?? 0, @@ -268,8 +270,7 @@ namespace osu.Game.Screens.Select { Name = "Top-left aligned metadata", Direction = FillDirection.Vertical, - Position = new Vector2(text_margin + shear_width, 12), - Width = .7f, + Padding = new MarginPadding { Horizontal = text_margin + shear_width, Top = 12 }, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Children = new Drawable[] From 0ac7cd7409e1c61cc0f8df03c1fa0b780adb43da Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Wed, 18 Jan 2023 13:55:52 +0100 Subject: [PATCH 013/157] Expose star difficulty to wedge to allow updating starcounter and background colour internally. --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 02d640fc0d..d90c002953 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -24,7 +24,6 @@ using osu.Game.Rulesets.Mods; namespace osu.Game.Screens.Select { - [Cached] public partial class BeatmapInfoWedgeV2 : VisibilityContainer { private const float shear_width = 21; @@ -41,6 +40,9 @@ namespace osu.Game.Screens.Select [Resolved] private IBindable ruleset { get; set; } = null!; + [Resolved] + private OsuColour colours { get; set; } = null!; + protected Container? DisplayedContent { get; private set; } protected WedgeInfoText? Info { get; private set; } @@ -183,6 +185,14 @@ namespace osu.Game.Screens.Select removeOldInfo(); Add(DisplayedContent = loaded); + + Info.StarRatingDisplay.DisplayedStars.BindValueChanged(s => + { + starCounter.Current = (float)s.NewValue; + starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); + + difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); + }, true); }); } } @@ -192,7 +202,7 @@ namespace osu.Game.Screens.Select public OsuSpriteText TitleLabel { get; private set; } = null!; public OsuSpriteText ArtistLabel { get; private set; } = null!; - private StarRatingDisplay starRatingDisplay = null!; + public StarRatingDisplay StarRatingDisplay = null!; private ILocalisedBindableString titleBinding = null!; private ILocalisedBindableString artistBinding = null!; @@ -202,15 +212,9 @@ namespace osu.Game.Screens.Select [Resolved] private IBindable> mods { get; set; } = null!; - [Resolved] - private OsuColour colours { get; set; } = null!; - [Resolved] private BeatmapDifficultyCache difficultyCache { get; set; } = null!; - [Resolved] - private BeatmapInfoWedgeV2 wedge { get; set; } = null!; - private ModSettingChangeTracker? settingChangeTracker; private IBindable? starDifficulty; @@ -246,7 +250,7 @@ namespace osu.Game.Screens.Select Spacing = new Vector2(0f, 5f), Children = new Drawable[] { - starRatingDisplay = new StarRatingDisplay(default, animated: true) + StarRatingDisplay = new StarRatingDisplay(default, animated: true) { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -302,24 +306,16 @@ namespace osu.Game.Screens.Select { base.LoadComplete(); - starRatingDisplay.DisplayedStars.BindValueChanged(s => - { - wedge.starCounter.Current = (float)s.NewValue; - wedge.starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); - - wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); - }, true); - starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); starDifficulty.BindValueChanged(s => { - starRatingDisplay.Current.Value = s.NewValue ?? default; + StarRatingDisplay.Current.Value = s.NewValue ?? default; // Don't roll the counter on initial display (but still allow it to roll on applying mods etc.) - if (!starRatingDisplay.IsPresent) - starRatingDisplay.FinishTransforms(true); + if (!StarRatingDisplay.IsPresent) + StarRatingDisplay.FinishTransforms(true); - starRatingDisplay.FadeIn(transition_duration); + StarRatingDisplay.FadeIn(transition_duration); }); mods.BindValueChanged(m => From 655242371b2858371c82970d9fe316eb7d26cd6d Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 23 Jan 2023 17:00:46 +0100 Subject: [PATCH 014/157] Buffer wedge content to avoid opacity issues when showing / hiding --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index d90c002953..63e414d6ad 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -49,6 +49,7 @@ namespace osu.Game.Screens.Select private readonly Container difficultyColourBar; private readonly StarCounter starCounter; + private readonly BufferedContainer bufferedContent; public BeatmapInfoWedgeV2() { @@ -64,30 +65,35 @@ namespace osu.Game.Screens.Select }; CornerRadius = corner_radius; - Children = new Drawable[] + // We want to buffer the wedge to avoid weird transparency overlaps between the colour bar and the background. + Child = bufferedContent = new BufferedContainer { - // These elements can't be grouped with the rest of the content, due to being present either outside or under the backgrounds area - difficultyColourBar = new Container + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - Colour = Colour4.Transparent, - Depth = float.MaxValue, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - RelativeSizeAxes = Axes.Y, + // These elements can't be grouped with the rest of the content, due to being present either outside or under the backgrounds area + difficultyColourBar = new Container + { + Colour = Colour4.Transparent, + Depth = float.MaxValue, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Y, - // By limiting the width we avoid this box showing up as an outline around the drawables that are on top of it. - Width = colour_bar_width + corner_radius, - Child = new Box { RelativeSizeAxes = Axes.Both } - }, - starCounter = new StarCounter - { - Colour = Colour4.Transparent, - Anchor = Anchor.CentreRight, - Origin = Anchor.Centre, - Scale = new Vector2(0.35f), - Shear = -wedged_container_shear, - X = -colour_bar_width / 2, - Direction = FillDirection.Vertical + // By limiting the width we avoid this box showing up as an outline around the drawables that are on top of it. + Width = colour_bar_width + corner_radius, + Child = new Box { RelativeSizeAxes = Axes.Both } + }, + starCounter = new StarCounter + { + Colour = Colour4.Transparent, + Anchor = Anchor.CentreRight, + Origin = Anchor.Centre, + Scale = new Vector2(0.35f), + Shear = -wedged_container_shear, + X = -colour_bar_width / 2, + Direction = FillDirection.Vertical + } } }; } @@ -184,9 +190,9 @@ namespace osu.Game.Screens.Select if (loaded != loadingInfo) return; removeOldInfo(); - Add(DisplayedContent = loaded); + bufferedContent.Add(DisplayedContent = loaded); - Info.StarRatingDisplay.DisplayedStars.BindValueChanged(s => + Info.DisplayedStars.BindValueChanged(s => { starCounter.Current = (float)s.NewValue; starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); @@ -202,13 +208,15 @@ namespace osu.Game.Screens.Select public OsuSpriteText TitleLabel { get; private set; } = null!; public OsuSpriteText ArtistLabel { get; private set; } = null!; - public StarRatingDisplay StarRatingDisplay = null!; + private StarRatingDisplay starRatingDisplay = null!; private ILocalisedBindableString titleBinding = null!; private ILocalisedBindableString artistBinding = null!; private readonly WorkingBeatmap working; + public IBindable DisplayedStars => starRatingDisplay.DisplayedStars; + [Resolved] private IBindable> mods { get; set; } = null!; @@ -250,7 +258,7 @@ namespace osu.Game.Screens.Select Spacing = new Vector2(0f, 5f), Children = new Drawable[] { - StarRatingDisplay = new StarRatingDisplay(default, animated: true) + starRatingDisplay = new StarRatingDisplay(default, animated: true) { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -309,13 +317,13 @@ namespace osu.Game.Screens.Select starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); starDifficulty.BindValueChanged(s => { - StarRatingDisplay.Current.Value = s.NewValue ?? default; + starRatingDisplay.Current.Value = s.NewValue ?? default; // Don't roll the counter on initial display (but still allow it to roll on applying mods etc.) - if (!StarRatingDisplay.IsPresent) - StarRatingDisplay.FinishTransforms(true); + if (!starRatingDisplay.IsPresent) + starRatingDisplay.FinishTransforms(true); - StarRatingDisplay.FadeIn(transition_duration); + starRatingDisplay.FadeIn(transition_duration); }); mods.BindValueChanged(m => From c7d49bdc82c4ab48ab60040cdd0e161a481fdf94 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 30 Jan 2023 13:13:57 +0100 Subject: [PATCH 015/157] Update ```BeatmapInfoWedgeV2.cs``` animation to be similar to exit transition in ```SongSelect.cs`` --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 63e414d6ad..6a1662fd6a 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -113,20 +113,18 @@ namespace osu.Game.Screens.Select starCounter.Children.First().Origin = Anchor.Centre; } - private const double animation_duration = 800; + private const double animation_duration = 600; protected override void PopIn() { this.MoveToX(0, animation_duration, Easing.OutQuint); - this.RotateTo(0, animation_duration, Easing.OutQuint); - this.FadeIn(transition_duration); + this.FadeIn(200, Easing.In); } protected override void PopOut() { - this.MoveToX(-100, animation_duration, Easing.In); - this.RotateTo(10, animation_duration, Easing.In); - this.FadeOut(transition_duration * 2, Easing.In); + this.MoveToX(-150, animation_duration, Easing.OutQuint); + this.FadeOut(200, Easing.OutQuint); } private WorkingBeatmap? beatmap; From 92690afa5fecd750583924c5917fc3b877b73041 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 30 Jan 2023 16:12:26 +0100 Subject: [PATCH 016/157] de-nest ```removeOldInfo()``` --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 6a1662fd6a..41fe9d8d50 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -152,15 +152,6 @@ namespace osu.Game.Screens.Select void perform() { - void removeOldInfo() - { - State.Value = beatmap == null ? Visibility.Hidden : Visibility.Visible; - - DisplayedContent?.FadeOut(transition_duration); - DisplayedContent?.Expire(); - DisplayedContent = null; - } - if (beatmap == null) { removeOldInfo(); @@ -199,6 +190,15 @@ namespace osu.Game.Screens.Select }, true); }); } + + void removeOldInfo() + { + State.Value = beatmap == null ? Visibility.Hidden : Visibility.Visible; + + DisplayedContent?.FadeOut(transition_duration); + DisplayedContent?.Expire(); + DisplayedContent = null; + } } public partial class WedgeInfoText : Container From 27c52a45fc079174f29067ae6b7e97529f02cceb Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Mon, 30 Jan 2023 16:13:55 +0100 Subject: [PATCH 017/157] Use inline lambda for scheduling --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 41fe9d8d50..0cc60e4bba 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -148,9 +148,7 @@ namespace osu.Game.Screens.Select private void updateDisplay() { - Scheduler.AddOnce(perform); - - void perform() + Scheduler.AddOnce(() => { if (beatmap == null) { @@ -189,7 +187,7 @@ namespace osu.Game.Screens.Select difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); }, true); }); - } + }); void removeOldInfo() { From 5fc8f1d1bef944c43f1e9b1ac0456ded7015db72 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Fri, 3 Feb 2023 19:52:01 +0100 Subject: [PATCH 018/157] Fix ```BeatmapInfoWedgeV2.cs``` starCounter needing janky rotation application --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 0cc60e4bba..48a16d5449 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using osuTK; using osu.Framework.Allocation; @@ -84,15 +83,25 @@ namespace osu.Game.Screens.Select Width = colour_bar_width + corner_radius, Child = new Box { RelativeSizeAxes = Axes.Both } }, - starCounter = new StarCounter + new Container { - Colour = Colour4.Transparent, - Anchor = Anchor.CentreRight, - Origin = Anchor.Centre, - Scale = new Vector2(0.35f), + // Applying the shear to this container and nesting the starCounter inside avoids + // the deformation that occurs if the shear is applied to the starCounter whilst rotated Shear = -wedged_container_shear, X = -colour_bar_width / 2, - Direction = FillDirection.Vertical + Anchor = Anchor.CentreRight, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Width = colour_bar_width, + Child = starCounter = new StarCounter + { + Rotation = (float)(Math.Atan(shear_width / wedge_height) * (180 / Math.PI)), + Colour = Colour4.Transparent, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(0.35f), + Direction = FillDirection.Vertical + } } } }; @@ -102,15 +111,6 @@ namespace osu.Game.Screens.Select private void load() { ruleset.BindValueChanged(_ => updateDisplay()); - - float starAngle = (float)(Math.Atan(shear_width / wedge_height) * (180 / Math.PI)); - - // Applying the rotation directly to the StarCounter distorts the stars, hence it is applied to the child container - starCounter.Children.First().Rotation = starAngle; - - // Makes sure the stars center themselves properly in the colour bar - starCounter.Children.First().Anchor = Anchor.Centre; - starCounter.Children.First().Origin = Anchor.Centre; } private const double animation_duration = 600; From de37a0a000bfb99ad0f56eaadbe9929eb93229ab Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Fri, 3 Feb 2023 19:53:04 +0100 Subject: [PATCH 019/157] enable pixelSnapping for the ```BufferedContainer``` in BeatmapInfoWedgeV2.cs --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 48a16d5449..a18d4086f7 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Select CornerRadius = corner_radius; // We want to buffer the wedge to avoid weird transparency overlaps between the colour bar and the background. - Child = bufferedContent = new BufferedContainer + Child = bufferedContent = new BufferedContainer(pixelSnapping: true) { RelativeSizeAxes = Axes.Both, Children = new Drawable[] From 38cc47d64ec35313d7cb928ae78a018b5641e2d5 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sat, 4 Feb 2023 16:52:30 +0100 Subject: [PATCH 020/157] Remove ```IsPresent``` usages --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index a18d4086f7..fda20dde4d 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -142,8 +142,6 @@ namespace osu.Game.Screens.Select } } - public override bool IsPresent => base.IsPresent || DisplayedContent == null; // Visibility is updated in the LoadComponentAsync callback - private Container? loadingInfo; private void updateDisplay() @@ -316,7 +314,7 @@ namespace osu.Game.Screens.Select starRatingDisplay.Current.Value = s.NewValue ?? default; // Don't roll the counter on initial display (but still allow it to roll on applying mods etc.) - if (!starRatingDisplay.IsPresent) + if (starRatingDisplay.Alpha > 0) starRatingDisplay.FinishTransforms(true); starRatingDisplay.FadeIn(transition_duration); From cb679ccc2b95858b0ff85e86bffcd6ee6a27d9dd Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sat, 11 Feb 2023 18:00:17 +0100 Subject: [PATCH 021/157] Separate wedge visibility test into its own method --- .../SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index 4904e2a723..f99950dfb0 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -7,6 +7,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -49,12 +50,6 @@ namespace osu.Game.Tests.Visual.SongSelect AddWaitStep("wait for select", 3); - AddStep("hide", () => { infoWedge.Hide(); }); - - AddWaitStep("wait for hide", 3); - - AddStep("show", () => { infoWedge.Show(); }); - AddSliderStep("change star difficulty", 0, 11.9, 5.55, v => { foreach (var hasCurrentValue in infoWedge.Info.ChildrenOfType>()) @@ -76,6 +71,26 @@ namespace osu.Game.Tests.Visual.SongSelect } } + [Test] + public void TestWedgeVisibility() + { + AddStep("Make shadow red for test visibility", () => + { + infoWedge.EdgeEffect = new EdgeEffectParameters + { + Colour = Colour4.Red, + Type = EdgeEffectType.Shadow, + Radius = 5, + }; + }); + AddStep("hide", () => { infoWedge.Hide(); }); + AddWaitStep("wait for hide", 3); + AddAssert("check visibility", () => infoWedge.Alpha == 0); + AddStep("show", () => { infoWedge.Show(); }); + AddWaitStep("wait for show", 1); + AddAssert("check visibility", () => infoWedge.Alpha > 0); + } + private void testBeatmapLabels(Ruleset ruleset) { AddAssert("check title", () => infoWedge.Info!.TitleLabel.Current.Value == $"{ruleset.ShortName}Title"); From 468419896a5364252afa23263d9e43d26c4b7edf Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sat, 11 Feb 2023 18:08:50 +0100 Subject: [PATCH 022/157] Separate ruleset changing tests into their own method. Add small clarification for edge colouring in visibility test --- .../SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index f99950dfb0..ebd8c008b3 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -39,22 +39,25 @@ namespace osu.Game.Tests.Visual.SongSelect Add(infoWedge = new TestBeatmapInfoWedgeV2 { + State = { Value = Visibility.Visible }, Width = 0.6f, RelativeSizeAxes = Axes.X, Margin = new MarginPadding { Top = 20 } }); - AddStep("show", () => infoWedge.Show()); - - selectBeatmap(Beatmap.Value.Beatmap); - - AddWaitStep("wait for select", 3); - AddSliderStep("change star difficulty", 0, 11.9, 5.55, v => { foreach (var hasCurrentValue in infoWedge.Info.ChildrenOfType>()) hasCurrentValue.Current.Value = new StarDifficulty(v, 0); }); + } + + [Test] + public void TestRulesetChange() + { + selectBeatmap(Beatmap.Value.Beatmap); + + AddWaitStep("wait for select", 3); foreach (var rulesetInfo in rulesets.AvailableRulesets) { @@ -74,6 +77,8 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestWedgeVisibility() { + // Mostly just in case someone runs this test before others, + // leading to the shadow being very hard to see if it is black AddStep("Make shadow red for test visibility", () => { infoWedge.EdgeEffect = new EdgeEffectParameters From 09cb6ca3a797e516c3097b48883468be0f85f237 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Sat, 11 Feb 2023 18:15:21 +0100 Subject: [PATCH 023/157] Clean up formatting and wedge placement in testscene a tad, --- .../Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index ebd8c008b3..3f3c7441f4 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.SongSelect State = { Value = Visibility.Visible }, Width = 0.6f, RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Top = 20 } + Margin = new MarginPadding { Top = 20, Left = -10 } }); AddSliderStep("change star difficulty", 0, 11.9, 5.55, v => @@ -79,7 +79,7 @@ namespace osu.Game.Tests.Visual.SongSelect { // Mostly just in case someone runs this test before others, // leading to the shadow being very hard to see if it is black - AddStep("Make shadow red for test visibility", () => + AddStep("make shadow red for test visibility", () => { infoWedge.EdgeEffect = new EdgeEffectParameters { From 299023fce036d6995ead30d00d1de6364bbcc137 Mon Sep 17 00:00:00 2001 From: mk56-spn Date: Tue, 21 Feb 2023 16:07:26 +0100 Subject: [PATCH 024/157] Improve visibility of wedge shading in test scene and fix an issue with excessive roundness on said shadow. --- .../SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 25 ++++++++++++++----- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 9 +++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index 3f3c7441f4..09b93119cc 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -37,12 +38,25 @@ namespace osu.Game.Tests.Visual.SongSelect { base.LoadComplete(); - Add(infoWedge = new TestBeatmapInfoWedgeV2 + AddRange(new Drawable[] { - State = { Value = Visibility.Visible }, - Width = 0.6f, - RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Top = 20, Left = -10 } + // This exists only to make the wedge more visible in the test scene + new Box + { + Y = -20, + Colour = Colour4.Cornsilk.Darken(0.2f), + Height = BeatmapInfoWedgeV2.WEDGE_HEIGHT + 40, + Width = 0.65f, + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = 20, Left = -10 } + }, + infoWedge = new TestBeatmapInfoWedgeV2 + { + State = { Value = Visibility.Visible }, + Width = 0.6f, + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = 20, Left = -10 } + }, }); AddSliderStep("change star difficulty", 0, 11.9, 5.55, v => @@ -200,7 +214,6 @@ namespace osu.Game.Tests.Visual.SongSelect private partial class TestBeatmapInfoWedgeV2 : BeatmapInfoWedgeV2 { public new Container? DisplayedContent => base.DisplayedContent; - public new WedgeInfoText? Info => base.Info; } diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index fda20dde4d..0a35e68c7e 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -25,8 +25,8 @@ namespace osu.Game.Screens.Select { public partial class BeatmapInfoWedgeV2 : VisibilityContainer { + public const float WEDGE_HEIGHT = 120; private const float shear_width = 21; - private const float wedge_height = 120; private const float transition_duration = 250; private const float corner_radius = 10; private const float colour_bar_width = 30; @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Select /// Todo: move this const out to song select when more new design elements are implemented for the beatmap details area, since it applies to text alignment of various elements private const float text_margin = 62; - private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / wedge_height, 0); + private static readonly Vector2 wedged_container_shear = new Vector2(shear_width / WEDGE_HEIGHT, 0); [Resolved] private IBindable ruleset { get; set; } = null!; @@ -52,7 +52,7 @@ namespace osu.Game.Screens.Select public BeatmapInfoWedgeV2() { - Height = wedge_height; + Height = WEDGE_HEIGHT; Shear = wedged_container_shear; Masking = true; EdgeEffect = new EdgeEffectParameters @@ -60,7 +60,6 @@ namespace osu.Game.Screens.Select Colour = Colour4.Black.Opacity(.25f), Type = EdgeEffectType.Shadow, Radius = corner_radius, - Roundness = corner_radius }; CornerRadius = corner_radius; @@ -95,7 +94,7 @@ namespace osu.Game.Screens.Select Width = colour_bar_width, Child = starCounter = new StarCounter { - Rotation = (float)(Math.Atan(shear_width / wedge_height) * (180 / Math.PI)), + Rotation = (float)(Math.Atan(shear_width / WEDGE_HEIGHT) * (180 / Math.PI)), Colour = Colour4.Transparent, Anchor = Anchor.Centre, Origin = Anchor.Centre, From f21238f517fa8e22a694affd4406bf3b858a8bb4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2023 16:51:57 +0900 Subject: [PATCH 025/157] Adjust shadow to look better --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 0a35e68c7e..b7b60cffab 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -57,9 +57,9 @@ namespace osu.Game.Screens.Select Masking = true; EdgeEffect = new EdgeEffectParameters { - Colour = Colour4.Black.Opacity(.25f), + Colour = Colour4.Black.Opacity(0.2f), Type = EdgeEffectType.Shadow, - Radius = corner_radius, + Radius = 3, }; CornerRadius = corner_radius; From 768d7b5e1c30329280447dc452fde063b6e440b3 Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Mon, 17 Jul 2023 23:31:21 -0400 Subject: [PATCH 026/157] correct implementation of stable notelock --- .../TestSceneHitCircle.cs | 2 +- .../Objects/Drawables/DrawableHitCircle.cs | 7 ++- .../Objects/Drawables/DrawableOsuHitObject.cs | 10 ++-- .../Objects/Drawables/DrawableSliderHead.cs | 3 +- osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs | 2 +- osu.Game.Rulesets.Osu/UI/ClickAction.cs | 18 +++++++ osu.Game.Rulesets.Osu/UI/IHitPolicy.cs | 2 +- .../UI/ObjectOrderedHitPolicy.cs | 53 ++++++++++--------- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 2 +- .../UI/StartTimeOrderedHitPolicy.cs | 8 +-- osu.Game/Rulesets/UI/HitObjectContainer.cs | 2 +- osu.Game/Rulesets/UI/IHitObjectContainer.cs | 2 +- 12 files changed, 72 insertions(+), 39 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/UI/ClickAction.cs diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs index 0314afc1ac..c818a361df 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs @@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Tests protected override void CheckForResult(bool userTriggered, double timeOffset) { - if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current) != false) + if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current) == ClickAction.Hit) { // force success ApplyResult(r => r.Type = HitResult.Great); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 3458069dd1..09d818def8 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -18,6 +18,7 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Skinning; using osu.Game.Rulesets.Osu.Skinning.Default; +using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; using osuTK; @@ -154,13 +155,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } var result = ResultFor(timeOffset); + var clickAction = CheckHittable?.Invoke(this, Time.Current); - if (result == HitResult.None || CheckHittable?.Invoke(this, Time.Current) == false) + if (clickAction == ClickAction.Shake || (result == HitResult.None && clickAction != ClickAction.Ignore)) { Shake(); return; } + if (result == HitResult.None) + return; + ApplyResult(r => { var circleResult = (OsuHitCircleJudgementResult)r; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index df0ba344d8..a8ce2118c8 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -12,6 +12,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Scoring; +using osu.Game.Rulesets.Osu.UI; using osuTK; using osuTK.Graphics; @@ -30,10 +31,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override float SamplePlaybackPosition => CalculateDrawableRelativePosition(this); /// - /// Whether this can be hit, given a time value. - /// If non-null, judgements will be ignored (resulting in a shake) whilst the function returns false. + /// What action this should take in response to a + /// click at the given time value. + /// If non-null, judgements will be ignored for return values of + /// and , and this hit object will be shaken for return values of + /// . /// - public Func CheckHittable; + public Func CheckHittable; protected DrawableOsuHitObject(OsuHitObject hitObject) : base(hitObject) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs index b8a1efabe0..a4cf69ee31 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using JetBrains.Annotations; using osu.Framework.Bindables; using osu.Game.Rulesets.Objects.Types; +using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Osu.Objects.Drawables @@ -60,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables pathVersion.BindTo(DrawableSlider.PathVersion); - CheckHittable = (d, t) => DrawableSlider.CheckHittable?.Invoke(d, t) ?? true; + CheckHittable = (d, t) => DrawableSlider.CheckHittable?.Invoke(d, t) ?? ClickAction.Hit; } protected override void Update() diff --git a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs index afa54c2dfb..7503c43e0b 100644 --- a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs @@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } - public bool IsHittable(DrawableHitObject hitObject, double time) => true; + public ClickAction CheckHittable(DrawableHitObject hitObject, double time) => ClickAction.Hit; public void HandleHit(DrawableHitObject hitObject) { diff --git a/osu.Game.Rulesets.Osu/UI/ClickAction.cs b/osu.Game.Rulesets.Osu/UI/ClickAction.cs new file mode 100644 index 0000000000..2b00f5acce --- /dev/null +++ b/osu.Game.Rulesets.Osu/UI/ClickAction.cs @@ -0,0 +1,18 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Osu.Objects.Drawables; + +namespace osu.Game.Rulesets.Osu.UI +{ + /// + /// An action that an recommends be taken in response to a click + /// on a . + /// + public enum ClickAction + { + Ignore, + Shake, + Hit + } +} diff --git a/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs index b509796742..9820b8c188 100644 --- a/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI /// The to check. /// The time to check. /// Whether can be hit at the given . - bool IsHittable(DrawableHitObject hitObject, double time); + ClickAction CheckHittable(DrawableHitObject hitObject, double time); /// /// Handles a being hit. diff --git a/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs index 6330208d37..07942954e1 100644 --- a/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs @@ -3,8 +3,7 @@ #nullable disable -using System.Collections.Generic; -using System.Linq; +using System; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; @@ -22,35 +21,41 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } - public bool IsHittable(DrawableHitObject hitObject, double time) => enumerateHitObjectsUpTo(hitObject.HitObject.StartTime).All(obj => obj.AllJudged); - public void HandleHit(DrawableHitObject hitObject) { } - private IEnumerable enumerateHitObjectsUpTo(double targetTime) + public ClickAction CheckHittable(DrawableHitObject hitObject, double time) { - foreach (var obj in HitObjectContainer.AliveObjects) + int index = HitObjectContainer.AliveObjects.IndexOf(hitObject); + + if (index > 0) { - if (obj.HitObject.StartTime >= targetTime) - yield break; - - switch (obj) - { - case DrawableSpinner: - continue; - - case DrawableSlider slider: - yield return slider.HeadCircle; - - break; - - default: - yield return obj; - - break; - } + var previousHitObject = (DrawableOsuHitObject)HitObjectContainer.AliveObjects[index - 1]; + if (previousHitObject.HitObject.StackHeight > 0 && !previousHitObject.AllJudged) + return ClickAction.Ignore; } + + foreach (DrawableHitObject testObject in HitObjectContainer.AliveObjects) + { + if (testObject.AllJudged) + continue; + + // if we found the object being checked, we can move on to the final timing test. + if (testObject == hitObject) + break; + + // for all other objects, we check for validity and block the hit if any are still valid. + // 3ms of extra leniency to account for slightly unsnapped objects. + if (testObject.HitObject.GetEndTime() + 3 < hitObject.HitObject.StartTime) + return ClickAction.Shake; + } + + // stable has `const HitObjectManager.HITTABLE_RANGE = 400;`, which is only used for notelock code. + // probably not a coincidence that this is equivalent to lazer's OsuHitWindows.MISS_WINDOW. + + // TODO stable compares to 200 when autopilot is enabled, instead of 400. + return Math.Abs(hitObject.HitObject.StartTime - time) < 400 ? ClickAction.Hit : ClickAction.Shake; } } } diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index ed02284a4b..15ca0a90de 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.UI protected override void OnNewDrawableHitObject(DrawableHitObject drawable) { - ((DrawableOsuHitObject)drawable).CheckHittable = hitPolicy.IsHittable; + ((DrawableOsuHitObject)drawable).CheckHittable = hitPolicy.CheckHittable; Debug.Assert(!drawable.IsLoaded, $"Already loaded {nameof(DrawableHitObject)} is added to {nameof(OsuPlayfield)}"); drawable.OnLoadComplete += onDrawableHitObjectLoaded; diff --git a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs index edc3ba0818..f33ca58aef 100644 --- a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } - public bool IsHittable(DrawableHitObject hitObject, double time) + public ClickAction CheckHittable(DrawableHitObject hitObject, double time) { DrawableHitObject blockingObject = null; @@ -36,13 +36,13 @@ namespace osu.Game.Rulesets.Osu.UI // If there is no previous hitobject, allow the hit. if (blockingObject == null) - return true; + return ClickAction.Hit; // A hit is allowed if: // 1. The last blocking hitobject has been judged. // 2. The current time is after the last hitobject's start time. // Hits at exactly the same time as the blocking hitobject are allowed for maps that contain simultaneous hitobjects (e.g. /b/372245). - return blockingObject.Judged || time >= blockingObject.HitObject.StartTime; + return (blockingObject.Judged || time >= blockingObject.HitObject.StartTime) ? ClickAction.Hit : ClickAction.Shake; } public void HandleHit(DrawableHitObject hitObject) @@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Osu.UI if (!hitObjectCanBlockFutureHits(hitObject)) return; - if (!IsHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset)) + if (CheckHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset) != ClickAction.Hit) throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!"); // Miss all hitobjects prior to the hit one. diff --git a/osu.Game/Rulesets/UI/HitObjectContainer.cs b/osu.Game/Rulesets/UI/HitObjectContainer.cs index 099be486b3..454a83bcda 100644 --- a/osu.Game/Rulesets/UI/HitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/HitObjectContainer.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.UI { public IEnumerable Objects => InternalChildren.Cast().OrderBy(h => h.HitObject.StartTime); - public IEnumerable AliveObjects => AliveEntries.Select(pair => pair.Drawable).OrderBy(h => h.HitObject.StartTime); + public IList AliveObjects => AliveEntries.Select(pair => pair.Drawable).OrderBy(h => h.HitObject.StartTime).ToList(); /// /// Invoked when a is judged. diff --git a/osu.Game/Rulesets/UI/IHitObjectContainer.cs b/osu.Game/Rulesets/UI/IHitObjectContainer.cs index 6dcb0944be..bb4806206d 100644 --- a/osu.Game/Rulesets/UI/IHitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/IHitObjectContainer.cs @@ -19,6 +19,6 @@ namespace osu.Game.Rulesets.UI /// /// If this uses pooled objects, this is equivalent to . /// - IEnumerable AliveObjects { get; } + IList AliveObjects { get; } } } From 15af85226ce9c15c6bdb18d1c727cd257683d4e1 Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Wed, 19 Jul 2023 02:06:29 -0400 Subject: [PATCH 027/157] adjust test for correct stable notelock stable actually allows for hitobjs to be hit in the middle of sliders, as long as it doesn't interfere with the end time of the slider. --- .../TestSceneObjectOrderedHitPolicy.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs index ee70441688..be2affa50f 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs @@ -213,10 +213,10 @@ namespace osu.Game.Rulesets.Osu.Tests } /// - /// Tests clicking a future circle after a slider's start time, but hitting all slider ticks. + /// Tests clicking a future circle after a slider's start time, but hitting the slider head and all slider ticks. /// [Test] - public void TestMissSliderHeadAndHitAllSliderTicks() + public void TestHitCircleBeforeSliderHead() { const double time_slider = 1500; const double time_circle = 1510; @@ -248,7 +248,7 @@ namespace osu.Game.Rulesets.Osu.Tests new OsuReplayFrame { Time = time_slider + 10, Position = positionSlider, Actions = { OsuAction.RightButton } } }); - addJudgementAssert(hitObjects[0], HitResult.Miss); + addJudgementAssert(hitObjects[0], HitResult.Great); addJudgementAssert(hitObjects[1], HitResult.Great); addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.LargeTickHit); addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.LargeTickHit); From 2c97ac74107c975f8f37e6a840caff06bef08fc8 Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Wed, 19 Jul 2023 14:28:04 -0400 Subject: [PATCH 028/157] convert AliveObjects to list in hit policy instead of globally --- osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs | 8 +++++--- osu.Game/Rulesets/UI/HitObjectContainer.cs | 2 +- osu.Game/Rulesets/UI/IHitObjectContainer.cs | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs index 07942954e1..172e5a39d8 100644 --- a/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs @@ -4,6 +4,7 @@ #nullable disable using System; +using System.Linq; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; @@ -27,16 +28,17 @@ namespace osu.Game.Rulesets.Osu.UI public ClickAction CheckHittable(DrawableHitObject hitObject, double time) { - int index = HitObjectContainer.AliveObjects.IndexOf(hitObject); + var aliveObjects = HitObjectContainer.AliveObjects.ToList(); + int index = aliveObjects.IndexOf(hitObject); if (index > 0) { - var previousHitObject = (DrawableOsuHitObject)HitObjectContainer.AliveObjects[index - 1]; + var previousHitObject = (DrawableOsuHitObject)aliveObjects[index - 1]; if (previousHitObject.HitObject.StackHeight > 0 && !previousHitObject.AllJudged) return ClickAction.Ignore; } - foreach (DrawableHitObject testObject in HitObjectContainer.AliveObjects) + foreach (DrawableHitObject testObject in aliveObjects) { if (testObject.AllJudged) continue; diff --git a/osu.Game/Rulesets/UI/HitObjectContainer.cs b/osu.Game/Rulesets/UI/HitObjectContainer.cs index 454a83bcda..099be486b3 100644 --- a/osu.Game/Rulesets/UI/HitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/HitObjectContainer.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.UI { public IEnumerable Objects => InternalChildren.Cast().OrderBy(h => h.HitObject.StartTime); - public IList AliveObjects => AliveEntries.Select(pair => pair.Drawable).OrderBy(h => h.HitObject.StartTime).ToList(); + public IEnumerable AliveObjects => AliveEntries.Select(pair => pair.Drawable).OrderBy(h => h.HitObject.StartTime); /// /// Invoked when a is judged. diff --git a/osu.Game/Rulesets/UI/IHitObjectContainer.cs b/osu.Game/Rulesets/UI/IHitObjectContainer.cs index bb4806206d..6dcb0944be 100644 --- a/osu.Game/Rulesets/UI/IHitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/IHitObjectContainer.cs @@ -19,6 +19,6 @@ namespace osu.Game.Rulesets.UI /// /// If this uses pooled objects, this is equivalent to . /// - IList AliveObjects { get; } + IEnumerable AliveObjects { get; } } } From 6a8123029854e79f9124ea90f88c41e0245fda16 Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Wed, 19 Jul 2023 14:44:28 -0400 Subject: [PATCH 029/157] rename ObjectOrderedHitPolicy to LegacyHitPolicy --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 2 +- .../UI/{ObjectOrderedHitPolicy.cs => LegacyHitPolicy.cs} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename osu.Game.Rulesets.Osu/UI/{ObjectOrderedHitPolicy.cs => LegacyHitPolicy.cs} (97%) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index 250d97c537..229f80c2bd 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Mods var osuRuleset = (DrawableOsuRuleset)drawableRuleset; if (ClassicNoteLock.Value) - osuRuleset.Playfield.HitPolicy = new ObjectOrderedHitPolicy(); + osuRuleset.Playfield.HitPolicy = new LegacyHitPolicy(); usingHiddenFading = drawableRuleset.Mods.OfType().SingleOrDefault()?.OnlyFadeApproachCircles.Value == false; } diff --git a/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs similarity index 97% rename from osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs rename to osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs index 172e5a39d8..c35d4a1b56 100644 --- a/osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.UI /// Hits will be blocked until the previous s have been judged. /// /// - public class ObjectOrderedHitPolicy : IHitPolicy + public class LegacyHitPolicy : IHitPolicy { public IHitObjectContainer HitObjectContainer { get; set; } From d2798c7a1ca1d9c79438fd8319662b5aba098c4e Mon Sep 17 00:00:00 2001 From: Wleter Date: Sun, 20 Aug 2023 17:55:19 +0200 Subject: [PATCH 030/157] don't allow negative scaling --- osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index 72216f040e..a952cf3035 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -71,6 +71,9 @@ namespace osu.Game.Overlays.SkinEditor scale.Y = scale.X / selectionRect.Width * selectionRect.Height; } + // If scaling reverses the selection, don't scale. + if (adjustedRect.Width + scale.X < 0 || adjustedRect.Height + scale.Y < 0) return true; + if (anchor.HasFlagFast(Anchor.x0)) adjustedRect.X -= scale.X; if (anchor.HasFlagFast(Anchor.y0)) adjustedRect.Y -= scale.Y; @@ -79,8 +82,8 @@ namespace osu.Game.Overlays.SkinEditor // scale adjust applied to each individual item should match that of the quad itself. var scaledDelta = new Vector2( - MathF.Max(adjustedRect.Width / selectionRect.Width, 0), - MathF.Max(adjustedRect.Height / selectionRect.Height, 0) + adjustedRect.Width / selectionRect.Width, + adjustedRect.Height / selectionRect.Height ); foreach (var b in SelectedBlueprints) From 9f4f81c150895ddc08bb4680bbcbd981a03f9d0d Mon Sep 17 00:00:00 2001 From: Wleter Date: Mon, 21 Aug 2023 19:36:11 +0200 Subject: [PATCH 031/157] accumulating negative scaling --- .../SkinEditor/SkinSelectionHandler.cs | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index a952cf3035..c90a1d8edf 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -31,6 +31,8 @@ namespace osu.Game.Overlays.SkinEditor UpdatePosition = updateDrawablePosition }; + private float accumulatedNegativeScaling; + public override bool HandleScale(Vector2 scale, Anchor anchor) { // convert scale to screen space @@ -71,8 +73,25 @@ namespace osu.Game.Overlays.SkinEditor scale.Y = scale.X / selectionRect.Width * selectionRect.Height; } - // If scaling reverses the selection, don't scale. - if (adjustedRect.Width + scale.X < 0 || adjustedRect.Height + scale.Y < 0) return true; + // If scaling reverses the selection, don't scale and accumulate the amount of scaling. + if (adjustedRect.Width + scale.X < 0 || adjustedRect.Height + scale.Y < 0) + { + accumulatedNegativeScaling += scale.Length; // - new Vector2(selectionRect.Width, selectionRect.Height).Length; + + return true; + } + + // Compensate for accumulated negative scaling. + if (Precision.AlmostBigger(accumulatedNegativeScaling, 0) && !Precision.AlmostEquals(accumulatedNegativeScaling, 0)) + { + float length = scale.Length; + accumulatedNegativeScaling -= length; + + // If the accumulated negative scaling is still positive, don't scale. + if (Precision.AlmostBigger(accumulatedNegativeScaling, 0)) return true; + scale *= Math.Abs(accumulatedNegativeScaling) / length; + accumulatedNegativeScaling = 0; + } if (anchor.HasFlagFast(Anchor.x0)) adjustedRect.X -= scale.X; if (anchor.HasFlagFast(Anchor.y0)) adjustedRect.Y -= scale.Y; @@ -150,6 +169,12 @@ namespace osu.Game.Overlays.SkinEditor public static void ApplyClosestAnchor(Drawable drawable) => applyAnchor(drawable, getClosestAnchor(drawable)); + protected override void OnOperationEnded() + { + base.OnOperationEnded(); + accumulatedNegativeScaling = 0; + } + protected override void OnSelectionChanged() { base.OnSelectionChanged(); From 290d18ad690accc2a54c3290e3403f6c2534fb45 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Aug 2023 17:31:19 +0900 Subject: [PATCH 032/157] Split out difficulties in beatmap carousel in a bit of a hacky way Seems like the simplest path forward for now, without a full rewrite. --- osu.Game/Screens/Select/BeatmapCarousel.cs | 82 ++++++++++++++++------ osu.Game/Screens/Select/FilterCriteria.cs | 5 ++ 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 9af9a0ce72..d1a9b4176b 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -78,6 +78,8 @@ namespace osu.Game.Screens.Select private CarouselBeatmapSet? selectedBeatmapSet; + private IEnumerable originalBeatmapSetsDetached = Enumerable.Empty(); + /// /// Raised when the is changed. /// @@ -127,13 +129,29 @@ namespace osu.Game.Screens.Select private void loadBeatmapSets(IEnumerable beatmapSets) { + originalBeatmapSetsDetached = beatmapSets.Detach(); + CarouselRoot newRoot = new CarouselRoot(this); - newRoot.AddItems(beatmapSets.Select(s => createCarouselSet(s.Detach())).OfType()); + if (beatmapsSplitOut) + { + var carouselBeatmapSets = originalBeatmapSetsDetached.SelectMany(s => s.Beatmaps).Select(b => + { + var set = new BeatmapSetInfo(new[] { b }); + return createCarouselSet(set); + }).OfType(); + + newRoot.AddItems(carouselBeatmapSets); + } + else + { + var carouselBeatmapSets = originalBeatmapSetsDetached.Select(createCarouselSet).OfType(); + newRoot.AddItems(carouselBeatmapSets); + } root = newRoot; - if (selectedBeatmapSet != null && !beatmapSets.Contains(selectedBeatmapSet.BeatmapSet)) + if (selectedBeatmapSet != null && !originalBeatmapSetsDetached.Contains(selectedBeatmapSet.BeatmapSet)) selectedBeatmapSet = null; Scroll.Clear(false); @@ -330,8 +348,8 @@ namespace osu.Game.Screens.Select // Only require to action here if the beatmap is missing. // This avoids processing these events unnecessarily when new beatmaps are imported, for example. - if (root.BeatmapSetsByID.TryGetValue(beatmapSet.ID, out var existingSet) - && existingSet.BeatmapSet.Beatmaps.All(b => b.ID != beatmapInfo.ID)) + if (root.BeatmapSetsByID.TryGetValue(beatmapSet.ID, out var existingSets) + && existingSets.SelectMany(s => s.Beatmaps).All(b => b.BeatmapInfo.ID != beatmapInfo.ID)) { UpdateBeatmapSet(beatmapSet.Detach()); } @@ -345,15 +363,18 @@ namespace osu.Game.Screens.Select private void removeBeatmapSet(Guid beatmapSetID) => Schedule(() => { - if (!root.BeatmapSetsByID.TryGetValue(beatmapSetID, out var existingSet)) + if (!root.BeatmapSetsByID.TryGetValue(beatmapSetID, out var existingSets)) return; - foreach (var beatmap in existingSet.Beatmaps) - randomSelectedBeatmaps.Remove(beatmap); + foreach (var set in existingSets) + { + foreach (var beatmap in set.Beatmaps) + randomSelectedBeatmaps.Remove(beatmap); + previouslyVisitedRandomSets.Remove(set); - previouslyVisitedRandomSets.Remove(existingSet); + root.RemoveItem(set); + } - root.RemoveItem(existingSet); itemsCache.Invalidate(); if (!Scroll.UserScrolling) @@ -371,13 +392,16 @@ namespace osu.Game.Screens.Select previouslySelectedID = selectedBeatmap?.BeatmapInfo.ID; var newSet = createCarouselSet(beatmapSet); - var removedSet = root.RemoveChild(beatmapSet.ID); + var removedSets = root.RemoveChild(beatmapSet.ID); - // If we don't remove this here, it may remain in a hidden state until scrolled off screen. - // Doesn't really affect anything during actual user interaction, but makes testing annoying. - var removedDrawable = Scroll.FirstOrDefault(c => c.Item == removedSet); - if (removedDrawable != null) - expirePanelImmediately(removedDrawable); + foreach (var removedSet in removedSets) + { + // If we don't remove this here, it may remain in a hidden state until scrolled off screen. + // Doesn't really affect anything during actual user interaction, but makes testing annoying. + var removedDrawable = Scroll.FirstOrDefault(c => c.Item == removedSet); + if (removedDrawable != null) + expirePanelImmediately(removedDrawable); + } if (newSet != null) { @@ -632,6 +656,8 @@ namespace osu.Game.Screens.Select applyActiveCriteria(debounce); } + private bool beatmapsSplitOut; + private void applyActiveCriteria(bool debounce, bool alwaysResetScrollPosition = true) { PendingFilter?.Cancel(); @@ -652,6 +678,13 @@ namespace osu.Game.Screens.Select { PendingFilter = null; + if (activeCriteria.SplitOutDifficulties != beatmapsSplitOut) + { + beatmapsSplitOut = activeCriteria.SplitOutDifficulties; + loadBeatmapSets(originalBeatmapSetsDetached); + return; + } + root.Filter(activeCriteria); itemsCache.Invalidate(); @@ -1055,7 +1088,7 @@ namespace osu.Game.Screens.Select // May only be null during construction (State.Value set causes PerformSelection to be triggered). private readonly BeatmapCarousel? carousel; - public readonly Dictionary BeatmapSetsByID = new Dictionary(); + public readonly Dictionary> BeatmapSetsByID = new Dictionary>(); public CarouselRoot(BeatmapCarousel carousel) { @@ -1069,20 +1102,25 @@ namespace osu.Game.Screens.Select public override void AddItem(CarouselItem i) { CarouselBeatmapSet set = (CarouselBeatmapSet)i; - BeatmapSetsByID.Add(set.BeatmapSet.ID, set); + if (BeatmapSetsByID.TryGetValue(set.BeatmapSet.ID, out var sets)) + sets.Add(set); + else + BeatmapSetsByID.Add(set.BeatmapSet.ID, new List { set }); base.AddItem(i); } - public CarouselBeatmapSet? RemoveChild(Guid beatmapSetID) + public IEnumerable RemoveChild(Guid beatmapSetID) { - if (BeatmapSetsByID.TryGetValue(beatmapSetID, out var carouselBeatmapSet)) + if (BeatmapSetsByID.TryGetValue(beatmapSetID, out var carouselBeatmapSets)) { - RemoveItem(carouselBeatmapSet); - return carouselBeatmapSet; + foreach (var set in carouselBeatmapSets) + RemoveItem(set); + + return carouselBeatmapSets; } - return null; + return Enumerable.Empty(); } public override void RemoveItem(CarouselItem i) diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index ab4f85fc92..a2ae114126 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -19,6 +19,11 @@ namespace osu.Game.Screens.Select public GroupMode Group; public SortMode Sort; + /// + /// Whether the display of beatmap sets should be split apart per-difficulty for the current criteria. + /// + public bool SplitOutDifficulties => Sort == SortMode.Difficulty; + public BeatmapSetInfo? SelectedBeatmapSet; public OptionalRange StarDifficulty; From 2b1c6ae612cb4e6cecbd6736748da942fa724e39 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Aug 2023 18:38:23 +0900 Subject: [PATCH 033/157] Ensure ID is maintained in temporary `BeatmapSetInfo`s --- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index d1a9b4176b..5157e37a31 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -137,8 +137,10 @@ namespace osu.Game.Screens.Select { var carouselBeatmapSets = originalBeatmapSetsDetached.SelectMany(s => s.Beatmaps).Select(b => { - var set = new BeatmapSetInfo(new[] { b }); - return createCarouselSet(set); + return createCarouselSet(new BeatmapSetInfo(new[] { b }) + { + ID = b.BeatmapSet!.ID, + }); }).OfType(); newRoot.AddItems(carouselBeatmapSets); From ecbf0f138e2c7b3cf5716020a1aad4f8a834dfd7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Aug 2023 18:38:43 +0900 Subject: [PATCH 034/157] Fix incorrect handling when new beatmaps arrive --- osu.Game/Screens/Select/BeatmapCarousel.cs | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 5157e37a31..2227eb801a 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -393,7 +393,6 @@ namespace osu.Game.Screens.Select if (selectedBeatmapSet?.BeatmapSet.ID == beatmapSet.ID) previouslySelectedID = selectedBeatmap?.BeatmapInfo.ID; - var newSet = createCarouselSet(beatmapSet); var removedSets = root.RemoveChild(beatmapSet.ID); foreach (var removedSet in removedSets) @@ -405,13 +404,37 @@ namespace osu.Game.Screens.Select expirePanelImmediately(removedDrawable); } - if (newSet != null) + if (beatmapsSplitOut) { - root.AddItem(newSet); + foreach (var beatmap in beatmapSet.Beatmaps) + { + var newSet = createCarouselSet(new BeatmapSetInfo(new[] { beatmap }) + { + ID = beatmapSet.ID + }); - // check if we can/need to maintain our current selection. - if (previouslySelectedID != null) - select((CarouselItem?)newSet.Beatmaps.FirstOrDefault(b => b.BeatmapInfo.ID == previouslySelectedID) ?? newSet); + if (newSet != null) + { + root.AddItem(newSet); + + // check if we can/need to maintain our current selection. + if (previouslySelectedID != null) + select((CarouselItem?)newSet.Beatmaps.FirstOrDefault(b => b.BeatmapInfo.ID == previouslySelectedID) ?? newSet); + } + } + } + else + { + var newSet = createCarouselSet(beatmapSet); + + if (newSet != null) + { + root.AddItem(newSet); + + // check if we can/need to maintain our current selection. + if (previouslySelectedID != null) + select((CarouselItem?)newSet.Beatmaps.FirstOrDefault(b => b.BeatmapInfo.ID == previouslySelectedID) ?? newSet); + } } itemsCache.Invalidate(); From 018be4c20f408ee98bb00a3897e2658b4f016596 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Aug 2023 18:40:34 +0900 Subject: [PATCH 035/157] Fix selection not being retained when switching between split mode --- osu.Game/Screens/Select/BeatmapCarousel.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 2227eb801a..c5e46a00b6 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -131,6 +131,12 @@ namespace osu.Game.Screens.Select { originalBeatmapSetsDetached = beatmapSets.Detach(); + if (selectedBeatmapSet != null && !originalBeatmapSetsDetached.Contains(selectedBeatmapSet.BeatmapSet)) + selectedBeatmapSet = null; + + var selectedSetBefore = selectedBeatmapSet; + var selectedBetmapBefore = selectedBeatmap; + CarouselRoot newRoot = new CarouselRoot(this); if (beatmapsSplitOut) @@ -148,14 +154,12 @@ namespace osu.Game.Screens.Select else { var carouselBeatmapSets = originalBeatmapSetsDetached.Select(createCarouselSet).OfType(); + newRoot.AddItems(carouselBeatmapSets); } root = newRoot; - if (selectedBeatmapSet != null && !originalBeatmapSetsDetached.Contains(selectedBeatmapSet.BeatmapSet)) - selectedBeatmapSet = null; - Scroll.Clear(false); itemsCache.Invalidate(); ScrollToSelected(); @@ -164,6 +168,15 @@ namespace osu.Game.Screens.Select if (loadedTestBeatmaps) signalBeatmapsLoaded(); + + // Restore selection + if (selectedBetmapBefore != null && selectedSetBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedSetBefore.BeatmapSet.ID, out var newSelectionCandidates)) + { + CarouselBeatmap? found = newSelectionCandidates.SelectMany(s => s.Beatmaps).SingleOrDefault(b => b.BeatmapInfo.ID == selectedBetmapBefore.BeatmapInfo.ID); + + if (found != null) + found.State.Value = CarouselItemState.Selected; + } } private readonly List visibleItems = new List(); From 5555f73e97f22f9c6f0425bc4c9459bef88f3be5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 23 Aug 2023 19:38:18 +0900 Subject: [PATCH 036/157] Update test to match new behaviour --- .../SongSelect/TestSceneBeatmapCarousel.cs | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 61f95dc628..b0aff8b4db 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -758,7 +758,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] - public void TestSortingWithFiltered() + public void TestSortingWithDifficultyFiltered() { List sets = new List(); @@ -777,13 +777,32 @@ namespace osu.Game.Tests.Visual.SongSelect loadBeatmaps(sets); + AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false)); + + checkVisibleItemCount(false, 9); + checkVisibleItemCount(true, 1); + AddStep("Filter to normal", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Normal" }, false)); - AddAssert("Check first set at end", () => carousel.BeatmapSets.First().Equals(sets.Last())); - AddAssert("Check last set at start", () => carousel.BeatmapSets.Last().Equals(sets.First())); + checkVisibleItemCount(false, 3); + checkVisibleItemCount(true, 1); + + AddUntilStep("Check all visible sets have one normal", () => + { + return carousel.Items.OfType() + .Where(p => p.IsPresent) + .Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Normal", StringComparison.Ordinal)) == 3; + }); AddStep("Filter to insane", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Insane" }, false)); - AddAssert("Check first set at start", () => carousel.BeatmapSets.First().Equals(sets.First())); - AddAssert("Check last set at end", () => carousel.BeatmapSets.Last().Equals(sets.Last())); + checkVisibleItemCount(false, 3); + checkVisibleItemCount(true, 1); + + AddUntilStep("Check all visible sets have one insane", () => + { + return carousel.Items.OfType() + .Where(p => p.IsPresent) + .Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Insane", StringComparison.Ordinal)) == 3; + }); } [Test] From a64381f8553dd49b9c5c5142aa2934c333b101a4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 23 Aug 2023 19:43:08 +0900 Subject: [PATCH 037/157] Add test coverage of add/remove when difficulties are split out --- .../SongSelect/TestSceneBeatmapCarousel.cs | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index b0aff8b4db..5af6d862b2 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -39,6 +39,7 @@ namespace osu.Game.Tests.Visual.SongSelect private BeatmapInfo currentSelection => carousel.SelectedBeatmapInfo; private const int set_count = 5; + private const int diff_count = 3; [BackgroundDependencyLoader] private void load(RulesetStore rulesets) @@ -501,6 +502,36 @@ namespace osu.Game.Tests.Visual.SongSelect waitForSelection(set_count); } + [Test] + public void TestAddRemoveDifficultySort() + { + loadBeatmaps(); + + AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false)); + + checkVisibleItemCount(false, set_count * diff_count); + + var firstAdded = TestResources.CreateTestBeatmapSetInfo(diff_count); + var secondAdded = TestResources.CreateTestBeatmapSetInfo(diff_count); + + AddStep("Add new set", () => carousel.UpdateBeatmapSet(firstAdded)); + AddStep("Add new set", () => carousel.UpdateBeatmapSet(secondAdded)); + + checkVisibleItemCount(false, (set_count + 2) * diff_count); + + AddStep("Remove set", () => carousel.RemoveBeatmapSet(firstAdded)); + + checkVisibleItemCount(false, (set_count + 1) * diff_count); + + setSelected(set_count + 1, 1); + + AddStep("Remove set", () => carousel.RemoveBeatmapSet(secondAdded)); + + checkVisibleItemCount(false, (set_count) * diff_count); + + waitForSelection(set_count); + } + [Test] public void TestSelectionEnteringFromEmptyRuleset() { @@ -662,7 +693,7 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < 3; i++) { - var set = TestResources.CreateTestBeatmapSetInfo(3); + var set = TestResources.CreateTestBeatmapSetInfo(diff_count); // only need to set the first as they are a shared reference. var beatmap = set.Beatmaps.First(); @@ -709,7 +740,7 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < 3; i++) { - var set = TestResources.CreateTestBeatmapSetInfo(3); + var set = TestResources.CreateTestBeatmapSetInfo(diff_count); // only need to set the first as they are a shared reference. var beatmap = set.Beatmaps.First(); @@ -768,7 +799,7 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < 3; i++) { - var set = TestResources.CreateTestBeatmapSetInfo(3); + var set = TestResources.CreateTestBeatmapSetInfo(diff_count); set.Beatmaps[0].StarRating = 3 - i; set.Beatmaps[2].StarRating = 6 + i; sets.Add(set); @@ -857,7 +888,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("create hidden set", () => { - hidingSet = TestResources.CreateTestBeatmapSetInfo(3); + hidingSet = TestResources.CreateTestBeatmapSetInfo(diff_count); hidingSet.Beatmaps[1].Hidden = true; hiddenList.Clear(); @@ -904,7 +935,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("add mixed ruleset beatmapset", () => { - testMixed = TestResources.CreateTestBeatmapSetInfo(3); + testMixed = TestResources.CreateTestBeatmapSetInfo(diff_count); for (int i = 0; i <= 2; i++) { @@ -926,7 +957,7 @@ namespace osu.Game.Tests.Visual.SongSelect BeatmapSetInfo testSingle = null; AddStep("add single ruleset beatmapset", () => { - testSingle = TestResources.CreateTestBeatmapSetInfo(3); + testSingle = TestResources.CreateTestBeatmapSetInfo(diff_count); testSingle.Beatmaps.ForEach(b => { b.Ruleset = rulesets.AvailableRulesets.ElementAt(1); @@ -949,7 +980,7 @@ namespace osu.Game.Tests.Visual.SongSelect manySets.Clear(); for (int i = 1; i <= 50; i++) - manySets.Add(TestResources.CreateTestBeatmapSetInfo(3)); + manySets.Add(TestResources.CreateTestBeatmapSetInfo(diff_count)); }); loadBeatmaps(manySets); @@ -1113,7 +1144,7 @@ namespace osu.Game.Tests.Visual.SongSelect { beatmapSets.Add(randomDifficulties ? TestResources.CreateTestBeatmapSetInfo() - : TestResources.CreateTestBeatmapSetInfo(3)); + : TestResources.CreateTestBeatmapSetInfo(diff_count)); } } From 5eac604f8b2cf59a5346956d99a7fea0fdda0cd9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 23 Aug 2023 19:44:39 +0900 Subject: [PATCH 038/157] Add coverage of selection retention when difficulties are split out --- .../SongSelect/TestSceneBeatmapCarousel.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 5af6d862b2..daa8c9c4c2 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -1005,6 +1005,43 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("Selection was remembered", () => eagerSelectedIDs.Count == 1); } + [Test] + public void TestCarouselRemembersSelectionDifficultySort() + { + List manySets = new List(); + + AddStep("Populuate beatmap sets", () => + { + manySets.Clear(); + + for (int i = 1; i <= 50; i++) + manySets.Add(TestResources.CreateTestBeatmapSetInfo(diff_count)); + }); + + loadBeatmaps(manySets); + + AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false)); + + advanceSelection(direction: 1, diff: false); + + for (int i = 0; i < 5; i++) + { + AddStep("Toggle non-matching filter", () => + { + carousel.Filter(new FilterCriteria { SearchText = Guid.NewGuid().ToString() }, false); + }); + + AddStep("Restore no filter", () => + { + carousel.Filter(new FilterCriteria(), false); + eagerSelectedIDs.Add(carousel.SelectedBeatmapSet!.ID); + }); + } + + // always returns to same selection as long as it's available. + AddAssert("Selection was remembered", () => eagerSelectedIDs.Count == 1); + } + [Test] public void TestFilteringByUserStarDifficulty() { From 4881130caeccc728dbb789665fd161da1cfb0b53 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2023 03:32:12 +0900 Subject: [PATCH 039/157] Limit set/diff count in test to better fit on screen --- .../SongSelect/TestSceneBeatmapCarousel.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index daa8c9c4c2..d68fa6100c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -791,17 +791,20 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestSortingWithDifficultyFiltered() { + const int local_diff_count = 3; + const int local_set_count = 2; + List sets = new List(); AddStep("Populuate beatmap sets", () => { sets.Clear(); - for (int i = 0; i < 3; i++) + for (int i = 0; i < local_set_count; i++) { - var set = TestResources.CreateTestBeatmapSetInfo(diff_count); + var set = TestResources.CreateTestBeatmapSetInfo(local_diff_count); set.Beatmaps[0].StarRating = 3 - i; - set.Beatmaps[2].StarRating = 6 + i; + set.Beatmaps[1].StarRating = 6 + i; sets.Add(set); } }); @@ -810,29 +813,29 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false)); - checkVisibleItemCount(false, 9); + checkVisibleItemCount(false, local_set_count * local_diff_count); checkVisibleItemCount(true, 1); AddStep("Filter to normal", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Normal" }, false)); - checkVisibleItemCount(false, 3); + checkVisibleItemCount(false, local_set_count); checkVisibleItemCount(true, 1); AddUntilStep("Check all visible sets have one normal", () => { return carousel.Items.OfType() .Where(p => p.IsPresent) - .Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Normal", StringComparison.Ordinal)) == 3; + .Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Normal", StringComparison.Ordinal)) == local_set_count; }); AddStep("Filter to insane", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Insane" }, false)); - checkVisibleItemCount(false, 3); + checkVisibleItemCount(false, local_set_count); checkVisibleItemCount(true, 1); AddUntilStep("Check all visible sets have one insane", () => { return carousel.Items.OfType() .Where(p => p.IsPresent) - .Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Insane", StringComparison.Ordinal)) == 3; + .Count(p => ((CarouselBeatmapSet)p.Item)!.Beatmaps.Single().BeatmapInfo.DifficultyName.StartsWith("Insane", StringComparison.Ordinal)) == local_set_count; }); } From c8f42f73e87029f3e235b92d3a97ba776d6327f9 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 24 Aug 2023 11:17:41 +0900 Subject: [PATCH 040/157] Adjust mania hit windows with gameplay rate --- .../Mods/IManiaRateAdjustmentMod.cs | 47 +++++++++++++++++++ .../Mods/ManiaModDaycore.cs | 5 +- .../Mods/ManiaModDoubleTime.cs | 5 +- .../Mods/ManiaModHalfTime.cs | 5 +- .../Mods/ManiaModNightcore.cs | 5 +- .../Scoring/ManiaHitWindows.cs | 20 ++++++++ 6 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Mods/IManiaRateAdjustmentMod.cs diff --git a/osu.Game.Rulesets.Mania/Mods/IManiaRateAdjustmentMod.cs b/osu.Game.Rulesets.Mania/Mods/IManiaRateAdjustmentMod.cs new file mode 100644 index 0000000000..ea01bd4436 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Mods/IManiaRateAdjustmentMod.cs @@ -0,0 +1,47 @@ +// 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.Bindables; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Scoring; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Scoring; + +namespace osu.Game.Rulesets.Mania.Mods +{ + /// + /// May be attached to rate-adjustment mods to adjust hit windows adjust relative to gameplay rate. + /// + /// + /// Historically, in osu!mania, hit windows are expected to adjust relative to the gameplay rate such that the real-world hit window remains the same. + /// + public interface IManiaRateAdjustmentMod : IApplicableToDifficulty, IApplicableToHitObject + { + BindableNumber SpeedChange { get; } + + HitWindows HitWindows { get; set; } + + void IApplicableToDifficulty.ApplyToDifficulty(BeatmapDifficulty difficulty) + { + HitWindows = new ManiaHitWindows(SpeedChange.Value); + HitWindows.SetDifficulty(difficulty.OverallDifficulty); + } + + void IApplicableToHitObject.ApplyToHitObject(HitObject hitObject) + { + switch (hitObject) + { + case Note: + hitObject.HitWindows = HitWindows; + break; + + case HoldNote hold: + hold.Head.HitWindows = HitWindows; + hold.Tail.HitWindows = HitWindows; + break; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModDaycore.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModDaycore.cs index 309393b664..dbe2a9a9fc 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModDaycore.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModDaycore.cs @@ -1,11 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModDaycore : ModDaycore + public class ManiaModDaycore : ModDaycore, IManiaRateAdjustmentMod { + public HitWindows HitWindows { get; set; } = new ManiaHitWindows(); } } diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModDoubleTime.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModDoubleTime.cs index f4b9cf3b88..a841a8ab37 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModDoubleTime.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModDoubleTime.cs @@ -1,11 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModDoubleTime : ModDoubleTime + public class ManiaModDoubleTime : ModDoubleTime, IManiaRateAdjustmentMod { + public HitWindows HitWindows { get; set; } = new ManiaHitWindows(); } } diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModHalfTime.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModHalfTime.cs index 8d48e3acde..b0fbb11396 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModHalfTime.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModHalfTime.cs @@ -1,11 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModHalfTime : ModHalfTime + public class ManiaModHalfTime : ModHalfTime, IManiaRateAdjustmentMod { + public HitWindows HitWindows { get; set; } = new ManiaHitWindows(); } } diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModNightcore.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModNightcore.cs index 748725af9f..f64f7ae31a 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModNightcore.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModNightcore.cs @@ -2,11 +2,14 @@ // See the LICENCE file in the repository root for full licence text. using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Scoring; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModNightcore : ModNightcore + public class ManiaModNightcore : ModNightcore, IManiaRateAdjustmentMod { + public HitWindows HitWindows { get; set; } = new ManiaHitWindows(); } } diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaHitWindows.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaHitWindows.cs index 289f8a00ef..627f48f391 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaHitWindows.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaHitWindows.cs @@ -1,12 +1,25 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Mania.Scoring { public class ManiaHitWindows : HitWindows { + private readonly double multiplier; + + public ManiaHitWindows() + : this(1) + { + } + + public ManiaHitWindows(double multiplier) + { + this.multiplier = multiplier; + } + public override bool IsHitResultAllowed(HitResult result) { switch (result) @@ -22,5 +35,12 @@ namespace osu.Game.Rulesets.Mania.Scoring return false; } + + protected override DifficultyRange[] GetRanges() => base.GetRanges().Select(r => + new DifficultyRange( + r.Result, + r.Min * multiplier, + r.Average * multiplier, + r.Max * multiplier)).ToArray(); } } From ba70d48d2cc0013fbc42338e0867cbe1e6ea8c82 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2023 13:31:33 +0900 Subject: [PATCH 041/157] Fix one more test probably going off-screen --- .../SongSelect/TestSceneBeatmapCarousel.cs | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index d68fa6100c..8a38e2a84b 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -112,7 +112,7 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestScrollPositionMaintainedOnAdd() { - loadBeatmaps(count: 1, randomDifficulties: false); + loadBeatmaps(setCount: 1); for (int i = 0; i < 10; i++) { @@ -125,7 +125,7 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestDeletion() { - loadBeatmaps(count: 5, randomDifficulties: true); + loadBeatmaps(setCount: 5, randomDifficulties: true); AddStep("remove first set", () => carousel.RemoveBeatmapSet(carousel.Items.Select(item => item.Item).OfType().First().BeatmapSet)); AddUntilStep("4 beatmap sets visible", () => this.ChildrenOfType().Count(set => set.Alpha > 0) == 4); @@ -134,7 +134,7 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestScrollPositionMaintainedOnDelete() { - loadBeatmaps(count: 50, randomDifficulties: false); + loadBeatmaps(setCount: 50); for (int i = 0; i < 10; i++) { @@ -151,7 +151,7 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestManyPanels() { - loadBeatmaps(count: 5000, randomDifficulties: true); + loadBeatmaps(setCount: 5000, randomDifficulties: true); } [Test] @@ -505,31 +505,34 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestAddRemoveDifficultySort() { - loadBeatmaps(); + const int local_set_count = 1; + const int local_diff_count = 1; + + loadBeatmaps(setCount: local_set_count, diffCount: local_diff_count); AddStep("Sort by difficulty", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty }, false)); - checkVisibleItemCount(false, set_count * diff_count); + checkVisibleItemCount(false, local_set_count * local_diff_count); - var firstAdded = TestResources.CreateTestBeatmapSetInfo(diff_count); - var secondAdded = TestResources.CreateTestBeatmapSetInfo(diff_count); + var firstAdded = TestResources.CreateTestBeatmapSetInfo(local_diff_count); + var secondAdded = TestResources.CreateTestBeatmapSetInfo(local_diff_count); AddStep("Add new set", () => carousel.UpdateBeatmapSet(firstAdded)); AddStep("Add new set", () => carousel.UpdateBeatmapSet(secondAdded)); - checkVisibleItemCount(false, (set_count + 2) * diff_count); + checkVisibleItemCount(false, (local_set_count + 2) * local_diff_count); AddStep("Remove set", () => carousel.RemoveBeatmapSet(firstAdded)); - checkVisibleItemCount(false, (set_count + 1) * diff_count); + checkVisibleItemCount(false, (local_set_count + 1) * local_diff_count); - setSelected(set_count + 1, 1); + setSelected(local_set_count + 1, 1); AddStep("Remove set", () => carousel.RemoveBeatmapSet(secondAdded)); - checkVisibleItemCount(false, (set_count) * diff_count); + checkVisibleItemCount(false, (local_set_count) * local_diff_count); - waitForSelection(set_count); + waitForSelection(local_set_count); } [Test] @@ -1171,8 +1174,8 @@ namespace osu.Game.Tests.Visual.SongSelect } } - private void loadBeatmaps(List beatmapSets = null, Func initialCriteria = null, Action carouselAdjust = null, int? count = null, - bool randomDifficulties = false) + private void loadBeatmaps(List beatmapSets = null, Func initialCriteria = null, Action carouselAdjust = null, + int? setCount = null, int? diffCount = null, bool randomDifficulties = false) { bool changed = false; @@ -1180,11 +1183,11 @@ namespace osu.Game.Tests.Visual.SongSelect { beatmapSets = new List(); - for (int i = 1; i <= (count ?? set_count); i++) + for (int i = 1; i <= (setCount ?? set_count); i++) { beatmapSets.Add(randomDifficulties ? TestResources.CreateTestBeatmapSetInfo() - : TestResources.CreateTestBeatmapSetInfo(diff_count)); + : TestResources.CreateTestBeatmapSetInfo(diffCount ?? diff_count)); } } From a045cb71fc3d94f7d0d4f2bc0ab4ff770a1e0878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 22 Aug 2023 19:44:22 +0200 Subject: [PATCH 042/157] Add assertions checking action type taken by legacy hit policy --- .../TestSceneObjectOrderedHitPolicy.cs | 35 +++++++++++++++++++ osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs index 8a38bf2b08..afda805d26 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs @@ -11,17 +11,20 @@ using NUnit.Framework; using osu.Framework.Extensions; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Screens; +using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.Formats; using osu.Game.Replays; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Replays; using osu.Game.Rulesets.Osu.Scoring; +using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; @@ -83,6 +86,7 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[1], HitResult.Miss); // note lock prevented the object from being hit, so the judgement offset should be very late. addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh)); + addClickActionAssert(0, ClickAction.Shake); } /// @@ -119,6 +123,7 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[1], HitResult.Miss); // note lock prevented the object from being hit, so the judgement offset should be very late. addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh)); + addClickActionAssert(0, ClickAction.Shake); } /// @@ -155,6 +160,7 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[1], HitResult.Miss); // note lock prevented the object from being hit, so the judgement offset should be very late. addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh)); + addClickActionAssert(0, ClickAction.Shake); } /// @@ -192,6 +198,8 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[1], HitResult.Meh); addJudgementOffsetAssert(hitObjects[0], -190); // time_first_circle - 190 addJudgementOffsetAssert(hitObjects[0], -90); // time_second_circle - first_circle_time - 90 + addClickActionAssert(0, ClickAction.Hit); + addClickActionAssert(1, ClickAction.Hit); } /// @@ -229,6 +237,8 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[1], HitResult.Ok); addJudgementOffsetAssert(hitObjects[0], -190); // time_first_circle - 190 addJudgementOffsetAssert(hitObjects[1], -100); // time_second_circle - first_circle_time + addClickActionAssert(0, ClickAction.Hit); + addClickActionAssert(1, ClickAction.Hit); } /// @@ -271,6 +281,8 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[1], HitResult.Great); addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.LargeTickHit); addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.LargeTickHit); + addClickActionAssert(0, ClickAction.Hit); + addClickActionAssert(1, ClickAction.Hit); } /// @@ -314,6 +326,8 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[1], HitResult.Great); addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.LargeTickHit); addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.LargeTickHit); + addClickActionAssert(0, ClickAction.Hit); + addClickActionAssert(1, ClickAction.Hit); } /// @@ -353,6 +367,7 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[0], HitResult.Great); addJudgementAssert(hitObjects[1], HitResult.Meh); + addClickActionAssert(0, ClickAction.Hit); } [Test] @@ -391,6 +406,9 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[0], HitResult.Great); addJudgementAssert(hitObjects[1], HitResult.Great); + addClickActionAssert(0, ClickAction.Shake); + addClickActionAssert(1, ClickAction.Hit); + addClickActionAssert(2, ClickAction.Hit); } private void addJudgementAssert(OsuHitObject hitObject, HitResult result) @@ -411,8 +429,12 @@ namespace osu.Game.Rulesets.Osu.Tests () => judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, () => Is.EqualTo(offset).Within(100)); } + private void addClickActionAssert(int inputIndex, ClickAction action) + => AddAssert($"input #{inputIndex} resulted in {action}", () => testPolicy.ClickActions[inputIndex], () => Is.EqualTo(action)); + private ScoreAccessibleReplayPlayer currentPlayer = null!; private List judgementResults = null!; + private TestLegacyHitPolicy testPolicy = null!; private void performTest(List hitObjects, List frames, [CallerMemberName] string testCaseName = "") { @@ -513,6 +535,7 @@ namespace osu.Game.Rulesets.Osu.Tests AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0); AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen()); + AddStep("Substitute hit policy", () => currentPlayer.ChildrenOfType().Single().HitPolicy = testPolicy = new TestLegacyHitPolicy()); AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value); } @@ -540,5 +563,17 @@ namespace osu.Game.Rulesets.Osu.Tests { } } + + private class TestLegacyHitPolicy : LegacyHitPolicy + { + public List ClickActions { get; } = new List(); + + public override ClickAction CheckHittable(DrawableHitObject hitObject, double time) + { + var action = base.CheckHittable(hitObject, time); + ClickActions.Add(action); + return action; + } + } } } diff --git a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs index c35d4a1b56..6a740a6839 100644 --- a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs @@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.UI { } - public ClickAction CheckHittable(DrawableHitObject hitObject, double time) + public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time) { var aliveObjects = HitObjectContainer.AliveObjects.ToList(); int index = aliveObjects.IndexOf(hitObject); From 9ffc6cdd6110a94524c37b8d2c5bd3eaabb7e5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 22 Aug 2023 19:58:31 +0200 Subject: [PATCH 043/157] Add test case covering overlapping slider fail case --- .../TestSceneObjectOrderedHitPolicy.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs index afda805d26..fbbac91af5 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs @@ -411,6 +411,53 @@ namespace osu.Game.Rulesets.Osu.Tests addClickActionAssert(2, ClickAction.Hit); } + [Test] + public void TestOverlappingSliders() + { + const double time_first_slider = 1000; + const double time_second_slider = 1200; + Vector2 positionFirstSlider = new Vector2(100, 50); + Vector2 positionSecondSlider = new Vector2(100, 80); + var midpoint = (positionFirstSlider + positionSecondSlider) / 2; + + var hitObjects = new List + { + new Slider + { + StartTime = time_first_slider, + Position = positionFirstSlider, + Path = new SliderPath(PathType.Linear, new[] + { + Vector2.Zero, + new Vector2(25, 0), + }) + }, + new Slider + { + StartTime = time_second_slider, + Position = positionSecondSlider, + Path = new SliderPath(PathType.Linear, new[] + { + Vector2.Zero, + new Vector2(25, 0), + }) + } + }; + + performTest(hitObjects, new List + { + new OsuReplayFrame { Time = time_first_slider, Position = midpoint, Actions = { OsuAction.RightButton } }, + new OsuReplayFrame { Time = time_first_slider + 25, Position = midpoint, Actions = { OsuAction.LeftButton, OsuAction.RightButton } }, + new OsuReplayFrame { Time = time_first_slider + 50, Position = midpoint }, + new OsuReplayFrame { Time = time_second_slider, Position = positionSecondSlider + new Vector2(0, 10), Actions = { OsuAction.LeftButton } }, + }); + + addJudgementAssert(hitObjects[0], HitResult.Ok); + addJudgementAssert(hitObjects[1], HitResult.Great); + addClickActionAssert(0, ClickAction.Hit); + addClickActionAssert(1, ClickAction.Hit); + } + private void addJudgementAssert(OsuHitObject hitObject, HitResult result) { AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}", From 48b3f7dced93f0600fdf22837c5b9c94308bf1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 22 Aug 2023 20:34:36 +0200 Subject: [PATCH 044/157] Add test case covering stacks not shaking --- .../TestSceneObjectOrderedHitPolicy.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs index fbbac91af5..738d1a0739 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs @@ -458,6 +458,26 @@ namespace osu.Game.Rulesets.Osu.Tests addClickActionAssert(1, ClickAction.Hit); } + [Test] + public void TestStacksDoNotShake() + { + const double time_stack_start = 1000; + Vector2 position = new Vector2(80); + + var hitObjects = Enumerable.Range(0, 20).Select(i => new HitCircle + { + StartTime = time_stack_start + i * 100, + Position = position + }).Cast().ToList(); + + performTest(hitObjects, new List + { + new OsuReplayFrame { Time = time_stack_start - 450, Position = new Vector2(55), Actions = { OsuAction.LeftButton } }, + }); + + addClickActionAssert(0, ClickAction.Ignore); + } + private void addJudgementAssert(OsuHitObject hitObject, HitResult result) { AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}", From 64b36a73b10691c38889fb5ed530e7c08e53c0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 23 Aug 2023 12:43:53 +0200 Subject: [PATCH 045/157] Rename test scene to match tested class --- ...eObjectOrderedHitPolicy.cs => TestSceneLegacyHitPolicy.cs} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename osu.Game.Rulesets.Osu.Tests/{TestSceneObjectOrderedHitPolicy.cs => TestSceneLegacyHitPolicy.cs} (99%) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs similarity index 99% rename from osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs rename to osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs index 738d1a0739..6366a185f2 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneObjectOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs @@ -35,7 +35,7 @@ using osuTK; namespace osu.Game.Rulesets.Osu.Tests { - public partial class TestSceneObjectOrderedHitPolicy : RateAdjustedBeatmapTestScene + public partial class TestSceneLegacyHitPolicy : RateAdjustedBeatmapTestScene { private readonly OsuHitWindows referenceHitWindows; @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Tests /// private readonly string? exportLocation = null; - public TestSceneObjectOrderedHitPolicy() + public TestSceneLegacyHitPolicy() { referenceHitWindows = new OsuHitWindows(); referenceHitWindows.SetDifficulty(0); From ed2b1a07540fe4038b03424abe14582de495b661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 23 Aug 2023 13:12:18 +0200 Subject: [PATCH 046/157] Contain entirety of legacy notelock badness inside the hit policy --- osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs | 2 +- osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs | 4 ++-- .../Objects/Drawables/DrawableHitCircle.cs | 9 +++------ .../Objects/Drawables/DrawableOsuHitObject.cs | 3 ++- .../Objects/Drawables/DrawableSliderHead.cs | 2 +- osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs | 3 ++- osu.Game.Rulesets.Osu/UI/IHitPolicy.cs | 4 +++- osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs | 6 +++++- osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs | 5 +++-- 9 files changed, 22 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs index c818a361df..af02087d1a 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs @@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Tests protected override void CheckForResult(bool userTriggered, double timeOffset) { - if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current) == ClickAction.Hit) + if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current, HitResult.Great) == ClickAction.Hit) { // force success ApplyResult(r => r.Type = HitResult.Great); diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs index 6366a185f2..3accf4fad7 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs @@ -635,9 +635,9 @@ namespace osu.Game.Rulesets.Osu.Tests { public List ClickActions { get; } = new List(); - public override ClickAction CheckHittable(DrawableHitObject hitObject, double time) + public override ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) { - var action = base.CheckHittable(hitObject, time); + var action = base.CheckHittable(hitObject, time, result); ClickActions.Add(action); return action; } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 09d818def8..932f6d3fff 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -155,15 +155,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } var result = ResultFor(timeOffset); - var clickAction = CheckHittable?.Invoke(this, Time.Current); + var clickAction = CheckHittable?.Invoke(this, Time.Current, result); - if (clickAction == ClickAction.Shake || (result == HitResult.None && clickAction != ClickAction.Ignore)) - { + if (clickAction == ClickAction.Shake) Shake(); - return; - } - if (result == HitResult.None) + if (result == HitResult.None || clickAction != ClickAction.Hit) return; ApplyResult(r => diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index a8ce2118c8..920dfcab03 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -13,6 +13,7 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.UI; +using osu.Game.Rulesets.Scoring; using osuTK; using osuTK.Graphics; @@ -37,7 +38,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables /// and , and this hit object will be shaken for return values of /// . /// - public Func CheckHittable; + public Func CheckHittable; protected DrawableOsuHitObject(OsuHitObject hitObject) : base(hitObject) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs index a4cf69ee31..41f6a40c0a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs @@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables pathVersion.BindTo(DrawableSlider.PathVersion); - CheckHittable = (d, t) => DrawableSlider.CheckHittable?.Invoke(d, t) ?? ClickAction.Hit; + CheckHittable = (d, t, r) => DrawableSlider.CheckHittable?.Invoke(d, t, r) ?? ClickAction.Hit; } protected override void Update() diff --git a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs index 7503c43e0b..69bd360b5e 100644 --- a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs @@ -4,6 +4,7 @@ #nullable disable using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -15,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } - public ClickAction CheckHittable(DrawableHitObject hitObject, double time) => ClickAction.Hit; + public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) => ClickAction.Hit; public void HandleHit(DrawableHitObject hitObject) { diff --git a/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs index 9820b8c188..44d3b37408 100644 --- a/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs @@ -3,6 +3,7 @@ using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -19,8 +20,9 @@ namespace osu.Game.Rulesets.Osu.UI /// /// The to check. /// The time to check. + /// The result that the object would be judged with if hit. /// Whether can be hit at the given . - ClickAction CheckHittable(DrawableHitObject hitObject, double time); + ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result); /// /// Handles a being hit. diff --git a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs index 6a740a6839..5260215345 100644 --- a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs @@ -8,6 +8,7 @@ using System.Linq; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -26,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.UI { } - public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time) + public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) { var aliveObjects = HitObjectContainer.AliveObjects.ToList(); int index = aliveObjects.IndexOf(hitObject); @@ -38,6 +39,9 @@ namespace osu.Game.Rulesets.Osu.UI return ClickAction.Ignore; } + if (result == HitResult.None) + return ClickAction.Shake; + foreach (DrawableHitObject testObject in aliveObjects) { if (testObject.AllJudged) diff --git a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs index f33ca58aef..6fd0b512be 100644 --- a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -24,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } - public ClickAction CheckHittable(DrawableHitObject hitObject, double time) + public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult _) { DrawableHitObject blockingObject = null; @@ -51,7 +52,7 @@ namespace osu.Game.Rulesets.Osu.UI if (!hitObjectCanBlockFutureHits(hitObject)) return; - if (CheckHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset) != ClickAction.Hit) + if (CheckHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset, hitObject.Result.Type) != ClickAction.Hit) throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!"); // Miss all hitobjects prior to the hit one. From a3160364603211a7dd1d06e1996c8603d5c700df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 23 Aug 2023 13:20:38 +0200 Subject: [PATCH 047/157] Add failing test case for special autopilot hittable range --- .../TestSceneLegacyHitPolicy.cs | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs index 3accf4fad7..cc5c27a62c 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs @@ -17,6 +17,7 @@ using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.Formats; using osu.Game.Replays; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; @@ -478,6 +479,32 @@ namespace osu.Game.Rulesets.Osu.Tests addClickActionAssert(0, ClickAction.Ignore); } + [Test] + public void TestAutopilotReducesHittableRange() + { + const double time_circle = 1500; + Vector2 positionCircle = Vector2.Zero; + + var hitObjects = new List + { + new HitCircle + { + StartTime = time_circle, + Position = positionCircle + }, + }; + + performTest(hitObjects, new List + { + new OsuReplayFrame { Time = time_circle - 250, Position = positionCircle, Actions = { OsuAction.LeftButton } } + }, new Mod[] { new OsuModAutopilot() }); + + addJudgementAssert(hitObjects[0], HitResult.Miss); + // note lock prevented the object from being hit, so the judgement offset should be very late. + addJudgementOffsetAssert(hitObjects[0], referenceHitWindows.WindowFor(HitResult.Meh)); + addClickActionAssert(0, ClickAction.Shake); + } + private void addJudgementAssert(OsuHitObject hitObject, HitResult result) { AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}", @@ -503,11 +530,20 @@ namespace osu.Game.Rulesets.Osu.Tests private List judgementResults = null!; private TestLegacyHitPolicy testPolicy = null!; - private void performTest(List hitObjects, List frames, [CallerMemberName] string testCaseName = "") + private void performTest(List hitObjects, List frames, IEnumerable? extraMods = null, [CallerMemberName] string testCaseName = "") { + List mods = null!; IBeatmap playableBeatmap = null!; Score score = null!; + AddStep("set up mods", () => + { + mods = new List { new OsuModClassic() }; + + if (extraMods != null) + mods.AddRange(extraMods); + }); + AddStep("create beatmap", () => { var cpi = new ControlPointInfo(); @@ -550,7 +586,8 @@ namespace osu.Game.Rulesets.Osu.Tests ScoreInfo = { Ruleset = new OsuRuleset().RulesetInfo, - BeatmapInfo = playableBeatmap.BeatmapInfo + BeatmapInfo = playableBeatmap.BeatmapInfo, + Mods = mods.ToArray() } }; }); @@ -584,7 +621,7 @@ namespace osu.Game.Rulesets.Osu.Tests AddStep("load player", () => { - SelectedMods.Value = new[] { new OsuModClassic() }; + SelectedMods.Value = mods.ToArray(); var p = new ScoreAccessibleReplayPlayer(score); From 7f215f163ffc307ce9060e9d32f572162996e5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 23 Aug 2023 13:37:39 +0200 Subject: [PATCH 048/157] Use reduced hittable range with autopilot active --- .../TestSceneLegacyHitPolicy.cs | 16 ++++++++++++++-- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 6 +++++- osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs | 14 +++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs index cc5c27a62c..b4ab53a658 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs @@ -639,7 +639,12 @@ namespace osu.Game.Rulesets.Osu.Tests AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0); AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen()); - AddStep("Substitute hit policy", () => currentPlayer.ChildrenOfType().Single().HitPolicy = testPolicy = new TestLegacyHitPolicy()); + AddStep("Substitute hit policy", () => + { + var playfield = currentPlayer.ChildrenOfType().Single(); + var currentPolicy = playfield.HitPolicy; + playfield.HitPolicy = testPolicy = new TestLegacyHitPolicy(currentPolicy); + }); AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value); } @@ -670,11 +675,18 @@ namespace osu.Game.Rulesets.Osu.Tests private class TestLegacyHitPolicy : LegacyHitPolicy { + private readonly IHitPolicy currentPolicy; + + public TestLegacyHitPolicy(IHitPolicy currentPolicy) + { + this.currentPolicy = currentPolicy; + } + public List ClickActions { get; } = new List(); public override ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) { - var action = base.CheckHittable(hitObject, time, result); + var action = currentPolicy.CheckHittable(hitObject, time, result); ClickActions.Add(action); return action; } diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index 229f80c2bd..82deec41f5 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -11,6 +11,7 @@ using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -57,7 +58,10 @@ namespace osu.Game.Rulesets.Osu.Mods var osuRuleset = (DrawableOsuRuleset)drawableRuleset; if (ClassicNoteLock.Value) - osuRuleset.Playfield.HitPolicy = new LegacyHitPolicy(); + { + double hittableRange = OsuHitWindows.MISS_WINDOW - (drawableRuleset.Mods.OfType().Any() ? 200 : 0); + osuRuleset.Playfield.HitPolicy = new LegacyHitPolicy(hittableRange); + } usingHiddenFading = drawableRuleset.Mods.OfType().SingleOrDefault()?.OnlyFadeApproachCircles.Value == false; } diff --git a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs index 5260215345..2b6359fb46 100644 --- a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs @@ -8,6 +8,7 @@ using System.Linq; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -23,6 +24,13 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } + private readonly double hittableRange; + + public LegacyHitPolicy(double hittableRange = OsuHitWindows.MISS_WINDOW) + { + this.hittableRange = hittableRange; + } + public void HandleHit(DrawableHitObject hitObject) { } @@ -57,11 +65,7 @@ namespace osu.Game.Rulesets.Osu.UI return ClickAction.Shake; } - // stable has `const HitObjectManager.HITTABLE_RANGE = 400;`, which is only used for notelock code. - // probably not a coincidence that this is equivalent to lazer's OsuHitWindows.MISS_WINDOW. - - // TODO stable compares to 200 when autopilot is enabled, instead of 400. - return Math.Abs(hitObject.HitObject.StartTime - time) < 400 ? ClickAction.Hit : ClickAction.Shake; + return Math.Abs(hitObject.HitObject.StartTime - time) < hittableRange ? ClickAction.Hit : ClickAction.Shake; } } } From 38e34593911801c0f31a8ca787b142c18f54b9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 24 Aug 2023 08:54:38 +0200 Subject: [PATCH 049/157] Fix broken assertion --- osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs index b4ab53a658..2cfbe6611f 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs @@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Osu.Tests addJudgementAssert(hitObjects[0], HitResult.Meh); addJudgementAssert(hitObjects[1], HitResult.Meh); addJudgementOffsetAssert(hitObjects[0], -190); // time_first_circle - 190 - addJudgementOffsetAssert(hitObjects[0], -90); // time_second_circle - first_circle_time - 90 + addJudgementOffsetAssert(hitObjects[1], -190); // time_second_circle - first_circle_time - 90 addClickActionAssert(0, ClickAction.Hit); addClickActionAssert(1, ClickAction.Hit); } @@ -520,7 +520,7 @@ namespace osu.Game.Rulesets.Osu.Tests private void addJudgementOffsetAssert(OsuHitObject hitObject, double offset) { AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judged at {offset}", - () => judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, () => Is.EqualTo(offset).Within(100)); + () => judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, () => Is.EqualTo(offset).Within(50)); } private void addClickActionAssert(int inputIndex, ClickAction action) From b471ab07a62dc225275154efdfd15c46646f0104 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2023 18:30:59 +0900 Subject: [PATCH 050/157] Fix typo in test step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartłomiej Dach --- osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 8a38e2a84b..110466f6d5 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -1016,7 +1016,7 @@ namespace osu.Game.Tests.Visual.SongSelect { List manySets = new List(); - AddStep("Populuate beatmap sets", () => + AddStep("Populate beatmap sets", () => { manySets.Clear(); From 9e94f3809103b6079a158e19050f9bc15829235a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 24 Aug 2023 18:33:15 +0900 Subject: [PATCH 051/157] Fix typo in local variable --- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index c5e46a00b6..91d1ced9d9 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -135,7 +135,7 @@ namespace osu.Game.Screens.Select selectedBeatmapSet = null; var selectedSetBefore = selectedBeatmapSet; - var selectedBetmapBefore = selectedBeatmap; + var selectedBeatmapBefore = selectedBeatmap; CarouselRoot newRoot = new CarouselRoot(this); @@ -170,9 +170,9 @@ namespace osu.Game.Screens.Select signalBeatmapsLoaded(); // Restore selection - if (selectedBetmapBefore != null && selectedSetBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedSetBefore.BeatmapSet.ID, out var newSelectionCandidates)) + if (selectedBeatmapBefore != null && selectedSetBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedSetBefore.BeatmapSet.ID, out var newSelectionCandidates)) { - CarouselBeatmap? found = newSelectionCandidates.SelectMany(s => s.Beatmaps).SingleOrDefault(b => b.BeatmapInfo.ID == selectedBetmapBefore.BeatmapInfo.ID); + CarouselBeatmap? found = newSelectionCandidates.SelectMany(s => s.Beatmaps).SingleOrDefault(b => b.BeatmapInfo.ID == selectedBeatmapBefore.BeatmapInfo.ID); if (found != null) found.State.Value = CarouselItemState.Selected; From 89eeff515b42a9724ffd2e552f9e7d462f848d5a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2023 00:52:54 +0900 Subject: [PATCH 052/157] Reduce complexity of selection restore --- osu.Game/Screens/Select/BeatmapCarousel.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 91d1ced9d9..d52b5592f8 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -134,8 +134,7 @@ namespace osu.Game.Screens.Select if (selectedBeatmapSet != null && !originalBeatmapSetsDetached.Contains(selectedBeatmapSet.BeatmapSet)) selectedBeatmapSet = null; - var selectedSetBefore = selectedBeatmapSet; - var selectedBeatmapBefore = selectedBeatmap; + var selectedBeatmapBefore = selectedBeatmap?.BeatmapInfo; CarouselRoot newRoot = new CarouselRoot(this); @@ -170,9 +169,9 @@ namespace osu.Game.Screens.Select signalBeatmapsLoaded(); // Restore selection - if (selectedBeatmapBefore != null && selectedSetBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedSetBefore.BeatmapSet.ID, out var newSelectionCandidates)) + if (selectedBeatmapBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedBeatmapBefore.BeatmapSet!.ID, out var newSelectionCandidates)) { - CarouselBeatmap? found = newSelectionCandidates.SelectMany(s => s.Beatmaps).SingleOrDefault(b => b.BeatmapInfo.ID == selectedBeatmapBefore.BeatmapInfo.ID); + CarouselBeatmap? found = newSelectionCandidates.SelectMany(s => s.Beatmaps).SingleOrDefault(b => b.BeatmapInfo.ID == selectedBeatmapBefore.ID); if (found != null) found.State.Value = CarouselItemState.Selected; From 84f4fab9cfad4a122a271977ed7902f9e504904b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2023 18:09:51 +0900 Subject: [PATCH 053/157] Adjust test to actually test diff splitting --- .../SongSelect/TestSceneBeatmapCarousel.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 110466f6d5..040b341584 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -505,8 +505,8 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestAddRemoveDifficultySort() { - const int local_set_count = 1; - const int local_diff_count = 1; + const int local_set_count = 2; + const int local_diff_count = 2; loadBeatmaps(setCount: local_set_count, diffCount: local_diff_count); @@ -515,23 +515,17 @@ namespace osu.Game.Tests.Visual.SongSelect checkVisibleItemCount(false, local_set_count * local_diff_count); var firstAdded = TestResources.CreateTestBeatmapSetInfo(local_diff_count); - var secondAdded = TestResources.CreateTestBeatmapSetInfo(local_diff_count); AddStep("Add new set", () => carousel.UpdateBeatmapSet(firstAdded)); - AddStep("Add new set", () => carousel.UpdateBeatmapSet(secondAdded)); - - checkVisibleItemCount(false, (local_set_count + 2) * local_diff_count); - - AddStep("Remove set", () => carousel.RemoveBeatmapSet(firstAdded)); checkVisibleItemCount(false, (local_set_count + 1) * local_diff_count); - setSelected(local_set_count + 1, 1); - - AddStep("Remove set", () => carousel.RemoveBeatmapSet(secondAdded)); + AddStep("Remove set", () => carousel.RemoveBeatmapSet(firstAdded)); checkVisibleItemCount(false, (local_set_count) * local_diff_count); + setSelected(local_set_count, 1); + waitForSelection(local_set_count); } From 10b14501380320939f43fe715b033970b8af4a2e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 25 Aug 2023 18:10:54 +0900 Subject: [PATCH 054/157] Rename remove method to better explain return type being `IEnumerable` --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index d52b5592f8..a8da5dc742 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -405,7 +405,7 @@ namespace osu.Game.Screens.Select if (selectedBeatmapSet?.BeatmapSet.ID == beatmapSet.ID) previouslySelectedID = selectedBeatmap?.BeatmapInfo.ID; - var removedSets = root.RemoveChild(beatmapSet.ID); + var removedSets = root.RemoveItemsByID(beatmapSet.ID); foreach (var removedSet in removedSets) { @@ -1147,7 +1147,7 @@ namespace osu.Game.Screens.Select base.AddItem(i); } - public IEnumerable RemoveChild(Guid beatmapSetID) + public IEnumerable RemoveItemsByID(Guid beatmapSetID) { if (BeatmapSetsByID.TryGetValue(beatmapSetID, out var carouselBeatmapSets)) { From 3a6920c3067f90c53578d021f3ecf7e89d368c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Aug 2023 09:51:37 +0200 Subject: [PATCH 055/157] Add failing test coverage of beatmap update flow w/ split diffs --- .../TestSceneUpdateBeatmapSetButton.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs index 11d55bc0bd..585d93d3af 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs @@ -15,6 +15,7 @@ using osu.Game.Overlays; using osu.Game.Overlays.Dialog; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Carousel; +using osu.Game.Screens.Select.Filter; using osu.Game.Tests.Online; using osu.Game.Tests.Resources; using osuTK.Input; @@ -192,6 +193,57 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("release mouse button", () => InputManager.ReleaseButton(MouseButton.Left)); } + [Test] + public void TestSplitDisplay() + { + ArchiveDownloadRequest? downloadRequest = null; + + AddStep("set difficulty sort mode", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty })); + AddStep("update online hash", () => + { + testBeatmapSetInfo.Beatmaps.First().OnlineMD5Hash = "different hash"; + testBeatmapSetInfo.Beatmaps.First().LastOnlineUpdate = DateTimeOffset.Now; + + carousel.UpdateBeatmapSet(testBeatmapSetInfo); + }); + + AddUntilStep("multiple \"sets\" visible", () => carousel.ChildrenOfType().Count(), () => Is.GreaterThan(1)); + AddUntilStep("update button visible", getUpdateButton, () => Is.Not.Null); + + AddStep("click button", () => getUpdateButton()?.TriggerClick()); + + AddUntilStep("wait for download started", () => + { + downloadRequest = beatmapDownloader.GetExistingDownload(testBeatmapSetInfo); + return downloadRequest != null; + }); + + AddUntilStep("wait for button disabled", () => getUpdateButton()?.Enabled.Value == false); + + AddUntilStep("progress download to completion", () => + { + if (downloadRequest is TestSceneOnlinePlayBeatmapAvailabilityTracker.TestDownloadRequest testRequest) + { + testRequest.SetProgress(testRequest.Progress + 0.1f); + + if (testRequest.Progress >= 1) + { + testRequest.TriggerSuccess(); + + // usually this would be done by the import process. + testBeatmapSetInfo.Beatmaps.First().MD5Hash = "different hash"; + testBeatmapSetInfo.Beatmaps.First().LastOnlineUpdate = DateTimeOffset.Now; + + // usually this would be done by a realm subscription. + carousel.UpdateBeatmapSet(testBeatmapSetInfo); + return true; + } + } + + return false; + }); + } + private BeatmapCarousel createCarousel() { return carousel = new BeatmapCarousel From 6251803868588f188ca7b78f74ad4c9e18d4b10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Aug 2023 10:02:05 +0200 Subject: [PATCH 056/157] Add failing test coverage of selection not being retained on song select --- .../TestSceneBeatmapEditorNavigation.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs index 54ee1659e1..d0fa5fc737 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneBeatmapEditorNavigation.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Screens; using osu.Framework.Testing; using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Rulesets.Mania; using osu.Game.Rulesets.Osu; @@ -16,6 +17,7 @@ using osu.Game.Screens.Edit; using osu.Game.Screens.Edit.GameplayTest; using osu.Game.Screens.Menu; using osu.Game.Screens.Select; +using osu.Game.Screens.Select.Filter; using osu.Game.Tests.Resources; using osuTK.Input; @@ -203,6 +205,33 @@ namespace osu.Game.Tests.Visual.Navigation AddUntilStep("wait for music stopped", () => !Game.MusicController.IsPlaying); } + [TestCase(SortMode.Title)] + [TestCase(SortMode.Difficulty)] + public void TestSelectionRetainedOnExit(SortMode sortMode) + { + BeatmapSetInfo beatmapSet = null!; + + AddStep("import test beatmap", () => Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely()); + AddStep("retrieve beatmap", () => beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach()); + + AddStep($"set sort mode to {sortMode}", () => Game.LocalConfig.SetValue(OsuSetting.SongSelectSortingMode, sortMode)); + AddStep("present beatmap", () => Game.PresentBeatmap(beatmapSet)); + AddUntilStep("wait for song select", + () => Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet) + && Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect + && songSelect.IsLoaded); + + AddStep("open editor", () => ((PlaySongSelect)Game.ScreenStack.CurrentScreen).Edit(beatmapSet.Beatmaps.First(beatmap => beatmap.Ruleset.OnlineID == 0))); + AddUntilStep("wait for editor open", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.ReadyForUse); + + AddStep("exit editor", () => InputManager.Key(Key.Escape)); + AddUntilStep("wait for editor exit", () => Game.ScreenStack.CurrentScreen is not Editor); + + AddUntilStep("selection retained on song select", + () => Game.Beatmap.Value.BeatmapInfo.ID, + () => Is.EqualTo(beatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0).ID)); + } + private EditorBeatmap getEditorBeatmap() => getEditor().ChildrenOfType().Single(); private Editor getEditor() => (Editor)Game.ScreenStack.CurrentScreen; From 0af6cc1394f7fe521bdf94773b423b5ff61c2bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Aug 2023 10:02:30 +0200 Subject: [PATCH 057/157] Fix online ID not being propagated in split difficulty mode Would result in failures to re-download the beatmap in update flows, for instance. --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index a8da5dc742..0354e72803 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -145,6 +145,7 @@ namespace osu.Game.Screens.Select return createCarouselSet(new BeatmapSetInfo(new[] { b }) { ID = b.BeatmapSet!.ID, + OnlineID = b.BeatmapSet!.OnlineID }); }).OfType(); @@ -422,7 +423,8 @@ namespace osu.Game.Screens.Select { var newSet = createCarouselSet(new BeatmapSetInfo(new[] { beatmap }) { - ID = beatmapSet.ID + ID = beatmapSet.ID, + OnlineID = beatmapSet.OnlineID }); if (newSet != null) From 80ec18d117fc7ae252731bcde4e65a71be838ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Aug 2023 10:06:26 +0200 Subject: [PATCH 058/157] Fix incorrect selection restore code in split case The fallback to "any of the added sets" needs to be applied after they've all been added, rather than with every added one. Otherwise, in flows that expect a particular difficulty to be selected in the end (such as exiting from editor) would end up switching away from the edited beatmap. --- osu.Game/Screens/Select/BeatmapCarousel.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 0354e72803..861385f453 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -419,6 +419,8 @@ namespace osu.Game.Screens.Select if (beatmapsSplitOut) { + var newSets = new List(); + foreach (var beatmap in beatmapSet.Beatmaps) { var newSet = createCarouselSet(new BeatmapSetInfo(new[] { beatmap }) @@ -429,13 +431,18 @@ namespace osu.Game.Screens.Select if (newSet != null) { + newSets.Add(newSet); root.AddItem(newSet); - - // check if we can/need to maintain our current selection. - if (previouslySelectedID != null) - select((CarouselItem?)newSet.Beatmaps.FirstOrDefault(b => b.BeatmapInfo.ID == previouslySelectedID) ?? newSet); } } + + // check if we can/need to maintain our current selection. + if (previouslySelectedID != null) + { + var toSelect = newSets.FirstOrDefault(s => s.Beatmaps.Any(b => b.BeatmapInfo.ID == previouslySelectedID)) + ?? newSets.FirstOrDefault(); + select(toSelect); + } } else { From b9795eb3d4e09d66c9e2950da6e8742637dd8dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Aug 2023 11:02:22 +0200 Subject: [PATCH 059/157] Fix changes to beatmap sets being undone on switching sort mode --- osu.Game/Screens/Select/BeatmapCarousel.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 861385f453..9ea94b2a52 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Select private CarouselBeatmapSet? selectedBeatmapSet; - private IEnumerable originalBeatmapSetsDetached = Enumerable.Empty(); + private List originalBeatmapSetsDetached = new List(); /// /// Raised when the is changed. @@ -381,6 +381,8 @@ namespace osu.Game.Screens.Select if (!root.BeatmapSetsByID.TryGetValue(beatmapSetID, out var existingSets)) return; + originalBeatmapSetsDetached.RemoveAll(set => set.ID == beatmapSetID); + foreach (var set in existingSets) { foreach (var beatmap in set.Beatmaps) @@ -402,6 +404,9 @@ namespace osu.Game.Screens.Select { Guid? previouslySelectedID = null; + originalBeatmapSetsDetached.RemoveAll(set => set.ID == beatmapSet.ID); + originalBeatmapSetsDetached.Add(beatmapSet.Detach()); + // If the selected beatmap is about to be removed, store its ID so it can be re-selected if required if (selectedBeatmapSet?.BeatmapSet.ID == beatmapSet.ID) previouslySelectedID = selectedBeatmap?.BeatmapInfo.ID; From 99d5ff9efbd7b7197497acd53f757345dc1666b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Aug 2023 13:50:52 +0200 Subject: [PATCH 060/157] Switch download requests to new API endpoint This API endpoint is intended for usage with the entire `solo_scores` machinery and ID schema, rather than the legacy `*_scores_high` ID schema. It also supports automagically falling back to downloading legacy replays if a stable-imported score is requested for download (internally this happens via `legacy_score_id` in the `data` json). This change will allow replays to be downloaded, but it will still not yield 100% correct behaviour, as there is further work to be done in that respect. The download tracker is expecting score hashes to arrive from web to verify the integrity of the incoming download, but the API does not expose such a facility right now; we will have to decide as to whether we want to add one web-side, or whether we want to disable the checking client-side. --- osu.Game/Online/API/Requests/DownloadReplayRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/DownloadReplayRequest.cs b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs index 77174f0bb5..3ea57cf637 100644 --- a/osu.Game/Online/API/Requests/DownloadReplayRequest.cs +++ b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs @@ -14,6 +14,6 @@ namespace osu.Game.Online.API.Requests protected override string FileExtension => ".osr"; - protected override string Target => $@"scores/{Model.Ruleset.ShortName}/{Model.OnlineID}/download"; + protected override string Target => $@"scores/{Model.OnlineID}/download"; } } From 118c86df342340da729c3931a4c58a1ed72e0f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 28 Aug 2023 14:57:00 +0200 Subject: [PATCH 061/157] Fix `TestSceneUpdateBeatmapSetButton` using random difficulty count --- .../Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs index 585d93d3af..6d97be730b 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneUpdateBeatmapSetButton.cs @@ -251,7 +251,7 @@ namespace osu.Game.Tests.Visual.SongSelect RelativeSizeAxes = Axes.Both, BeatmapSets = new List { - (testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo()), + (testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo(5)), } }; } From 07e126241da902fcf7471e28576c5204fc8b826d Mon Sep 17 00:00:00 2001 From: Wleter Date: Mon, 28 Aug 2023 16:41:55 +0200 Subject: [PATCH 062/157] working negative scaling --- .../SkinEditor/SkinSelectionHandler.cs | 41 ++++++------------- .../Edit/Compose/Components/SelectionBox.cs | 2 + .../SelectionBoxDragHandleContainer.cs | 12 ++++++ 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index c90a1d8edf..ae0a3d0635 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -31,8 +31,6 @@ namespace osu.Game.Overlays.SkinEditor UpdatePosition = updateDrawablePosition }; - private float accumulatedNegativeScaling; - public override bool HandleScale(Vector2 scale, Anchor anchor) { // convert scale to screen space @@ -73,32 +71,25 @@ namespace osu.Game.Overlays.SkinEditor scale.Y = scale.X / selectionRect.Width * selectionRect.Height; } - // If scaling reverses the selection, don't scale and accumulate the amount of scaling. - if (adjustedRect.Width + scale.X < 0 || adjustedRect.Height + scale.Y < 0) - { - accumulatedNegativeScaling += scale.Length; // - new Vector2(selectionRect.Width, selectionRect.Height).Length; - - return true; - } - - // Compensate for accumulated negative scaling. - if (Precision.AlmostBigger(accumulatedNegativeScaling, 0) && !Precision.AlmostEquals(accumulatedNegativeScaling, 0)) - { - float length = scale.Length; - accumulatedNegativeScaling -= length; - - // If the accumulated negative scaling is still positive, don't scale. - if (Precision.AlmostBigger(accumulatedNegativeScaling, 0)) return true; - scale *= Math.Abs(accumulatedNegativeScaling) / length; - accumulatedNegativeScaling = 0; - } - if (anchor.HasFlagFast(Anchor.x0)) adjustedRect.X -= scale.X; if (anchor.HasFlagFast(Anchor.y0)) adjustedRect.Y -= scale.Y; adjustedRect.Width += scale.X; adjustedRect.Height += scale.Y; + if (adjustedRect.Width < 0) + { + SelectionBox.ScaleHandlesFlip(Direction.Horizontal); + HandleFlip(Direction.Horizontal, false); + } + if (adjustedRect.Height < 0) + { + SelectionBox.ScaleHandlesFlip(Direction.Vertical); + HandleFlip(Direction.Vertical, false); + } + if (adjustedRect.Width < 0 || adjustedRect.Height < 0) + return true; + // scale adjust applied to each individual item should match that of the quad itself. var scaledDelta = new Vector2( adjustedRect.Width / selectionRect.Width, @@ -169,12 +160,6 @@ namespace osu.Game.Overlays.SkinEditor public static void ApplyClosestAnchor(Drawable drawable) => applyAnchor(drawable, getClosestAnchor(drawable)); - protected override void OnOperationEnded() - { - base.OnOperationEnded(); - accumulatedNegativeScaling = 0; - } - protected override void OnSelectionChanged() { base.OnSelectionChanged(); diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs index 876e8ccbe9..a261b635b3 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs @@ -307,6 +307,8 @@ namespace osu.Game.Screens.Edit.Compose.Components return button; } + public void ScaleHandlesFlip(Direction direction) => dragHandles.ScaleHandlesFlip(direction); + private void addScaleHandle(Anchor anchor) { var handle = new SelectionBoxScaleHandle diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs index 5c87271493..4fd2e9aba9 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; using osu.Framework.Allocation; +using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -69,6 +70,17 @@ namespace osu.Game.Screens.Edit.Compose.Components allDragHandles.Add(handle); } + public void ScaleHandlesFlip(Direction direction) + { + foreach (var handle in scaleHandles) + { + if (direction == Direction.Horizontal && !handle.Anchor.HasFlagFast(Anchor.x1)) + handle.Anchor ^= Anchor.x0 | Anchor.x2; + if (direction == Direction.Vertical && !handle.Anchor.HasFlagFast(Anchor.y1)) + handle.Anchor ^= Anchor.y0 | Anchor.y2; + } + } + private SelectionBoxRotationHandle displayedRotationHandle; private SelectionBoxDragHandle activeHandle; From 390b6f649dd9b9c6408d96b8a9347ba71b12c4a1 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 29 Aug 2023 03:46:11 +0900 Subject: [PATCH 063/157] Add test --- .../Mods/TestSceneManiaModDoubleTime.cs | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs diff --git a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs new file mode 100644 index 0000000000..08e83b04b5 --- /dev/null +++ b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs @@ -0,0 +1,65 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.Mods; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Replays; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Replays; +using osu.Game.Tests.Visual; + +namespace osu.Game.Rulesets.Mania.Tests.Mods +{ + public partial class TestSceneManiaModDoubleTime : ModTestScene + { + private const double offset = 18; + + protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset(); + + [Test] + public void TestHitWindowWithoutDoubleTime() => CreateModTest(new ModTestData + { + Mod = new ModNoMod(), + PassCondition = () => Player.ScoreProcessor.JudgedHits > 0 && Player.ScoreProcessor.Accuracy.Value != 1, + Autoplay = false, + Beatmap = new Beatmap + { + BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }, + Difficulty = { OverallDifficulty = 10 }, + HitObjects = new List + { + new Note { StartTime = 1000 } + }, + }, + ReplayFrames = new List + { + new ManiaReplayFrame(1000 + offset, ManiaAction.Key1) + } + }); + + [Test] + public void TestHitWindowWithDoubleTime() => CreateModTest(new ModTestData + { + Mod = new ManiaModDoubleTime(), + PassCondition = () => Player.ScoreProcessor.JudgedHits > 0 && Player.ScoreProcessor.Accuracy.Value == 1, + Autoplay = false, + Beatmap = new Beatmap + { + BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }, + Difficulty = { OverallDifficulty = 10 }, + HitObjects = new List + { + new Note { StartTime = 1000 } + }, + }, + ReplayFrames = new List + { + new ManiaReplayFrame(1000 + offset, ManiaAction.Key1) + } + }); + } +} From d07530b24102faaf6929ce12221bc5903d126095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 29 Aug 2023 11:48:47 +0200 Subject: [PATCH 064/157] Mark "Score V2" mod as not user-playable The mod generally will only be present on scores imported from stable. As such, it's probably ok to mark it as such. The primary reason for this change is to address #24436 (Score V2 being visible on beatmap overlay leaderboard mod selector). There is one possibly-unintended consequence of this change, namely that the results screen uses `UserPlayable` to determine as to whether animations should be played back, with the intention of turning off the animation playback for autoplay scores specifically. Therefore, turning off this flag will mean that the results screen animations will not play out for Score V2 scores - but I tend to consider this as either largely unimportant, or something that should be fixed in some other way (possibly by checking against the autoplay mod directly). Other usages of `UserPlayable` are either innocuous, or straight-up good safeties going forward in the context of Score V2 (guards against selection in mod select overlays, against score submission with the mod). --- osu.Game/Rulesets/Mods/ModScoreV2.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Rulesets/Mods/ModScoreV2.cs b/osu.Game/Rulesets/Mods/ModScoreV2.cs index 6d56b2d86f..df83d96769 100644 --- a/osu.Game/Rulesets/Mods/ModScoreV2.cs +++ b/osu.Game/Rulesets/Mods/ModScoreV2.cs @@ -16,5 +16,6 @@ namespace osu.Game.Rulesets.Mods public override ModType Type => ModType.System; public override LocalisableString Description => "Score set on earlier osu! versions with the V2 scoring algorithm active."; public override double ScoreMultiplier => 1; + public override bool UserPlayable => false; } } From 3c575516ab2f642431e0e4db16f6303d5b3c7e42 Mon Sep 17 00:00:00 2001 From: Wleter Date: Tue, 29 Aug 2023 17:06:23 +0200 Subject: [PATCH 065/157] add correct scaling for 90 degrees rotation --- osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index ae0a3d0635..ff6b52ca4d 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -48,10 +48,6 @@ namespace osu.Game.Overlays.SkinEditor // copy to mutate, as we will need to compare to the original later on. var adjustedRect = selectionRect; - // first, remove any scale axis we are not interested in. - if (anchor.HasFlagFast(Anchor.x1)) scale.X = 0; - if (anchor.HasFlagFast(Anchor.y1)) scale.Y = 0; - // for now aspect lock scale adjustments that occur at corners.. if (!anchor.HasFlagFast(Anchor.x1) && !anchor.HasFlagFast(Anchor.y1)) { @@ -61,7 +57,7 @@ namespace osu.Game.Overlays.SkinEditor } // ..or if any of the selection have been rotated. // this is to avoid requiring skew logic (which would likely not be the user's expected transform anyway). - else if (SelectedBlueprints.Any(b => !Precision.AlmostEquals(((Drawable)b.Item).Rotation, 0))) + else if (SelectedBlueprints.Any(b => !Precision.AlmostEquals(((Drawable)b.Item).Rotation % 90, 0))) { if (anchor.HasFlagFast(Anchor.x1)) // if dragging from the horizontal centre, only a vertical component is available. @@ -115,6 +111,11 @@ namespace osu.Game.Overlays.SkinEditor ); updateDrawablePosition(drawableItem, newPositionInAdjusted); + + if (Precision.AlmostEquals(MathF.Abs(drawableItem.Rotation) % 180, 90)) + { + scaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X); + } drawableItem.Scale *= scaledDelta; } From d56ab0fe9af86a96ebf2fe3047d0b059b29aedbb Mon Sep 17 00:00:00 2001 From: Wleter Date: Tue, 29 Aug 2023 17:25:52 +0200 Subject: [PATCH 066/157] change names --- .../SkinEditor/SkinSelectionHandler.cs | 25 ++++++++++--------- .../Edit/Compose/Components/SelectionBox.cs | 2 +- .../SelectionBoxDragHandleContainer.cs | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index ff6b52ca4d..afa592dfba 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -73,18 +73,20 @@ namespace osu.Game.Overlays.SkinEditor adjustedRect.Width += scale.X; adjustedRect.Height += scale.Y; - if (adjustedRect.Width < 0) - { - SelectionBox.ScaleHandlesFlip(Direction.Horizontal); - HandleFlip(Direction.Horizontal, false); - } - if (adjustedRect.Height < 0) - { - SelectionBox.ScaleHandlesFlip(Direction.Vertical); - HandleFlip(Direction.Vertical, false); - } if (adjustedRect.Width < 0 || adjustedRect.Height < 0) + { + if (adjustedRect.Width < 0) + { + SelectionBox.FlipScaleHandles(Direction.Horizontal); + HandleFlip(Direction.Horizontal, false); + } + if (adjustedRect.Height < 0) + { + SelectionBox.FlipScaleHandles(Direction.Vertical); + HandleFlip(Direction.Vertical, false); + } return true; + } // scale adjust applied to each individual item should match that of the quad itself. var scaledDelta = new Vector2( @@ -113,9 +115,8 @@ namespace osu.Game.Overlays.SkinEditor updateDrawablePosition(drawableItem, newPositionInAdjusted); if (Precision.AlmostEquals(MathF.Abs(drawableItem.Rotation) % 180, 90)) - { scaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X); - } + drawableItem.Scale *= scaledDelta; } diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs index a261b635b3..bbf9ea8c3c 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs @@ -307,7 +307,7 @@ namespace osu.Game.Screens.Edit.Compose.Components return button; } - public void ScaleHandlesFlip(Direction direction) => dragHandles.ScaleHandlesFlip(direction); + public void FlipScaleHandles(Direction direction) => dragHandles.FlipScaleHandles(direction); private void addScaleHandle(Anchor anchor) { diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs index 4fd2e9aba9..e7f69b7b37 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxDragHandleContainer.cs @@ -70,7 +70,7 @@ namespace osu.Game.Screens.Edit.Compose.Components allDragHandles.Add(handle); } - public void ScaleHandlesFlip(Direction direction) + public void FlipScaleHandles(Direction direction) { foreach (var handle in scaleHandles) { From 586ce6e8d3e6d9ebdbb629d3dff76a6539739cd4 Mon Sep 17 00:00:00 2001 From: Wleter Date: Tue, 29 Aug 2023 17:47:42 +0200 Subject: [PATCH 067/157] fix multiple selected --- osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index afa592dfba..971ea3d266 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -73,14 +73,14 @@ namespace osu.Game.Overlays.SkinEditor adjustedRect.Width += scale.X; adjustedRect.Height += scale.Y; - if (adjustedRect.Width < 0 || adjustedRect.Height < 0) + if (adjustedRect.Width <= 0 || adjustedRect.Height <= 0) { - if (adjustedRect.Width < 0) + if (adjustedRect.Width <= 0) { SelectionBox.FlipScaleHandles(Direction.Horizontal); HandleFlip(Direction.Horizontal, false); } - if (adjustedRect.Height < 0) + if (adjustedRect.Height <= 0) { SelectionBox.FlipScaleHandles(Direction.Vertical); HandleFlip(Direction.Vertical, false); @@ -114,10 +114,11 @@ namespace osu.Game.Overlays.SkinEditor updateDrawablePosition(drawableItem, newPositionInAdjusted); + var currentScaledDelta = scaledDelta; if (Precision.AlmostEquals(MathF.Abs(drawableItem.Rotation) % 180, 90)) - scaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X); + currentScaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X); - drawableItem.Scale *= scaledDelta; + drawableItem.Scale *= currentScaledDelta; } return true; From ce1bc7156727ec30c059ab44dab689c4c6d990cc Mon Sep 17 00:00:00 2001 From: Wleter Date: Tue, 29 Aug 2023 18:41:56 +0200 Subject: [PATCH 068/157] formatting --- osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index 971ea3d266..2acddff0e4 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -80,11 +80,13 @@ namespace osu.Game.Overlays.SkinEditor SelectionBox.FlipScaleHandles(Direction.Horizontal); HandleFlip(Direction.Horizontal, false); } + if (adjustedRect.Height <= 0) { SelectionBox.FlipScaleHandles(Direction.Vertical); HandleFlip(Direction.Vertical, false); } + return true; } From b658b0e3462170adcb3a57901de17ee514a8d9c1 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Tue, 29 Aug 2023 23:28:50 +0200 Subject: [PATCH 069/157] Fix and use score user's IsBot property in results screen animation While a mod-created replay did flag itself as performed by a bot, the extension method converting it into a Score did not copy all the generated properties. As noted, it might be preferable for ModCreatedUser to inherit APIUser and forward it as-is to the Score instance. Related to PR #24675 --- osu.Game/Rulesets/Mods/ModExtensions.cs | 4 +++- osu.Game/Screens/Ranking/ResultsScreen.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Mods/ModExtensions.cs b/osu.Game/Rulesets/Mods/ModExtensions.cs index b22030414b..49a3c9178a 100644 --- a/osu.Game/Rulesets/Mods/ModExtensions.cs +++ b/osu.Game/Rulesets/Mods/ModExtensions.cs @@ -21,8 +21,10 @@ namespace osu.Game.Rulesets.Mods { User = new APIUser { - Id = APIUser.SYSTEM_USER_ID, + // TODO: Some fields weren't copied from replayData.User (namely IsBot and Id). Should ModCreatedUser inherit from APIUser so we could pass it verbatim to avoid future mistakes ? + Id = replayData.User.OnlineID, Username = replayData.User.Username, + IsBot = replayData.User.IsBot, } } }; diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 1d0499c909..03231f9329 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -156,7 +156,7 @@ namespace osu.Game.Screens.Ranking if (Score != null) { // only show flair / animation when arriving after watching a play that isn't autoplay. - bool shouldFlair = player != null && Score.Mods.All(m => m.UserPlayable); + bool shouldFlair = player != null && !Score.User.IsBot; ScorePanelList.AddScore(Score, shouldFlair); } From 270e2a66009b7b551837ad39ed45be9d3cdbf3b9 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Tue, 29 Aug 2023 23:59:08 +0200 Subject: [PATCH 070/157] Update osu.Game/Rulesets/Mods/ModExtensions.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartłomiej Dach --- osu.Game/Rulesets/Mods/ModExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Rulesets/Mods/ModExtensions.cs b/osu.Game/Rulesets/Mods/ModExtensions.cs index 49a3c9178a..aa106f1203 100644 --- a/osu.Game/Rulesets/Mods/ModExtensions.cs +++ b/osu.Game/Rulesets/Mods/ModExtensions.cs @@ -21,7 +21,6 @@ namespace osu.Game.Rulesets.Mods { User = new APIUser { - // TODO: Some fields weren't copied from replayData.User (namely IsBot and Id). Should ModCreatedUser inherit from APIUser so we could pass it verbatim to avoid future mistakes ? Id = replayData.User.OnlineID, Username = replayData.User.Username, IsBot = replayData.User.IsBot, From a85f0d57911fd880bb7a406cd5bd82d3934f0b50 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 Aug 2023 13:29:08 +0900 Subject: [PATCH 071/157] Allow saving changes in tournament system using `Ctrl`+`S` --- osu.Game.Tournament/SaveChangesOverlay.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tournament/SaveChangesOverlay.cs b/osu.Game.Tournament/SaveChangesOverlay.cs index 7838d4ba48..0b5194a51f 100644 --- a/osu.Game.Tournament/SaveChangesOverlay.cs +++ b/osu.Game.Tournament/SaveChangesOverlay.cs @@ -7,13 +7,16 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; +using osu.Framework.Input.Bindings; +using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Online.Multiplayer; using osuTK; namespace osu.Game.Tournament { - internal partial class SaveChangesOverlay : CompositeDrawable + internal partial class SaveChangesOverlay : CompositeDrawable, IKeyBindingHandler { [Resolved] private TournamentGame tournamentGame { get; set; } = null!; @@ -78,6 +81,21 @@ namespace osu.Game.Tournament scheduleNextCheck(); } + public bool OnPressed(KeyBindingPressEvent e) + { + if (e.Action == PlatformAction.Save && !e.Repeat) + { + saveChangesButton.TriggerClick(); + return true; + } + + return false; + } + + public void OnReleased(KeyBindingReleaseEvent e) + { + } + private void scheduleNextCheck() => Scheduler.AddDelayed(() => checkForChanges().FireAndForget(), 1000); private void saveChanges() From 24d6cbefe12b5ac570db353ebaeb2c7e3e192dad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 30 Aug 2023 13:44:59 +0900 Subject: [PATCH 072/157] Remove tournament client minimum window size This seemed like a good idea but people were using it with smaller resolutions, do let's just not do it. Addresses https://github.com/ppy/osu/discussions/24670. --- osu.Game.Tournament/TournamentGame.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Tournament/TournamentGame.cs b/osu.Game.Tournament/TournamentGame.cs index ba3b17b513..9baa448ab8 100644 --- a/osu.Game.Tournament/TournamentGame.cs +++ b/osu.Game.Tournament/TournamentGame.cs @@ -48,8 +48,6 @@ namespace osu.Game.Tournament { frameworkConfig.BindWith(FrameworkSetting.WindowedSize, windowSize); - windowSize.MinValue = new Size(TournamentSceneManager.REQUIRED_WIDTH, TournamentSceneManager.STREAM_AREA_HEIGHT); - windowMode = frameworkConfig.GetBindable(FrameworkSetting.WindowMode); Add(loadingSpinner = new LoadingSpinner(true, true) From 0f123fd8e0be4127405236fec5cb4a114a5893fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 30 Aug 2023 08:20:57 +0200 Subject: [PATCH 073/157] Remove unused using directive --- osu.Game.Tournament/TournamentGame.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tournament/TournamentGame.cs b/osu.Game.Tournament/TournamentGame.cs index 9baa448ab8..25dc8ae1e5 100644 --- a/osu.Game.Tournament/TournamentGame.cs +++ b/osu.Game.Tournament/TournamentGame.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Drawing; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; From f277909470749c7ecadae849f4b25e30b1bf0260 Mon Sep 17 00:00:00 2001 From: Wleter Date: Wed, 30 Aug 2023 09:16:16 +0200 Subject: [PATCH 074/157] maintain rotated selection's centre position --- osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index 2acddff0e4..ff53095e22 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -47,6 +47,7 @@ namespace osu.Game.Overlays.SkinEditor // copy to mutate, as we will need to compare to the original later on. var adjustedRect = selectionRect; + bool isRotated = false; // for now aspect lock scale adjustments that occur at corners.. if (!anchor.HasFlagFast(Anchor.x1) && !anchor.HasFlagFast(Anchor.y1)) @@ -59,6 +60,7 @@ namespace osu.Game.Overlays.SkinEditor // this is to avoid requiring skew logic (which would likely not be the user's expected transform anyway). else if (SelectedBlueprints.Any(b => !Precision.AlmostEquals(((Drawable)b.Item).Rotation % 90, 0))) { + isRotated = true; if (anchor.HasFlagFast(Anchor.x1)) // if dragging from the horizontal centre, only a vertical component is available. scale.X = scale.Y / selectionRect.Height * selectionRect.Width; @@ -70,6 +72,10 @@ namespace osu.Game.Overlays.SkinEditor if (anchor.HasFlagFast(Anchor.x0)) adjustedRect.X -= scale.X; if (anchor.HasFlagFast(Anchor.y0)) adjustedRect.Y -= scale.Y; + // Maintain the selection's centre position if dragging from the centre anchors and selection is rotated. + if (isRotated && anchor.HasFlagFast(Anchor.x1)) adjustedRect.X -= scale.X / 2; + if (isRotated && anchor.HasFlagFast(Anchor.y1)) adjustedRect.Y -= scale.Y / 2; + adjustedRect.Width += scale.X; adjustedRect.Height += scale.Y; From c91031604c20043e5e9315ef2eff5de6c708344d Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 30 Aug 2023 21:41:57 +0300 Subject: [PATCH 075/157] Add test cases for hitting hit circles with "early fade" behaviour --- .../TestSceneHitCircleLateFade.cs | 74 ++++++++++++++++--- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs index 3c32b4fa65..149fd61311 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -3,8 +3,10 @@ using System; using System.Linq; +using FFmpeg.AutoGen; using NUnit.Framework; using osu.Framework.Extensions.ObjectExtensions; +using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Mods; @@ -13,6 +15,7 @@ using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Tests.Visual; using osuTK; @@ -23,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Tests private float? alphaAtMiss; [Test] - public void TestHitCircleClassicMod() + public void TestHitCircleClassicModMiss() { AddStep("Create hit circle", () => { @@ -61,8 +64,21 @@ namespace osu.Game.Rulesets.Osu.Tests AddAssert("Transparent when missed", () => alphaAtMiss == 0); } + /// + /// No early fade is expected to be applied if the hit circle has been hit. + /// [Test] - public void TestHitCircleNoMod() + public void TestHitCircleClassicModHit() + { + AddStep("Create hit circle", () => + { + SelectedMods.Value = new Mod[] { new OsuModClassic() }; + createCircle(true); + }); + } + + [Test] + public void TestHitCircleNoModMiss() { AddStep("Create hit circle", () => { @@ -74,6 +90,16 @@ namespace osu.Game.Rulesets.Osu.Tests AddAssert("Opaque when missed", () => alphaAtMiss == 1); } + [Test] + public void TestHitCircleNoModHit() + { + AddStep("Create hit circle", () => + { + SelectedMods.Value = Array.Empty(); + createCircle(true); + }); + } + [Test] public void TestSliderClassicMod() { @@ -100,24 +126,27 @@ namespace osu.Game.Rulesets.Osu.Tests AddAssert("Head circle opaque when missed", () => alphaAtMiss == 1); } - private void createCircle() + private void createCircle(bool auto = false) { alphaAtMiss = null; - DrawableHitCircle drawableHitCircle = new DrawableHitCircle(new HitCircle + TestDrawableHitCircle drawableHitCircle = new TestDrawableHitCircle(new HitCircle { StartTime = Time.Current + 500, - Position = new Vector2(250) - }); + Position = new Vector2(250), + }, auto); + + drawableHitCircle.Scale = new Vector2(2f); foreach (var mod in SelectedMods.Value.OfType()) mod.ApplyToDrawableHitObject(drawableHitCircle); drawableHitCircle.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); - drawableHitCircle.OnNewResult += (_, _) => + drawableHitCircle.OnNewResult += (_, result) => { - alphaAtMiss = drawableHitCircle.Alpha; + if (!result.IsHit) + alphaAtMiss = drawableHitCircle.Alpha; }; Child = drawableHitCircle; @@ -138,6 +167,8 @@ namespace osu.Game.Rulesets.Osu.Tests }) }); + drawableSlider.Scale = new Vector2(2f); + drawableSlider.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); drawableSlider.OnLoadComplete += _ => @@ -145,12 +176,35 @@ namespace osu.Game.Rulesets.Osu.Tests foreach (var mod in SelectedMods.Value.OfType()) mod.ApplyToDrawableHitObject(drawableSlider.HeadCircle); - drawableSlider.HeadCircle.OnNewResult += (_, _) => + drawableSlider.HeadCircle.OnNewResult += (_, result) => { - alphaAtMiss = drawableSlider.HeadCircle.Alpha; + if (!result.IsHit) + alphaAtMiss = drawableSlider.HeadCircle.Alpha; }; }; Child = drawableSlider; } + + protected partial class TestDrawableHitCircle : DrawableHitCircle + { + private readonly bool auto; + + public TestDrawableHitCircle(HitCircle h, bool auto) + : base(h) + { + this.auto = auto; + } + + protected override void CheckForResult(bool userTriggered, double timeOffset) + { + if (auto && !userTriggered && timeOffset >= 0 && CheckHittable?.Invoke(this, Time.Current) != false) + { + // force success + ApplyResult(r => r.Type = HitResult.Great); + } + else + base.CheckForResult(userTriggered, timeOffset); + } + } } } From 993cebe785a07d8c9054a4e7bf6c36567b65ef61 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 30 Aug 2023 21:42:47 +0300 Subject: [PATCH 076/157] Fix mod "Classic" interfering with `DrawableHitCircle` animation while in hit state --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index 250d97c537..e740e6d201 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -85,13 +85,16 @@ namespace osu.Game.Rulesets.Osu.Mods private void applyEarlyFading(DrawableHitCircle circle) { - circle.ApplyCustomUpdateState += (o, _) => + circle.ApplyCustomUpdateState += (dho, state) => { - using (o.BeginAbsoluteSequence(o.StateUpdateTime)) + using (dho.BeginAbsoluteSequence(dho.StateUpdateTime)) { - double okWindow = o.HitObject.HitWindows.WindowFor(HitResult.Ok); - double lateMissFadeTime = o.HitObject.HitWindows.WindowFor(HitResult.Meh) - okWindow; - o.Delay(okWindow).FadeOut(lateMissFadeTime); + if (state != ArmedState.Hit) + { + double okWindow = dho.HitObject.HitWindows.WindowFor(HitResult.Ok); + double lateMissFadeTime = dho.HitObject.HitWindows.WindowFor(HitResult.Meh) - okWindow; + dho.Delay(okWindow).FadeOut(lateMissFadeTime); + } } }; } From b8df714f56c162376396efa2ee71a8c14894e276 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 30 Aug 2023 21:50:52 +0300 Subject: [PATCH 077/157] Remove unused using directives --- osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs index 149fd61311..1557afbf84 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -3,10 +3,8 @@ using System; using System.Linq; -using FFmpeg.AutoGen; using NUnit.Framework; using osu.Framework.Extensions.ObjectExtensions; -using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Mods; From 2d88135198c245a1185fe904b0d61abbd483319f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 16:18:18 +0900 Subject: [PATCH 078/157] Add automated test coverage for new test --- .../TestSceneHitCircleLateFade.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs index 1557afbf84..3b051912fd 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -68,11 +68,17 @@ namespace osu.Game.Rulesets.Osu.Tests [Test] public void TestHitCircleClassicModHit() { + TestDrawableHitCircle circle = null!; + AddStep("Create hit circle", () => { SelectedMods.Value = new Mod[] { new OsuModClassic() }; - createCircle(true); + circle = createCircle(true); }); + + AddUntilStep("Wait until circle is hit", () => circle.Result?.Type == HitResult.Great); + AddUntilStep("Wait for miss window", () => Clock.CurrentTime, () => Is.GreaterThanOrEqualTo(circle.HitObject.StartTime + circle.HitObject.HitWindows.WindowFor(HitResult.Miss))); + AddAssert("Check circle is still visible", () => circle.Alpha, () => Is.GreaterThan(0)); } [Test] @@ -124,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Tests AddAssert("Head circle opaque when missed", () => alphaAtMiss == 1); } - private void createCircle(bool auto = false) + private TestDrawableHitCircle createCircle(bool shouldHit = false) { alphaAtMiss = null; @@ -132,7 +138,7 @@ namespace osu.Game.Rulesets.Osu.Tests { StartTime = Time.Current + 500, Position = new Vector2(250), - }, auto); + }, shouldHit); drawableHitCircle.Scale = new Vector2(2f); @@ -148,6 +154,8 @@ namespace osu.Game.Rulesets.Osu.Tests }; Child = drawableHitCircle; + + return drawableHitCircle; } private void createSlider() @@ -180,22 +188,23 @@ namespace osu.Game.Rulesets.Osu.Tests alphaAtMiss = drawableSlider.HeadCircle.Alpha; }; }; + Child = drawableSlider; } protected partial class TestDrawableHitCircle : DrawableHitCircle { - private readonly bool auto; + private readonly bool shouldHit; - public TestDrawableHitCircle(HitCircle h, bool auto) + public TestDrawableHitCircle(HitCircle h, bool shouldHit) : base(h) { - this.auto = auto; + this.shouldHit = shouldHit; } protected override void CheckForResult(bool userTriggered, double timeOffset) { - if (auto && !userTriggered && timeOffset >= 0 && CheckHittable?.Invoke(this, Time.Current) != false) + if (shouldHit && !userTriggered && timeOffset >= 0 && CheckHittable?.Invoke(this, Time.Current) != false) { // force success ApplyResult(r => r.Type = HitResult.Great); From 5fa31b7b359ca15a5a0cde035df2279a22f695d4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 18:05:34 +0900 Subject: [PATCH 079/157] Fix schedule screen not responding to new matches being added --- .../Screens/Schedule/ScheduleScreen.cs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs index 063c231add..ee4b762be3 100644 --- a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs +++ b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -19,6 +20,7 @@ namespace osu.Game.Tournament.Screens.Schedule { public partial class ScheduleScreen : TournamentScreen { + private readonly BindableList allMatches = new BindableList(); private readonly Bindable currentMatch = new Bindable(); private Container mainContainer = null!; private LadderInfo ladder = null!; @@ -101,16 +103,23 @@ namespace osu.Game.Tournament.Screens.Schedule { base.LoadComplete(); + allMatches.BindTo(ladder.Matches); + allMatches.BindCollectionChanged((_, _) => refresh()); + currentMatch.BindTo(ladder.CurrentMatch); - currentMatch.BindValueChanged(matchChanged, true); + currentMatch.BindValueChanged(_ => refresh(), true); } - private void matchChanged(ValueChangedEvent match) + private void refresh() { - var upcoming = ladder.Matches.Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4); - var conditionals = ladder - .Matches.Where(p => !p.Completed.Value && (p.Team1.Value == null || p.Team2.Value == null) && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4) - .SelectMany(m => m.ConditionalMatches.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a)))); + IEnumerable upcoming = + allMatches + .Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4); + + IEnumerable conditionals = + allMatches + .Where(p => !p.Completed.Value && (p.Team1.Value == null || p.Team2.Value == null) && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4) + .SelectMany(m => m.ConditionalMatches.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a)))); upcoming = upcoming.Concat(conditionals); upcoming = upcoming.OrderBy(p => p.Date.Value).Take(8); @@ -137,12 +146,12 @@ namespace osu.Game.Tournament.Screens.Schedule { RelativeSizeAxes = Axes.Both, Width = 0.4f, - ChildrenEnumerable = ladder.Matches - .Where(p => p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null - && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4) - .OrderByDescending(p => p.Date.Value) - .Take(8) - .Select(p => new ScheduleMatch(p)) + ChildrenEnumerable = allMatches + .Where(p => p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null + && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4) + .OrderByDescending(p => p.Date.Value) + .Take(8) + .Select(p => new ScheduleMatch(p)) }, new ScheduleContainer("upcoming matches") { @@ -161,7 +170,7 @@ namespace osu.Game.Tournament.Screens.Schedule } }; - if (match.NewValue != null) + if (currentMatch.Value != null) { comingUpNext.Child = new FillFlowContainer { @@ -170,12 +179,12 @@ namespace osu.Game.Tournament.Screens.Schedule Spacing = new Vector2(30), Children = new Drawable[] { - new ScheduleMatch(match.NewValue, false) + new ScheduleMatch(currentMatch.Value, false) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }, - new TournamentSpriteTextWithBackground(match.NewValue.Round.Value?.Name.Value ?? string.Empty) + new TournamentSpriteTextWithBackground(currentMatch.Value.Round.Value?.Name.Value ?? string.Empty) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -185,7 +194,7 @@ namespace osu.Game.Tournament.Screens.Schedule { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Text = match.NewValue.Team1.Value?.FullName + " vs " + match.NewValue.Team2.Value?.FullName, + Text = currentMatch.Value.Team1.Value?.FullName + " vs " + currentMatch.Value.Team2.Value?.FullName, Font = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold) }, new FillFlowContainer @@ -196,7 +205,7 @@ namespace osu.Game.Tournament.Screens.Schedule Origin = Anchor.CentreLeft, Children = new Drawable[] { - new ScheduleMatchDate(match.NewValue.Date.Value) + new ScheduleMatchDate(currentMatch.Value.Date.Value) { Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular) } From 7aa1505062cd3d15082d3e10dbf9cc232048b6c1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 18:13:36 +0900 Subject: [PATCH 080/157] Improve legibility of LINQ queries for recent/upcoming matches --- .../Screens/Schedule/ScheduleScreen.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs index ee4b762be3..62c54daa75 100644 --- a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs +++ b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs @@ -112,17 +112,25 @@ namespace osu.Game.Tournament.Screens.Schedule private void refresh() { - IEnumerable upcoming = - allMatches - .Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4); + const int days_for_displays = 4; IEnumerable conditionals = allMatches - .Where(p => !p.Completed.Value && (p.Team1.Value == null || p.Team2.Value == null) && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4) + .Where(m => !m.Completed.Value && (m.Team1.Value == null || m.Team2.Value == null) && Math.Abs(m.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < days_for_displays) .SelectMany(m => m.ConditionalMatches.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a)))); - upcoming = upcoming.Concat(conditionals); - upcoming = upcoming.OrderBy(p => p.Date.Value).Take(8); + IEnumerable upcoming = + allMatches + .Where(m => !m.Completed.Value && m.Team1.Value != null && m.Team2.Value != null && Math.Abs(m.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < days_for_displays) + .Concat(conditionals) + .OrderBy(m => m.Date.Value) + .Take(8); + + var recent = + allMatches + .Where(m => m.Completed.Value && m.Team1.Value != null && m.Team2.Value != null && Math.Abs(m.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < days_for_displays) + .OrderByDescending(m => m.Date.Value) + .Take(8); ScheduleContainer comingUpNext; @@ -146,12 +154,7 @@ namespace osu.Game.Tournament.Screens.Schedule { RelativeSizeAxes = Axes.Both, Width = 0.4f, - ChildrenEnumerable = allMatches - .Where(p => p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null - && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4) - .OrderByDescending(p => p.Date.Value) - .Take(8) - .Select(p => new ScheduleMatch(p)) + ChildrenEnumerable = recent.Select(p => new ScheduleMatch(p)) }, new ScheduleContainer("upcoming matches") { From 4b68493084a4f9b87bbead6fdb02367d5d062832 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 18:05:18 +0900 Subject: [PATCH 081/157] Add ability to test recent / upcoming matches on schedule screen --- .../Screens/TestSceneScheduleScreen.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneScheduleScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneScheduleScreen.cs index f3c3fdec97..a58f09d13a 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneScheduleScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneScheduleScreen.cs @@ -12,6 +12,13 @@ namespace osu.Game.Tournament.Tests.Screens { public partial class TestSceneScheduleScreen : TournamentScreenTestScene { + public override void SetUpSteps() + { + AddStep("clear matches", () => Ladder.Matches.Clear()); + + base.SetUpSteps(); + } + [BackgroundDependencyLoader] private void load() { @@ -34,6 +41,36 @@ namespace osu.Game.Tournament.Tests.Screens AddStep("Set null current match", () => Ladder.CurrentMatch.Value = null); } + [Test] + public void TestUpcomingMatches() + { + AddStep("Add upcoming match", () => + { + var tournamentMatch = CreateSampleMatch(); + + tournamentMatch.Date.Value = DateTimeOffset.UtcNow.AddMinutes(5); + tournamentMatch.Completed.Value = false; + + Ladder.Matches.Add(tournamentMatch); + }); + } + + [Test] + public void TestRecentMatches() + { + AddStep("Add recent match", () => + { + var tournamentMatch = CreateSampleMatch(); + + tournamentMatch.Date.Value = DateTimeOffset.UtcNow; + tournamentMatch.Completed.Value = true; + tournamentMatch.Team1Score.Value = tournamentMatch.PointsToWin; + tournamentMatch.Team2Score.Value = tournamentMatch.PointsToWin / 2; + + Ladder.Matches.Add(tournamentMatch); + }); + } + private void setMatchDate(TimeSpan relativeTime) // Humanizer cannot handle negative timespans. => AddStep($"start time is {relativeTime}", () => From 540c58c359ed47ee758519da0b089621be41b7cc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 18:46:47 +0900 Subject: [PATCH 082/157] Fix tournament screen tests not matching `OsuGameBase` resolution This would cause things to look completely out of whack. The numbers here match `DrawSizePreservingFillContainer` defaults as used by `OsuGameBase.CreateScalingContainer()`. --- osu.Game.Tournament.Tests/TournamentScreenTestScene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tournament.Tests/TournamentScreenTestScene.cs b/osu.Game.Tournament.Tests/TournamentScreenTestScene.cs index 8adffe1468..e8cca00c92 100644 --- a/osu.Game.Tournament.Tests/TournamentScreenTestScene.cs +++ b/osu.Game.Tournament.Tests/TournamentScreenTestScene.cs @@ -23,7 +23,7 @@ namespace osu.Game.Tournament.Tests { public TournamentScalingContainer() { - TargetDrawSize = new Vector2(1920, 1080); + TargetDrawSize = new Vector2(1024, 768); RelativeSizeAxes = Axes.Both; } From 4bdaca3816ad8cf6ddd3125fce83c5c11e975a20 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 18:05:04 +0900 Subject: [PATCH 083/157] Fix regression in spacing on schedule screen --- osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs index 62c54daa75..d02559d6b7 100644 --- a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs +++ b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs @@ -294,6 +294,7 @@ namespace osu.Game.Tournament.Screens.Schedule { Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.Both, + Spacing = new Vector2(0, -6), Margin = new MarginPadding(10) }, } From 34b279845bf4d4569b8cc9897cba0b58e4219c20 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 19:03:56 +0900 Subject: [PATCH 084/157] Add more testability for song bar --- osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs b/osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs index e0444b6126..95d6b6d107 100644 --- a/osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs +++ b/osu.Game.Tournament.Tests/Components/TestSceneSongBar.cs @@ -58,9 +58,14 @@ namespace osu.Game.Tournament.Tests.Components songBar.Beatmap = new TournamentBeatmap(beatmap); }); + AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock); AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime); AddStep("unset mods", () => songBar.Mods = LegacyMods.None); + + AddToggleStep("toggle expanded", expanded => songBar.Expanded = expanded); + + AddStep("set null beatmap", () => songBar.Beatmap = null); } } } From cf9c8120c5292774b8aec7d2b0282003cdca32d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 31 Aug 2023 19:04:06 +0900 Subject: [PATCH 085/157] Fix potential race condition in song bar beatmap lookup flow Cancelling a web request may not necessarily cancel the callbacks. This might help with https://github.com/ppy/osu/issues/24598. --- osu.Game.Tournament/IPC/FileBasedIPC.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament/IPC/FileBasedIPC.cs b/osu.Game.Tournament/IPC/FileBasedIPC.cs index bf835122cc..5407c21079 100644 --- a/osu.Game.Tournament/IPC/FileBasedIPC.cs +++ b/osu.Game.Tournament/IPC/FileBasedIPC.cs @@ -92,8 +92,16 @@ namespace osu.Game.Tournament.IPC else { beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId }); - beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b); - beatmapLookupRequest.Failure += _ => Beatmap.Value = null; + beatmapLookupRequest.Success += b => + { + if (lastBeatmapId == beatmapId) + Beatmap.Value = new TournamentBeatmap(b); + }; + beatmapLookupRequest.Failure += _ => + { + if (lastBeatmapId == beatmapId) + Beatmap.Value = null; + }; API.Queue(beatmapLookupRequest); } } From 47160f7744823a4f53716fbc001b707003430a15 Mon Sep 17 00:00:00 2001 From: Wleter Date: Thu, 31 Aug 2023 20:24:26 +0200 Subject: [PATCH 086/157] make getClosestAnchor work with rotated drawable --- .../SkinEditor/SkinSelectionHandler.cs | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index 72216f040e..fe2816db6f 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -291,7 +291,7 @@ namespace osu.Game.Overlays.SkinEditor if (parent == null) return drawable.Anchor; - var screenPosition = getScreenPosition(); + var screenPosition = drawable.ToScreenSpace(drawable.OriginPosition); var absolutePosition = parent.ToLocalSpace(screenPosition); var factor = parent.RelativeToAbsoluteFactor; @@ -313,26 +313,6 @@ namespace osu.Game.Overlays.SkinEditor result |= getAnchorFromPosition(absolutePosition.Y / factor.Y, Anchor.y0, Anchor.y1, Anchor.y2); return result; - - Vector2 getScreenPosition() - { - var quad = drawable.ScreenSpaceDrawQuad; - var origin = drawable.Origin; - - var pos = quad.TopLeft; - - if (origin.HasFlagFast(Anchor.x2)) - pos.X += quad.Width; - else if (origin.HasFlagFast(Anchor.x1)) - pos.X += quad.Width / 2f; - - if (origin.HasFlagFast(Anchor.y2)) - pos.Y += quad.Height; - else if (origin.HasFlagFast(Anchor.y1)) - pos.Y += quad.Height / 2f; - - return pos; - } } private static void applyAnchor(Drawable drawable, Anchor anchor) From c75b14c72994c51a54b4f01fc16a4f52c22d9c4d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Sep 2023 16:54:35 +0900 Subject: [PATCH 087/157] Apply NRT to new `LegacyHitPolicy` class (and other implementations) --- osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs | 4 +--- osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs | 7 ++++--- .../UI/StartTimeOrderedHitPolicy.cs | 14 +++++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs index 69bd360b5e..2c6895d7ec 100644 --- a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -14,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.UI /// public class AnyOrderHitPolicy : IHitPolicy { - public IHitObjectContainer HitObjectContainer { get; set; } + public IHitObjectContainer HitObjectContainer { get; set; } = null!; public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) => ClickAction.Hit; diff --git a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs index 2b6359fb46..daf498581e 100644 --- a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using osu.Game.Rulesets.Objects; @@ -22,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI /// public class LegacyHitPolicy : IHitPolicy { - public IHitObjectContainer HitObjectContainer { get; set; } + public IHitObjectContainer? HitObjectContainer { get; set; } private readonly double hittableRange; @@ -37,6 +35,9 @@ namespace osu.Game.Rulesets.Osu.UI public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) { + if (HitObjectContainer == null) + throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(CheckHittable)} is called."); + var aliveObjects = HitObjectContainer.AliveObjects.ToList(); int index = aliveObjects.IndexOf(hitObject); diff --git a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs index 6fd0b512be..2b24fb9398 100644 --- a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using osu.Game.Rulesets.Objects; @@ -23,11 +21,14 @@ namespace osu.Game.Rulesets.Osu.UI /// public class StartTimeOrderedHitPolicy : IHitPolicy { - public IHitObjectContainer HitObjectContainer { get; set; } + public IHitObjectContainer? HitObjectContainer { get; set; } public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult _) { - DrawableHitObject blockingObject = null; + if (HitObjectContainer == null) + throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(CheckHittable)} is called."); + + DrawableHitObject? blockingObject = null; foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime)) { @@ -48,6 +49,9 @@ namespace osu.Game.Rulesets.Osu.UI public void HandleHit(DrawableHitObject hitObject) { + if (HitObjectContainer == null) + throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(HandleHit)} is called."); + // Hitobjects which themselves don't block future hitobjects don't cause misses (e.g. slider ticks, spinners). if (!hitObjectCanBlockFutureHits(hitObject)) return; @@ -75,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.UI private IEnumerable enumerateHitObjectsUpTo(double targetTime) { - foreach (var obj in HitObjectContainer.AliveObjects) + foreach (var obj in HitObjectContainer!.AliveObjects) { if (obj.HitObject.StartTime >= targetTime) yield break; From ede9fae38166e69e85ee7fbd643109b218eea4d1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Sep 2023 17:19:39 +0900 Subject: [PATCH 088/157] Remove broken check from `TestSceneHitCircleLateFade` --- osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs index 3b051912fd..d74a31ada4 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleLateFade.cs @@ -204,7 +204,7 @@ namespace osu.Game.Rulesets.Osu.Tests protected override void CheckForResult(bool userTriggered, double timeOffset) { - if (shouldHit && !userTriggered && timeOffset >= 0 && CheckHittable?.Invoke(this, Time.Current) != false) + if (shouldHit && !userTriggered && timeOffset >= 0) { // force success ApplyResult(r => r.Type = HitResult.Great); From fc4069f794e91e6ea1eb4a4b28c334b12e301a85 Mon Sep 17 00:00:00 2001 From: Wleter Date: Fri, 1 Sep 2023 13:01:51 +0200 Subject: [PATCH 089/157] let SelectionBox perform flip with scale handles --- .../SkinEditor/SkinSelectionHandler.cs | 14 ++++--------- .../Edit/Compose/Components/SelectionBox.cs | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index ff53095e22..b30351f61b 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -81,18 +81,12 @@ namespace osu.Game.Overlays.SkinEditor if (adjustedRect.Width <= 0 || adjustedRect.Height <= 0) { - if (adjustedRect.Width <= 0) - { - SelectionBox.FlipScaleHandles(Direction.Horizontal); - HandleFlip(Direction.Horizontal, false); - } + Axes toFlip = Axes.None; - if (adjustedRect.Height <= 0) - { - SelectionBox.FlipScaleHandles(Direction.Vertical); - HandleFlip(Direction.Vertical, false); - } + if (adjustedRect.Width <= 0) toFlip |= Axes.X; + if (adjustedRect.Height <= 0) toFlip |= Axes.Y; + SelectionBox.PerformFlipFromScaleHandles(toFlip); return true; } diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs index bbf9ea8c3c..0c19f6c62e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs @@ -4,6 +4,7 @@ using System; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -307,7 +308,24 @@ namespace osu.Game.Screens.Edit.Compose.Components return button; } - public void FlipScaleHandles(Direction direction) => dragHandles.FlipScaleHandles(direction); + /// + /// This method should be called when a selection needs to be flipped + /// because of an ongoing scale handle drag that would otherwise cause width or height to go negative. + /// + public void PerformFlipFromScaleHandles(Axes axes) + { + if (axes.HasFlagFast(Axes.X)) + { + dragHandles.FlipScaleHandles(Direction.Horizontal); + OnFlip?.Invoke(Direction.Horizontal, false); + } + + if (axes.HasFlagFast(Axes.Y)) + { + dragHandles.FlipScaleHandles(Direction.Vertical); + OnFlip?.Invoke(Direction.Vertical, false); + } + } private void addScaleHandle(Anchor anchor) { From f74dfa9c6cc23c2807225b3e69be4f6ba446adac Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 1 Sep 2023 22:55:32 +0300 Subject: [PATCH 090/157] Apply flashlight slider dim immediately to match osu!(stable) --- osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs index efeac9a180..765af80959 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs @@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Osu.Mods public void OnSliderTrackingChange(ValueChangedEvent e) { // If a slider is in a tracking state, a further dim should be applied to the (remaining) visible portion of the playfield over a brief duration. - this.TransformTo(nameof(FlashlightDim), e.NewValue ? 0.8f : 0.0f, 50); + FlashlightDim = e.NewValue ? 0.8f : 0.0f; } protected override bool OnMouseMove(MouseMoveEvent e) From 920c6fa48facbd43c5edbae6ea1e66468fadc9b3 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 1 Sep 2023 23:29:51 +0300 Subject: [PATCH 091/157] Update comment --- osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs index 765af80959..252d7e2762 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs @@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Osu.Mods public void OnSliderTrackingChange(ValueChangedEvent e) { - // If a slider is in a tracking state, a further dim should be applied to the (remaining) visible portion of the playfield over a brief duration. + // If a slider is in a tracking state, a further dim should be applied to the (remaining) visible portion of the playfield. FlashlightDim = e.NewValue ? 0.8f : 0.0f; } From d674856e29d230fb6efd6b5a9c0873f6db628050 Mon Sep 17 00:00:00 2001 From: Magnus-Cosmos Date: Sat, 2 Sep 2023 22:49:29 -0400 Subject: [PATCH 092/157] Use existing localisations in `BeatmapInfoWedge` --- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 81759f6787..8bbf569566 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -30,6 +30,7 @@ using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using osu.Game.Graphics.Containers; +using osu.Game.Resources.Localisation.Web; namespace osu.Game.Screens.Select { @@ -371,7 +372,7 @@ namespace osu.Game.Screens.Select { new InfoLabel(new BeatmapStatistic { - Name = $"Length (Drain: {playableBeatmap.CalculateDrainLength().ToFormattedDuration().ToString()})", + Name = BeatmapsetsStrings.ShowStatsTotalLength(playableBeatmap.CalculateDrainLength().ToFormattedDuration()), CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length), Content = working.BeatmapInfo.Length.ToFormattedDuration().ToString(), }), @@ -415,7 +416,7 @@ namespace osu.Game.Screens.Select bpmLabelContainer.Child = new InfoLabel(new BeatmapStatistic { - Name = "BPM", + Name = BeatmapsetsStrings.ShowStatsBpm, CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Bpm), Content = labelText }); From 40dbf098d2d31730ddecf38032da48a8d2461910 Mon Sep 17 00:00:00 2001 From: Magnus-Cosmos Date: Sat, 2 Sep 2023 22:51:08 -0400 Subject: [PATCH 093/157] Use existing localisation for "view profile" --- osu.Game/Graphics/Containers/LinkFlowContainer.cs | 3 ++- osu.Game/Users/Drawables/ClickableAvatar.cs | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs index 2d27ce906b..40e883f8ac 100644 --- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs +++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs @@ -15,6 +15,7 @@ using osu.Framework.Localisation; using osu.Framework.Platform; using osu.Game.Online; using osu.Game.Users; +using osu.Game.Localisation; namespace osu.Game.Graphics.Containers { @@ -74,7 +75,7 @@ namespace osu.Game.Graphics.Containers } public void AddUserLink(IUser user, Action creationParameters = null) - => createLink(CreateChunkFor(user.Username, true, CreateSpriteText, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user), "view profile"); + => createLink(CreateChunkFor(user.Username, true, CreateSpriteText, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user), ContextMenuStrings.ViewProfile); private void createLink(ITextPart textPart, LinkDetails link, LocalisableString tooltipText, Action action = null) { diff --git a/osu.Game/Users/Drawables/ClickableAvatar.cs b/osu.Game/Users/Drawables/ClickableAvatar.cs index e74ffc9d54..677a8fff36 100644 --- a/osu.Game/Users/Drawables/ClickableAvatar.cs +++ b/osu.Game/Users/Drawables/ClickableAvatar.cs @@ -6,14 +6,13 @@ using osu.Framework.Allocation; using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Graphics.Containers; +using osu.Game.Localisation; using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Users.Drawables { public partial class ClickableAvatar : OsuClickableContainer { - private const string default_tooltip_text = "view profile"; - public override LocalisableString TooltipText { get @@ -21,7 +20,7 @@ namespace osu.Game.Users.Drawables if (!Enabled.Value) return string.Empty; - return ShowUsernameTooltip ? (user?.Username ?? string.Empty) : default_tooltip_text; + return ShowUsernameTooltip ? (user?.Username ?? string.Empty) : ContextMenuStrings.ViewProfile; } set => throw new NotSupportedException(); } From ae9c901b94201de270a3c2fd6ccdbed59107da05 Mon Sep 17 00:00:00 2001 From: Magnus-Cosmos Date: Sun, 3 Sep 2023 01:45:22 -0400 Subject: [PATCH 094/157] Fix `BeatmapInfoWedge` tests failing due to BPM --- osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs index a470ed47d4..7cd4f06bce 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs @@ -15,6 +15,7 @@ using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics.Sprites; +using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Mania; @@ -188,7 +189,7 @@ namespace osu.Game.Tests.Visual.SongSelect { AddUntilStep($"displayed bpm is {target}", () => { - var label = infoWedge.DisplayedContent.ChildrenOfType().Single(l => l.Statistic.Name == "BPM"); + var label = infoWedge.DisplayedContent.ChildrenOfType().Single(l => l.Statistic.Name == BeatmapsetsStrings.ShowStatsBpm); return label.Statistic.Content == target; }); } From b17a55d6a84aba14c6387a03d64053f5b82d4751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=E1=BB=93=20Nguy=C3=AAn=20Minh?= Date: Mon, 4 Sep 2023 10:43:05 +0700 Subject: [PATCH 095/157] Add length check for slider velocity --- .../Edit/Compose/Components/Timeline/DifficultyPointPiece.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs index 173a665d5c..366518eb58 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs @@ -177,6 +177,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline AddHeader("Final velocity"); AddValue($"{beatmapVelocity * current.Value:#,0.00}x"); + if (sliderVelocities.Length == 0) return; if (sliderVelocities.First() != sliderVelocities.Last()) { AddHeader("Beatmap velocity range"); From d5a89c4c45eddff8eb2d88cb7739c08e3260fecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=E1=BB=93=20Nguy=C3=AAn=20Minh?= Date: Mon, 4 Sep 2023 13:32:42 +0700 Subject: [PATCH 096/157] Fix formatting --- .../Compose/Components/Timeline/DifficultyPointPiece.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs index 366518eb58..99fb2ab874 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/DifficultyPointPiece.cs @@ -177,7 +177,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline AddHeader("Final velocity"); AddValue($"{beatmapVelocity * current.Value:#,0.00}x"); - if (sliderVelocities.Length == 0) return; + if (sliderVelocities.Length == 0) + { + return; + } + if (sliderVelocities.First() != sliderVelocities.Last()) { AddHeader("Beatmap velocity range"); From 0a1ba2ebe08877717f4617cb4d3070ea33d3b3b9 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 4 Sep 2023 15:56:32 +0900 Subject: [PATCH 097/157] Remove ModNoMod usage --- .../Mods/TestSceneManiaModDoubleTime.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs index 08e83b04b5..00b79529a9 100644 --- a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs +++ b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModDoubleTime.cs @@ -7,7 +7,6 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Mods; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Replays; -using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Replays; using osu.Game.Tests.Visual; @@ -23,7 +22,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods [Test] public void TestHitWindowWithoutDoubleTime() => CreateModTest(new ModTestData { - Mod = new ModNoMod(), PassCondition = () => Player.ScoreProcessor.JudgedHits > 0 && Player.ScoreProcessor.Accuracy.Value != 1, Autoplay = false, Beatmap = new Beatmap From 5abf271b56e24adeecffbcb60ca3edd8c62e667c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sun, 3 Sep 2023 21:49:29 -0700 Subject: [PATCH 098/157] Implement beatmap options popover --- .../SongSelect/TestSceneSongSelectFooterV2.cs | 7 +- .../Select/FooterV2/BeatmapOptionsPopover.cs | 148 ++++++++++++++++++ .../Select/FooterV2/FooterButtonOptionsV2.cs | 37 ++++- osu.Game/Screens/Select/FooterV2/FooterV2.cs | 10 +- osu.Game/Screens/Select/SongSelect.cs | 18 +-- 5 files changed, 205 insertions(+), 15 deletions(-) create mode 100644 osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs index 72adbfc104..ed2ae67ae5 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneSongSelectFooterV2.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Testing; using osu.Game.Overlays; using osu.Game.Overlays.Mods; @@ -37,10 +38,10 @@ namespace osu.Game.Tests.Visual.SongSelect Children = new Drawable[] { - footer = new FooterV2 + new PopoverContainer { - Anchor = Anchor.Centre, - Origin = Anchor.Centre + RelativeSizeAxes = Axes.Both, + Child = footer = new FooterV2(), }, overlay = new DummyOverlay() }; diff --git a/osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs b/osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs new file mode 100644 index 0000000000..ec35c6ff38 --- /dev/null +++ b/osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs @@ -0,0 +1,148 @@ +// 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.Linq; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Framework.Localisation; +using osu.Game.Collections; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; +using osu.Game.Overlays; +using osuTK; +using osuTK.Graphics; +using osuTK.Input; + +namespace osu.Game.Screens.Select.FooterV2 +{ + public partial class BeatmapOptionsPopover : OsuPopover + { + private FillFlowContainer buttonFlow = null!; + private readonly FooterButtonOptionsV2 footerButton; + + public BeatmapOptionsPopover(FooterButtonOptionsV2 footerButton) + { + this.footerButton = footerButton; + } + + [BackgroundDependencyLoader] + private void load(ManageCollectionsDialog? manageCollectionsDialog, SongSelect? songSelect, OsuColour colours) + { + Content.Padding = new MarginPadding(5); + + Child = buttonFlow = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(3), + }; + + addButton(@"Manage collections", FontAwesome.Solid.Book, () => manageCollectionsDialog?.Show()); + addButton(@"Delete all difficulties", FontAwesome.Solid.Trash, () => songSelect?.DeleteBeatmap(), colours.Red); + addButton(@"Remove from unplayed", FontAwesome.Regular.TimesCircle, null); + addButton(@"Clear local scores", FontAwesome.Solid.Eraser, () => songSelect?.ClearScores()); + + if (songSelect != null && songSelect.AllowEditing) + addButton(@"Edit beatmap", FontAwesome.Solid.PencilAlt, () => songSelect.Edit()); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(this)); + } + + private void addButton(LocalisableString text, IconUsage icon, Action? action, Color4? colour = null) + { + var button = new OptionButton + { + Text = text, + Icon = icon, + TextColour = colour, + Action = () => + { + Hide(); + action?.Invoke(); + }, + }; + + buttonFlow.Add(button); + } + + private partial class OptionButton : OsuButton + { + public IconUsage Icon { get; init; } + public Color4? TextColour { get; init; } + + public OptionButton() + { + Size = new Vector2(265, 50); + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + BackgroundColour = colourProvider.Background3; + + SpriteText.Colour = TextColour ?? Color4.White; + Content.CornerRadius = 10; + + Add(new SpriteIcon + { + Blending = BlendingParameters.Additive, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Size = new Vector2(17), + X = 15, + Icon = Icon, + Colour = TextColour ?? Color4.White, + }); + } + + protected override SpriteText CreateText() => new OsuSpriteText + { + Depth = -1, + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + X = 40 + }; + } + + protected override bool OnKeyDown(KeyDownEvent e) + { + // don't absorb control as ToolbarRulesetSelector uses control + number to navigate + if (e.ControlPressed) return false; + + if (!e.Repeat && e.Key >= Key.Number1 && e.Key <= Key.Number9) + { + int requested = e.Key - Key.Number1; + + OptionButton? found = buttonFlow.Children.ElementAtOrDefault(requested); + + if (found != null) + { + found.TriggerClick(); + return true; + } + } + + return base.OnKeyDown(e); + } + + protected override void UpdateState(ValueChangedEvent state) + { + base.UpdateState(state); + + if (state.NewValue == Visibility.Hidden) + footerButton.IsActive.Value = false; + } + } +} diff --git a/osu.Game/Screens/Select/FooterV2/FooterButtonOptionsV2.cs b/osu.Game/Screens/Select/FooterV2/FooterButtonOptionsV2.cs index 87cca0042a..a1559d32dc 100644 --- a/osu.Game/Screens/Select/FooterV2/FooterButtonOptionsV2.cs +++ b/osu.Game/Screens/Select/FooterV2/FooterButtonOptionsV2.cs @@ -2,14 +2,21 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Extensions; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Input.Bindings; namespace osu.Game.Screens.Select.FooterV2 { - public partial class FooterButtonOptionsV2 : FooterButtonV2 + public partial class FooterButtonOptionsV2 : FooterButtonV2, IHasPopover { + public readonly BindableBool IsActive = new BindableBool(); + [BackgroundDependencyLoader] private void load(OsuColour colour) { @@ -17,6 +24,34 @@ namespace osu.Game.Screens.Select.FooterV2 Icon = FontAwesome.Solid.Cog; AccentColour = colour.Purple1; Hotkey = GlobalAction.ToggleBeatmapOptions; + + Action = () => IsActive.Toggle(); } + + protected override void LoadComplete() + { + base.LoadComplete(); + + IsActive.BindValueChanged(active => + { + OverlayState.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden; + }); + + OverlayState.BindValueChanged(state => + { + switch (state.NewValue) + { + case Visibility.Hidden: + this.HidePopover(); + break; + + case Visibility.Visible: + this.ShowPopover(); + break; + } + }); + } + + public Popover GetPopover() => new BeatmapOptionsPopover(this); } } diff --git a/osu.Game/Screens/Select/FooterV2/FooterV2.cs b/osu.Game/Screens/Select/FooterV2/FooterV2.cs index cd95f3eb6c..0529f0d082 100644 --- a/osu.Game/Screens/Select/FooterV2/FooterV2.cs +++ b/osu.Game/Screens/Select/FooterV2/FooterV2.cs @@ -48,11 +48,17 @@ namespace osu.Game.Screens.Select.FooterV2 private FillFlowContainer buttons = null!; - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) + public FooterV2() { RelativeSizeAxes = Axes.X; Height = height; + Anchor = Anchor.BottomLeft; + Origin = Anchor.BottomLeft; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { InternalChildren = new Drawable[] { new Box diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 58755878d0..4ce7a6167e 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -311,9 +311,9 @@ namespace osu.Game.Screens.Select Footer.AddButton(button, overlay); BeatmapOptions.AddButton(@"Manage", @"collections", FontAwesome.Solid.Book, colours.Green, () => manageCollectionsDialog?.Show()); - BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo)); + BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, DeleteBeatmap); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null); - BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo)); + BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, ClearScores); } sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty"); @@ -916,18 +916,18 @@ namespace osu.Game.Screens.Select return true; } - private void delete(BeatmapSetInfo? beatmap) + public void DeleteBeatmap() { - if (beatmap == null) return; + if (Beatmap.Value.BeatmapSetInfo == null) return; - dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); + dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap.Value.BeatmapSetInfo)); } - private void clearScores(BeatmapInfo? beatmapInfo) + public void ClearScores() { - if (beatmapInfo == null) return; + if (Beatmap.Value.BeatmapInfo == null) return; - dialogOverlay?.Push(new BeatmapClearScoresDialog(beatmapInfo, () => + dialogOverlay?.Push(new BeatmapClearScoresDialog(Beatmap.Value.BeatmapInfo, () => // schedule done here rather than inside the dialog as the dialog may fade out and never callback. Schedule(() => BeatmapDetails.Refresh()))); } @@ -963,7 +963,7 @@ namespace osu.Game.Screens.Select if (e.ShiftPressed) { if (!Beatmap.IsDefault) - delete(Beatmap.Value.BeatmapSetInfo); + DeleteBeatmap(); return true; } From 6c0bd13308589a8efcc2ba83738bc6ed0c2c6ca9 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 00:21:48 -0700 Subject: [PATCH 099/157] Add xmldoc to newly exposed methods --- osu.Game/Screens/Select/SongSelect.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4ce7a6167e..f6fc55b2a5 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -916,6 +916,9 @@ namespace osu.Game.Screens.Select return true; } + /// + /// Request to delete the current beatmap. + /// public void DeleteBeatmap() { if (Beatmap.Value.BeatmapSetInfo == null) return; @@ -923,6 +926,9 @@ namespace osu.Game.Screens.Select dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap.Value.BeatmapSetInfo)); } + /// + /// Request to clear the scores of the current beatmap. + /// public void ClearScores() { if (Beatmap.Value.BeatmapInfo == null) return; From f616648730ac9fd438cc2d15aeb7eb065f875cae Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 09:40:35 -0700 Subject: [PATCH 100/157] Remove icon blending --- osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs b/osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs index ec35c6ff38..4e1334fd11 100644 --- a/osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs +++ b/osu.Game/Screens/Select/FooterV2/BeatmapOptionsPopover.cs @@ -97,7 +97,6 @@ namespace osu.Game.Screens.Select.FooterV2 Add(new SpriteIcon { - Blending = BlendingParameters.Additive, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Size = new Vector2(17), From bf71099e5743efb966482d5b145a551b0208729f Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 11:34:21 -0700 Subject: [PATCH 101/157] Fix truncating sprite text usage --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index b7b60cffab..7821aa5be0 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -280,15 +280,14 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.X, Children = new Drawable[] { - TitleLabel = new OsuSpriteText + TitleLabel = new TruncatingSpriteText { Shadow = true, Current = { BindTarget = titleBinding }, Font = OsuFont.TorusAlternate.With(size: 40, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, - Truncate = true }, - ArtistLabel = new OsuSpriteText + ArtistLabel = new TruncatingSpriteText { // TODO : figma design has a diffused shadow, instead of the solid one present here, not possible currently as far as i'm aware. Shadow = true, @@ -296,7 +295,6 @@ namespace osu.Game.Screens.Select // Not sure if this should be semi bold or medium Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, - Truncate = true } } } From e8a793425bf28e19ba3667c8c712c4db96fc09fa Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 12:38:40 -0700 Subject: [PATCH 102/157] Use right padding instead of negative x offset --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 7821aa5be0..284f14cd9e 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -155,18 +155,21 @@ namespace osu.Game.Screens.Select LoadComponentAsync(loadingInfo = new Container { - Masking = true, - // We offset this by the portion of the colour bar underneath we wish to show - X = -colour_bar_width, - CornerRadius = corner_radius, + Padding = new MarginPadding { Right = colour_bar_width }, RelativeSizeAxes = Axes.Both, Depth = DisplayedContent?.Depth + 1 ?? 0, - Children = new Drawable[] + Child = new Container { - // TODO: New wedge design uses a coloured horizontal gradient for its background, however this lacks implementation information in the figma draft. - // pending https://www.figma.com/file/DXKwqZhD5yyb1igc3mKo1P?node-id=2980:3361#340801912 being answered. - new BeatmapInfoWedgeBackground(beatmap) { Shear = -Shear }, - Info = new WedgeInfoText(beatmap) { Shear = -Shear } + Masking = true, + CornerRadius = corner_radius, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + // TODO: New wedge design uses a coloured horizontal gradient for its background, however this lacks implementation information in the figma draft. + // pending https://www.figma.com/file/DXKwqZhD5yyb1igc3mKo1P?node-id=2980:3361#340801912 being answered. + new BeatmapInfoWedgeBackground(beatmap) { Shear = -Shear }, + Info = new WedgeInfoText(beatmap) { Shear = -Shear } + } } }, loaded => { From 2df20027355ddbf24bd43401ef5feabf5a7e1823 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 12:42:01 -0700 Subject: [PATCH 103/157] Move negative corner radius margin to constructor --- .../SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 16 ++++++++++------ osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index 09b93119cc..ae5b739c4d 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -50,13 +50,17 @@ namespace osu.Game.Tests.Visual.SongSelect RelativeSizeAxes = Axes.X, Margin = new MarginPadding { Top = 20, Left = -10 } }, - infoWedge = new TestBeatmapInfoWedgeV2 + new Container { - State = { Value = Visibility.Visible }, - Width = 0.6f, - RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Top = 20, Left = -10 } - }, + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 20 }, + Child = infoWedge = new TestBeatmapInfoWedgeV2 + { + State = { Value = Visibility.Visible }, + Width = 0.6f, + RelativeSizeAxes = Axes.X, + }, + } }); AddSliderStep("change star difficulty", 0, 11.9, 5.55, v => diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 284f14cd9e..742d9011b9 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -55,6 +55,7 @@ namespace osu.Game.Screens.Select Height = WEDGE_HEIGHT; Shear = wedged_container_shear; Masking = true; + Margin = new MarginPadding { Left = -corner_radius }; EdgeEffect = new EdgeEffectParameters { Colour = Colour4.Black.Opacity(0.2f), From e70510ef191ef345eee35b490a12118fbb29a755 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 12:56:20 -0700 Subject: [PATCH 104/157] Move drawable and binding logic to standard places --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 742d9011b9..de3e634819 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -46,9 +46,9 @@ namespace osu.Game.Screens.Select protected WedgeInfoText? Info { get; private set; } - private readonly Container difficultyColourBar; - private readonly StarCounter starCounter; - private readonly BufferedContainer bufferedContent; + private Container difficultyColourBar = null!; + private StarCounter starCounter = null!; + private BufferedContainer bufferedContent = null!; public BeatmapInfoWedgeV2() { @@ -63,7 +63,11 @@ namespace osu.Game.Screens.Select Radius = 3, }; CornerRadius = corner_radius; + } + [BackgroundDependencyLoader] + private void load() + { // We want to buffer the wedge to avoid weird transparency overlaps between the colour bar and the background. Child = bufferedContent = new BufferedContainer(pixelSnapping: true) { @@ -107,9 +111,10 @@ namespace osu.Game.Screens.Select }; } - [BackgroundDependencyLoader] - private void load() + protected override void LoadComplete() { + base.LoadComplete(); + ruleset.BindValueChanged(_ => updateDisplay()); } @@ -228,6 +233,8 @@ namespace osu.Game.Screens.Select public WedgeInfoText(WorkingBeatmap working) { this.working = working; + + RelativeSizeAxes = Axes.Both; } [BackgroundDependencyLoader] @@ -236,8 +243,6 @@ namespace osu.Game.Screens.Select var beatmapInfo = working.BeatmapInfo; var metadata = working.Metadata; - RelativeSizeAxes = Axes.Both; - titleBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.TitleUnicode, metadata.Title)); artistBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.ArtistUnicode, metadata.Artist)); From 82fb9dc2ef5eb03f2db25426f11a19f836e62f68 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 12:59:21 -0700 Subject: [PATCH 105/157] Simplify text initialization --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index de3e634819..fd655c50ca 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -212,9 +212,6 @@ namespace osu.Game.Screens.Select private StarRatingDisplay starRatingDisplay = null!; - private ILocalisedBindableString titleBinding = null!; - private ILocalisedBindableString artistBinding = null!; - private readonly WorkingBeatmap working; public IBindable DisplayedStars => starRatingDisplay.DisplayedStars; @@ -238,14 +235,11 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader] - private void load(LocalisationManager localisation) + private void load() { var beatmapInfo = working.BeatmapInfo; var metadata = working.Metadata; - titleBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.TitleUnicode, metadata.Title)); - artistBinding = localisation.GetLocalisedBindableString(new RomanisableString(metadata.ArtistUnicode, metadata.Artist)); - Children = new Drawable[] { new FillFlowContainer @@ -292,7 +286,7 @@ namespace osu.Game.Screens.Select TitleLabel = new TruncatingSpriteText { Shadow = true, - Current = { BindTarget = titleBinding }, + Text = new RomanisableString(metadata.TitleUnicode, metadata.Title), Font = OsuFont.TorusAlternate.With(size: 40, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, }, @@ -300,7 +294,7 @@ namespace osu.Game.Screens.Select { // TODO : figma design has a diffused shadow, instead of the solid one present here, not possible currently as far as i'm aware. Shadow = true, - Current = { BindTarget = artistBinding }, + Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist), // Not sure if this should be semi bold or medium Font = OsuFont.Torus.With(size: 20, weight: FontWeight.SemiBold), RelativeSizeAxes = Axes.X, From e0a9c7e9a9680004b98a8086354fb758b65daa51 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 14:54:58 -0700 Subject: [PATCH 106/157] Fix wedge showing abruptly in test --- osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index ae5b739c4d..3236841dc3 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -56,7 +56,6 @@ namespace osu.Game.Tests.Visual.SongSelect Padding = new MarginPadding { Top = 20 }, Child = infoWedge = new TestBeatmapInfoWedgeV2 { - State = { Value = Visibility.Visible }, Width = 0.6f, RelativeSizeAxes = Axes.X, }, @@ -165,6 +164,7 @@ namespace osu.Game.Tests.Visual.SongSelect { containerBefore = infoWedge.DisplayedContent; infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : CreateWorkingBeatmap(b); + infoWedge.Show(); }); AddUntilStep("wait for async load", () => infoWedge.DisplayedContent != containerBefore); From 854bb323cc09e0a296ebd2ca948e4a6074950044 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 15:02:00 -0700 Subject: [PATCH 107/157] Remove weird red edge effect visibility --- .../Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index 3236841dc3..827d23c0fc 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -7,7 +7,6 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; @@ -94,17 +93,6 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestWedgeVisibility() { - // Mostly just in case someone runs this test before others, - // leading to the shadow being very hard to see if it is black - AddStep("make shadow red for test visibility", () => - { - infoWedge.EdgeEffect = new EdgeEffectParameters - { - Colour = Colour4.Red, - Type = EdgeEffectType.Shadow, - Radius = 5, - }; - }); AddStep("hide", () => { infoWedge.Hide(); }); AddWaitStep("wait for hide", 3); AddAssert("check visibility", () => infoWedge.Alpha == 0); From 9accd0ded262e451792a10013762e442b5523441 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 15:02:38 -0700 Subject: [PATCH 108/157] Fix star rating rolling counter regression --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index fd655c50ca..5316b4620b 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -314,7 +314,7 @@ namespace osu.Game.Screens.Select starRatingDisplay.Current.Value = s.NewValue ?? default; // Don't roll the counter on initial display (but still allow it to roll on applying mods etc.) - if (starRatingDisplay.Alpha > 0) + if (!starRatingDisplay.IsPresent) starRatingDisplay.FinishTransforms(true); starRatingDisplay.FadeIn(transition_duration); From 98d027d207143532178e4588c279368abb391d8b Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 21:34:53 -0700 Subject: [PATCH 109/157] Fix star counter animating weird and delayed --- osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs index 5316b4620b..de930ff837 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs @@ -187,11 +187,16 @@ namespace osu.Game.Screens.Select Info.DisplayedStars.BindValueChanged(s => { - starCounter.Current = (float)s.NewValue; starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f); difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue)); }, true); + + Info.ActualStars.BindValueChanged(s => + { + // use actual stars as star counter has its own animation + starCounter.Current = (float)s.NewValue; + }); }); }); @@ -215,6 +220,7 @@ namespace osu.Game.Screens.Select private readonly WorkingBeatmap working; public IBindable DisplayedStars => starRatingDisplay.DisplayedStars; + public Bindable ActualStars = new Bindable(); [Resolved] private IBindable> mods { get; set; } = null!; @@ -312,6 +318,7 @@ namespace osu.Game.Screens.Select starDifficulty.BindValueChanged(s => { starRatingDisplay.Current.Value = s.NewValue ?? default; + ActualStars.Value = s.NewValue?.Stars ?? 0; // Don't roll the counter on initial display (but still allow it to roll on applying mods etc.) if (!starRatingDisplay.IsPresent) From 94516133912a4c32048dddc52c53fb9696bb0477 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 4 Sep 2023 21:39:26 -0700 Subject: [PATCH 110/157] Rename null beatmap test to indicate there's a background --- osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs index 827d23c0fc..a8484caf1c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedgeV2.cs @@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] - public void TestNullBeatmap() + public void TestNullBeatmapWithBackground() { selectBeatmap(null); AddAssert("check default title", () => infoWedge.Info!.TitleLabel.Current.Value == Beatmap.Default.BeatmapInfo.Metadata.Title); From 1215ad7ace400cb404121d9a8ead9ac81f2ad2a2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Sep 2023 15:40:00 +0900 Subject: [PATCH 111/157] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 2d15bce85a..2bfdce5ab8 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -10,7 +10,7 @@ true - +