From 5d13efa76d6f4bb566b6c6c4d01d077059ae10bf Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 21 Aug 2017 16:14:44 +0900 Subject: [PATCH] Remove the concept of "queued hit objects", add a default speed adjustment. --- osu-framework | 2 +- osu.Game/Rulesets/UI/ScrollingPlayfield.cs | 52 +++++++++++----------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/osu-framework b/osu-framework index aba135ff83..92e1dc21c0 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit aba135ff83feabd9ca2e8e8075b811b64a9006ad +Subproject commit 92e1dc21c069a6b65ee71060f2f37f3f4180fd20 diff --git a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs index f8e090d613..b89f5e15c6 100644 --- a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs @@ -151,10 +151,6 @@ namespace osu.Game.Rulesets.UI /// public readonly BindableBool Reversed = new BindableBool(); - /// - /// Hit objects that are to be re-processed on the next update. - /// - private readonly List queuedHitObjects = new List(); private readonly Container speedAdjustments; private readonly Axes scrollingAxes; @@ -168,6 +164,9 @@ namespace osu.Game.Rulesets.UI this.scrollingAxes = scrollingAxes; AddInternal(speedAdjustments = new Container { RelativeSizeAxes = Axes.Both }); + + // Default speed adjustment + AddSpeedAdjustment(new SpeedAdjustmentContainer(new MultiplierControlPoint(0))); } /// @@ -180,6 +179,21 @@ namespace osu.Game.Rulesets.UI speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange); speedAdjustment.Reversed.BindTo(Reversed); speedAdjustments.Add(speedAdjustment); + + // We now need to re-sort the hit objects in the last speed adjustment prior to this one, to see if they need a new parent + var previousSpeedAdjustment = speedAdjustments.LastOrDefault(s => s.ControlPoint.StartTime < speedAdjustment.ControlPoint.StartTime); + if (previousSpeedAdjustment == null) + return; + + foreach (DrawableHitObject h in previousSpeedAdjustment.Children) + { + var newSpeedAdjustment = adjustmentContainerFor(h); + if (newSpeedAdjustment == previousSpeedAdjustment) + continue; + + previousSpeedAdjustment.Remove(h); + newSpeedAdjustment.Add(h); + } } public override IEnumerable Objects => speedAdjustments.SelectMany(s => s.Children); @@ -194,30 +208,14 @@ namespace osu.Game.Rulesets.UI if (!(hitObject is IScrollingHitObject)) throw new InvalidOperationException($"Hit objects added to a {nameof(ScrollingHitObjectContainer)} must implement {nameof(IScrollingHitObject)}."); - queuedHitObjects.Add(hitObject); + var target = adjustmentContainerFor(hitObject); + if (target == null) + throw new InvalidOperationException($"A {nameof(SpeedAdjustmentContainer)} to container {hitObject.ToString()} could not be found."); + + target.Add(hitObject); } - public override bool Remove(DrawableHitObject hitObject) => speedAdjustments.Any(s => s.Remove(hitObject)) || queuedHitObjects.Remove(hitObject); - - protected override void Update() - { - base.Update(); - - // Todo: At the moment this is going to re-process every single Update, however this will only be a null-op - // when there are no SpeedAdjustmentContainers available. This should probably error or something, but it's okay for now. - - for (int i = queuedHitObjects.Count - 1; i >= 0; i--) - { - var hitObject = queuedHitObjects[i]; - - var target = adjustmentContainerFor(hitObject); - if (target == null) - continue; - - target.Add(hitObject); - queuedHitObjects.RemoveAt(i); - } - } + public override bool Remove(DrawableHitObject hitObject) => speedAdjustments.Any(s => s.Remove(hitObject)); /// /// Finds the which provides the speed adjustment active at the start time @@ -237,4 +235,4 @@ namespace osu.Game.Rulesets.UI private SpeedAdjustmentContainer adjustmentContainerAt(double time) => speedAdjustments.FirstOrDefault(c => c.CanContain(time)) ?? speedAdjustments.LastOrDefault(); } } -} \ No newline at end of file +}