mirror of
https://github.com/ppy/osu.git
synced 2025-02-27 14:03:13 +08:00
Merge remote-tracking branch 'upstream/master' into merge-global-to-legacy
This commit is contained in:
commit
453e1dd48c
@ -15,6 +15,10 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrawableManiaJudgement()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
@ -33,8 +34,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
public IReadOnlyList<Column> Columns => columnFlow.Children;
|
public IReadOnlyList<Column> Columns => columnFlow.Children;
|
||||||
private readonly FillFlowContainer<Column> columnFlow;
|
private readonly FillFlowContainer<Column> columnFlow;
|
||||||
|
|
||||||
public Container<DrawableManiaJudgement> Judgements => judgements;
|
|
||||||
private readonly JudgementContainer<DrawableManiaJudgement> judgements;
|
private readonly JudgementContainer<DrawableManiaJudgement> judgements;
|
||||||
|
private readonly DrawablePool<DrawableManiaJudgement> judgementPool;
|
||||||
|
|
||||||
private readonly Drawable barLineContainer;
|
private readonly Drawable barLineContainer;
|
||||||
private readonly Container topLevelContainer;
|
private readonly Container topLevelContainer;
|
||||||
@ -63,6 +64,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
judgementPool = new DrawablePool<DrawableManiaJudgement>(2),
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
@ -208,12 +210,14 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
|
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
judgements.Clear();
|
judgements.Clear(false);
|
||||||
judgements.Add(new DrawableManiaJudgement(result, judgedObject)
|
judgements.Add(judgementPool.Get(j =>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
j.Apply(result, judgedObject);
|
||||||
Origin = Anchor.Centre,
|
|
||||||
});
|
j.Anchor = Anchor.Centre;
|
||||||
|
j.Origin = Anchor.Centre;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -109,25 +109,58 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CancellationTokenSource trackedUpdateCancellationSource;
|
private CancellationTokenSource trackedUpdateCancellationSource;
|
||||||
|
private readonly List<CancellationTokenSource> linkedCancellationSources = new List<CancellationTokenSource>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates all tracked <see cref="BindableStarDifficulty"/> using the current ruleset and mods.
|
/// Updates all tracked <see cref="BindableStarDifficulty"/> using the current ruleset and mods.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void updateTrackedBindables()
|
private void updateTrackedBindables()
|
||||||
{
|
{
|
||||||
trackedUpdateCancellationSource?.Cancel();
|
cancelTrackedBindableUpdate();
|
||||||
trackedUpdateCancellationSource = new CancellationTokenSource();
|
trackedUpdateCancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
foreach (var b in trackedBindables)
|
foreach (var b in trackedBindables)
|
||||||
{
|
{
|
||||||
if (trackedUpdateCancellationSource.IsCancellationRequested)
|
var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(trackedUpdateCancellationSource.Token, b.CancellationToken);
|
||||||
break;
|
linkedCancellationSources.Add(linkedSource);
|
||||||
|
|
||||||
using (var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(trackedUpdateCancellationSource.Token, b.CancellationToken))
|
updateBindable(b, currentRuleset.Value, currentMods.Value, linkedSource.Token);
|
||||||
updateBindable(b, currentRuleset.Value, currentMods.Value, linkedSource.Token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cancels the existing update of all tracked <see cref="BindableStarDifficulty"/> via <see cref="updateTrackedBindables"/>.
|
||||||
|
/// </summary>
|
||||||
|
private void cancelTrackedBindableUpdate()
|
||||||
|
{
|
||||||
|
trackedUpdateCancellationSource?.Cancel();
|
||||||
|
trackedUpdateCancellationSource = null;
|
||||||
|
|
||||||
|
if (linkedCancellationSources != null)
|
||||||
|
{
|
||||||
|
foreach (var c in linkedCancellationSources)
|
||||||
|
c.Dispose();
|
||||||
|
|
||||||
|
linkedCancellationSources.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="BindableStarDifficulty"/> and triggers an initial value update.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatmapInfo">The <see cref="BeatmapInfo"/> that star difficulty should correspond to.</param>
|
||||||
|
/// <param name="initialRulesetInfo">The initial <see cref="RulesetInfo"/> to get the difficulty with.</param>
|
||||||
|
/// <param name="initialMods">The initial <see cref="Mod"/>s to get the difficulty with.</param>
|
||||||
|
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops updating the star difficulty for the given <see cref="BeatmapInfo"/>.</param>
|
||||||
|
/// <returns>The <see cref="BindableStarDifficulty"/>.</returns>
|
||||||
|
private BindableStarDifficulty createBindable([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo initialRulesetInfo, [CanBeNull] IEnumerable<Mod> initialMods,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var bindable = new BindableStarDifficulty(beatmapInfo, cancellationToken);
|
||||||
|
updateBindable(bindable, initialRulesetInfo, initialMods, cancellationToken);
|
||||||
|
return bindable;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the value of a <see cref="BindableStarDifficulty"/> with a given ruleset + mods.
|
/// Updates the value of a <see cref="BindableStarDifficulty"/> with a given ruleset + mods.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -148,22 +181,6 @@ namespace osu.Game.Beatmaps
|
|||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new <see cref="BindableStarDifficulty"/> and triggers an initial value update.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="beatmapInfo">The <see cref="BeatmapInfo"/> that star difficulty should correspond to.</param>
|
|
||||||
/// <param name="initialRulesetInfo">The initial <see cref="RulesetInfo"/> to get the difficulty with.</param>
|
|
||||||
/// <param name="initialMods">The initial <see cref="Mod"/>s to get the difficulty with.</param>
|
|
||||||
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops updating the star difficulty for the given <see cref="BeatmapInfo"/>.</param>
|
|
||||||
/// <returns>The <see cref="BindableStarDifficulty"/>.</returns>
|
|
||||||
private BindableStarDifficulty createBindable([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo initialRulesetInfo, [CanBeNull] IEnumerable<Mod> initialMods,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var bindable = new BindableStarDifficulty(beatmapInfo, cancellationToken);
|
|
||||||
updateBindable(bindable, initialRulesetInfo, initialMods, cancellationToken);
|
|
||||||
return bindable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes the difficulty defined by a <see cref="DifficultyCacheLookup"/> key, and stores it to the timed cache.
|
/// Computes the difficulty defined by a <see cref="DifficultyCacheLookup"/> key, and stores it to the timed cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -220,6 +237,14 @@ namespace osu.Game.Beatmaps
|
|||||||
return difficultyCache.TryGetValue(key, out existingDifficulty);
|
return difficultyCache.TryGetValue(key, out existingDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
cancelTrackedBindableUpdate();
|
||||||
|
updateScheduler?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private readonly struct DifficultyCacheLookup : IEquatable<DifficultyCacheLookup>
|
private readonly struct DifficultyCacheLookup : IEquatable<DifficultyCacheLookup>
|
||||||
{
|
{
|
||||||
public readonly int BeatmapId;
|
public readonly int BeatmapId;
|
||||||
|
Loading…
Reference in New Issue
Block a user