mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Allow determining a BeatmapDifficultyCache's bindable return's completion state via nullability
This commit is contained in:
parent
9f3ceb99eb
commit
03771ce8ec
@ -70,7 +70,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="beatmapInfo">The <see cref="BeatmapInfo"/> to get the difficulty of.</param>
|
/// <param name="beatmapInfo">The <see cref="BeatmapInfo"/> to get the difficulty of.</param>
|
||||||
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops updating the star difficulty for the given <see cref="BeatmapInfo"/>.</param>
|
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops updating the star difficulty for the given <see cref="BeatmapInfo"/>.</param>
|
||||||
/// <returns>A bindable that is updated to contain the star difficulty when it becomes available.</returns>
|
/// <returns>A bindable that is updated to contain the star difficulty when it becomes available.</returns>
|
||||||
public IBindable<StarDifficulty> GetBindableDifficulty([NotNull] BeatmapInfo beatmapInfo, CancellationToken cancellationToken = default)
|
public IBindable<StarDifficulty?> GetBindableDifficulty([NotNull] BeatmapInfo beatmapInfo, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var bindable = createBindable(beatmapInfo, currentRuleset.Value, currentMods.Value, cancellationToken);
|
var bindable = createBindable(beatmapInfo, currentRuleset.Value, currentMods.Value, cancellationToken);
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="mods">The <see cref="Mod"/>s to get the difficulty with. If <c>null</c>, no mods will be assumed.</param>
|
/// <param name="mods">The <see cref="Mod"/>s to get the difficulty with. If <c>null</c>, no mods will be assumed.</param>
|
||||||
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops updating the star difficulty for the given <see cref="BeatmapInfo"/>.</param>
|
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops updating the star difficulty for the given <see cref="BeatmapInfo"/>.</param>
|
||||||
/// <returns>A bindable that is updated to contain the star difficulty when it becomes available.</returns>
|
/// <returns>A bindable that is updated to contain the star difficulty when it becomes available.</returns>
|
||||||
public IBindable<StarDifficulty> GetBindableDifficulty([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo, [CanBeNull] IEnumerable<Mod> mods,
|
public IBindable<StarDifficulty?> GetBindableDifficulty([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo, [CanBeNull] IEnumerable<Mod> mods,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
=> createBindable(beatmapInfo, rulesetInfo, mods, cancellationToken);
|
=> createBindable(beatmapInfo, rulesetInfo, mods, cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -313,7 +313,7 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BindableStarDifficulty : Bindable<StarDifficulty>
|
private class BindableStarDifficulty : Bindable<StarDifficulty?>
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo Beatmap;
|
public readonly BeatmapInfo Beatmap;
|
||||||
public readonly CancellationToken CancellationToken;
|
public readonly CancellationToken CancellationToken;
|
||||||
|
@ -151,7 +151,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
this.mods = mods;
|
this.mods = mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBindable<StarDifficulty> localStarDifficulty;
|
private IBindable<StarDifficulty?> localStarDifficulty;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -160,7 +160,11 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
localStarDifficulty = ruleset != null
|
localStarDifficulty = ruleset != null
|
||||||
? difficultyCache.GetBindableDifficulty(beatmap, ruleset, mods, difficultyCancellation.Token)
|
? difficultyCache.GetBindableDifficulty(beatmap, ruleset, mods, difficultyCancellation.Token)
|
||||||
: difficultyCache.GetBindableDifficulty(beatmap, difficultyCancellation.Token);
|
: difficultyCache.GetBindableDifficulty(beatmap, difficultyCancellation.Token);
|
||||||
localStarDifficulty.BindValueChanged(difficulty => StarDifficulty.Value = difficulty.NewValue);
|
localStarDifficulty.BindValueChanged(d =>
|
||||||
|
{
|
||||||
|
if (d.NewValue is StarDifficulty diff)
|
||||||
|
StarDifficulty.Value = diff;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -137,7 +137,7 @@ namespace osu.Game.Scoring
|
|||||||
ScoringMode.BindValueChanged(onScoringModeChanged, true);
|
ScoringMode.BindValueChanged(onScoringModeChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBindable<StarDifficulty> difficultyBindable;
|
private IBindable<StarDifficulty?> difficultyBindable;
|
||||||
private CancellationTokenSource difficultyCancellationSource;
|
private CancellationTokenSource difficultyCancellationSource;
|
||||||
|
|
||||||
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
||||||
@ -168,7 +168,11 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
// We can compute the max combo locally after the async beatmap difficulty computation.
|
// We can compute the max combo locally after the async beatmap difficulty computation.
|
||||||
difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods, (difficultyCancellationSource = new CancellationTokenSource()).Token);
|
difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods, (difficultyCancellationSource = new CancellationTokenSource()).Token);
|
||||||
difficultyBindable.BindValueChanged(d => updateScore(d.NewValue.MaxCombo), true);
|
difficultyBindable.BindValueChanged(d =>
|
||||||
|
{
|
||||||
|
if (d.NewValue is StarDifficulty diff)
|
||||||
|
updateScore(diff.MaxCombo);
|
||||||
|
}, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Select
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapDifficultyCache difficultyCache { get; set; }
|
private BeatmapDifficultyCache difficultyCache { get; set; }
|
||||||
|
|
||||||
private IBindable<StarDifficulty> beatmapDifficulty;
|
private IBindable<StarDifficulty?> beatmapDifficulty;
|
||||||
|
|
||||||
protected BufferedWedgeInfo Info;
|
protected BufferedWedgeInfo Info;
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ namespace osu.Game.Screens.Select
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value, beatmapDifficulty.Value)
|
LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value, beatmapDifficulty.Value ?? new StarDifficulty())
|
||||||
{
|
{
|
||||||
Shear = -Shear,
|
Shear = -Shear,
|
||||||
Depth = Info?.Depth + 1 ?? 0
|
Depth = Info?.Depth + 1 ?? 0
|
||||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
||||||
|
|
||||||
private IBindable<StarDifficulty> starDifficultyBindable;
|
private IBindable<StarDifficulty?> starDifficultyBindable;
|
||||||
private CancellationTokenSource starDifficultyCancellationSource;
|
private CancellationTokenSource starDifficultyCancellationSource;
|
||||||
|
|
||||||
public DrawableCarouselBeatmap(CarouselBeatmap panel)
|
public DrawableCarouselBeatmap(CarouselBeatmap panel)
|
||||||
@ -217,7 +217,10 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
// We've potentially cancelled the computation above so a new bindable is required.
|
// We've potentially cancelled the computation above so a new bindable is required.
|
||||||
starDifficultyBindable = difficultyCache.GetBindableDifficulty(beatmap, (starDifficultyCancellationSource = new CancellationTokenSource()).Token);
|
starDifficultyBindable = difficultyCache.GetBindableDifficulty(beatmap, (starDifficultyCancellationSource = new CancellationTokenSource()).Token);
|
||||||
starDifficultyBindable.BindValueChanged(d => starCounter.Current = (float)d.NewValue.Stars, true);
|
starDifficultyBindable.BindValueChanged(d =>
|
||||||
|
{
|
||||||
|
starCounter.Current = (float)(d.NewValue?.Stars ?? 0);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
base.ApplyState();
|
base.ApplyState();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user