2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 11:22:22 +08:00
|
|
|
|
using OpenTK;
|
2017-03-14 17:46:34 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-03-14 17:46:34 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-11-19 18:07:57 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2017-03-28 20:03:34 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2017-03-14 17:46:34 +08:00
|
|
|
|
using osu.Framework.Timing;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2017-03-14 17:46:34 +08:00
|
|
|
|
using System.Collections.Generic;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-10-26 16:26:26 +08:00
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
internal class TestCaseHitObjects : TestCase
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly FramedClock framedClock;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private bool auto;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
2016-11-13 01:34:36 +08:00
|
|
|
|
public TestCaseHitObjects()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2017-03-09 15:07:34 +08:00
|
|
|
|
var rateAdjustClock = new StopwatchClock(true);
|
2017-02-14 17:55:54 +08:00
|
|
|
|
framedClock = new FramedClock(rateAdjustClock);
|
|
|
|
|
playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; };
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private HitObjectType mode = HitObjectType.Slider;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
|
2017-02-14 17:55:54 +08:00
|
|
|
|
private Container playfieldContainer;
|
|
|
|
|
private Container approachContainer;
|
|
|
|
|
|
|
|
|
|
private void load(HitObjectType mode)
|
|
|
|
|
{
|
|
|
|
|
this.mode = mode;
|
|
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case HitObjectType.Circle:
|
|
|
|
|
const int count = 10;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
var h = new HitCircle
|
|
|
|
|
{
|
|
|
|
|
StartTime = framedClock.CurrentTime + 600 + i * 80,
|
|
|
|
|
Position = new Vector2((i - count / 2) * 14),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
add(new DrawableHitCircle(h));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HitObjectType.Slider:
|
|
|
|
|
add(new DrawableSlider(new Slider
|
|
|
|
|
{
|
|
|
|
|
StartTime = framedClock.CurrentTime + 600,
|
2017-04-21 19:29:27 +08:00
|
|
|
|
ControlPoints = new List<Vector2>
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
2017-04-21 19:29:27 +08:00
|
|
|
|
new Vector2(-200, 0),
|
|
|
|
|
new Vector2(400, 0),
|
2017-02-14 17:55:54 +08:00
|
|
|
|
},
|
2017-04-21 19:29:27 +08:00
|
|
|
|
Distance = 400,
|
2017-02-14 17:55:54 +08:00
|
|
|
|
Position = new Vector2(-200, 0),
|
|
|
|
|
Velocity = 1,
|
2017-02-16 12:20:40 +08:00
|
|
|
|
TickDistance = 100,
|
2017-02-14 17:55:54 +08:00
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
case HitObjectType.Spinner:
|
|
|
|
|
add(new DrawableSpinner(new Spinner
|
|
|
|
|
{
|
|
|
|
|
StartTime = framedClock.CurrentTime + 600,
|
2017-03-13 18:15:25 +08:00
|
|
|
|
EndTime = framedClock.CurrentTime + 1600,
|
2017-02-14 17:55:54 +08:00
|
|
|
|
Position = new Vector2(0, 0),
|
|
|
|
|
}));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Reset()
|
|
|
|
|
{
|
|
|
|
|
base.Reset();
|
|
|
|
|
|
2017-02-14 17:55:54 +08:00
|
|
|
|
playbackSpeed.TriggerChange();
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2017-03-31 16:55:07 +08:00
|
|
|
|
AddStep(@"circles", () => load(HitObjectType.Circle));
|
|
|
|
|
AddStep(@"slider", () => load(HitObjectType.Slider));
|
|
|
|
|
AddStep(@"spinner", () => load(HitObjectType.Spinner));
|
2016-11-19 18:07:57 +08:00
|
|
|
|
|
2017-03-31 16:55:07 +08:00
|
|
|
|
AddToggleStep(@"auto", state => { auto = state; load(mode); });
|
2016-11-19 18:07:57 +08:00
|
|
|
|
|
2017-04-10 16:10:15 +08:00
|
|
|
|
BasicSliderBar<double> sliderBar;
|
2017-03-31 16:55:07 +08:00
|
|
|
|
Add(new Container
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
2017-03-31 16:55:07 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteText { Text = "Playback Speed" },
|
2017-04-10 16:10:15 +08:00
|
|
|
|
sliderBar = new BasicSliderBar<double>
|
2017-03-31 16:55:07 +08:00
|
|
|
|
{
|
|
|
|
|
Width = 150,
|
|
|
|
|
Height = 10,
|
|
|
|
|
SelectionColor = Color4.Orange,
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-14 17:55:54 +08:00
|
|
|
|
});
|
2016-11-02 14:37:45 +08:00
|
|
|
|
|
2017-04-10 16:10:15 +08:00
|
|
|
|
sliderBar.Current.BindTo(playbackSpeed);
|
|
|
|
|
|
2017-02-14 17:55:54 +08:00
|
|
|
|
framedClock.ProcessFrame();
|
|
|
|
|
|
|
|
|
|
var clockAdjustContainer = new Container
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2017-02-14 17:55:54 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Clock = framedClock,
|
|
|
|
|
Children = new[]
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2017-02-14 17:55:54 +08:00
|
|
|
|
playfieldContainer = new Container { RelativeSizeAxes = Axes.Both },
|
|
|
|
|
approachContainer = new Container { RelativeSizeAxes = Axes.Both }
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2017-02-14 17:55:54 +08:00
|
|
|
|
Add(clockAdjustContainer);
|
2016-11-19 18:07:57 +08:00
|
|
|
|
|
2017-02-14 17:55:54 +08:00
|
|
|
|
load(mode);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private int depth;
|
|
|
|
|
|
2017-03-15 20:48:01 +08:00
|
|
|
|
private void add(DrawableOsuHitObject h)
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
h.Anchor = Anchor.Centre;
|
|
|
|
|
h.Depth = depth++;
|
2016-12-07 17:18:36 +08:00
|
|
|
|
|
2017-02-14 17:55:54 +08:00
|
|
|
|
if (auto)
|
|
|
|
|
{
|
|
|
|
|
h.State = ArmedState.Hit;
|
2017-03-23 18:00:18 +08:00
|
|
|
|
h.Judgement = new OsuJudgement { Result = HitResult.Hit };
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
|
|
|
|
playfieldContainer.Add(h);
|
|
|
|
|
var proxyable = h as IDrawableHitObjectWithProxiedApproach;
|
|
|
|
|
if (proxyable != null)
|
|
|
|
|
approachContainer.Add(proxyable.ProxiedLayer.CreateProxy());
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
2017-03-20 12:10:24 +08:00
|
|
|
|
|
|
|
|
|
private enum HitObjectType
|
|
|
|
|
{
|
|
|
|
|
Circle,
|
|
|
|
|
Slider,
|
|
|
|
|
Spinner
|
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|