1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-28 03:15:08 +08:00

We don't need to use Cached just yet.

This was here to support dynamic re-ordering of hit objects and speed adjustment containers, however there needs to be more work done to TimingControlPoints/MultiplierControlPoints in general before this is possible.
This commit is contained in:
smoogipooo 2017-06-16 10:53:02 +09:00
parent 5d7336b235
commit 41c6140435

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Caching;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -36,8 +35,6 @@ namespace osu.Game.Rulesets.Timing
protected override IComparer<Drawable> DepthComparer => new SpeedAdjustmentContainerReverseStartTimeComparer(); protected override IComparer<Drawable> DepthComparer => new SpeedAdjustmentContainerReverseStartTimeComparer();
private Cached layout = new Cached();
/// <summary> /// <summary>
/// Hit objects that are to be re-processed when <see cref="layout"/> is invalidated. /// Hit objects that are to be re-processed when <see cref="layout"/> is invalidated.
/// </summary> /// </summary>
@ -51,13 +48,11 @@ namespace osu.Game.Rulesets.Timing
public void Add(DrawableHitObject hitObject) public void Add(DrawableHitObject hitObject)
{ {
queuedHitObjects.Enqueue(hitObject); queuedHitObjects.Enqueue(hitObject);
layout.Invalidate();
} }
public override void Add(SpeedAdjustmentContainer speedAdjustment) public override void Add(SpeedAdjustmentContainer speedAdjustment)
{ {
speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange); speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange);
layout.Invalidate();
base.Add(speedAdjustment); base.Add(speedAdjustment);
} }
@ -65,31 +60,25 @@ namespace osu.Game.Rulesets.Timing
{ {
base.Update(); base.Update();
if (!layout.IsValid) // An external count is kept because hit objects that can't be added are re-queued
int count = queuedHitObjects.Count;
while (count-- > 0)
{ {
layout.Refresh(() => var hitObject = queuedHitObjects.Dequeue();
var target = adjustmentContainerFor(hitObject);
if (target == null)
{ {
// An external count is kept because hit objects that can't be added are re-queued // We can't add this hit object to a speed adjustment container yet, so re-queue it
int count = queuedHitObjects.Count; // for re-processing when the layout next invalidated
while (count-- > 0) queuedHitObjects.Enqueue(hitObject);
{ continue;
var hitObject = queuedHitObjects.Dequeue(); }
var target = adjustmentContainerFor(hitObject); if (hitObject.RelativePositionAxes != target.ScrollingAxes)
if (target == null) throw new InvalidOperationException($"Make sure to set all {nameof(DrawableHitObject)}'s {nameof(RelativePositionAxes)} are equal to the correct axes of scrolling ({target.ScrollingAxes}).");
{
// We can't add this hit object to a speed adjustment container yet, so re-queue it
// for re-processing when the layout next invalidated
queuedHitObjects.Enqueue(hitObject);
continue;
}
if (hitObject.RelativePositionAxes != target.ScrollingAxes) target.Add(hitObject);
throw new InvalidOperationException($"Make sure to set all {nameof(DrawableHitObject)}'s {nameof(RelativePositionAxes)} are equal to the correct axes of scrolling ({target.ScrollingAxes}).");
target.Add(hitObject);
}
});
} }
} }