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-14 17:46:34 +08:00
|
|
|
|
using osu.Framework.Screens.Testing;
|
|
|
|
|
using osu.Framework.Timing;
|
2017-03-15 11:52:25 +08:00
|
|
|
|
using osu.Game.Modes.Objects;
|
2017-03-14 17:46:34 +08:00
|
|
|
|
using osu.Game.Modes.Objects.Drawables;
|
2017-03-15 20:48:01 +08:00
|
|
|
|
using osu.Game.Modes.Osu.Judgements;
|
2017-03-14 17:46:34 +08:00
|
|
|
|
using osu.Game.Modes.Osu.Objects;
|
|
|
|
|
using osu.Game.Modes.Osu.Objects.Drawables;
|
|
|
|
|
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-02-14 17:55:54 +08:00
|
|
|
|
private FramedClock framedClock;
|
|
|
|
|
|
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-07 09:59:19 +08:00
|
|
|
|
private 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-03-15 11:52:25 +08:00
|
|
|
|
CurveObject = new CurvedHitObject
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
2017-03-15 11:52:25 +08:00
|
|
|
|
ControlPoints = new List<Vector2>
|
|
|
|
|
{
|
|
|
|
|
new Vector2(-200, 0),
|
|
|
|
|
new Vector2(400, 0),
|
|
|
|
|
},
|
|
|
|
|
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-02-14 17:55:54 +08:00
|
|
|
|
AddButton(@"circles", () => load(HitObjectType.Circle));
|
|
|
|
|
AddButton(@"slider", () => load(HitObjectType.Slider));
|
|
|
|
|
AddButton(@"spinner", () => load(HitObjectType.Spinner));
|
2016-11-19 18:07:57 +08:00
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
AddToggle(@"auto", state => { auto = state; load(mode); });
|
2016-11-19 18:07:57 +08:00
|
|
|
|
|
2017-02-14 17:55:54 +08:00
|
|
|
|
ButtonsContainer.Add(new SpriteText { Text = "Playback Speed" });
|
|
|
|
|
ButtonsContainer.Add(new BasicSliderBar<double>
|
|
|
|
|
{
|
|
|
|
|
Width = 150,
|
|
|
|
|
Height = 10,
|
|
|
|
|
SelectionColor = Color4.Orange,
|
|
|
|
|
Bindable = playbackSpeed
|
|
|
|
|
});
|
2016-11-02 14:37:45 +08:00
|
|
|
|
|
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;
|
|
|
|
|
h.Judgement = new OsuJudgementInfo { 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|