mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 03:23:03 +08:00
Add test for scrolling hit object lifetime
This commit is contained in:
parent
5d80950eaf
commit
781f5420b0
@ -11,8 +11,10 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -167,14 +169,39 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("add control points", () => addControlPoints(testControlPoints, Time.Current));
|
AddStep("add control points", () => addControlPoints(testControlPoints, Time.Current));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addHitObject(double time)
|
[Test]
|
||||||
|
public void TestVeryFlowScroll()
|
||||||
|
{
|
||||||
|
const double long_time_range = 100000;
|
||||||
|
var manualClock = new ManualClock();
|
||||||
|
|
||||||
|
AddStep("set manual clock", () =>
|
||||||
|
{
|
||||||
|
manualClock.CurrentTime = 0;
|
||||||
|
scrollContainers.ForEach(c => c.Clock = new FramedClock(manualClock));
|
||||||
|
|
||||||
|
setScrollAlgorithm(ScrollVisualisationMethod.Constant);
|
||||||
|
scrollContainers.ForEach(c => c.TimeRange = long_time_range);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("add hit objects", () =>
|
||||||
|
{
|
||||||
|
addHitObject(long_time_range);
|
||||||
|
addHitObject(long_time_range + 100, 250);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("hit objects are alive", () => playfields.All(p => p.HitObjectContainer.AliveObjects.Count() == 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addHitObject(double time, float size = 75)
|
||||||
{
|
{
|
||||||
playfields.ForEach(p =>
|
playfields.ForEach(p =>
|
||||||
{
|
{
|
||||||
var hitObject = new TestDrawableHitObject(time);
|
var hitObject = new TestHitObject(size) { StartTime = time };
|
||||||
setAnchor(hitObject, p);
|
var drawable = new TestDrawableHitObject(hitObject);
|
||||||
|
|
||||||
p.Add(hitObject);
|
setAnchor(drawable, p);
|
||||||
|
p.Add(drawable);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +275,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override ScrollingHitObjectContainer CreateScrollingHitObjectContainer() => new TestScrollingHitObjectContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
||||||
@ -281,22 +310,39 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestDrawableHitObject : DrawableHitObject<HitObject>
|
private class TestHitObject : HitObject
|
||||||
{
|
{
|
||||||
public TestDrawableHitObject(double time)
|
public readonly float Size;
|
||||||
: base(new HitObject { StartTime = time, HitWindows = HitWindows.Empty })
|
|
||||||
{
|
|
||||||
Origin = Anchor.Custom;
|
|
||||||
OriginPosition = new Vector2(75 / 4.0f);
|
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
public TestHitObject(float size)
|
||||||
|
{
|
||||||
|
Size = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestDrawableHitObject : DrawableHitObject<TestHitObject>
|
||||||
|
{
|
||||||
|
public TestDrawableHitObject(TestHitObject hitObject)
|
||||||
|
: base(hitObject)
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Size = new Vector2(hitObject.Size);
|
||||||
|
|
||||||
AddInternal(new Box
|
AddInternal(new Box
|
||||||
{
|
{
|
||||||
Size = new Vector2(75),
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)
|
Colour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestScrollingHitObjectContainer : ScrollingHitObjectContainer
|
||||||
|
{
|
||||||
|
protected override RectangleF GetConservativeBoundingBox(HitObjectLifetimeEntry entry)
|
||||||
|
{
|
||||||
|
var hitObject = (TestHitObject)entry.HitObject;
|
||||||
|
return new RectangleF().Inflate(hitObject.Size / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Vector2 ScreenSpacePositionAtTime(double time) => HitObjectContainer.ScreenSpacePositionAtTime(time);
|
public virtual Vector2 ScreenSpacePositionAtTime(double time) => HitObjectContainer.ScreenSpacePositionAtTime(time);
|
||||||
|
|
||||||
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();
|
protected sealed override HitObjectContainer CreateHitObjectContainer() => CreateScrollingHitObjectContainer();
|
||||||
|
|
||||||
|
protected virtual ScrollingHitObjectContainer CreateScrollingHitObjectContainer() => new ScrollingHitObjectContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user