2020-05-14 10:17:24 +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.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-05-27 14:15:16 +00:00
|
|
|
using System.Linq;
|
2020-05-14 10:17:24 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Configuration;
|
2020-05-27 14:15:16 +00:00
|
|
|
using osu.Game.Rulesets.Edit;
|
2020-05-14 10:17:24 +00:00
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Mania.Edit;
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2021-09-01 09:05:10 +00:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2020-05-27 14:15:16 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.UI;
|
2020-05-14 10:17:24 +00:00
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osu.Game.Screens.Edit;
|
|
|
|
using osu.Game.Tests.Visual;
|
2020-05-27 14:15:16 +00:00
|
|
|
using osuTK;
|
2020-05-14 10:17:24 +00:00
|
|
|
|
2020-09-25 09:48:04 +00:00
|
|
|
namespace osu.Game.Rulesets.Mania.Tests.Editor
|
2020-05-14 10:17:24 +00:00
|
|
|
{
|
2020-05-27 14:15:16 +00:00
|
|
|
public class TestSceneManiaBeatSnapGrid : EditorClockTestScene
|
2020-05-14 10:17:24 +00:00
|
|
|
{
|
|
|
|
[Cached(typeof(IScrollingInfo))]
|
|
|
|
private ScrollingTestContainer.TestScrollingInfo scrollingInfo = new ScrollingTestContainer.TestScrollingInfo();
|
|
|
|
|
|
|
|
[Cached(typeof(EditorBeatmap))]
|
|
|
|
private EditorBeatmap editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition()));
|
|
|
|
|
|
|
|
private readonly ManiaBeatSnapGrid beatSnapGrid;
|
|
|
|
|
|
|
|
public TestSceneManiaBeatSnapGrid()
|
|
|
|
{
|
|
|
|
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 200 });
|
|
|
|
editorBeatmap.ControlPointInfo.Add(10000, new TimingControlPoint { BeatLength = 200 });
|
|
|
|
|
|
|
|
BeatDivisor.Value = 3;
|
|
|
|
|
|
|
|
// Some sane defaults
|
|
|
|
scrollingInfo.Algorithm.Algorithm = ScrollVisualisationMethod.Constant;
|
|
|
|
scrollingInfo.Direction.Value = ScrollingDirection.Up;
|
|
|
|
scrollingInfo.TimeRange.Value = 1000;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
Playfield = new ManiaPlayfield(new List<StageDefinition>
|
|
|
|
{
|
|
|
|
new StageDefinition { Columns = 4 },
|
|
|
|
new StageDefinition { Columns = 3 }
|
|
|
|
})
|
|
|
|
{
|
|
|
|
Clock = new FramedClock(new StopwatchClock())
|
|
|
|
},
|
2020-05-27 14:15:16 +00:00
|
|
|
new TestHitObjectComposer(Playfield)
|
|
|
|
{
|
|
|
|
Child = beatSnapGrid = new ManiaBeatSnapGrid()
|
|
|
|
}
|
2020-05-14 10:17:24 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
|
|
{
|
|
|
|
// We're providing a constant scroll algorithm.
|
|
|
|
float relativePosition = Playfield.Stages[0].HitObjectContainer.ToLocalSpace(e.ScreenSpaceMousePosition).Y / Playfield.Stages[0].HitObjectContainer.DrawHeight;
|
|
|
|
double timeValue = scrollingInfo.TimeRange.Value * relativePosition;
|
|
|
|
|
2020-05-18 12:27:26 +00:00
|
|
|
beatSnapGrid.SelectionTimeRange = (timeValue, timeValue);
|
2020-05-14 10:17:24 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ManiaPlayfield Playfield { get; }
|
|
|
|
}
|
2020-05-27 14:15:16 +00:00
|
|
|
|
|
|
|
public class TestHitObjectComposer : HitObjectComposer
|
|
|
|
{
|
|
|
|
public override Playfield Playfield { get; }
|
|
|
|
public override IEnumerable<DrawableHitObject> HitObjects => Enumerable.Empty<DrawableHitObject>();
|
|
|
|
public override bool CursorInPlacementArea => false;
|
|
|
|
|
|
|
|
public TestHitObjectComposer(Playfield playfield)
|
|
|
|
{
|
|
|
|
Playfield = playfield;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Drawable Child
|
|
|
|
{
|
|
|
|
set => InternalChild = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2020-11-24 08:14:39 +00:00
|
|
|
public override SnapResult SnapScreenSpacePositionToValidPosition(Vector2 screenSpacePosition)
|
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2021-09-01 09:05:10 +00:00
|
|
|
public override float GetBeatSnapDistanceAt(HitObject referenceObject)
|
2020-05-27 14:15:16 +00:00
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2021-09-01 09:05:10 +00:00
|
|
|
public override float DurationToDistance(HitObject referenceObject, double duration)
|
2020-05-27 14:15:16 +00:00
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2021-09-01 09:05:10 +00:00
|
|
|
public override double DistanceToDuration(HitObject referenceObject, float distance)
|
2020-05-27 14:15:16 +00:00
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2021-09-01 09:05:10 +00:00
|
|
|
public override double GetSnappedDurationFromDistance(HitObject referenceObject, float distance)
|
2020-05-27 14:15:16 +00:00
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2021-09-01 09:05:10 +00:00
|
|
|
public override float GetSnappedDistanceFromDistance(HitObject referenceObject, float distance)
|
2020-05-27 14:15:16 +00:00
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
2020-05-14 10:17:24 +00:00
|
|
|
}
|