1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 14:37:30 +08:00

Store difficulty to reduce flickering

The computation usually finishes in a few milliseconds anyway.
This commit is contained in:
Dan Balasescu 2024-10-17 20:36:15 +09:00
parent f9a9ceb41c
commit b40c31af3a
No known key found for this signature in database

View File

@ -51,6 +51,7 @@ namespace osu.Game.Skinning.Components
private IBindable<StarDifficulty?>? 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();