1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 18:27:26 +08:00

Fix beatmap attributes display in mod select recreating star difficulty bindable every setting change

This commit is contained in:
Salman Ahmed 2024-07-19 03:25:12 +03:00
parent 868604ca04
commit 2ad8eeb918

View File

@ -108,8 +108,6 @@ namespace osu.Game.Overlays.Mods
updateValues();
}, true);
BeatmapInfo.BindValueChanged(_ => updateValues());
Collapsed.BindValueChanged(_ =>
{
// Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation.
@ -120,12 +118,32 @@ namespace osu.Game.Overlays.Mods
GameRuleset = game.Ruleset.GetBoundCopy();
GameRuleset.BindValueChanged(_ => updateValues());
BeatmapInfo.BindValueChanged(_ => updateValues());
BeatmapInfo.BindValueChanged(_ =>
{
updateStarDifficultyBindable();
updateValues();
}, true);
updateValues();
updateCollapsedState();
}
private void updateStarDifficultyBindable()
{
cancellationSource?.Cancel();
if (BeatmapInfo.Value == null)
return;
starDifficulty = difficultyCache.GetBindableDifficulty(BeatmapInfo.Value, (cancellationSource = new CancellationTokenSource()).Token);
starDifficulty.BindValueChanged(s =>
{
starRatingDisplay.Current.Value = s.NewValue ?? default;
if (!starRatingDisplay.IsPresent)
starRatingDisplay.FinishTransforms(true);
});
}
protected override bool OnHover(HoverEvent e)
{
startAnimating();
@ -154,17 +172,6 @@ namespace osu.Game.Overlays.Mods
if (BeatmapInfo.Value == null)
return;
cancellationSource?.Cancel();
starDifficulty = difficultyCache.GetBindableDifficulty(BeatmapInfo.Value, (cancellationSource = new CancellationTokenSource()).Token);
starDifficulty.BindValueChanged(s =>
{
starRatingDisplay.Current.Value = s.NewValue ?? default;
if (!starRatingDisplay.IsPresent)
starRatingDisplay.FinishTransforms(true);
});
double rate = ModUtils.CalculateRateWithMods(Mods.Value);
bpmDisplay.Current.Value = FormatUtils.RoundBPM(BeatmapInfo.Value.BPM, rate);