-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add star rating to the beatmap metadata in player loading screen #12717
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0f08c2a
Add star rating display underneath the beatmap metadata
frenzibyte 7b7e7a8
Allow null logo facade
frenzibyte 169a283
Add visual test scene
frenzibyte b4801fa
Pass ruleset info to constructor instead
frenzibyte 0410ede
Refactor `StarRatingDisplay` to be mutable with a current bindable
frenzibyte 4309006
Use `BeatmapDifficultyCache.GetBindableDifficulty(...)` instead
frenzibyte dca5efc
Remove no longer necessary ruleset info requirement
frenzibyte 26c0010
Fix test not handling 0 beatmap sets
frenzibyte d9605e8
Remove test scene description
frenzibyte 3575d98
Use regular test steps rather than one-time set up and scheduling
frenzibyte a75347c
Remove nullable facade logic
frenzibyte ca55287
Pass empty facade and replace random property with method instead
frenzibyte 655e8d3
Remove pattern-matching on nullable with simple `.HasValue`/`.Value`
frenzibyte c52f173
Apply further refactoring to star rating display UX-wise
frenzibyte f701c33
Add initial fade in to the metadata display
frenzibyte 8fba655
Allow changing ruleset during test
frenzibyte 0c973fe
Tidy up test scene
peppy 2b90bc4
Remove unnecessary ruleset switching steps
peppy b7acf9d
Make test work without manually clicking things
peppy 9ba412d
Add the osu! logo to the test scene
peppy 52ce16f
Merge branch 'master' into player-loader-star-rating
peppy 004ce95
Merge branch 'current-star-rating' into player-loader-star-rating
frenzibyte e0728a6
Make `BeatmapDifficultyCache.GetDifficultyAsync` virtual
frenzibyte db361ef
Add test beatmap difficulty cache with calc. blocking support
frenzibyte 0dc3bfd
Apply simple transforms to star rating display when ready if not
frenzibyte 93007c1
Merge branch 'current-star-rating' into player-loader-star-rating
frenzibyte 7c2fc9b
Update usage due to nullability removal
frenzibyte dc56250
Merge branch 'master' into player-loader-star-rating
peppy 34d1490
Remove null conditional
frenzibyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapMetadataDisplay.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// 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.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Utils; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets; | ||
using osu.Game.Rulesets.Mods; | ||
using osu.Game.Screens.Menu; | ||
using osu.Game.Screens.Play; | ||
using osuTK; | ||
|
||
namespace osu.Game.Tests.Visual.SongSelect | ||
{ | ||
public class TestSceneBeatmapMetadataDisplay : OsuTestScene | ||
{ | ||
private BeatmapMetadataDisplay display; | ||
|
||
[Resolved] | ||
private BeatmapManager manager { get; set; } | ||
|
||
[Cached(typeof(BeatmapDifficultyCache))] | ||
private readonly TestBeatmapDifficultyCache testDifficultyCache = new TestBeatmapDifficultyCache(); | ||
|
||
[Test] | ||
public void TestLocal([Values("Beatmap", "Some long title and stuff")] | ||
string title, | ||
[Values("Trial", "Some1's very hardest difficulty")] | ||
string version) | ||
{ | ||
showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap | ||
{ | ||
BeatmapInfo = | ||
{ | ||
Metadata = new BeatmapMetadata | ||
{ | ||
Title = title, | ||
}, | ||
Version = version, | ||
StarDifficulty = RNG.NextDouble(0, 10), | ||
} | ||
})); | ||
} | ||
|
||
[Test] | ||
public void TestDelayedStarRating() | ||
{ | ||
AddStep("block calculation", () => testDifficultyCache.BlockCalculation = true); | ||
|
||
showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap | ||
{ | ||
BeatmapInfo = | ||
{ | ||
Metadata = new BeatmapMetadata | ||
{ | ||
Title = "Heavy beatmap", | ||
}, | ||
Version = "10k objects", | ||
StarDifficulty = 99.99f, | ||
} | ||
})); | ||
|
||
AddStep("allow calculation", () => testDifficultyCache.BlockCalculation = false); | ||
} | ||
|
||
[Test] | ||
public void TestRandomFromDatabase() | ||
{ | ||
showMetadataForBeatmap(() => | ||
{ | ||
var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal); | ||
if (allBeatmapSets.Count == 0) | ||
return manager.DefaultBeatmap; | ||
|
||
var randomBeatmapSet = allBeatmapSets[RNG.Next(0, allBeatmapSets.Count - 1)]; | ||
var randomBeatmap = randomBeatmapSet.Beatmaps[RNG.Next(0, randomBeatmapSet.Beatmaps.Count - 1)]; | ||
|
||
return manager.GetWorkingBeatmap(randomBeatmap); | ||
}); | ||
} | ||
|
||
private void showMetadataForBeatmap(Func<WorkingBeatmap> getBeatmap) | ||
{ | ||
AddStep("setup display", () => | ||
{ | ||
var randomMods = Ruleset.Value.CreateInstance().GetAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList(); | ||
|
||
OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) }; | ||
|
||
Remove(testDifficultyCache); | ||
|
||
Children = new Drawable[] | ||
{ | ||
testDifficultyCache, | ||
display = new BeatmapMetadataDisplay(getBeatmap(), new Bindable<IReadOnlyList<Mod>>(randomMods), logo) | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Alpha = 0f, | ||
} | ||
}; | ||
|
||
display.FadeIn(400, Easing.OutQuint); | ||
}); | ||
|
||
AddWaitStep("wait a bit", 5); | ||
|
||
AddStep("finish loading", () => display.Loading = false); | ||
} | ||
|
||
private class TestBeatmapDifficultyCache : BeatmapDifficultyCache | ||
{ | ||
private TaskCompletionSource<bool> calculationBlocker; | ||
|
||
private bool blockCalculation; | ||
|
||
public bool BlockCalculation | ||
{ | ||
get => blockCalculation; | ||
set | ||
{ | ||
if (value == blockCalculation) | ||
return; | ||
|
||
blockCalculation = value; | ||
|
||
if (value) | ||
calculationBlocker = new TaskCompletionSource<bool>(); | ||
else | ||
calculationBlocker?.SetResult(false); | ||
} | ||
} | ||
|
||
public override async Task<StarDifficulty> GetDifficultyAsync(BeatmapInfo beatmapInfo, RulesetInfo rulesetInfo = null, IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default) | ||
{ | ||
if (blockCalculation) | ||
await calculationBlocker.Task; | ||
|
||
return await base.GetDifficultyAsync(beatmapInfo, rulesetInfo, mods, cancellationToken); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really not sure about adding more test scenes which depend on the local beatmaps to function correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added it to check how metadata would look on real local beatmaps, and I imagined it to be useful for others (especially when it comes to tweaking the design).
unless you think it's better not to rely on local databases all the time and always go with the option of adding programmatically written beatmaps.