mirror of
https://github.com/ppy/osu.git
synced 2026-05-13 20:33:35 +08:00
08c02e29b9
Also fixes wrong rank showing briefly in some scenarios. --- I'm quite confused why the overhead is in the post-async-filter collection access, but it is. It occurs when using `MaxBy` (realm snapshot creation), but also when calling `.Count` on the collection, or even just accessing `sender[0]`. I tried everything, and ended up settling on simplifying the realm part enough that we can do post-filtering without much sweat or mess. Before: https://github.com/user-attachments/assets/59aed895-03ed-4923-9515-9a5426156f7e After: https://github.com/user-attachments/assets/9a37f34a-c955-45bf-877f-89f248d8ea72 Tested using [this realm](https://screvillshot.s-ul.eu/YJUJ4SR1). - Closes https://github.com/ppy/osu/issues/37574. - Closes https://github.com/ppy/osu/issues/37661.
137 lines
4.5 KiB
C#
137 lines
4.5 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Extensions;
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Testing;
|
|
using osu.Framework.Utils;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Graphics.Carousel;
|
|
using osu.Game.Graphics.Cursor;
|
|
using osu.Game.Online.Leaderboards;
|
|
using osu.Game.Overlays;
|
|
using osu.Game.Rulesets.Mania;
|
|
using osu.Game.Rulesets.Osu;
|
|
using osu.Game.Scoring;
|
|
using osu.Game.Screens.Select;
|
|
using osu.Game.Tests.Resources;
|
|
using osu.Game.Tests.Visual.UserInterface;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Tests.Visual.SongSelect
|
|
{
|
|
public partial class TestScenePanelBeatmap : ThemeComparisonTestScene
|
|
{
|
|
[Resolved]
|
|
private BeatmapManager beatmaps { get; set; } = null!;
|
|
|
|
private BeatmapInfo beatmap = null!;
|
|
|
|
public TestScenePanelBeatmap()
|
|
: base(false)
|
|
{
|
|
}
|
|
|
|
[SetUp]
|
|
public void SetUp() => Schedule(() =>
|
|
{
|
|
var beatmapSet = beatmaps.GetAllUsableBeatmapSets().FirstOrDefault(b => b.OnlineID == 241526)
|
|
?? beatmaps.GetAllUsableBeatmapSets().FirstOrDefault(b => !b.Protected)
|
|
?? TestResources.CreateTestBeatmapSetInfo();
|
|
|
|
beatmap = beatmapSet.Beatmaps.First();
|
|
});
|
|
|
|
[Test]
|
|
public void TestDisplay()
|
|
{
|
|
AddStep("display", () => CreateThemedContent(OverlayColourScheme.Aquamarine));
|
|
}
|
|
|
|
[Test]
|
|
public void TestRandomBeatmap()
|
|
{
|
|
AddStep("random beatmap", () =>
|
|
{
|
|
var randomSet = beatmaps.GetAllUsableBeatmapSets().MinBy(_ => RNG.Next());
|
|
randomSet ??= TestResources.CreateTestBeatmapSetInfo();
|
|
beatmap = randomSet.Beatmaps.MinBy(_ => RNG.Next())!;
|
|
|
|
CreateThemedContent(OverlayColourScheme.Aquamarine);
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void TestManiaRuleset()
|
|
{
|
|
AddToggleStep("mania ruleset", v => Ruleset.Value = v ? new ManiaRuleset().RulesetInfo : new OsuRuleset().RulesetInfo);
|
|
}
|
|
|
|
[Test]
|
|
public void TestLocalRank()
|
|
{
|
|
AddStep("set null rank", () => this.ChildrenOfType<UpdateableRank>().ForEach(p =>
|
|
{
|
|
p.Hide();
|
|
p.Rank = null;
|
|
}));
|
|
|
|
foreach (var rank in Enum.GetValues<ScoreRank>())
|
|
{
|
|
AddStep($"set {rank.GetDescription()} rank", () => this.ChildrenOfType<UpdateableRank>().ForEach(p =>
|
|
{
|
|
p.Show();
|
|
p.Rank = rank;
|
|
}));
|
|
}
|
|
}
|
|
|
|
protected override Drawable CreateContent()
|
|
{
|
|
return new OsuContextMenuContainer
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Child = new FillFlowContainer
|
|
{
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Width = 0.5f,
|
|
RelativeSizeAxes = Axes.X,
|
|
AutoSizeAxes = Axes.Y,
|
|
Direction = FillDirection.Vertical,
|
|
Spacing = new Vector2(0f, 5f),
|
|
Children = new Drawable[]
|
|
{
|
|
new PanelBeatmap
|
|
{
|
|
Item = new CarouselItem(new GroupedBeatmap(null, beatmap))
|
|
},
|
|
new PanelBeatmap
|
|
{
|
|
Item = new CarouselItem(new GroupedBeatmap(null, beatmap)),
|
|
KeyboardSelected = { Value = true }
|
|
},
|
|
new PanelBeatmap
|
|
{
|
|
Item = new CarouselItem(new GroupedBeatmap(null, beatmap)),
|
|
Selected = { Value = true }
|
|
},
|
|
new PanelBeatmap
|
|
{
|
|
Item = new CarouselItem(new GroupedBeatmap(null, beatmap)),
|
|
KeyboardSelected = { Value = true },
|
|
Selected = { Value = true }
|
|
},
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|