2021-01-16 04:46: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.
|
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2021-01-16 04:46:46 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Beatmaps
|
|
|
|
|
{
|
2021-01-19 22:10:15 +00:00
|
|
|
|
public abstract partial class LegacyBeatmapSkinColourTest : ScreenTestScene
|
2021-01-16 04:46:46 +00:00
|
|
|
|
{
|
|
|
|
|
protected readonly Bindable<bool> BeatmapSkins = new Bindable<bool>();
|
|
|
|
|
protected readonly Bindable<bool> BeatmapColours = new Bindable<bool>();
|
|
|
|
|
|
|
|
|
|
protected ExposedPlayer TestPlayer;
|
|
|
|
|
|
2021-05-31 10:57:31 +00:00
|
|
|
|
private WorkingBeatmap testBeatmap;
|
2021-01-16 04:46:46 +00:00
|
|
|
|
|
2021-05-31 10:57:31 +00:00
|
|
|
|
protected void PrepareBeatmap(Func<WorkingBeatmap> createBeatmap) => AddStep("prepare beatmap", () => testBeatmap = createBeatmap());
|
2021-01-16 04:46:46 +00:00
|
|
|
|
|
2021-05-31 10:57:31 +00:00
|
|
|
|
protected void ConfigureTest(bool useBeatmapSkin, bool useBeatmapColours, bool userHasCustomColours)
|
2021-01-16 04:46:46 +00:00
|
|
|
|
{
|
|
|
|
|
configureSettings(useBeatmapSkin, useBeatmapColours);
|
2021-05-31 10:57:31 +00:00
|
|
|
|
AddStep("load beatmap", () => TestPlayer = LoadBeatmap(userHasCustomColours));
|
2021-01-16 04:46:46 +00:00
|
|
|
|
AddUntilStep("wait for player load", () => TestPlayer.IsLoaded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void configureSettings(bool beatmapSkins, bool beatmapColours)
|
|
|
|
|
{
|
|
|
|
|
AddStep($"{(beatmapSkins ? "enable" : "disable")} beatmap skins", () =>
|
|
|
|
|
{
|
|
|
|
|
BeatmapSkins.Value = beatmapSkins;
|
|
|
|
|
});
|
|
|
|
|
AddStep($"{(beatmapColours ? "enable" : "disable")} beatmap colours", () =>
|
|
|
|
|
{
|
|
|
|
|
BeatmapColours.Value = beatmapColours;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual ExposedPlayer LoadBeatmap(bool userHasCustomColours)
|
|
|
|
|
{
|
|
|
|
|
ExposedPlayer player;
|
|
|
|
|
|
2021-06-22 07:48:03 +00:00
|
|
|
|
Beatmap.Value = testBeatmap;
|
2021-01-16 04:46:46 +00:00
|
|
|
|
|
|
|
|
|
LoadScreen(player = CreateTestPlayer(userHasCustomColours));
|
|
|
|
|
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual ExposedPlayer CreateTestPlayer(bool userHasCustomColours) => new ExposedPlayer(userHasCustomColours);
|
|
|
|
|
|
2021-05-05 06:21:09 +00:00
|
|
|
|
protected partial class ExposedPlayer : TestPlayer
|
2021-01-16 04:46:46 +00:00
|
|
|
|
{
|
|
|
|
|
protected readonly bool UserHasCustomColours;
|
|
|
|
|
|
|
|
|
|
public ExposedPlayer(bool userHasCustomColours)
|
2021-05-05 06:21:09 +00:00
|
|
|
|
: base(false, false)
|
2021-01-16 04:46:46 +00:00
|
|
|
|
{
|
|
|
|
|
UserHasCustomColours = userHasCustomColours;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
|
{
|
|
|
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
|
|
|
dependencies.CacheAs<ISkinSource>(new TestSkin(UserHasCustomColours));
|
|
|
|
|
return dependencies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IReadOnlyList<Color4> UsableComboColours =>
|
|
|
|
|
GameplayClockContainer.ChildrenOfType<BeatmapSkinProvidingContainer>()
|
|
|
|
|
.First()
|
|
|
|
|
.GetConfig<GlobalSkinColours, IReadOnlyList<Color4>>(GlobalSkinColours.ComboColours)?.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected class CustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
|
|
|
|
{
|
|
|
|
|
public readonly bool HasColours;
|
|
|
|
|
|
|
|
|
|
public CustomSkinWorkingBeatmap(IBeatmap beatmap, AudioManager audio, bool hasColours)
|
|
|
|
|
: base(beatmap, null, null, audio)
|
|
|
|
|
{
|
|
|
|
|
HasColours = hasColours;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-15 16:38:01 +00:00
|
|
|
|
protected internal override ISkin GetSkin() => new TestBeatmapSkin(BeatmapInfo, HasColours);
|
2021-01-16 04:46:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected class TestBeatmapSkin : LegacyBeatmapSkin
|
|
|
|
|
{
|
|
|
|
|
public static Color4[] Colours { get; } =
|
|
|
|
|
{
|
|
|
|
|
new Color4(50, 100, 150, 255),
|
|
|
|
|
new Color4(40, 80, 120, 255),
|
2021-05-05 06:21:38 +00:00
|
|
|
|
new Color4(25, 50, 75, 255),
|
|
|
|
|
new Color4(10, 20, 30, 255),
|
2021-01-16 04:46:46 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-01-16 07:09:35 +00:00
|
|
|
|
public static readonly Color4 HYPER_DASH_COLOUR = Color4.DarkBlue;
|
|
|
|
|
|
|
|
|
|
public static readonly Color4 HYPER_DASH_AFTER_IMAGE_COLOUR = Color4.DarkCyan;
|
|
|
|
|
|
|
|
|
|
public static readonly Color4 HYPER_DASH_FRUIT_COLOUR = Color4.DarkGoldenrod;
|
|
|
|
|
|
2021-10-02 15:55:29 +00:00
|
|
|
|
public TestBeatmapSkin(BeatmapInfo beatmapInfo, bool hasColours)
|
2022-03-23 05:31:24 +00:00
|
|
|
|
: base(beatmapInfo, null)
|
2021-01-16 04:46:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (hasColours)
|
2021-01-16 07:09:35 +00:00
|
|
|
|
{
|
2021-08-15 14:00:22 +00:00
|
|
|
|
Configuration.CustomComboColours = Colours.ToList();
|
2021-01-16 07:09:35 +00:00
|
|
|
|
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
|
|
|
|
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
|
|
|
|
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
|
|
|
|
}
|
2021-01-16 04:46:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected class TestSkin : LegacySkin, ISkinSource
|
|
|
|
|
{
|
|
|
|
|
public static Color4[] Colours { get; } =
|
|
|
|
|
{
|
|
|
|
|
new Color4(150, 100, 50, 255),
|
|
|
|
|
new Color4(20, 20, 20, 255),
|
2021-05-05 06:21:38 +00:00
|
|
|
|
new Color4(75, 50, 25, 255),
|
|
|
|
|
new Color4(80, 80, 80, 255),
|
2021-01-16 04:46:46 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-01-16 07:09:35 +00:00
|
|
|
|
public static readonly Color4 HYPER_DASH_COLOUR = Color4.LightBlue;
|
|
|
|
|
|
|
|
|
|
public static readonly Color4 HYPER_DASH_AFTER_IMAGE_COLOUR = Color4.LightCoral;
|
|
|
|
|
|
|
|
|
|
public static readonly Color4 HYPER_DASH_FRUIT_COLOUR = Color4.LightCyan;
|
|
|
|
|
|
2021-01-16 04:46:46 +00:00
|
|
|
|
public TestSkin(bool hasCustomColours)
|
2022-03-23 06:05:01 +00:00
|
|
|
|
: base(new SkinInfo(), null, null)
|
2021-01-16 04:46:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (hasCustomColours)
|
2021-01-16 07:09:35 +00:00
|
|
|
|
{
|
2021-08-15 14:00:22 +00:00
|
|
|
|
Configuration.CustomComboColours = Colours.ToList();
|
2021-01-16 07:09:35 +00:00
|
|
|
|
Configuration.CustomColours.Add("HyperDash", HYPER_DASH_COLOUR);
|
|
|
|
|
Configuration.CustomColours.Add("HyperDashAfterImage", HYPER_DASH_AFTER_IMAGE_COLOUR);
|
|
|
|
|
Configuration.CustomColours.Add("HyperDashFruit", HYPER_DASH_FRUIT_COLOUR);
|
|
|
|
|
}
|
2021-01-16 04:46:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event Action SourceChanged
|
|
|
|
|
{
|
|
|
|
|
add { }
|
|
|
|
|
remove { }
|
|
|
|
|
}
|
2021-06-06 02:08:54 +00:00
|
|
|
|
|
2021-06-22 09:02:21 +00:00
|
|
|
|
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => lookupFunction(this) ? this : null;
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ISkin> AllSources => new[] { this };
|
2021-01-16 04:46:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|