2021-07-08 14:51:46 +08: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 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-07-08 15:12:02 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NUnit.Framework;
|
2021-07-08 14:51:46 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-07-08 15:12:02 +08:00
|
|
|
using osu.Framework.Testing;
|
2021-07-08 14:51:46 +08:00
|
|
|
using osu.Framework.Timing;
|
2021-07-08 15:12:02 +08:00
|
|
|
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
2021-07-08 14:51:46 +08:00
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osu.Game.Tests.Visual;
|
2021-07-08 15:12:02 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Input;
|
2021-07-08 14:51:46 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests.Editor
|
|
|
|
{
|
|
|
|
public abstract partial class CatchPlacementBlueprintTestScene : PlacementBlueprintTestScene
|
|
|
|
{
|
2021-07-08 15:12:02 +08:00
|
|
|
protected const double TIME_SNAP = 100;
|
|
|
|
|
|
|
|
protected DrawableCatchHitObject LastObject;
|
|
|
|
|
2021-07-08 14:51:46 +08:00
|
|
|
protected new ScrollingHitObjectContainer HitObjectContainer => contentContainer.Playfield.HitObjectContainer;
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => contentContainer;
|
|
|
|
|
|
|
|
private readonly CatchEditorTestSceneContainer contentContainer;
|
|
|
|
|
|
|
|
protected CatchPlacementBlueprintTestScene()
|
|
|
|
{
|
2021-07-08 15:17:09 +08:00
|
|
|
base.Content.Add(contentContainer = new CatchEditorTestSceneContainer());
|
|
|
|
|
|
|
|
contentContainer.Playfield.Clock = new FramedClock(new ManualClock());
|
2021-07-08 14:51:46 +08:00
|
|
|
}
|
|
|
|
|
2021-07-08 15:12:02 +08:00
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() =>
|
|
|
|
{
|
|
|
|
HitObjectContainer.Clear();
|
|
|
|
ResetPlacement();
|
|
|
|
LastObject = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
protected void AddMoveStep(double time, float x) => AddStep($"move to time={time}, x={x}", () =>
|
|
|
|
{
|
|
|
|
float y = HitObjectContainer.PositionAtTime(time);
|
|
|
|
Vector2 pos = HitObjectContainer.ToScreenSpace(new Vector2(x, y + HitObjectContainer.DrawHeight));
|
|
|
|
InputManager.MoveMouseTo(pos);
|
|
|
|
});
|
|
|
|
|
|
|
|
protected void AddClickStep(MouseButton button) => AddStep($"click {button}", () =>
|
|
|
|
{
|
|
|
|
InputManager.Click(button);
|
|
|
|
});
|
|
|
|
|
|
|
|
protected IEnumerable<FruitOutline> FruitOutlines => Content.ChildrenOfType<FruitOutline>();
|
|
|
|
|
2021-07-08 14:51:46 +08:00
|
|
|
// Unused because AddHitObject is overriden
|
|
|
|
protected override Container CreateHitObjectContainer() => new Container();
|
|
|
|
|
|
|
|
protected override void AddHitObject(DrawableHitObject hitObject)
|
|
|
|
{
|
2021-07-08 15:12:02 +08:00
|
|
|
LastObject = (DrawableCatchHitObject)hitObject;
|
2021-07-08 14:51:46 +08:00
|
|
|
contentContainer.Playfield.HitObjectContainer.Add(hitObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override SnapResult SnapForBlueprint(PlacementBlueprint blueprint)
|
|
|
|
{
|
|
|
|
var result = base.SnapForBlueprint(blueprint);
|
2021-07-08 15:12:02 +08:00
|
|
|
result.Time = Math.Round(HitObjectContainer.TimeAtScreenSpacePosition(result.ScreenSpacePosition) / TIME_SNAP) * TIME_SNAP;
|
2021-07-08 14:51:46 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|