1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 16:22:21 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/ThemeComparisonTestScene.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

95 lines
3.0 KiB
C#
Raw Normal View History

// 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.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Tests.Visual.UserInterface
{
public abstract partial class ThemeComparisonTestScene : OsuManualInputManagerTestScene
{
2024-02-14 18:53:41 +08:00
private readonly bool showWithoutColourProvider;
2024-02-14 08:49:29 +08:00
public Container ContentContainer { get; private set; } = null!;
2024-02-14 18:53:41 +08:00
protected ThemeComparisonTestScene(bool showWithoutColourProvider = true)
{
2024-02-14 18:53:41 +08:00
this.showWithoutColourProvider = showWithoutColourProvider;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Child = ContentContainer = new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
};
2024-02-14 18:53:41 +08:00
if (showWithoutColourProvider)
{
ContentContainer.Size = new Vector2(0.5f, 1f);
Add(new Container
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f, 1f),
Children = new[]
2024-02-14 08:49:29 +08:00
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.GreySeaFoam
},
CreateContent()
}
2024-02-14 08:49:29 +08:00
});
}
}
protected void CreateThemedContent(OverlayColourScheme colourScheme)
{
var colourProvider = new OverlayColourProvider(colourScheme);
ContentContainer.Clear();
ContentContainer.Add(new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[]
{
(typeof(OverlayColourProvider), colourProvider)
},
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
2024-09-04 19:57:53 +08:00
Colour = colourProvider.Background3
},
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));
}
}
}