2020-01-04 04:54:56 +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 osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
2020-01-20 17:21:21 +08:00
|
|
|
|
public class TestSceneOverlayHeader : OsuTestScene
|
2020-01-04 04:54:56 +08:00
|
|
|
|
{
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(OverlayHeader),
|
2020-01-08 05:41:52 +08:00
|
|
|
|
typeof(TabControlOverlayHeader<>),
|
2020-01-04 04:54:56 +08:00
|
|
|
|
typeof(BreadcrumbControlOverlayHeader),
|
|
|
|
|
typeof(TestNoControlHeader),
|
2020-01-08 05:41:52 +08:00
|
|
|
|
typeof(TestStringTabControlHeader),
|
|
|
|
|
typeof(TestEnumTabControlHeader),
|
2020-01-04 04:54:56 +08:00
|
|
|
|
typeof(TestBreadcrumbControlHeader),
|
2020-01-27 20:36:19 +08:00
|
|
|
|
typeof(OverlayHeaderBackground)
|
2020-01-04 04:54:56 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private readonly FillFlowContainer flow;
|
|
|
|
|
|
2020-01-20 17:21:21 +08:00
|
|
|
|
public TestSceneOverlayHeader()
|
2020-01-04 04:54:56 +08:00
|
|
|
|
{
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
new BasicScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = flow = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-27 20:36:19 +08:00
|
|
|
|
addHeader("Orange OverlayHeader (no background)", new TestNoBackgroundHeader(), OverlayColourScheme.Orange);
|
2020-01-26 21:35:07 +08:00
|
|
|
|
addHeader("Blue OverlayHeader", new TestNoControlHeader(), OverlayColourScheme.Blue);
|
|
|
|
|
addHeader("Green TabControlOverlayHeader (string)", new TestStringTabControlHeader(), OverlayColourScheme.Green);
|
|
|
|
|
addHeader("Pink TabControlOverlayHeader (enum)", new TestEnumTabControlHeader(), OverlayColourScheme.Pink);
|
2020-01-27 20:42:46 +08:00
|
|
|
|
addHeader("Red BreadcrumbControlOverlayHeader (no background)", new TestBreadcrumbControlHeader(), OverlayColourScheme.Red);
|
2020-01-04 04:54:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 21:35:07 +08:00
|
|
|
|
private void addHeader(string name, OverlayHeader header, OverlayColourScheme colourScheme)
|
2020-01-04 04:54:56 +08:00
|
|
|
|
{
|
|
|
|
|
flow.Add(new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2020-01-08 05:41:52 +08:00
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2020-01-04 04:54:56 +08:00
|
|
|
|
Margin = new MarginPadding(20),
|
|
|
|
|
Text = name,
|
|
|
|
|
},
|
2020-01-26 21:35:07 +08:00
|
|
|
|
new ColourProvidedContainer(colourScheme, header)
|
2020-01-08 05:41:52 +08:00
|
|
|
|
{
|
2020-01-26 21:35:07 +08:00
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
}
|
2020-01-04 04:54:56 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 21:35:07 +08:00
|
|
|
|
private class ColourProvidedContainer : Container
|
|
|
|
|
{
|
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider colourProvider;
|
|
|
|
|
|
|
|
|
|
public ColourProvidedContainer(OverlayColourScheme colourScheme, OverlayHeader header)
|
|
|
|
|
{
|
|
|
|
|
colourProvider = new OverlayColourProvider(colourScheme);
|
|
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Add(header);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 20:36:19 +08:00
|
|
|
|
private class TestNoBackgroundHeader : OverlayHeader
|
|
|
|
|
{
|
|
|
|
|
protected override ScreenTitle CreateTitle() => new TestTitle();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-04 04:54:56 +08:00
|
|
|
|
private class TestNoControlHeader : OverlayHeader
|
|
|
|
|
{
|
2020-01-27 20:36:19 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/changelog");
|
2020-01-04 04:54:56 +08:00
|
|
|
|
|
|
|
|
|
protected override ScreenTitle CreateTitle() => new TestTitle();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 05:41:52 +08:00
|
|
|
|
private class TestStringTabControlHeader : TabControlOverlayHeader<string>
|
2020-01-04 04:54:56 +08:00
|
|
|
|
{
|
2020-01-27 20:36:19 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
|
2020-01-04 04:54:56 +08:00
|
|
|
|
|
|
|
|
|
protected override ScreenTitle CreateTitle() => new TestTitle();
|
|
|
|
|
|
2020-01-26 21:35:07 +08:00
|
|
|
|
public TestStringTabControlHeader()
|
2020-01-04 04:54:56 +08:00
|
|
|
|
{
|
|
|
|
|
TabControl.AddItem("tab1");
|
|
|
|
|
TabControl.AddItem("tab2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 05:41:52 +08:00
|
|
|
|
private class TestEnumTabControlHeader : TabControlOverlayHeader<TestEnum>
|
|
|
|
|
{
|
2020-01-27 20:36:19 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings");
|
2020-01-08 05:41:52 +08:00
|
|
|
|
|
|
|
|
|
protected override ScreenTitle CreateTitle() => new TestTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private enum TestEnum
|
|
|
|
|
{
|
|
|
|
|
Some,
|
|
|
|
|
Cool,
|
|
|
|
|
Tabs
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-04 04:54:56 +08:00
|
|
|
|
private class TestBreadcrumbControlHeader : BreadcrumbControlOverlayHeader
|
|
|
|
|
{
|
|
|
|
|
protected override ScreenTitle CreateTitle() => new TestTitle();
|
|
|
|
|
|
2020-01-26 21:35:07 +08:00
|
|
|
|
public TestBreadcrumbControlHeader()
|
2020-01-04 04:54:56 +08:00
|
|
|
|
{
|
2020-01-21 11:00:12 +08:00
|
|
|
|
TabControl.AddItem("tab1");
|
|
|
|
|
TabControl.AddItem("tab2");
|
|
|
|
|
TabControl.Current.Value = "tab2";
|
2020-01-04 04:54:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestTitle : ScreenTitle
|
|
|
|
|
{
|
|
|
|
|
public TestTitle()
|
|
|
|
|
{
|
|
|
|
|
Title = "title";
|
|
|
|
|
Section = "section";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|