mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 20:32:55 +08:00
Merge pull request #10921 from peppy/hitcircle-test-scene-shows-judgements
Refactor TestSceneHitCircle to show judgements
This commit is contained in:
commit
721005e306
@ -1,17 +1,17 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
||||||
using osuTK;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
@ -38,13 +38,37 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Drawable testSingle(float circleSize, bool auto = false, double timeOffset = 0, Vector2? positionOffset = null)
|
private Drawable testSingle(float circleSize, bool auto = false, double timeOffset = 0, Vector2? positionOffset = null)
|
||||||
|
{
|
||||||
|
var drawable = createSingle(circleSize, auto, timeOffset, positionOffset);
|
||||||
|
|
||||||
|
var playfield = new TestOsuPlayfield();
|
||||||
|
playfield.Add(drawable);
|
||||||
|
return playfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable testStream(float circleSize, bool auto = false)
|
||||||
|
{
|
||||||
|
var playfield = new TestOsuPlayfield();
|
||||||
|
|
||||||
|
Vector2 pos = new Vector2(-250, 0);
|
||||||
|
|
||||||
|
for (int i = 0; i <= 1000; i += 100)
|
||||||
|
{
|
||||||
|
playfield.Add(createSingle(circleSize, auto, i, pos));
|
||||||
|
pos.X += 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
return playfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestDrawableHitCircle createSingle(float circleSize, bool auto, double timeOffset, Vector2? positionOffset)
|
||||||
{
|
{
|
||||||
positionOffset ??= Vector2.Zero;
|
positionOffset ??= Vector2.Zero;
|
||||||
|
|
||||||
var circle = new HitCircle
|
var circle = new HitCircle
|
||||||
{
|
{
|
||||||
StartTime = Time.Current + 1000 + timeOffset,
|
StartTime = Time.Current + 1000 + timeOffset,
|
||||||
Position = positionOffset.Value,
|
Position = OsuPlayfield.BASE_SIZE / 4 + positionOffset.Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
|
circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
|
||||||
@ -53,31 +77,14 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||||
|
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto) => new TestDrawableHitCircle(circle, auto)
|
protected virtual TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto) => new TestDrawableHitCircle(circle, auto)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Depth = depthIndex++
|
Depth = depthIndex++
|
||||||
};
|
};
|
||||||
|
|
||||||
private Drawable testStream(float circleSize, bool auto = false)
|
|
||||||
{
|
|
||||||
var container = new Container { RelativeSizeAxes = Axes.Both };
|
|
||||||
|
|
||||||
Vector2 pos = new Vector2(-250, 0);
|
|
||||||
|
|
||||||
for (int i = 0; i <= 1000; i += 100)
|
|
||||||
{
|
|
||||||
container.Add(testSingle(circleSize, auto, i, pos));
|
|
||||||
pos.X += 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected class TestDrawableHitCircle : DrawableHitCircle
|
protected class TestDrawableHitCircle : DrawableHitCircle
|
||||||
{
|
{
|
||||||
private readonly bool auto;
|
private readonly bool auto;
|
||||||
@ -101,5 +108,13 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
base.CheckForResult(userTriggered, timeOffset);
|
base.CheckForResult(userTriggered, timeOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected class TestOsuPlayfield : OsuPlayfield
|
||||||
|
{
|
||||||
|
public TestOsuPlayfield()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
@ -10,6 +13,19 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public class TestSceneShaking : TestSceneHitCircle
|
public class TestSceneShaking : TestSceneHitCircle
|
||||||
{
|
{
|
||||||
|
private readonly List<ScheduledDelegate> scheduledTasks = new List<ScheduledDelegate>();
|
||||||
|
|
||||||
|
protected override IBeatmap CreateBeatmapForSkinProvider()
|
||||||
|
{
|
||||||
|
// best way to run cleanup before a new step is run
|
||||||
|
foreach (var task in scheduledTasks)
|
||||||
|
task.Cancel();
|
||||||
|
|
||||||
|
scheduledTasks.Clear();
|
||||||
|
|
||||||
|
return base.CreateBeatmapForSkinProvider();
|
||||||
|
}
|
||||||
|
|
||||||
protected override TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto)
|
protected override TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto)
|
||||||
{
|
{
|
||||||
var drawableHitObject = base.CreateDrawableHitCircle(circle, auto);
|
var drawableHitObject = base.CreateDrawableHitCircle(circle, auto);
|
||||||
@ -17,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
Debug.Assert(drawableHitObject.HitObject.HitWindows != null);
|
Debug.Assert(drawableHitObject.HitObject.HitWindows != null);
|
||||||
|
|
||||||
double delay = drawableHitObject.HitObject.StartTime - (drawableHitObject.HitObject.HitWindows.WindowFor(HitResult.Miss) + RNG.Next(0, 300)) - Time.Current;
|
double delay = drawableHitObject.HitObject.StartTime - (drawableHitObject.HitObject.HitWindows.WindowFor(HitResult.Miss) + RNG.Next(0, 300)) - Time.Current;
|
||||||
Scheduler.AddDelayed(() => drawableHitObject.TriggerJudgement(), delay);
|
scheduledTasks.Add(Scheduler.AddDelayed(() => drawableHitObject.TriggerJudgement(), delay));
|
||||||
|
|
||||||
return drawableHitObject;
|
return drawableHitObject;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user