mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 10:47:28 +08:00
Add barebones test for smoke
This commit is contained in:
parent
343bdaa98e
commit
ccef189b81
Binary file not shown.
After Width: | Height: | Size: 251 B |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/cursor-smoke.png
Normal file
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/cursor-smoke.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
97
osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs
Normal file
97
osu.Game.Rulesets.Osu.Tests/TestSceneSmoke.cs
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Input.States;
|
||||||
|
using osu.Framework.Testing.Input;
|
||||||
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public class TestSceneSmoke : OsuSkinnableTestScene
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestSmoking()
|
||||||
|
{
|
||||||
|
AddStep("Create smoke", () =>
|
||||||
|
{
|
||||||
|
SetContents(_ =>
|
||||||
|
{
|
||||||
|
return new SmokingInputManager
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Size = new Vector2(0.95f),
|
||||||
|
Child = new TestSmokeContainer { RelativeSizeAxes = Axes.Both },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private const double spin_duration = 5_000;
|
||||||
|
private const float spin_angle = 4 * MathF.PI;
|
||||||
|
|
||||||
|
private class SmokingInputManager : ManualInputManager
|
||||||
|
{
|
||||||
|
private double? startTime;
|
||||||
|
|
||||||
|
public SmokingInputManager()
|
||||||
|
{
|
||||||
|
UseParentInput = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
MoveMouseTo(ToScreenSpace(DrawSize / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
startTime ??= Time.Current;
|
||||||
|
|
||||||
|
float fraction = (float)((Time.Current - startTime) / spin_duration);
|
||||||
|
|
||||||
|
float angle = fraction * spin_angle;
|
||||||
|
float radius = fraction * Math.Min(DrawSize.X, DrawSize.Y) / 2;
|
||||||
|
|
||||||
|
Vector2 pos = radius * new Vector2(MathF.Cos(angle), MathF.Sin(angle)) + DrawSize / 2;
|
||||||
|
MoveMouseTo(ToScreenSpace(pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestSmokeContainer : SmokeContainer
|
||||||
|
{
|
||||||
|
private double? startTime;
|
||||||
|
private bool isPressing;
|
||||||
|
private bool isFinished;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
startTime ??= Time.Current;
|
||||||
|
|
||||||
|
if (!isPressing && !isFinished && Time.Current > startTime + 0.1)
|
||||||
|
{
|
||||||
|
OnPressed(new KeyBindingPressEvent<OsuAction>(new InputState(), OsuAction.Smoke));
|
||||||
|
isPressing = true;
|
||||||
|
isFinished = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPressing && Time.Current > startTime + spin_duration)
|
||||||
|
{
|
||||||
|
OnReleased(new KeyBindingReleaseEvent<OsuAction>(new InputState(), OsuAction.Smoke));
|
||||||
|
isPressing = false;
|
||||||
|
isFinished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Osu.Skinning;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Rulesets.Osu.Skinning.Default;
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -30,6 +30,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
{
|
{
|
||||||
if (e.Action == OsuAction.Smoke)
|
if (e.Action == OsuAction.Smoke)
|
||||||
{
|
{
|
||||||
|
Logger.Log("holy moly");
|
||||||
|
|
||||||
isSmoking = true;
|
isSmoking = true;
|
||||||
AddInternal(new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Smoke), _ => new DefaultSmoke()));
|
AddInternal(new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Smoke), _ => new DefaultSmoke()));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user