mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 04:53:06 +08:00
Merge pull request #10576 from Game4all/song-select-wedge-dynamic-star-rating
This commit is contained in:
commit
8232bf1957
@ -18,13 +18,13 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 1.23 }),
|
new StarRatingDisplay(new StarDifficulty(1.23, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 2.34 }),
|
new StarRatingDisplay(new StarDifficulty(2.34, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 3.45 }),
|
new StarRatingDisplay(new StarDifficulty(3.45, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 4.56 }),
|
new StarRatingDisplay(new StarDifficulty(4.56, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 5.67 }),
|
new StarRatingDisplay(new StarDifficulty(5.67, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 6.78 }),
|
new StarRatingDisplay(new StarDifficulty(6.78, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 10.11 }),
|
new StarRatingDisplay(new StarDifficulty(10.11, 0)),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -51,7 +52,7 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(BeatmapDifficultyManager beatmapDifficultyManager)
|
||||||
{
|
{
|
||||||
var beatmap = score.Beatmap;
|
var beatmap = score.Beatmap;
|
||||||
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
||||||
@ -138,7 +139,7 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
Spacing = new Vector2(5, 0),
|
Spacing = new Vector2(5, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new StarRatingDisplay(beatmap)
|
new StarRatingDisplay(beatmapDifficultyManager.GetDifficulty(beatmap, score.Ruleset, score.Mods))
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft
|
Origin = Anchor.CentreLeft
|
||||||
|
@ -22,29 +22,30 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class StarRatingDisplay : CompositeDrawable
|
public class StarRatingDisplay : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly StarDifficulty difficulty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="StarRatingDisplay"/>.
|
/// Creates a new <see cref="StarRatingDisplay"/> using an already computed <see cref="StarDifficulty"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The <see cref="BeatmapInfo"/> to display the star difficulty of.</param>
|
/// <param name="starDifficulty">The already computed <see cref="StarDifficulty"/> to display the star difficulty of.</param>
|
||||||
public StarRatingDisplay(BeatmapInfo beatmap)
|
public StarRatingDisplay(StarDifficulty starDifficulty)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
difficulty = starDifficulty;
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours, BeatmapDifficultyManager difficultyManager)
|
||||||
{
|
{
|
||||||
var starRatingParts = beatmap.StarDifficulty.ToString("0.00", CultureInfo.InvariantCulture).Split('.');
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
var starRatingParts = difficulty.Stars.ToString("0.00", CultureInfo.InvariantCulture).Split('.');
|
||||||
string wholePart = starRatingParts[0];
|
string wholePart = starRatingParts[0];
|
||||||
string fractionPart = starRatingParts[1];
|
string fractionPart = starRatingParts[1];
|
||||||
string separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
string separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||||
|
|
||||||
ColourInfo backgroundColour = beatmap.DifficultyRating == DifficultyRating.ExpertPlus
|
ColourInfo backgroundColour = difficulty.DifficultyRating == DifficultyRating.ExpertPlus
|
||||||
? ColourInfo.GradientVertical(Color4Extensions.FromHex("#C1C1C1"), Color4Extensions.FromHex("#595959"))
|
? ColourInfo.GradientVertical(Color4Extensions.FromHex("#C1C1C1"), Color4Extensions.FromHex("#595959"))
|
||||||
: (ColourInfo)colours.ForDifficultyRating(beatmap.DifficultyRating);
|
: (ColourInfo)colours.ForDifficultyRating(difficulty.DifficultyRating);
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,11 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapDifficultyManager difficultyManager { get; set; }
|
||||||
|
|
||||||
|
private IBindable<StarDifficulty> beatmapDifficulty;
|
||||||
|
|
||||||
protected BufferedWedgeInfo Info;
|
protected BufferedWedgeInfo Info;
|
||||||
|
|
||||||
public BeatmapInfoWedge()
|
public BeatmapInfoWedge()
|
||||||
@ -88,6 +93,11 @@ namespace osu.Game.Screens.Select
|
|||||||
if (beatmap == value) return;
|
if (beatmap == value) return;
|
||||||
|
|
||||||
beatmap = value;
|
beatmap = value;
|
||||||
|
|
||||||
|
beatmapDifficulty?.UnbindAll();
|
||||||
|
beatmapDifficulty = difficultyManager.GetBindableDifficulty(beatmap.BeatmapInfo);
|
||||||
|
beatmapDifficulty.BindValueChanged(_ => updateDisplay());
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +123,7 @@ namespace osu.Game.Screens.Select
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value)
|
LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value, beatmapDifficulty.Value)
|
||||||
{
|
{
|
||||||
Shear = -Shear,
|
Shear = -Shear,
|
||||||
Depth = Info?.Depth + 1 ?? 0
|
Depth = Info?.Depth + 1 ?? 0
|
||||||
@ -141,12 +151,14 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly WorkingBeatmap beatmap;
|
private readonly WorkingBeatmap beatmap;
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
|
private readonly StarDifficulty starDifficulty;
|
||||||
|
|
||||||
public BufferedWedgeInfo(WorkingBeatmap beatmap, RulesetInfo userRuleset)
|
public BufferedWedgeInfo(WorkingBeatmap beatmap, RulesetInfo userRuleset, StarDifficulty difficulty)
|
||||||
: base(pixelSnapping: true)
|
: base(pixelSnapping: true)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset;
|
ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset;
|
||||||
|
starDifficulty = difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -190,7 +202,7 @@ namespace osu.Game.Screens.Select
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new DifficultyColourBar(beatmapInfo)
|
new DifficultyColourBar(starDifficulty)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = 20,
|
Width = 20,
|
||||||
@ -226,7 +238,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Shear = wedged_container_shear,
|
Shear = wedged_container_shear,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
createStarRatingDisplay(beatmapInfo).With(display =>
|
createStarRatingDisplay(starDifficulty).With(display =>
|
||||||
{
|
{
|
||||||
display.Anchor = Anchor.TopRight;
|
display.Anchor = Anchor.TopRight;
|
||||||
display.Origin = Anchor.TopRight;
|
display.Origin = Anchor.TopRight;
|
||||||
@ -293,8 +305,8 @@ namespace osu.Game.Screens.Select
|
|||||||
StatusPill.Hide();
|
StatusPill.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable createStarRatingDisplay(BeatmapInfo beatmapInfo) => beatmapInfo.StarDifficulty > 0
|
private static Drawable createStarRatingDisplay(StarDifficulty difficulty) => difficulty.Stars > 0
|
||||||
? new StarRatingDisplay(beatmapInfo)
|
? new StarRatingDisplay(difficulty)
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Bottom = 5 }
|
Margin = new MarginPadding { Bottom = 5 }
|
||||||
}
|
}
|
||||||
@ -447,11 +459,11 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private class DifficultyColourBar : Container
|
private class DifficultyColourBar : Container
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly StarDifficulty difficulty;
|
||||||
|
|
||||||
public DifficultyColourBar(BeatmapInfo beatmap)
|
public DifficultyColourBar(StarDifficulty difficulty)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.difficulty = difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -459,7 +471,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
const float full_opacity_ratio = 0.7f;
|
const float full_opacity_ratio = 0.7f;
|
||||||
|
|
||||||
var difficultyColour = colours.ForDifficultyRating(beatmap.DifficultyRating);
|
var difficultyColour = colours.ForDifficultyRating(difficulty.DifficultyRating);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user