mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 16:42:55 +08:00
Removed BeatmapInfo in StarRatingDisplay
This commit is contained in:
parent
9fba87f67a
commit
d6928e91fd
@ -29,13 +29,19 @@ namespace osu.Game.Screens.Ranking.Expanded
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
private CircularContainer colorContainer;
|
||||
private CancellationTokenSource cancellationTokenSource;
|
||||
private IBindable<StarDifficulty?> bindableStarDifficulty;
|
||||
private OsuSpriteText wholePartText;
|
||||
private OsuSpriteText fractionPartText;
|
||||
private StarDifficulty starDifficulty;
|
||||
|
||||
private readonly StarDifficulty starDifficulty;
|
||||
private readonly BeatmapInfo beatmapInfo;
|
||||
public StarDifficulty StarDifficulty
|
||||
{
|
||||
get => starDifficulty;
|
||||
set
|
||||
{
|
||||
starDifficulty = value;
|
||||
setDifficulty(starDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StarRatingDisplay"/> using an already computed <see cref="StarDifficulty"/>.
|
||||
@ -46,15 +52,6 @@ namespace osu.Game.Screens.Ranking.Expanded
|
||||
this.starDifficulty = starDifficulty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StarRatingDisplay"/> using a <see cref="BeatmapInfo"/> to use a bindable for the difficulty.
|
||||
/// </summary>
|
||||
/// <param name="beatmapInfo">The <see cref="BeatmapInfo"/> to use to create a bindable for <see cref="StarDifficulty"/></param>
|
||||
public StarRatingDisplay(BeatmapInfo beatmapInfo)
|
||||
{
|
||||
this.beatmapInfo = beatmapInfo;
|
||||
}
|
||||
|
||||
private void setDifficulty(StarDifficulty difficulty)
|
||||
{
|
||||
var starRatingParts = difficulty.Stars.ToString("0.00", CultureInfo.InvariantCulture).Split('.');
|
||||
@ -71,21 +68,12 @@ namespace osu.Game.Screens.Ranking.Expanded
|
||||
wholePartText.Text = $"{wholePart}";
|
||||
fractionPartText.Text = $"{separator}{fractionPart}";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapDifficultyCache difficultyCache)
|
||||
{
|
||||
if (beatmapInfo != null)
|
||||
{
|
||||
cancellationTokenSource?.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
bindableStarDifficulty?.UnbindAll();
|
||||
bindableStarDifficulty = difficultyCache.GetBindableDifficulty(beatmapInfo, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
@ -144,16 +132,7 @@ namespace osu.Game.Screens.Ranking.Expanded
|
||||
}
|
||||
};
|
||||
|
||||
if (bindableStarDifficulty != null)
|
||||
bindableStarDifficulty.BindValueChanged(valueChanged => setDifficulty(valueChanged.NewValue ?? new StarDifficulty()), true);
|
||||
else
|
||||
setDifficulty(starDifficulty);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
cancellationTokenSource?.Cancel();
|
||||
setDifficulty(starDifficulty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ namespace osu.Game.Screens.Select
|
||||
private ILocalisedBindableString titleBinding;
|
||||
private ILocalisedBindableString artistBinding;
|
||||
private FillFlowContainer infoLabelContainer;
|
||||
private Drawable starRatingDisplay;
|
||||
private StarRatingDisplay starRatingDisplay;
|
||||
private Container bpmLabelContainer;
|
||||
private ModSettingChangeTracker settingChangeTracker;
|
||||
private CancellationTokenSource cancellationTokenSource;
|
||||
@ -246,9 +246,9 @@ namespace osu.Game.Screens.Select
|
||||
Padding = new MarginPadding { Top = 14, Right = shear_width / 2 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Shear = wedged_container_shear,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
starRatingDisplay = new StarRatingDisplay(beatmapInfo)
|
||||
starRatingDisplay = new StarRatingDisplay(starDifficulty.Value ?? new StarDifficulty())
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
@ -311,19 +311,21 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
titleBinding.BindValueChanged(_ => setMetadata(metadata.Source));
|
||||
artistBinding.BindValueChanged(_ => setMetadata(metadata.Source), true);
|
||||
starDifficulty.BindValueChanged(_ => setStarRatingDisplayVisibility(), true);
|
||||
starDifficulty.BindValueChanged(updateStarRatingDisplay, true);
|
||||
|
||||
// no difficulty means it can't have a status to show
|
||||
if (beatmapInfo.Version == null)
|
||||
StatusPill.Hide();
|
||||
}
|
||||
|
||||
private void setStarRatingDisplayVisibility()
|
||||
private void updateStarRatingDisplay(ValueChangedEvent<StarDifficulty?> valueChanged)
|
||||
{
|
||||
if (starDifficulty.Value.HasValue && starDifficulty.Value.Value.Stars > 0)
|
||||
if (valueChanged.NewValue.HasValue && valueChanged.NewValue.Value.Stars > 0)
|
||||
starRatingDisplay.Show();
|
||||
else
|
||||
starRatingDisplay.Hide();
|
||||
|
||||
starRatingDisplay.StarDifficulty = valueChanged.NewValue ?? new StarDifficulty();
|
||||
}
|
||||
|
||||
private InfoLabel[] getRulesetInfoLabels()
|
||||
|
Loading…
Reference in New Issue
Block a user