Skip to content

Commit

Permalink
Merge pull request #28936 from frenzibyte/fix-beatmap-atttributes-dis…
Browse files Browse the repository at this point in the history
…play

Fix degraded performance when changing mod settings on a large beatmap
  • Loading branch information
bdach committed Jul 19, 2024
2 parents 124bc9c + a06bcd7 commit da4d37c
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ protected override void LoadComplete()
updateValues();
}, true);

BeatmapInfo.BindValueChanged(_ => updateValues());

Collapsed.BindValueChanged(_ =>
{
// Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation.
Expand All @@ -120,12 +118,32 @@ protected override void LoadComplete()
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();
Expand Down Expand Up @@ -154,17 +172,6 @@ private void updateValues() => Scheduler.AddOnce(() =>
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);
Expand Down

0 comments on commit da4d37c

Please sign in to comment.