mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 16:02:58 +08:00
Add tab control to setup screen header
This commit is contained in:
parent
95d7e6c74b
commit
3572178bdc
@ -13,12 +13,17 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
public class SetupScreen : EditorScreen
|
||||
{
|
||||
public const int HORIZONTAL_PADDING = 100;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[Cached]
|
||||
protected readonly OverlayColourProvider ColourProvider;
|
||||
|
||||
[Cached]
|
||||
private SectionsContainer<SetupSection> sections = new SectionsContainer<SetupSection>();
|
||||
|
||||
public SetupScreen()
|
||||
: base(EditorScreenMode.SongSetup)
|
||||
{
|
||||
@ -44,7 +49,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
Colour = ColourProvider.Dark4,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new SectionsContainer<SetupSection>
|
||||
sections = new SectionsContainer<SetupSection>
|
||||
{
|
||||
FixedHeader = new SetupScreenHeader(),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -60,19 +65,4 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal class SetupScreenHeader : OverlayHeader
|
||||
{
|
||||
protected override OverlayTitle CreateTitle() => new SetupScreenTitle();
|
||||
|
||||
private class SetupScreenTitle : OverlayTitle
|
||||
{
|
||||
public SetupScreenTitle()
|
||||
{
|
||||
Title = "beatmap setup";
|
||||
Description = "change general settings of your beatmap";
|
||||
IconTexture = "Icons/Hexacons/social";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
106
osu.Game/Screens/Edit/Setup/SetupScreenHeader.cs
Normal file
106
osu.Game/Screens/Edit/Setup/SetupScreenHeader.cs
Normal file
@ -0,0 +1,106 @@
|
||||
// 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.Allocation;
|
||||
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;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
internal class SetupScreenHeader : OverlayHeader
|
||||
{
|
||||
[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,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
tabControl = new SetupScreenTabControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 30
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
[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);
|
||||
});
|
||||
}
|
||||
|
||||
private class SetupScreenTitle : OverlayTitle
|
||||
{
|
||||
public SetupScreenTitle()
|
||||
{
|
||||
Title = "beatmap setup";
|
||||
Description = "change general settings of your beatmap";
|
||||
IconTexture = "Icons/Hexacons/social";
|
||||
}
|
||||
}
|
||||
|
||||
internal class SetupScreenTabControl : OverlayTabControl<SetupSection>
|
||||
{
|
||||
private readonly Box background;
|
||||
|
||||
public Color4 BackgroundColour
|
||||
{
|
||||
get => background.Colour;
|
||||
set => background.Colour = value;
|
||||
}
|
||||
|
||||
public SetupScreenTabControl()
|
||||
{
|
||||
TabContainer.Margin = new MarginPadding { Horizontal = SetupScreen.HORIZONTAL_PADDING };
|
||||
|
||||
AddInternal(background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = 1
|
||||
});
|
||||
}
|
||||
|
||||
protected override TabItem<SetupSection> CreateTabItem(SetupSection value) => new SetupScreenTabItem(value)
|
||||
{
|
||||
AccentColour = AccentColour
|
||||
};
|
||||
|
||||
private class SetupScreenTabItem : OverlayTabItem
|
||||
{
|
||||
public SetupScreenTabItem(SetupSection value)
|
||||
: base(value)
|
||||
{
|
||||
Text.Text = value.Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Vertical = 10,
|
||||
Horizontal = 90
|
||||
Horizontal = SetupScreen.HORIZONTAL_PADDING
|
||||
};
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
|
Loading…
Reference in New Issue
Block a user