diff --git a/osu.Android.props b/osu.Android.props
index aaac6ec427..5b200ee104 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -52,6 +52,6 @@
-
+
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
index f1750f4a01..d569d68b59 100644
--- a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs
@@ -45,6 +45,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
new Container
{
RelativeSizeAxes = Axes.Both,
+ Masking = true,
BorderThickness = 1,
BorderColour = colours.Yellow,
Child = new Box
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOutOfOrderHits.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOutOfOrderHits.cs
new file mode 100644
index 0000000000..d6858f831e
--- /dev/null
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOutOfOrderHits.cs
@@ -0,0 +1,412 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Extensions.TypeExtensions;
+using osu.Framework.Screens;
+using osu.Framework.Utils;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Replays;
+using osu.Game.Rulesets.Judgements;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Objects.Types;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Rulesets.Osu.Replays;
+using osu.Game.Rulesets.Replays;
+using osu.Game.Rulesets.Scoring;
+using osu.Game.Scoring;
+using osu.Game.Screens.Play;
+using osu.Game.Tests.Visual;
+using osuTK;
+
+namespace osu.Game.Rulesets.Osu.Tests
+{
+ public class TestSceneOutOfOrderHits : RateAdjustedBeatmapTestScene
+ {
+ private const double early_miss_window = 1000; // time after -1000 to -500 is considered a miss
+ private const double late_miss_window = 500; // time after +500 is considered a miss
+
+ ///
+ /// Tests clicking a future circle before the first circle's start time, while the first circle HAS NOT been judged.
+ ///
+ [Test]
+ public void TestClickSecondCircleBeforeFirstCircleTime()
+ {
+ const double time_first_circle = 1500;
+ const double time_second_circle = 1600;
+ Vector2 positionFirstCircle = Vector2.Zero;
+ Vector2 positionSecondCircle = new Vector2(80);
+
+ var hitObjects = new List
+ {
+ new TestHitCircle
+ {
+ StartTime = time_first_circle,
+ Position = positionFirstCircle
+ },
+ new TestHitCircle
+ {
+ StartTime = time_second_circle,
+ Position = positionSecondCircle
+ }
+ };
+
+ performTest(hitObjects, new List
+ {
+ new OsuReplayFrame { Time = time_first_circle - 100, Position = positionSecondCircle, Actions = { OsuAction.LeftButton } }
+ });
+
+ addJudgementAssert(hitObjects[0], HitResult.Miss);
+ addJudgementAssert(hitObjects[1], HitResult.Miss);
+ addJudgementOffsetAssert(hitObjects[0], late_miss_window);
+ }
+
+ ///
+ /// Tests clicking a future circle at the first circle's start time, while the first circle HAS NOT been judged.
+ ///
+ [Test]
+ public void TestClickSecondCircleAtFirstCircleTime()
+ {
+ const double time_first_circle = 1500;
+ const double time_second_circle = 1600;
+ Vector2 positionFirstCircle = Vector2.Zero;
+ Vector2 positionSecondCircle = new Vector2(80);
+
+ var hitObjects = new List
+ {
+ new TestHitCircle
+ {
+ StartTime = time_first_circle,
+ Position = positionFirstCircle
+ },
+ new TestHitCircle
+ {
+ StartTime = time_second_circle,
+ Position = positionSecondCircle
+ }
+ };
+
+ performTest(hitObjects, new List
+ {
+ new OsuReplayFrame { Time = time_first_circle, Position = positionSecondCircle, Actions = { OsuAction.LeftButton } }
+ });
+
+ addJudgementAssert(hitObjects[0], HitResult.Miss);
+ addJudgementAssert(hitObjects[1], HitResult.Great);
+ addJudgementOffsetAssert(hitObjects[0], 0);
+ }
+
+ ///
+ /// Tests clicking a future circle after the first circle's start time, while the first circle HAS NOT been judged.
+ ///
+ [Test]
+ public void TestClickSecondCircleAfterFirstCircleTime()
+ {
+ const double time_first_circle = 1500;
+ const double time_second_circle = 1600;
+ Vector2 positionFirstCircle = Vector2.Zero;
+ Vector2 positionSecondCircle = new Vector2(80);
+
+ var hitObjects = new List
+ {
+ new TestHitCircle
+ {
+ StartTime = time_first_circle,
+ Position = positionFirstCircle
+ },
+ new TestHitCircle
+ {
+ StartTime = time_second_circle,
+ Position = positionSecondCircle
+ }
+ };
+
+ performTest(hitObjects, new List
+ {
+ new OsuReplayFrame { Time = time_first_circle + 100, Position = positionSecondCircle, Actions = { OsuAction.LeftButton } }
+ });
+
+ addJudgementAssert(hitObjects[0], HitResult.Miss);
+ addJudgementAssert(hitObjects[1], HitResult.Great);
+ addJudgementOffsetAssert(hitObjects[0], 100);
+ }
+
+ ///
+ /// Tests clicking a future circle before the first circle's start time, while the first circle HAS been judged.
+ ///
+ [Test]
+ public void TestClickSecondCircleBeforeFirstCircleTimeWithFirstCircleJudged()
+ {
+ const double time_first_circle = 1500;
+ const double time_second_circle = 1600;
+ Vector2 positionFirstCircle = Vector2.Zero;
+ Vector2 positionSecondCircle = new Vector2(80);
+
+ var hitObjects = new List
+ {
+ new TestHitCircle
+ {
+ StartTime = time_first_circle,
+ Position = positionFirstCircle
+ },
+ new TestHitCircle
+ {
+ StartTime = time_second_circle,
+ Position = positionSecondCircle
+ }
+ };
+
+ performTest(hitObjects, new List
+ {
+ new OsuReplayFrame { Time = time_first_circle - 200, Position = positionFirstCircle, Actions = { OsuAction.LeftButton } },
+ new OsuReplayFrame { Time = time_first_circle - 100, Position = positionSecondCircle, Actions = { OsuAction.RightButton } }
+ });
+
+ addJudgementAssert(hitObjects[0], HitResult.Great);
+ addJudgementAssert(hitObjects[1], HitResult.Great);
+ addJudgementOffsetAssert(hitObjects[0], -200); // time_first_circle - 200
+ addJudgementOffsetAssert(hitObjects[0], -200); // time_second_circle - first_circle_time - 100
+ }
+
+ ///
+ /// Tests clicking a future circle after a slider's start time, but hitting all slider ticks.
+ ///
+ [Test]
+ public void TestMissSliderHeadAndHitAllSliderTicks()
+ {
+ const double time_slider = 1500;
+ const double time_circle = 1510;
+ Vector2 positionCircle = Vector2.Zero;
+ Vector2 positionSlider = new Vector2(80);
+
+ var hitObjects = new List
+ {
+ new TestHitCircle
+ {
+ StartTime = time_circle,
+ Position = positionCircle
+ },
+ new TestSlider
+ {
+ StartTime = time_slider,
+ Position = positionSlider,
+ Path = new SliderPath(PathType.Linear, new[]
+ {
+ Vector2.Zero,
+ new Vector2(25, 0),
+ })
+ }
+ };
+
+ performTest(hitObjects, new List
+ {
+ new OsuReplayFrame { Time = time_slider, Position = positionCircle, Actions = { OsuAction.LeftButton } },
+ new OsuReplayFrame { Time = time_slider + 10, Position = positionSlider, Actions = { OsuAction.RightButton } }
+ });
+
+ addJudgementAssert(hitObjects[0], HitResult.Great);
+ addJudgementAssert(hitObjects[1], HitResult.Great);
+ addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.Miss);
+ addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.Great);
+ }
+
+ ///
+ /// Tests clicking hitting future slider ticks before a circle.
+ ///
+ [Test]
+ public void TestHitSliderTicksBeforeCircle()
+ {
+ const double time_slider = 1500;
+ const double time_circle = 1510;
+ Vector2 positionCircle = Vector2.Zero;
+ Vector2 positionSlider = new Vector2(80);
+
+ var hitObjects = new List
+ {
+ new TestHitCircle
+ {
+ StartTime = time_circle,
+ Position = positionCircle
+ },
+ new TestSlider
+ {
+ StartTime = time_slider,
+ Position = positionSlider,
+ Path = new SliderPath(PathType.Linear, new[]
+ {
+ Vector2.Zero,
+ new Vector2(25, 0),
+ })
+ }
+ };
+
+ performTest(hitObjects, new List
+ {
+ new OsuReplayFrame { Time = time_slider, Position = positionSlider, Actions = { OsuAction.LeftButton } },
+ new OsuReplayFrame { Time = time_circle + late_miss_window - 100, Position = positionCircle, Actions = { OsuAction.RightButton } },
+ new OsuReplayFrame { Time = time_circle + late_miss_window - 90, Position = positionSlider, Actions = { OsuAction.LeftButton } },
+ });
+
+ addJudgementAssert(hitObjects[0], HitResult.Great);
+ addJudgementAssert(hitObjects[1], HitResult.Great);
+ addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.Great);
+ addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.Great);
+ }
+
+ ///
+ /// Tests clicking a future circle before a spinner.
+ ///
+ [Test]
+ public void TestHitCircleBeforeSpinner()
+ {
+ const double time_spinner = 1500;
+ const double time_circle = 1800;
+ Vector2 positionCircle = Vector2.Zero;
+
+ var hitObjects = new List
+ {
+ new TestSpinner
+ {
+ StartTime = time_spinner,
+ Position = new Vector2(256, 192),
+ EndTime = time_spinner + 1000,
+ },
+ new TestHitCircle
+ {
+ StartTime = time_circle,
+ Position = positionCircle
+ },
+ };
+
+ performTest(hitObjects, new List
+ {
+ new OsuReplayFrame { Time = time_spinner - 100, Position = positionCircle, Actions = { OsuAction.LeftButton } },
+ new OsuReplayFrame { Time = time_spinner + 10, Position = new Vector2(236, 192), Actions = { OsuAction.RightButton } },
+ new OsuReplayFrame { Time = time_spinner + 20, Position = new Vector2(256, 172), Actions = { OsuAction.RightButton } },
+ new OsuReplayFrame { Time = time_spinner + 30, Position = new Vector2(276, 192), Actions = { OsuAction.RightButton } },
+ new OsuReplayFrame { Time = time_spinner + 40, Position = new Vector2(256, 212), Actions = { OsuAction.RightButton } },
+ new OsuReplayFrame { Time = time_spinner + 50, Position = new Vector2(236, 192), Actions = { OsuAction.RightButton } },
+ });
+
+ addJudgementAssert(hitObjects[0], HitResult.Great);
+ addJudgementAssert(hitObjects[1], HitResult.Great);
+ }
+
+ private void addJudgementAssert(OsuHitObject hitObject, HitResult result)
+ {
+ AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}",
+ () => judgementResults.Single(r => r.HitObject == hitObject).Type == result);
+ }
+
+ private void addJudgementAssert(string name, Func hitObject, HitResult result)
+ {
+ AddAssert($"{name} judgement is {result}",
+ () => judgementResults.Single(r => r.HitObject == hitObject()).Type == result);
+ }
+
+ private void addJudgementOffsetAssert(OsuHitObject hitObject, double offset)
+ {
+ AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judged at {offset}",
+ () => Precision.AlmostEquals(judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, offset, 100));
+ }
+
+ private ScoreAccessibleReplayPlayer currentPlayer;
+ private List judgementResults;
+ private bool allJudgedFired;
+
+ private void performTest(List hitObjects, List frames)
+ {
+ AddStep("load player", () =>
+ {
+ Beatmap.Value = CreateWorkingBeatmap(new Beatmap
+ {
+ HitObjects = hitObjects,
+ BeatmapInfo =
+ {
+ BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
+ Ruleset = new OsuRuleset().RulesetInfo
+ },
+ });
+
+ Beatmap.Value.Beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f });
+
+ var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
+
+ p.OnLoadComplete += _ =>
+ {
+ p.ScoreProcessor.NewJudgement += result =>
+ {
+ if (currentPlayer == p) judgementResults.Add(result);
+ };
+ p.ScoreProcessor.AllJudged += () =>
+ {
+ if (currentPlayer == p) allJudgedFired = true;
+ };
+ };
+
+ LoadScreen(currentPlayer = p);
+ allJudgedFired = false;
+ judgementResults = new List();
+ });
+
+ AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
+ AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
+ AddUntilStep("Wait for all judged", () => allJudgedFired);
+ }
+
+ private class TestHitCircle : HitCircle
+ {
+ protected override HitWindows CreateHitWindows() => new TestHitWindows();
+ }
+
+ private class TestSlider : Slider
+ {
+ public TestSlider()
+ {
+ DefaultsApplied += () =>
+ {
+ HeadCircle.HitWindows = new TestHitWindows();
+ TailCircle.HitWindows = new TestHitWindows();
+ };
+ }
+ }
+
+ private class TestSpinner : Spinner
+ {
+ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
+ {
+ base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
+ SpinsRequired = 1;
+ }
+ }
+
+ private class TestHitWindows : HitWindows
+ {
+ private static readonly DifficultyRange[] ranges =
+ {
+ new DifficultyRange(HitResult.Great, 500, 500, 500),
+ new DifficultyRange(HitResult.Miss, early_miss_window, early_miss_window, early_miss_window),
+ };
+
+ public override bool IsHitResultAllowed(HitResult result) => result == HitResult.Great || result == HitResult.Miss;
+
+ protected override DifficultyRange[] GetRanges() => ranges;
+ }
+
+ private class ScoreAccessibleReplayPlayer : ReplayPlayer
+ {
+ public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
+
+ protected override bool PauseOnFocusLost => false;
+
+ public ScoreAccessibleReplayPlayer(Score score)
+ : base(score, false, false)
+ {
+ }
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
index 5202327245..d73ad888f4 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
@@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
var result = HitObject.HitWindows.ResultFor(timeOffset);
- if (result == HitResult.None)
+ if (result == HitResult.None || CheckHittable?.Invoke(this, Time.Current) == false)
{
Shake(Math.Abs(timeOffset) - HitObject.HitWindows.WindowFor(HitResult.Miss));
return;
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
index a677cb6a72..fe23e3729d 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
@@ -1,11 +1,13 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Graphics.Containers;
+using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
@@ -16,6 +18,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
// Must be set to update IsHovered as it's used in relax mdo to detect osu hit objects.
public override bool HandlePositionalInput => true;
+ ///
+ /// Whether this can be hit.
+ /// If non-null, judgements will be ignored (resulting in a shake) whilst the function returns false.
+ ///
+ public Func CheckHittable;
+
protected DrawableOsuHitObject(OsuHitObject hitObject)
: base(hitObject)
{
@@ -54,6 +62,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}
}
+ ///
+ /// Causes this to get missed, disregarding all conditions in implementations of .
+ ///
+ public void MissForcefully() => ApplyResult(r => r.Type = HitResult.Miss);
+
protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(HitObject, judgement);
}
}
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
index 9b6f39d91d..522217a916 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
@@ -124,7 +124,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
case SliderTailCircle tail:
return new DrawableSliderTail(slider, tail);
- case HitCircle head:
+ case SliderHeadCircle head:
return new DrawableSliderHead(slider, head) { OnShake = Shake };
case SliderTick tick:
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs
index a360071f26..04f563eeec 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs
@@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly Slider slider;
- public DrawableSliderHead(Slider slider, HitCircle h)
+ public DrawableSliderHead(Slider slider, SliderHeadCircle h)
: base(h)
{
this.slider = slider;
diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs
index db1f46d8e2..e5d6c20738 100644
--- a/osu.Game.Rulesets.Osu/Objects/Slider.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs
@@ -155,7 +155,7 @@ namespace osu.Game.Rulesets.Osu.Objects
break;
case SliderEventType.Head:
- AddNested(HeadCircle = new SliderCircle
+ AddNested(HeadCircle = new SliderHeadCircle
{
StartTime = e.Time,
Position = Position,
diff --git a/osu.Game.Rulesets.Osu/Objects/SliderHeadCircle.cs b/osu.Game.Rulesets.Osu/Objects/SliderHeadCircle.cs
new file mode 100644
index 0000000000..f6d46aeef5
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Objects/SliderHeadCircle.cs
@@ -0,0 +1,9 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Rulesets.Osu.Objects
+{
+ public class SliderHeadCircle : HitCircle
+ {
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/UI/OrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/OrderedHitPolicy.cs
new file mode 100644
index 0000000000..dfca2aff7b
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/UI/OrderedHitPolicy.cs
@@ -0,0 +1,127 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Objects.Drawables;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Rulesets.Osu.Objects.Drawables;
+using osu.Game.Rulesets.UI;
+
+namespace osu.Game.Rulesets.Osu.UI
+{
+ ///
+ /// Ensures that s are hit in-order.
+ /// If a is hit out of order:
+ ///
+ /// - The hit is blocked if it occurred earlier than the previous 's start time.
+ /// - The hit causes all previous s to missed otherwise.
+ ///
+ ///
+ public class OrderedHitPolicy
+ {
+ private readonly HitObjectContainer hitObjectContainer;
+
+ public OrderedHitPolicy(HitObjectContainer hitObjectContainer)
+ {
+ this.hitObjectContainer = hitObjectContainer;
+ }
+
+ ///
+ /// Determines whether a can be hit at a point in time.
+ ///
+ /// The to check.
+ /// The time to check.
+ /// Whether can be hit at the given .
+ public bool IsHittable(DrawableHitObject hitObject, double time)
+ {
+ DrawableHitObject blockingObject = null;
+
+ // Find the last hitobject which blocks future hits.
+ foreach (var obj in hitObjectContainer.AliveObjects)
+ {
+ if (obj == hitObject)
+ break;
+
+ if (drawableCanBlockFutureHits(obj))
+ blockingObject = obj;
+ }
+
+ // If there is no previous hitobject, allow the hit.
+ if (blockingObject == null)
+ return true;
+
+ // A hit is allowed if:
+ // 1. The last blocking hitobject has been judged.
+ // 2. The current time is after the last hitobject's start time.
+ // Hits at exactly the same time as the blocking hitobject are allowed for maps that contain simultaneous hitobjects (e.g. /b/372245).
+ if (blockingObject.Judged || time >= blockingObject.HitObject.StartTime)
+ return true;
+
+ return false;
+ }
+
+ ///
+ /// Handles a being hit to potentially miss all earlier s.
+ ///
+ /// The that was hit.
+ public void HandleHit(HitObject hitObject)
+ {
+ // Hitobjects which themselves don't block future hitobjects don't cause misses (e.g. slider ticks, spinners).
+ if (!hitObjectCanBlockFutureHits(hitObject))
+ return;
+
+ double maximumTime = hitObject.StartTime;
+
+ // Iterate through and apply miss results to all top-level and nested hitobjects which block future hits.
+ foreach (var obj in hitObjectContainer.AliveObjects)
+ {
+ if (obj.Judged || obj.HitObject.StartTime >= maximumTime)
+ continue;
+
+ if (hitObjectCanBlockFutureHits(obj.HitObject))
+ applyMiss(obj);
+
+ foreach (var nested in obj.NestedHitObjects)
+ {
+ if (nested.Judged || nested.HitObject.StartTime >= maximumTime)
+ continue;
+
+ if (hitObjectCanBlockFutureHits(nested.HitObject))
+ applyMiss(nested);
+ }
+ }
+
+ static void applyMiss(DrawableHitObject obj) => ((DrawableOsuHitObject)obj).MissForcefully();
+ }
+
+ ///
+ /// Whether a blocks hits on future s until its start time is reached.
+ ///
+ ///
+ /// This will ONLY match on top-most s.
+ ///
+ /// The to test.
+ private static bool drawableCanBlockFutureHits(DrawableHitObject hitObject)
+ {
+ // Special considerations for slider tails aren't required since only top-most drawable hitobjects are being iterated over.
+ return hitObject is DrawableHitCircle || hitObject is DrawableSlider;
+ }
+
+ ///
+ /// Whether a blocks hits on future s until its start time is reached.
+ ///
+ ///
+ /// This is more rigorous and may not match on top-most s as does.
+ ///
+ /// The to test.
+ private static bool hitObjectCanBlockFutureHits(HitObject hitObject)
+ {
+ // Unlike the above we will receive slider tails, but they do not block future hits.
+ if (hitObject is SliderTailCircle)
+ return false;
+
+ // All other hitcircles continue to block future hits.
+ return hitObject is HitCircle;
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs
index 6d1ea4bbfc..2f222f59b4 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs
@@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI
private readonly ApproachCircleProxyContainer approachCircles;
private readonly JudgementContainer judgementLayer;
private readonly FollowPointRenderer followPoints;
+ private readonly OrderedHitPolicy hitPolicy;
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
@@ -51,6 +52,8 @@ namespace osu.Game.Rulesets.Osu.UI
Depth = -1,
},
};
+
+ hitPolicy = new OrderedHitPolicy(HitObjectContainer);
}
public override void Add(DrawableHitObject h)
@@ -64,7 +67,10 @@ namespace osu.Game.Rulesets.Osu.UI
base.Add(h);
- followPoints.AddFollowPoints((DrawableOsuHitObject)h);
+ DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
+ osuHitObject.CheckHittable = hitPolicy.IsHittable;
+
+ followPoints.AddFollowPoints(osuHitObject);
}
public override bool Remove(DrawableHitObject h)
@@ -79,6 +85,9 @@ namespace osu.Game.Rulesets.Osu.UI
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
{
+ // Hitobjects that block future hits should miss previous hitobjects if they're hit out-of-order.
+ hitPolicy.HandleHit(result.HitObject);
+
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
return;
diff --git a/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs b/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs
index d367d9f88b..2d4587341d 100644
--- a/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs
+++ b/osu.Game.Tests/Beatmaps/TestSceneEditorBeatmap.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore.Internal;
using NUnit.Framework;
@@ -162,5 +163,69 @@ namespace osu.Game.Tests.Beatmaps
Assert.That(editorBeatmap.HitObjects.Count(h => h == hitCircle), Is.EqualTo(1));
Assert.That(editorBeatmap.HitObjects.IndexOf(hitCircle), Is.EqualTo(1));
}
+
+ ///
+ /// Tests that multiple hitobjects are updated simultaneously.
+ ///
+ [Test]
+ public void TestMultipleHitObjectUpdate()
+ {
+ var updatedObjects = new List();
+ var allHitObjects = new List();
+ EditorBeatmap editorBeatmap = null;
+
+ AddStep("add beatmap", () =>
+ {
+ updatedObjects.Clear();
+
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+
+ for (int i = 0; i < 10; i++)
+ {
+ var h = new HitCircle();
+ editorBeatmap.Add(h);
+ allHitObjects.Add(h);
+ }
+ });
+
+ AddStep("change all start times", () =>
+ {
+ editorBeatmap.HitObjectUpdated += h => updatedObjects.Add(h);
+
+ for (int i = 0; i < 10; i++)
+ allHitObjects[i].StartTime += 10;
+ });
+
+ // Distinct ensures that all hitobjects have been updated once, debounce is tested below.
+ AddAssert("all hitobjects updated", () => updatedObjects.Distinct().Count() == 10);
+ }
+
+ ///
+ /// Tests that hitobject updates are debounced when they happen too soon.
+ ///
+ [Test]
+ public void TestDebouncedUpdate()
+ {
+ var updatedObjects = new List();
+ EditorBeatmap editorBeatmap = null;
+
+ AddStep("add beatmap", () =>
+ {
+ updatedObjects.Clear();
+
+ Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ editorBeatmap.Add(new HitCircle());
+ });
+
+ AddStep("change start time twice", () =>
+ {
+ editorBeatmap.HitObjectUpdated += h => updatedObjects.Add(h);
+
+ editorBeatmap.HitObjects[0].StartTime = 10;
+ editorBeatmap.HitObjects[0].StartTime = 20;
+ });
+
+ AddAssert("only updated once", () => updatedObjects.Count == 1);
+ }
}
}
diff --git a/osu.Game.Tests/Editor/LegacyEditorBeatmapDifferTest.cs b/osu.Game.Tests/Editor/LegacyEditorBeatmapPatcherTest.cs
similarity index 93%
rename from osu.Game.Tests/Editor/LegacyEditorBeatmapDifferTest.cs
rename to osu.Game.Tests/Editor/LegacyEditorBeatmapPatcherTest.cs
index d70a112b7f..c24418d688 100644
--- a/osu.Game.Tests/Editor/LegacyEditorBeatmapDifferTest.cs
+++ b/osu.Game.Tests/Editor/LegacyEditorBeatmapPatcherTest.cs
@@ -20,15 +20,15 @@ using Decoder = osu.Game.Beatmaps.Formats.Decoder;
namespace osu.Game.Tests.Editor
{
[TestFixture]
- public class LegacyEditorBeatmapDifferTest
+ public class LegacyEditorBeatmapPatcherTest
{
- private LegacyEditorBeatmapDiffer differ;
+ private LegacyEditorBeatmapPatcher patcher;
private EditorBeatmap current;
[SetUp]
public void Setup()
{
- differ = new LegacyEditorBeatmapDiffer(current = new EditorBeatmap(new OsuBeatmap
+ patcher = new LegacyEditorBeatmapPatcher(current = new EditorBeatmap(new OsuBeatmap
{
BeatmapInfo =
{
@@ -312,30 +312,30 @@ namespace osu.Game.Tests.Editor
patch = decode(encode(patch));
// Apply the patch.
- differ.Patch(encode(current), encode(patch));
+ patcher.Patch(encode(current), encode(patch));
// Convert beatmaps to strings for assertion purposes.
- string currentStr = Encoding.ASCII.GetString(encode(current).ToArray());
- string patchStr = Encoding.ASCII.GetString(encode(patch).ToArray());
+ string currentStr = Encoding.ASCII.GetString(encode(current));
+ string patchStr = Encoding.ASCII.GetString(encode(patch));
Assert.That(currentStr, Is.EqualTo(patchStr));
}
- private MemoryStream encode(IBeatmap beatmap)
+ private byte[] encode(IBeatmap beatmap)
{
- var encoded = new MemoryStream();
+ using (var encoded = new MemoryStream())
+ {
+ using (var sw = new StreamWriter(encoded))
+ new LegacyBeatmapEncoder(beatmap).Encode(sw);
- using (var sw = new StreamWriter(encoded, leaveOpen: true))
- new LegacyBeatmapEncoder(beatmap).Encode(sw);
-
- return encoded;
+ return encoded.ToArray();
+ }
}
- private IBeatmap decode(Stream stream)
+ private IBeatmap decode(byte[] state)
{
- stream.Seek(0, SeekOrigin.Begin);
-
- using (var reader = new LineBufferedReader(stream, true))
+ using (var stream = new MemoryStream(state))
+ using (var reader = new LineBufferedReader(stream))
return Decoder.GetDecoder(reader).Decode(reader);
}
}
diff --git a/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs b/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
index 909409835c..27f5b29738 100644
--- a/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
+++ b/osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
@@ -20,26 +20,30 @@ namespace osu.Game.Tests.Visual.Navigation
public void TestFromMainMenu()
{
var firstImport = importBeatmap(1);
+ var secondimport = importBeatmap(3);
+
presentAndConfirm(firstImport);
-
- AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
- AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
-
- var secondimport = importBeatmap(2);
+ returnToMenu();
presentAndConfirm(secondimport);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(secondimport, 3);
}
[Test]
public void TestFromMainMenuDifferentRuleset()
{
var firstImport = importBeatmap(1);
+ var secondimport = importBeatmap(3, new ManiaRuleset().RulesetInfo);
+
presentAndConfirm(firstImport);
-
- AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
- AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
-
- var secondimport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
+ returnToMenu();
presentAndConfirm(secondimport);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ returnToMenu();
+ presentSecondDifficultyAndConfirm(secondimport, 3);
}
[Test]
@@ -48,8 +52,11 @@ namespace osu.Game.Tests.Visual.Navigation
var firstImport = importBeatmap(1);
presentAndConfirm(firstImport);
- var secondimport = importBeatmap(2);
+ var secondimport = importBeatmap(3);
presentAndConfirm(secondimport);
+
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ presentSecondDifficultyAndConfirm(secondimport, 3);
}
[Test]
@@ -58,8 +65,17 @@ namespace osu.Game.Tests.Visual.Navigation
var firstImport = importBeatmap(1);
presentAndConfirm(firstImport);
- var secondimport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
+ var secondimport = importBeatmap(3, new ManiaRuleset().RulesetInfo);
presentAndConfirm(secondimport);
+
+ presentSecondDifficultyAndConfirm(firstImport, 1);
+ presentSecondDifficultyAndConfirm(secondimport, 3);
+ }
+
+ private void returnToMenu()
+ {
+ AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
+ AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
}
private Func importBeatmap(int i, RulesetInfo ruleset = null)
@@ -89,6 +105,13 @@ namespace osu.Game.Tests.Visual.Navigation
BaseDifficulty = difficulty,
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
},
+ new BeatmapInfo
+ {
+ OnlineBeatmapID = i * 2048,
+ Metadata = metadata,
+ BaseDifficulty = difficulty,
+ Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
+ },
}
}).Result;
});
@@ -106,5 +129,15 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapSetInfo.ID == getImport().ID);
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Beatmaps.First().Ruleset.ID);
}
+
+ private void presentSecondDifficultyAndConfirm(Func getImport, int importedID)
+ {
+ Predicate pred = b => b.OnlineBeatmapID == importedID * 2048;
+ AddStep("present difficulty", () => Game.PresentBeatmap(getImport(), pred));
+
+ AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect);
+ AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapInfo.OnlineBeatmapID == importedID * 2048);
+ AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Beatmaps.First().Ruleset.ID);
+ }
}
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs
index 864fd31a0f..22d20f7098 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs
@@ -24,7 +24,6 @@ namespace osu.Game.Tests.Visual.Online
typeof(ChangelogListing),
typeof(ChangelogSingleBuild),
typeof(ChangelogBuild),
- typeof(Comments),
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index 1b2fd658f4..5e93d760e3 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -315,8 +315,15 @@ namespace osu.Game
/// The user should have already requested this interactively.
///
/// The beatmap to select.
- public void PresentBeatmap(BeatmapSetInfo beatmap)
+ ///
+ /// Optional predicate used to try and find a difficulty to select.
+ /// If omitted, this will try to present the first beatmap from the current ruleset.
+ /// In case of failure the first difficulty of the set will be presented, ignoring the predicate.
+ ///
+ public void PresentBeatmap(BeatmapSetInfo beatmap, Predicate difficultyCriteria = null)
{
+ difficultyCriteria ??= b => b.Ruleset.Equals(Ruleset.Value);
+
var databasedSet = beatmap.OnlineBeatmapSetID != null
? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID)
: BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash);
@@ -334,13 +341,13 @@ namespace osu.Game
menuScreen.LoadToSolo();
// we might even already be at the song
- if (Beatmap.Value.BeatmapSetInfo.Hash == databasedSet.Hash)
+ if (Beatmap.Value.BeatmapSetInfo.Hash == databasedSet.Hash && difficultyCriteria(Beatmap.Value.BeatmapInfo))
{
return;
}
- // Use first beatmap available for current ruleset, else switch ruleset.
- var first = databasedSet.Beatmaps.Find(b => b.Ruleset.Equals(Ruleset.Value)) ?? databasedSet.Beatmaps.First();
+ // Find first beatmap that matches our predicate.
+ var first = databasedSet.Beatmaps.Find(difficultyCriteria) ?? databasedSet.Beatmaps.First();
Ruleset.Value = first.Ruleset;
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(first);
diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs
index 29c259b7f8..11dc424183 100644
--- a/osu.Game/Overlays/BeatmapSet/Header.cs
+++ b/osu.Game/Overlays/BeatmapSet/Header.cs
@@ -277,7 +277,8 @@ namespace osu.Game.Overlays.BeatmapSet
downloadButtonsContainer.Child = new PanelDownloadButton(BeatmapSet.Value)
{
Width = 50,
- RelativeSizeAxes = Axes.Y
+ RelativeSizeAxes = Axes.Y,
+ SelectedBeatmap = { BindTarget = Picker.Beatmap }
};
break;
diff --git a/osu.Game/Overlays/Changelog/Comments.cs b/osu.Game/Overlays/Changelog/Comments.cs
deleted file mode 100644
index 4cf39e7b44..0000000000
--- a/osu.Game/Overlays/Changelog/Comments.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using osu.Framework.Allocation;
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.Sprites;
-using osu.Game.Graphics;
-using osu.Game.Graphics.Containers;
-using osu.Game.Online.API.Requests.Responses;
-using osuTK.Graphics;
-
-namespace osu.Game.Overlays.Changelog
-{
- public class Comments : CompositeDrawable
- {
- private readonly APIChangelogBuild build;
-
- public Comments(APIChangelogBuild build)
- {
- this.build = build;
-
- RelativeSizeAxes = Axes.X;
- AutoSizeAxes = Axes.Y;
-
- Padding = new MarginPadding
- {
- Horizontal = 50,
- Vertical = 20,
- };
- }
-
- [BackgroundDependencyLoader]
- private void load(OsuColour colours)
- {
- LinkFlowContainer text;
-
- InternalChildren = new Drawable[]
- {
- new Container
- {
- RelativeSizeAxes = Axes.Both,
- Masking = true,
- CornerRadius = 10,
- Child = new Box
- {
- RelativeSizeAxes = Axes.Both,
- Colour = colours.GreyVioletDarker
- },
- },
- text = new LinkFlowContainer(t =>
- {
- t.Colour = colours.PinkLighter;
- t.Font = OsuFont.Default.With(size: 14);
- })
- {
- Padding = new MarginPadding(20),
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- }
- };
-
- text.AddParagraph("Got feedback?", t =>
- {
- t.Colour = Color4.White;
- t.Font = OsuFont.Default.With(italics: true, size: 20);
- t.Padding = new MarginPadding { Bottom = 20 };
- });
-
- text.AddParagraph("We would love to hear what you think of this update! ");
- text.AddIcon(FontAwesome.Regular.GrinHearts);
-
- text.AddParagraph("Please visit the ");
- text.AddLink("web version", $"{build.Url}#comments");
- text.AddText(" of this changelog to leave any comments.");
- }
- }
-}
diff --git a/osu.Game/Overlays/Direct/PanelDownloadButton.cs b/osu.Game/Overlays/Direct/PanelDownloadButton.cs
index 1b3657f010..08e3ed9b38 100644
--- a/osu.Game/Overlays/Direct/PanelDownloadButton.cs
+++ b/osu.Game/Overlays/Direct/PanelDownloadButton.cs
@@ -1,7 +1,9 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
@@ -16,6 +18,11 @@ namespace osu.Game.Overlays.Direct
private readonly bool noVideo;
+ ///
+ /// Currently selected beatmap. Used to present the correct difficulty after completing a download.
+ ///
+ public readonly IBindable SelectedBeatmap = new Bindable();
+
private readonly ShakeContainer shakeContainer;
private readonly DownloadButton button;
@@ -62,7 +69,11 @@ namespace osu.Game.Overlays.Direct
break;
case DownloadState.LocallyAvailable:
- game?.PresentBeatmap(BeatmapSet.Value);
+ Predicate findPredicate = null;
+ if (SelectedBeatmap.Value != null)
+ findPredicate = b => b.OnlineBeatmapID == SelectedBeatmap.Value.OnlineBeatmapID;
+
+ game?.PresentBeatmap(BeatmapSet.Value, findPredicate);
break;
default:
diff --git a/osu.Game/Overlays/Music/CollectionsDropdown.cs b/osu.Game/Overlays/Music/CollectionsDropdown.cs
index 4f59b053b6..5bd321f31e 100644
--- a/osu.Game/Overlays/Music/CollectionsDropdown.cs
+++ b/osu.Game/Overlays/Music/CollectionsDropdown.cs
@@ -29,14 +29,8 @@ namespace osu.Game.Overlays.Music
{
public CollectionsMenu()
{
+ Masking = true;
CornerRadius = 5;
- EdgeEffect = new EdgeEffectParameters
- {
- Type = EdgeEffectType.Shadow,
- Colour = Color4.Black.Opacity(0.3f),
- Radius = 3,
- Offset = new Vector2(0f, 1f),
- };
}
[BackgroundDependencyLoader]
diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
index 0011faefbb..8fa0c041d4 100644
--- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
+++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
@@ -375,7 +375,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
}
}
- protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => AllJudged && base.ComputeIsMaskedAway(maskingBounds);
+ public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => AllJudged && base.UpdateSubTreeMasking(source, maskingBounds);
protected override void UpdateAfterChildren()
{
diff --git a/osu.Game/Screens/Edit/EditorBeatmap.cs b/osu.Game/Screens/Edit/EditorBeatmap.cs
index 22e0061b61..a2d2f08ce9 100644
--- a/osu.Game/Screens/Edit/EditorBeatmap.cs
+++ b/osu.Game/Screens/Edit/EditorBeatmap.cs
@@ -63,6 +63,7 @@ namespace osu.Game.Screens.Edit
trackStartTime(obj);
}
+ private readonly HashSet pendingUpdates = new HashSet();
private ScheduledDelegate scheduledUpdate;
///
@@ -74,15 +75,27 @@ namespace osu.Game.Screens.Edit
private void updateHitObject([CanBeNull] HitObject hitObject, bool silent)
{
scheduledUpdate?.Cancel();
- scheduledUpdate = Scheduler.AddDelayed(() =>
+
+ if (hitObject != null)
+ pendingUpdates.Add(hitObject);
+
+ scheduledUpdate = Schedule(() =>
{
beatmapProcessor?.PreProcess();
- hitObject?.ApplyDefaults(ControlPointInfo, BeatmapInfo.BaseDifficulty);
+
+ foreach (var obj in pendingUpdates)
+ obj.ApplyDefaults(ControlPointInfo, BeatmapInfo.BaseDifficulty);
+
beatmapProcessor?.PostProcess();
if (!silent)
- HitObjectUpdated?.Invoke(hitObject);
- }, 0);
+ {
+ foreach (var obj in pendingUpdates)
+ HitObjectUpdated?.Invoke(obj);
+ }
+
+ pendingUpdates.Clear();
+ });
}
public BeatmapInfo BeatmapInfo
diff --git a/osu.Game/Screens/Edit/EditorChangeHandler.cs b/osu.Game/Screens/Edit/EditorChangeHandler.cs
index 7e372926ba..00a27801f4 100644
--- a/osu.Game/Screens/Edit/EditorChangeHandler.cs
+++ b/osu.Game/Screens/Edit/EditorChangeHandler.cs
@@ -15,8 +15,10 @@ namespace osu.Game.Screens.Edit
///
public class EditorChangeHandler : IEditorChangeHandler
{
- private readonly LegacyEditorBeatmapDiffer differ;
- private readonly List savedStates = new List();
+ private readonly LegacyEditorBeatmapPatcher patcher;
+
+ private readonly List savedStates = new List();
+
private int currentState = -1;
private readonly EditorBeatmap editorBeatmap;
@@ -35,7 +37,7 @@ namespace osu.Game.Screens.Edit
editorBeatmap.HitObjectRemoved += hitObjectRemoved;
editorBeatmap.HitObjectUpdated += hitObjectUpdated;
- differ = new LegacyEditorBeatmapDiffer(editorBeatmap);
+ patcher = new LegacyEditorBeatmapPatcher(editorBeatmap);
// Initial state.
SaveState();
@@ -69,15 +71,17 @@ namespace osu.Game.Screens.Edit
if (isRestoring)
return;
- var stream = new MemoryStream();
-
- using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
- new LegacyBeatmapEncoder(editorBeatmap).Encode(sw);
-
if (currentState < savedStates.Count - 1)
savedStates.RemoveRange(currentState + 1, savedStates.Count - currentState - 1);
- savedStates.Add(stream);
+ using (var stream = new MemoryStream())
+ {
+ using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
+ new LegacyBeatmapEncoder(editorBeatmap).Encode(sw);
+
+ savedStates.Add(stream.ToArray());
+ }
+
currentState = savedStates.Count - 1;
}
@@ -99,7 +103,7 @@ namespace osu.Game.Screens.Edit
isRestoring = true;
- differ.Patch(savedStates[currentState], savedStates[newState]);
+ patcher.Patch(savedStates[currentState], savedStates[newState]);
currentState = newState;
isRestoring = false;
diff --git a/osu.Game/Screens/Edit/LegacyEditorBeatmapDiffer.cs b/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs
similarity index 82%
rename from osu.Game/Screens/Edit/LegacyEditorBeatmapDiffer.cs
rename to osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs
index 8d2f577a1d..17eba87076 100644
--- a/osu.Game/Screens/Edit/LegacyEditorBeatmapDiffer.cs
+++ b/osu.Game/Screens/Edit/LegacyEditorBeatmapPatcher.cs
@@ -4,25 +4,29 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Text;
using DiffPlex;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
-using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
+using Decoder = osu.Game.Beatmaps.Formats.Decoder;
namespace osu.Game.Screens.Edit
{
- public class LegacyEditorBeatmapDiffer
+ ///
+ /// Patches an based on the difference between two legacy (.osu) states.
+ ///
+ public class LegacyEditorBeatmapPatcher
{
private readonly EditorBeatmap editorBeatmap;
- public LegacyEditorBeatmapDiffer(EditorBeatmap editorBeatmap)
+ public LegacyEditorBeatmapPatcher(EditorBeatmap editorBeatmap)
{
this.editorBeatmap = editorBeatmap;
}
- public void Patch(Stream currentState, Stream newState)
+ public void Patch(byte[] currentState, byte[] newState)
{
// Diff the beatmaps
var result = new Differ().CreateLineDiffs(readString(currentState), readString(newState), true, false);
@@ -36,7 +40,7 @@ namespace osu.Game.Screens.Edit
foreach (var block in result.DiffBlocks)
{
- // Removed hitobject
+ // Removed hitobjects
for (int i = 0; i < block.DeleteCountA; i++)
{
int hoIndex = block.DeleteStartA + i - oldHitObjectsIndex - 1;
@@ -47,7 +51,7 @@ namespace osu.Game.Screens.Edit
toRemove.Add(hoIndex);
}
- // Added hitobject
+ // Added hitobjects
for (int i = 0; i < block.InsertCountB; i++)
{
int hoIndex = block.InsertStartB + i - newHitObjectsIndex - 1;
@@ -74,18 +78,11 @@ namespace osu.Game.Screens.Edit
}
}
- private string readString(Stream stream)
+ private string readString(byte[] state) => Encoding.UTF8.GetString(state);
+
+ private IBeatmap readBeatmap(byte[] state)
{
- stream.Seek(0, SeekOrigin.Begin);
-
- using (var sr = new StreamReader(stream, System.Text.Encoding.UTF8, true, 1024, true))
- return sr.ReadToEnd();
- }
-
- private IBeatmap readBeatmap(Stream stream)
- {
- stream.Seek(0, SeekOrigin.Begin);
-
+ using (var stream = new MemoryStream(state))
using (var reader = new LineBufferedReader(stream, true))
return new PassThroughWorkingBeatmap(Decoder.GetDecoder(reader).Decode(reader)).GetPlayableBeatmap(editorBeatmap.BeatmapInfo.Ruleset);
}
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index 3dd84caea9..2eae969ab4 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/osu.iOS.props b/osu.iOS.props
index 7e6f6b5246..c46e9674d2 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -70,7 +70,7 @@
-
+
@@ -80,7 +80,7 @@
-
+