2020-06-12 13:48:52 +00:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-06-19 10:08:36 +00:00
|
|
|
using NUnit.Framework;
|
2020-06-12 13:48:52 +00:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Input.Events;
|
2020-06-19 10:08:36 +00:00
|
|
|
using osu.Framework.Threading;
|
2020-06-12 13:48:52 +00:00
|
|
|
using osu.Framework.Utils;
|
2020-06-15 12:48:59 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Statistics;
|
2020-06-19 10:58:35 +00:00
|
|
|
using osu.Game.Scoring;
|
2020-06-18 13:11:03 +00:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2020-06-19 12:14:31 +00:00
|
|
|
using osu.Game.Tests.Visual;
|
2020-06-12 13:48:52 +00:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-06-19 12:14:31 +00:00
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
2020-06-12 13:48:52 +00:00
|
|
|
{
|
|
|
|
public partial class TestSceneAccuracyHeatmap : OsuManualInputManagerTestScene
|
|
|
|
{
|
2020-06-19 10:08:36 +00:00
|
|
|
private Box background;
|
|
|
|
private Drawable object1;
|
|
|
|
private Drawable object2;
|
2020-06-19 12:14:31 +00:00
|
|
|
private TestAccuracyHeatmap accuracyHeatmap;
|
2020-06-19 10:08:36 +00:00
|
|
|
private ScheduledDelegate automaticAdditionDelegate;
|
2020-06-12 13:48:52 +00:00
|
|
|
|
2020-06-19 10:08:36 +00:00
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() =>
|
2020-06-12 13:48:52 +00:00
|
|
|
{
|
2020-06-19 10:08:36 +00:00
|
|
|
automaticAdditionDelegate?.Cancel();
|
|
|
|
automaticAdditionDelegate = null;
|
|
|
|
|
2020-06-12 13:48:52 +00:00
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
background = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4Extensions.FromHex("#333"),
|
|
|
|
},
|
2020-06-22 12:00:35 +00:00
|
|
|
object1 = new BorderCircle
|
2020-06-12 13:48:52 +00:00
|
|
|
{
|
|
|
|
Position = new Vector2(256, 192),
|
|
|
|
Colour = Color4.Yellow,
|
|
|
|
},
|
2020-06-22 12:00:35 +00:00
|
|
|
object2 = new BorderCircle
|
2020-06-12 13:48:52 +00:00
|
|
|
{
|
2020-06-19 10:08:36 +00:00
|
|
|
Position = new Vector2(100, 300),
|
2020-06-12 13:48:52 +00:00
|
|
|
},
|
2021-10-04 08:35:53 +00:00
|
|
|
accuracyHeatmap = new TestAccuracyHeatmap(new ScoreInfo { BeatmapInfo = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo })
|
2020-06-12 13:48:52 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2020-06-16 07:31:02 +00:00
|
|
|
Size = new Vector2(130)
|
2020-06-12 13:48:52 +00:00
|
|
|
}
|
|
|
|
};
|
2020-06-19 10:08:36 +00:00
|
|
|
});
|
2020-06-12 13:48:52 +00:00
|
|
|
|
2020-06-19 10:08:36 +00:00
|
|
|
[Test]
|
|
|
|
public void TestManyHitPointsAutomatic()
|
2020-06-12 13:48:52 +00:00
|
|
|
{
|
2020-06-19 10:08:36 +00:00
|
|
|
AddStep("add scheduled delegate", () =>
|
2020-06-12 13:48:52 +00:00
|
|
|
{
|
2020-06-19 10:08:36 +00:00
|
|
|
automaticAdditionDelegate = Scheduler.AddDelayed(() =>
|
|
|
|
{
|
|
|
|
var randomPos = new Vector2(
|
|
|
|
RNG.NextSingle(object1.DrawPosition.X - object1.DrawSize.X / 2, object1.DrawPosition.X + object1.DrawSize.X / 2),
|
|
|
|
RNG.NextSingle(object1.DrawPosition.Y - object1.DrawSize.Y / 2, object1.DrawPosition.Y + object1.DrawSize.Y / 2));
|
2020-06-12 13:48:52 +00:00
|
|
|
|
2020-06-19 10:08:36 +00:00
|
|
|
// The background is used for ToLocalSpace() since we need to go _inside_ the DrawSizePreservingContainer (Content of TestScene).
|
2020-06-19 12:14:31 +00:00
|
|
|
accuracyHeatmap.AddPoint(object2.Position, object1.Position, randomPos, RNG.NextSingle(10, 500));
|
2020-06-19 10:08:36 +00:00
|
|
|
InputManager.MoveMouseTo(background.ToScreenSpace(randomPos));
|
|
|
|
}, 1, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddWaitStep("wait for some hit points", 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestManualPlacement()
|
|
|
|
{
|
|
|
|
AddStep("return user input", () => InputManager.UseParentInput = true);
|
2020-06-12 13:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
|
|
|
{
|
2020-06-19 12:14:31 +00:00
|
|
|
accuracyHeatmap.AddPoint(object2.Position, object1.Position, background.ToLocalSpace(e.ScreenSpaceMouseDownPosition), 50);
|
2020-06-12 13:48:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-19 12:14:31 +00:00
|
|
|
private partial class TestAccuracyHeatmap : AccuracyHeatmap
|
2020-06-16 07:31:02 +00:00
|
|
|
{
|
2020-06-19 12:14:31 +00:00
|
|
|
public TestAccuracyHeatmap(ScoreInfo score)
|
2020-06-22 09:38:41 +00:00
|
|
|
: base(score, new TestBeatmap(new OsuRuleset().RulesetInfo))
|
2020-06-16 07:31:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public new void AddPoint(Vector2 start, Vector2 end, Vector2 hitPoint, float radius)
|
|
|
|
=> base.AddPoint(start, end, hitPoint, radius);
|
|
|
|
}
|
|
|
|
|
2020-06-12 13:48:52 +00:00
|
|
|
private partial class BorderCircle : CircularContainer
|
|
|
|
{
|
|
|
|
public BorderCircle()
|
|
|
|
{
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
Size = new Vector2(100);
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
BorderThickness = 2;
|
|
|
|
BorderColour = Color4.White;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
|
|
|
},
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Size = new Vector2(4),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|