2018-01-04 07:21:15 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
|
|
|
|
|
|
2018-01-04 07:38:07 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2018-01-04 08:07:16 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
2018-01-04 07:21:15 +00:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-01-04 08:07:16 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-01-04 07:21:15 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-01-04 09:35:48 +00:00
|
|
|
|
using osu.Game.Rulesets.Timing;
|
2018-01-04 07:21:15 +00:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2018-01-04 08:07:16 +00:00
|
|
|
|
using OpenTK.Graphics;
|
2018-01-04 07:21:15 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
|
|
|
|
public class TestCaseScrollingHitObjects : OsuTestCase
|
|
|
|
|
{
|
2018-01-04 07:38:07 +00:00
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
|
|
|
|
|
|
2018-01-04 08:07:16 +00:00
|
|
|
|
private readonly List<TestPlayfield> playfields = new List<TestPlayfield>();
|
2018-01-04 07:38:07 +00:00
|
|
|
|
|
2018-01-04 07:21:15 +00:00
|
|
|
|
public TestCaseScrollingHitObjects()
|
|
|
|
|
{
|
2018-01-04 10:17:40 +00:00
|
|
|
|
playfields.Add(new TestPlayfield(ScrollingDirection.Down));
|
|
|
|
|
playfields.Add(new TestPlayfield(ScrollingDirection.Right));
|
2018-01-04 07:21:15 +00:00
|
|
|
|
|
2018-01-04 09:35:48 +00:00
|
|
|
|
playfields.ForEach(p => p.HitObjects.ControlPoints.Add(new MultiplierControlPoint(double.MinValue)));
|
|
|
|
|
|
2018-01-04 08:07:16 +00:00
|
|
|
|
Add(new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = new Vector2(0.85f),
|
|
|
|
|
Masking = true,
|
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
|
BorderThickness = 2,
|
|
|
|
|
MaskingSmoothness = 1,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Name = "Background",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0.35f,
|
|
|
|
|
},
|
|
|
|
|
playfields[0],
|
|
|
|
|
playfields[1]
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddSliderStep("Time range", 100, 10000, 5000, v => playfields.ForEach(p => p.TimeRange.Value = v));
|
2018-01-04 09:35:48 +00:00
|
|
|
|
AddStep("Add control point", () => addControlPoint(Time.Current + 5000));
|
2018-01-04 07:21:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 07:38:07 +00:00
|
|
|
|
protected override void LoadComplete()
|
2018-01-04 07:21:15 +00:00
|
|
|
|
{
|
2018-01-04 07:38:07 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= 5000; i += 1000)
|
|
|
|
|
addHitObject(Time.Current + i);
|
|
|
|
|
|
|
|
|
|
Scheduler.AddDelayed(() => addHitObject(Time.Current + 5000), 1000, true);
|
2018-01-04 07:21:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 07:38:07 +00:00
|
|
|
|
private void addHitObject(double time)
|
2018-01-04 07:21:15 +00:00
|
|
|
|
{
|
2018-01-04 07:38:07 +00:00
|
|
|
|
playfields.ForEach(p =>
|
2018-01-04 07:21:15 +00:00
|
|
|
|
{
|
2018-01-04 09:35:48 +00:00
|
|
|
|
p.Add(new TestDrawableHitObject(time)
|
2018-01-04 07:38:07 +00:00
|
|
|
|
{
|
2018-01-04 10:17:40 +00:00
|
|
|
|
Anchor = p.Direction == ScrollingDirection.Right ? Anchor.CentreRight : Anchor.BottomCentre
|
2018-01-04 07:38:07 +00:00
|
|
|
|
});
|
2018-01-04 07:21:15 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 09:35:48 +00:00
|
|
|
|
private void addControlPoint(double time)
|
|
|
|
|
{
|
|
|
|
|
playfields.ForEach(p =>
|
|
|
|
|
{
|
|
|
|
|
p.HitObjects.ControlPoints.AddRange(new[]
|
|
|
|
|
{
|
|
|
|
|
new MultiplierControlPoint(time) { DifficultyPoint = { SpeedMultiplier = 3 } },
|
|
|
|
|
new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } },
|
|
|
|
|
new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
TestDrawableControlPoint createDrawablePoint(double t) => new TestDrawableControlPoint(t)
|
|
|
|
|
{
|
2018-01-04 10:17:40 +00:00
|
|
|
|
Anchor = p.Direction == ScrollingDirection.Right ? Anchor.CentreRight : Anchor.BottomCentre
|
2018-01-04 09:35:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
p.Add(createDrawablePoint(time));
|
|
|
|
|
p.Add(createDrawablePoint(time + 2000));
|
|
|
|
|
p.Add(createDrawablePoint(time + 3000));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 07:21:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class TestPlayfield : Playfield
|
|
|
|
|
{
|
2018-01-04 08:07:16 +00:00
|
|
|
|
public readonly BindableDouble TimeRange = new BindableDouble(5000);
|
|
|
|
|
|
2018-01-04 10:17:40 +00:00
|
|
|
|
public readonly ScrollingDirection Direction;
|
2018-01-04 07:21:15 +00:00
|
|
|
|
|
2018-01-04 10:20:43 +00:00
|
|
|
|
public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)base.HitObjects;
|
2018-01-04 09:35:48 +00:00
|
|
|
|
|
2018-01-04 10:17:40 +00:00
|
|
|
|
public TestPlayfield(ScrollingDirection direction)
|
2018-01-04 07:21:15 +00:00
|
|
|
|
{
|
2018-01-04 10:17:40 +00:00
|
|
|
|
Direction = direction;
|
2018-01-04 07:21:15 +00:00
|
|
|
|
|
2018-01-04 10:20:43 +00:00
|
|
|
|
base.HitObjects = new ScrollingHitObjectContainer(direction);
|
2018-01-04 09:35:48 +00:00
|
|
|
|
HitObjects.TimeRange.BindTo(TimeRange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
|
|
|
|
{
|
|
|
|
|
private readonly Box box;
|
|
|
|
|
|
|
|
|
|
public TestDrawableControlPoint(double time)
|
|
|
|
|
: base(new HitObject { StartTime = time })
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
Add(box = new Box
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2018-01-04 08:07:16 +00:00
|
|
|
|
|
2018-01-04 09:35:48 +00:00
|
|
|
|
RelativeSizeAxes = (Anchor & Anchor.x2) > 0 ? Axes.Y : Axes.X;
|
|
|
|
|
Size = new Vector2(1);
|
|
|
|
|
|
|
|
|
|
box.Size = DrawSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
2018-01-04 07:21:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestDrawableHitObject : DrawableHitObject<HitObject>
|
|
|
|
|
{
|
2018-01-04 09:35:48 +00:00
|
|
|
|
public TestDrawableHitObject(double time)
|
|
|
|
|
: base(new HitObject { StartTime = time })
|
2018-01-04 07:21:15 +00:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Add(new Box { Size = new Vector2(75) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|