1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 00:22:57 +08:00
osu-lazer/osu.Game/Screens/Edit/Setup/SetupScreenHeader.cs

125 lines
4.0 KiB
C#
Raw Normal View History

2021-04-04 02:02:26 +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-06-17 15:37:17 +08:00
#nullable disable
2021-04-04 02:02:26 +08:00
using osu.Framework.Allocation;
2022-08-19 01:17:05 +08:00
using osu.Framework.Extensions.LocalisationExtensions;
2021-04-04 02:02:26 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osuTK.Graphics;
using osu.Game.Localisation;
2021-04-04 02:02:26 +08:00
namespace osu.Game.Screens.Edit.Setup
{
2022-11-24 13:32:20 +08:00
internal partial class SetupScreenHeader : OverlayHeader
2021-04-04 02:02:26 +08:00
{
2021-04-04 18:50:50 +08:00
public SetupScreenHeaderBackground Background { get; private set; }
2021-04-04 02:02:26 +08:00
[Resolved]
private SectionsContainer<SetupSection> sections { get; set; }
private SetupScreenTabControl tabControl;
protected override OverlayTitle CreateTitle() => new SetupScreenTitle();
protected override Drawable CreateContent() => new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2021-04-04 02:21:36 +08:00
// reverse flow is used to ensure that the tab control's expandable bars extend over the background chooser.
Child = new ReverseChildIDFillFlowContainer<Drawable>
2021-04-04 02:02:26 +08:00
{
2021-04-04 02:21:36 +08:00
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
2021-04-04 02:02:26 +08:00
{
2021-04-04 02:21:36 +08:00
tabControl = new SetupScreenTabControl
{
RelativeSizeAxes = Axes.X,
Height = 30
},
2021-04-04 18:50:50 +08:00
Background = new SetupScreenHeaderBackground
2021-04-04 02:21:36 +08:00
{
RelativeSizeAxes = Axes.X,
Height = 120
}
2021-04-04 02:02:26 +08:00
}
}
};
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
tabControl.AccentColour = colourProvider.Highlight1;
tabControl.BackgroundColour = colourProvider.Dark5;
foreach (var section in sections)
tabControl.AddItem(section);
}
protected override void LoadComplete()
{
base.LoadComplete();
sections.SelectedSection.BindValueChanged(section => tabControl.Current.Value = section.NewValue);
tabControl.Current.BindValueChanged(section =>
{
if (section.NewValue != sections.SelectedSection.Value)
sections.ScrollTo(section.NewValue);
});
}
2022-11-24 13:32:20 +08:00
private partial class SetupScreenTitle : OverlayTitle
2021-04-04 02:02:26 +08:00
{
public SetupScreenTitle()
{
2022-08-19 01:17:05 +08:00
Title = EditorSetupStrings.BeatmapSetup.ToLower();
Description = EditorSetupStrings.BeatmapSetupDescription;
2021-04-04 02:02:26 +08:00
IconTexture = "Icons/Hexacons/social";
}
}
2022-11-24 13:32:20 +08:00
internal partial class SetupScreenTabControl : OverlayTabControl<SetupSection>
2021-04-04 02:02:26 +08:00
{
private readonly Box background;
public Color4 BackgroundColour
{
get => background.Colour;
set => background.Colour = value;
}
public SetupScreenTabControl()
{
TabContainer.Margin = new MarginPadding { Horizontal = 100 };
2021-04-04 02:02:26 +08:00
AddInternal(background = new Box
{
RelativeSizeAxes = Axes.Both,
Depth = 1
});
}
protected override TabItem<SetupSection> CreateTabItem(SetupSection value) => new SetupScreenTabItem(value)
{
AccentColour = AccentColour
};
2022-11-24 13:32:20 +08:00
private partial class SetupScreenTabItem : OverlayTabItem
2021-04-04 02:02:26 +08:00
{
public SetupScreenTabItem(SetupSection value)
: base(value)
{
Text.Text = value.Title;
}
}
}
}
}