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;
|
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 partial class TestSceneManiaBeatSnapGrid : EditorClockTestScene
|
2020-05-14 10:17:24 +00:00
|
|
|
|
{
|
|
|
|
|
[Cached(typeof(IScrollingInfo))]
|
|
|
|
|
private ScrollingTestContainer.TestScrollingInfo scrollingInfo = new ScrollingTestContainer.TestScrollingInfo();
|
|
|
|
|
|
|
|
|
|
[Cached(typeof(EditorBeatmap))]
|
2022-10-05 10:14:31 +00:00
|
|
|
|
private EditorBeatmap editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition(2))
|
2022-01-12 14:17:35 +00:00
|
|
|
|
{
|
|
|
|
|
BeatmapInfo =
|
|
|
|
|
{
|
|
|
|
|
Ruleset = new ManiaRuleset().RulesetInfo
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-05-14 10:17:24 +00:00
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
{
|
2022-10-05 10:14:31 +00:00
|
|
|
|
new StageDefinition(4),
|
|
|
|
|
new StageDefinition(3)
|
2020-05-14 10:17:24 +00:00
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
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 partial 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)
|
2022-11-30 11:17:58 +00:00
|
|
|
|
: base(new ManiaRuleset())
|
2020-05-27 14:15:16 +00:00
|
|
|
|
{
|
|
|
|
|
Playfield = playfield;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Drawable Child
|
|
|
|
|
{
|
|
|
|
|
set => InternalChild = value;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-12 06:23:41 +00:00
|
|
|
|
public override SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.All)
|
2020-11-24 08:14:39 +00:00
|
|
|
|
{
|
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
|
}
|
2020-05-27 14:15:16 +00:00
|
|
|
|
}
|
2020-05-14 10:17:24 +00:00
|
|
|
|
}
|