2021-07-08 06:51:46 +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.
|
|
|
|
|
2021-07-08 07:36:44 +00:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Framework.Utils;
|
2021-07-08 06:51:46 +00:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Rulesets.Catch.Edit.Blueprints;
|
2021-07-08 07:36:44 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
|
2021-07-08 06:51:46 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2021-07-08 07:36:44 +00:00
|
|
|
using osuTK.Input;
|
2021-07-08 06:51:46 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Tests.Editor
|
|
|
|
{
|
|
|
|
public class TestSceneBananaShowerPlacementBlueprint : CatchPlacementBlueprintTestScene
|
|
|
|
{
|
|
|
|
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableBananaShower((BananaShower)hitObject);
|
|
|
|
|
|
|
|
protected override PlacementBlueprint CreateBlueprint() => new BananaShowerPlacementBlueprint();
|
|
|
|
|
|
|
|
protected override void AddHitObject(DrawableHitObject hitObject)
|
|
|
|
{
|
|
|
|
// Create nested bananas (but positions are not randomized because beatmap processing is not done).
|
|
|
|
hitObject.HitObject.ApplyDefaults(new ControlPointInfo(), Beatmap.Value.BeatmapInfo.BaseDifficulty);
|
|
|
|
|
|
|
|
base.AddHitObject(hitObject);
|
|
|
|
}
|
2021-07-08 07:36:44 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBasicPlacement()
|
|
|
|
{
|
|
|
|
const double start_time = 100;
|
|
|
|
const double end_time = 500;
|
|
|
|
|
|
|
|
AddMoveStep(start_time, 0);
|
|
|
|
AddClickStep(MouseButton.Left);
|
|
|
|
AddMoveStep(end_time, 0);
|
|
|
|
AddClickStep(MouseButton.Right);
|
|
|
|
AddAssert("banana shower is placed", () => LastObject is DrawableBananaShower);
|
|
|
|
AddAssert("start time is correct", () => Precision.AlmostEquals(LastObject.HitObject.StartTime, start_time));
|
|
|
|
AddAssert("end time is correct", () => Precision.AlmostEquals(LastObject.HitObject.GetEndTime(), end_time));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestReversePlacement()
|
|
|
|
{
|
|
|
|
const double start_time = 100;
|
|
|
|
const double end_time = 500;
|
|
|
|
|
|
|
|
AddMoveStep(end_time, 0);
|
|
|
|
AddClickStep(MouseButton.Left);
|
|
|
|
AddMoveStep(start_time, 0);
|
|
|
|
AddClickStep(MouseButton.Right);
|
|
|
|
AddAssert("start time is correct", () => Precision.AlmostEquals(LastObject.HitObject.StartTime, start_time));
|
|
|
|
AddAssert("end time is correct", () => Precision.AlmostEquals(LastObject.HitObject.GetEndTime(), end_time));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFinishWithZeroDuration()
|
|
|
|
{
|
|
|
|
AddMoveStep(100, 0);
|
|
|
|
AddClickStep(MouseButton.Left);
|
|
|
|
AddClickStep(MouseButton.Right);
|
|
|
|
AddAssert("banana shower is not placed", () => LastObject == null);
|
|
|
|
AddAssert("state is waiting", () => CurrentBlueprint?.PlacementActive == PlacementBlueprint.PlacementState.Waiting);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestOpacity()
|
|
|
|
{
|
|
|
|
AddMoveStep(100, 0);
|
|
|
|
AddClickStep(MouseButton.Left);
|
2021-07-08 07:40:18 +00:00
|
|
|
AddUntilStep("outline is semitransparent", () => Precision.DefinitelyBigger(1, timeSpanOutline.Alpha));
|
2021-07-08 07:36:44 +00:00
|
|
|
AddMoveStep(200, 0);
|
2021-07-08 07:40:18 +00:00
|
|
|
AddUntilStep("outline is opaque", () => Precision.AlmostEquals(timeSpanOutline.Alpha, 1));
|
2021-07-08 07:36:44 +00:00
|
|
|
AddMoveStep(100, 0);
|
2021-07-08 07:40:18 +00:00
|
|
|
AddUntilStep("outline is semitransparent", () => Precision.DefinitelyBigger(1, timeSpanOutline.Alpha));
|
2021-07-08 07:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private TimeSpanOutline timeSpanOutline => Content.ChildrenOfType<TimeSpanOutline>().Single();
|
2021-07-08 06:51:46 +00:00
|
|
|
}
|
|
|
|
}
|