1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Add star rating display underneath the beatmap metadata

This commit is contained in:
Salman Ahmed 2021-05-08 11:44:29 +03:00
parent fc04b88e1a
commit 0f08c2a479

View File

@ -12,8 +12,10 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Ranking.Expanded;
using osuTK; using osuTK;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
@ -30,6 +32,9 @@ namespace osu.Game.Screens.Play
public IBindable<IReadOnlyList<Mod>> Mods => mods; public IBindable<IReadOnlyList<Mod>> Mods => mods;
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
public bool Loading public bool Loading
{ {
set set
@ -51,10 +56,12 @@ namespace osu.Game.Screens.Play
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(BeatmapDifficultyCache difficultyCache)
{ {
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata(); var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
var starDifficulty = difficultyCache.GetDifficultyAsync(beatmap.BeatmapInfo, ruleset.Value, mods.Value).Result;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -107,16 +114,29 @@ namespace osu.Game.Screens.Play
loading = new LoadingLayer(true) loading = new LoadingLayer(true)
} }
}, },
new OsuSpriteText new FillFlowContainer
{ {
Text = beatmap?.BeatmapInfo?.Version, AutoSizeAxes = Axes.Both,
Font = OsuFont.GetFont(size: 26, italics: true),
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Margin = new MarginPadding Origin = Anchor.TopCentre,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5f),
Margin = new MarginPadding { Bottom = 40 },
Children = new Drawable[]
{ {
Bottom = 40 new OsuSpriteText
}, {
Text = beatmap?.BeatmapInfo?.Version,
Font = OsuFont.GetFont(size: 26, italics: true),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
new StarRatingDisplay(starDifficulty)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}
}
}, },
new GridContainer new GridContainer
{ {