1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 04:52:56 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/ThemeComparisonTestScene.cs

78 lines
2.4 KiB
C#
Raw Normal View History

2023-06-23 00:37:25 +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.
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.UserInterface
{
2022-11-24 13:32:20 +08:00
public abstract partial class ThemeComparisonTestScene : OsuGridTestScene
{
2024-02-14 18:53:41 +08:00
private readonly bool showWithoutColourProvider;
2024-02-14 08:49:29 +08:00
2024-02-14 18:53:41 +08:00
protected ThemeComparisonTestScene(bool showWithoutColourProvider = true)
: base(1, showWithoutColourProvider ? 2 : 1)
{
2024-02-14 18:53:41 +08:00
this.showWithoutColourProvider = showWithoutColourProvider;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2024-02-14 18:53:41 +08:00
if (showWithoutColourProvider)
{
2024-02-14 08:49:29 +08:00
Cell(0, 0).AddRange(new[]
{
2024-02-14 08:49:29 +08:00
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.GreySeaFoam
},
CreateContent()
});
}
}
protected void CreateThemedContent(OverlayColourScheme colourScheme)
{
var colourProvider = new OverlayColourProvider(colourScheme);
2024-02-14 18:53:41 +08:00
int col = showWithoutColourProvider ? 1 : 0;
2024-02-14 08:49:29 +08:00
Cell(0, col).Clear();
Cell(0, col).Add(new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[]
{
(typeof(OverlayColourProvider), colourProvider)
},
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4
},
CreateContent()
}
});
}
protected abstract Drawable CreateContent();
[Test]
public void TestAllColourSchemes()
{
foreach (var scheme in Enum.GetValues(typeof(OverlayColourScheme)).Cast<OverlayColourScheme>())
AddStep($"set {scheme} scheme", () => CreateThemedContent(scheme));
}
}
}