2021-04-27 17:03:49 +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-03-21 16:01:46 +08:00
|
|
|
using System.Linq;
|
2021-04-29 12:53:01 +08:00
|
|
|
using NUnit.Framework;
|
2022-03-16 21:23:19 +08:00
|
|
|
using osu.Framework.Allocation;
|
2023-02-22 16:56:59 +08:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2021-04-30 11:35:58 +08:00
|
|
|
using osu.Framework.Graphics;
|
2022-03-21 16:01:46 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2021-04-27 17:03:49 +08:00
|
|
|
using osu.Framework.Testing;
|
2022-03-16 21:23:19 +08:00
|
|
|
using osu.Game.Overlays;
|
2022-03-21 16:01:46 +08:00
|
|
|
using osu.Game.Overlays.Settings;
|
2023-01-26 17:21:04 +08:00
|
|
|
using osu.Game.Overlays.SkinEditor;
|
2021-04-28 14:14:48 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2023-02-16 14:24:37 +08:00
|
|
|
using osu.Game.Screens.Edit;
|
2022-03-21 16:01:46 +08:00
|
|
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
2022-07-28 16:58:07 +08:00
|
|
|
using osu.Game.Skinning;
|
2022-03-21 16:01:46 +08:00
|
|
|
using osuTK.Input;
|
2021-04-27 17:03:49 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
2021-04-29 12:53:01 +08:00
|
|
|
public partial class TestSceneSkinEditor : PlayerTestScene
|
2021-04-27 17:03:49 +08:00
|
|
|
{
|
2023-02-22 16:56:59 +08:00
|
|
|
private SkinEditor skinEditor = null!;
|
2021-04-29 12:53:01 +08:00
|
|
|
|
2021-05-13 13:54:52 +08:00
|
|
|
protected override bool Autoplay => true;
|
|
|
|
|
2022-03-16 21:23:19 +08:00
|
|
|
[Cached]
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
|
|
|
|
2023-02-16 14:24:37 +08:00
|
|
|
[Cached]
|
|
|
|
public readonly EditorClipboard Clipboard = new EditorClipboard();
|
|
|
|
|
2021-04-27 17:03:49 +08:00
|
|
|
[SetUpSteps]
|
2021-04-29 12:53:01 +08:00
|
|
|
public override void SetUpSteps()
|
2021-04-27 17:03:49 +08:00
|
|
|
{
|
2021-04-29 12:53:01 +08:00
|
|
|
base.SetUpSteps();
|
2021-04-27 17:03:49 +08:00
|
|
|
|
2023-02-15 17:31:55 +08:00
|
|
|
AddUntilStep("wait for hud load", () => Player.ChildrenOfType<SkinComponentsContainer>().All(c => c.ComponentsLoaded));
|
2022-07-28 16:58:07 +08:00
|
|
|
|
2021-05-10 21:36:20 +08:00
|
|
|
AddStep("reload skin editor", () =>
|
2021-04-29 12:53:01 +08:00
|
|
|
{
|
2023-02-22 16:56:59 +08:00
|
|
|
if (skinEditor.IsNotNull())
|
|
|
|
skinEditor.Expire();
|
2022-03-21 16:01:46 +08:00
|
|
|
Player.ScaleTo(0.4f);
|
2021-04-29 12:53:01 +08:00
|
|
|
LoadComponentAsync(skinEditor = new SkinEditor(Player), Add);
|
2021-04-27 17:03:49 +08:00
|
|
|
});
|
2023-02-22 16:56:59 +08:00
|
|
|
AddUntilStep("wait for loaded", () => skinEditor.IsLoaded);
|
2021-04-27 17:03:49 +08:00
|
|
|
}
|
|
|
|
|
2021-04-29 12:53:01 +08:00
|
|
|
[Test]
|
|
|
|
public void TestToggleEditor()
|
|
|
|
{
|
2023-02-22 16:56:59 +08:00
|
|
|
AddToggleStep("toggle editor visibility", _ => skinEditor.ToggleVisibility());
|
2021-04-29 12:53:01 +08:00
|
|
|
}
|
|
|
|
|
2022-03-21 16:01:46 +08:00
|
|
|
[Test]
|
|
|
|
public void TestEditComponent()
|
|
|
|
{
|
2022-09-08 23:47:55 +08:00
|
|
|
BarHitErrorMeter hitErrorMeter = null!;
|
2022-03-21 16:01:46 +08:00
|
|
|
|
|
|
|
AddStep("select bar hit error blueprint", () =>
|
|
|
|
{
|
|
|
|
var blueprint = skinEditor.ChildrenOfType<SkinBlueprint>().First(b => b.Item is BarHitErrorMeter);
|
|
|
|
|
|
|
|
hitErrorMeter = (BarHitErrorMeter)blueprint.Item;
|
2023-02-22 16:56:59 +08:00
|
|
|
skinEditor.SelectedComponents.Clear();
|
2022-03-21 16:01:46 +08:00
|
|
|
skinEditor.SelectedComponents.Add(blueprint.Item);
|
|
|
|
});
|
|
|
|
|
2022-09-08 23:47:55 +08:00
|
|
|
AddStep("move by keyboard", () => InputManager.Key(Key.Right));
|
|
|
|
|
|
|
|
AddAssert("hitErrorMeter moved", () => hitErrorMeter.X != 0);
|
|
|
|
|
2022-03-21 16:01:46 +08:00
|
|
|
AddAssert("value is default", () => hitErrorMeter.JudgementLineThickness.IsDefault);
|
|
|
|
|
|
|
|
AddStep("hover first slider", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(
|
|
|
|
skinEditor.ChildrenOfType<SkinSettingsToolbox>().First()
|
|
|
|
.ChildrenOfType<SettingsSlider<float>>().First()
|
|
|
|
.ChildrenOfType<SliderBar<float>>().First()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("adjust slider via keyboard", () => InputManager.Key(Key.Left));
|
|
|
|
|
|
|
|
AddAssert("value is less than default", () => hitErrorMeter.JudgementLineThickness.Value < hitErrorMeter.JudgementLineThickness.Default);
|
|
|
|
}
|
|
|
|
|
2021-04-29 12:53:01 +08:00
|
|
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
2021-04-27 17:03:49 +08:00
|
|
|
}
|
|
|
|
}
|