1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 23:37:26 +08:00
osu-lazer/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs

74 lines
2.1 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2019-09-09 11:48:34 +08:00
using osu.Framework.Testing.Input;
2018-04-13 17:19:50 +08:00
using osu.Game.Rulesets.Osu.UI.Cursor;
2019-09-09 11:48:34 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Osu.Tests
{
[TestFixture]
2019-08-30 12:58:17 +08:00
public class TestSceneGameplayCursor : SkinnableTestScene
2018-04-13 17:19:50 +08:00
{
2019-09-09 16:03:14 +08:00
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(OsuCursorContainer),
typeof(CursorTrail)
};
2018-04-13 17:19:50 +08:00
[BackgroundDependencyLoader]
private void load()
{
2019-09-09 11:48:34 +08:00
SetContents(() => new MovingCursorInputManager
2019-08-30 12:58:17 +08:00
{
2019-09-09 12:01:40 +08:00
Child = new ClickingCursorContainer
2019-09-09 11:48:34 +08:00
{
RelativeSizeAxes = Axes.Both,
Masking = true,
}
2019-08-30 12:58:17 +08:00
});
2018-04-13 17:19:50 +08:00
}
2019-09-09 11:48:34 +08:00
2019-09-09 12:01:40 +08:00
private class ClickingCursorContainer : OsuCursorContainer
{
protected override void Update()
{
base.Update();
double currentTime = Time.Current;
if (((int)(currentTime / 1000)) % 2 == 0)
OnPressed(OsuAction.LeftButton);
else
OnReleased(OsuAction.LeftButton);
}
}
2019-09-09 11:48:34 +08:00
private class MovingCursorInputManager : ManualInputManager
{
public MovingCursorInputManager()
{
UseParentInput = false;
}
protected override void Update()
{
base.Update();
const double spin_duration = 5000;
double currentTime = Time.Current;
double angle = (currentTime % spin_duration) / spin_duration * 2 * Math.PI;
Vector2 rPos = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
MoveMouseTo(ToScreenSpace(DrawSize / 2 + DrawSize / 3 * rPos));
}
}
2018-04-13 17:19:50 +08:00
}
}