From b40c31af3adc922d2c47ecd0f810e179aece085f Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 17 Oct 2024 20:36:15 +0900 Subject: [PATCH] Store difficulty to reduce flickering The computation usually finishes in a few milliseconds anyway. --- osu.Game/Skinning/Components/BeatmapAttributeText.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Skinning/Components/BeatmapAttributeText.cs b/osu.Game/Skinning/Components/BeatmapAttributeText.cs index ccee90410e..316b20035c 100644 --- a/osu.Game/Skinning/Components/BeatmapAttributeText.cs +++ b/osu.Game/Skinning/Components/BeatmapAttributeText.cs @@ -51,6 +51,7 @@ namespace osu.Game.Skinning.Components private IBindable? difficultyBindable; private CancellationTokenSource? difficultyCancellationSource; private ModSettingChangeTracker? modSettingTracker; + private StarDifficulty? starDifficulty; public BeatmapAttributeText() { @@ -80,7 +81,11 @@ namespace osu.Game.Skinning.Components difficultyBindable?.UnbindAll(); difficultyBindable = difficultyCache.GetBindableDifficulty(b.NewValue.BeatmapInfo, difficultyCancellationSource.Token); - difficultyBindable.BindValueChanged(_ => updateText()); + difficultyBindable.BindValueChanged(d => + { + starDifficulty = d.NewValue; + updateText(); + }); updateText(); }, true); @@ -213,9 +218,7 @@ namespace osu.Game.Skinning.Components return computeDifficulty().ApproachRate.ToLocalisableString(@"F2"); case BeatmapAttribute.StarRating: - return difficultyBindable?.Value is StarDifficulty starDifficulty - ? starDifficulty.Stars.ToLocalisableString(@"F2") - : @"..."; + return (starDifficulty?.Stars ?? 0).ToLocalisableString(@"F2"); default: throw new ArgumentOutOfRangeException();