2018-01-04 15:21:15 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2018-01-11 14:08:46 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2018-01-04 15:21:15 +08:00
|
|
|
|
|
2018-01-04 15:38:07 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2018-03-02 14:34:31 +08:00
|
|
|
|
using NUnit.Framework;
|
2018-01-11 15:51:46 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2018-01-04 15:21:15 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using osu.Framework.Graphics;
|
2018-01-04 16:07:16 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-01-04 15:21:15 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-01-04 17:35:48 +08:00
|
|
|
|
using osu.Game.Rulesets.Timing;
|
2018-01-04 15:21:15 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2018-01-04 18:22:15 +08:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-01-04 15:21:15 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
2018-03-02 14:34:31 +08:00
|
|
|
|
[TestFixture]
|
2018-01-04 15:21:15 +08:00
|
|
|
|
public class TestCaseScrollingHitObjects : OsuTestCase
|
|
|
|
|
{
|
2018-01-04 15:38:07 +08:00
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
|
|
|
|
|
|
2018-01-11 15:51:46 +08:00
|
|
|
|
private readonly TestPlayfield[] playfields = new TestPlayfield[4];
|
2018-01-04 15:38:07 +08:00
|
|
|
|
|
2018-01-04 15:21:15 +08:00
|
|
|
|
public TestCaseScrollingHitObjects()
|
|
|
|
|
{
|
2018-01-11 15:51:46 +08:00
|
|
|
|
Add(new GridContainer
|
2018-01-04 16:07:16 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-01-11 15:51:46 +08:00
|
|
|
|
Content = new[]
|
2018-01-04 16:07:16 +08:00
|
|
|
|
{
|
2018-01-11 15:51:46 +08:00
|
|
|
|
new Drawable[]
|
2018-01-04 16:07:16 +08:00
|
|
|
|
{
|
2018-01-11 15:51:46 +08:00
|
|
|
|
playfields[0] = new TestPlayfield(ScrollingDirection.Up),
|
|
|
|
|
playfields[1] = new TestPlayfield(ScrollingDirection.Down)
|
2018-01-04 16:07:16 +08:00
|
|
|
|
},
|
2018-01-11 15:51:46 +08:00
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
playfields[2] = new TestPlayfield(ScrollingDirection.Left),
|
|
|
|
|
playfields[3] = new TestPlayfield(ScrollingDirection.Right)
|
|
|
|
|
}
|
2018-01-04 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-01-11 15:51:46 +08:00
|
|
|
|
AddSliderStep("Time range", 100, 10000, 5000, v => playfields.ForEach(p => p.VisibleTimeRange.Value = v));
|
2018-01-04 17:35:48 +08:00
|
|
|
|
AddStep("Add control point", () => addControlPoint(Time.Current + 5000));
|
2018-01-04 15:21:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 15:38:07 +08:00
|
|
|
|
protected override void LoadComplete()
|
2018-01-04 15:21:15 +08:00
|
|
|
|
{
|
2018-01-04 15:38:07 +08:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2018-01-11 15:51:46 +08:00
|
|
|
|
playfields.ForEach(p => p.HitObjects.AddControlPoint(new MultiplierControlPoint(0)));
|
|
|
|
|
|
2018-01-04 15:38:07 +08:00
|
|
|
|
for (int i = 0; i <= 5000; i += 1000)
|
|
|
|
|
addHitObject(Time.Current + i);
|
|
|
|
|
|
|
|
|
|
Scheduler.AddDelayed(() => addHitObject(Time.Current + 5000), 1000, true);
|
2018-01-04 15:21:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 15:38:07 +08:00
|
|
|
|
private void addHitObject(double time)
|
2018-01-04 15:21:15 +08:00
|
|
|
|
{
|
2018-01-04 15:38:07 +08:00
|
|
|
|
playfields.ForEach(p =>
|
2018-01-04 15:21:15 +08:00
|
|
|
|
{
|
2018-01-11 15:51:46 +08:00
|
|
|
|
var hitObject = new TestDrawableHitObject(time);
|
|
|
|
|
setAnchor(hitObject, p);
|
|
|
|
|
|
|
|
|
|
p.Add(hitObject);
|
2018-01-04 15:21:15 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 17:35:48 +08:00
|
|
|
|
private void addControlPoint(double time)
|
|
|
|
|
{
|
|
|
|
|
playfields.ForEach(p =>
|
|
|
|
|
{
|
2018-01-05 19:56:21 +08:00
|
|
|
|
p.HitObjects.AddControlPoint(new MultiplierControlPoint(time) { DifficultyPoint = { SpeedMultiplier = 3 } });
|
|
|
|
|
p.HitObjects.AddControlPoint(new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } });
|
|
|
|
|
p.HitObjects.AddControlPoint(new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } });
|
2018-01-04 17:35:48 +08:00
|
|
|
|
|
2018-01-11 15:51:46 +08:00
|
|
|
|
TestDrawableControlPoint createDrawablePoint(double t)
|
2018-01-04 17:35:48 +08:00
|
|
|
|
{
|
2018-01-11 15:51:46 +08:00
|
|
|
|
var obj = new TestDrawableControlPoint(p.Direction, t);
|
|
|
|
|
setAnchor(obj, p);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
2018-01-04 17:35:48 +08:00
|
|
|
|
|
|
|
|
|
p.Add(createDrawablePoint(time));
|
|
|
|
|
p.Add(createDrawablePoint(time + 2000));
|
|
|
|
|
p.Add(createDrawablePoint(time + 3000));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-11 15:51:46 +08:00
|
|
|
|
private void setAnchor(DrawableHitObject obj, TestPlayfield playfield)
|
|
|
|
|
{
|
|
|
|
|
switch (playfield.Direction)
|
|
|
|
|
{
|
|
|
|
|
case ScrollingDirection.Up:
|
|
|
|
|
obj.Anchor = Anchor.TopCentre;
|
|
|
|
|
break;
|
|
|
|
|
case ScrollingDirection.Down:
|
|
|
|
|
obj.Anchor = Anchor.BottomCentre;
|
|
|
|
|
break;
|
|
|
|
|
case ScrollingDirection.Left:
|
|
|
|
|
obj.Anchor = Anchor.CentreLeft;
|
|
|
|
|
break;
|
|
|
|
|
case ScrollingDirection.Right:
|
|
|
|
|
obj.Anchor = Anchor.CentreRight;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-04 15:21:15 +08:00
|
|
|
|
|
|
|
|
|
|
2018-01-07 11:47:09 +08:00
|
|
|
|
private class TestPlayfield : ScrollingPlayfield
|
2018-01-04 15:21:15 +08:00
|
|
|
|
{
|
2018-01-04 18:17:40 +08:00
|
|
|
|
public readonly ScrollingDirection Direction;
|
2018-01-04 15:21:15 +08:00
|
|
|
|
|
2018-01-04 18:17:40 +08:00
|
|
|
|
public TestPlayfield(ScrollingDirection direction)
|
2018-01-07 11:47:09 +08:00
|
|
|
|
: base(direction)
|
2018-01-04 15:21:15 +08:00
|
|
|
|
{
|
2018-01-04 18:17:40 +08:00
|
|
|
|
Direction = direction;
|
2018-01-04 15:21:15 +08:00
|
|
|
|
|
2018-01-11 15:51:46 +08:00
|
|
|
|
Padding = new MarginPadding(2);
|
|
|
|
|
ScaledContent.Masking = true;
|
|
|
|
|
|
|
|
|
|
AddInternal(new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0.5f,
|
|
|
|
|
Depth = float.MaxValue
|
|
|
|
|
});
|
2018-01-04 17:35:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
|
|
|
|
{
|
2018-01-11 15:51:46 +08:00
|
|
|
|
public TestDrawableControlPoint(ScrollingDirection direction, double time)
|
2018-01-04 17:35:48 +08:00
|
|
|
|
: base(new HitObject { StartTime = time })
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2018-03-15 12:41:06 +08:00
|
|
|
|
InternalChild = new Box
|
2018-01-04 17:35:48 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-01-11 15:51:46 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2018-03-15 12:41:06 +08:00
|
|
|
|
};
|
2018-01-04 17:35:48 +08:00
|
|
|
|
|
2018-01-11 15:51:46 +08:00
|
|
|
|
switch (direction)
|
|
|
|
|
{
|
|
|
|
|
case ScrollingDirection.Up:
|
|
|
|
|
case ScrollingDirection.Down:
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = 2;
|
|
|
|
|
break;
|
|
|
|
|
case ScrollingDirection.Left:
|
|
|
|
|
case ScrollingDirection.Right:
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
|
Width = 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-01-04 17:35:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
2018-01-04 15:21:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestDrawableHitObject : DrawableHitObject<HitObject>
|
|
|
|
|
{
|
2018-01-04 17:35:48 +08:00
|
|
|
|
public TestDrawableHitObject(double time)
|
|
|
|
|
: base(new HitObject { StartTime = time })
|
2018-01-04 15:21:15 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
2018-03-15 12:41:06 +08:00
|
|
|
|
InternalChild = new Box { Size = new Vector2(75) };
|
2018-01-04 15:21:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|