1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 19:07:25 +08:00
osu-lazer/osu.Game/Overlays/Profile/ProfileSection.cs

117 lines
4.5 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.
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics.Shapes;
2021-07-17 20:57:05 +08:00
using osu.Framework.Localisation;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics.Sprites;
using osuTK;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Profile
{
2022-11-24 13:32:20 +08:00
public abstract partial class ProfileSection : Container
2018-04-13 17:19:50 +08:00
{
2021-07-17 20:57:05 +08:00
public abstract LocalisableString Title { get; }
2018-04-13 17:19:50 +08:00
public abstract string Identifier { get; }
private readonly FillFlowContainer<Drawable> content;
private readonly Box background;
2019-06-22 07:52:07 +08:00
private readonly Box underscore;
2018-04-13 17:19:50 +08:00
protected override Container<Drawable> Content => content;
2023-01-11 02:24:54 +08:00
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
2018-04-13 17:19:50 +08:00
private const float outer_gutter_width = 10;
2018-04-13 17:19:50 +08:00
protected ProfileSection()
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
2018-04-13 17:19:50 +08:00
InternalChildren = new Drawable[]
{
new Container
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 10,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0, 1),
Radius = 3,
Colour = Colour4.Black.Opacity(0.25f)
},
Child = background = new Box
{
RelativeSizeAxes = Axes.Both,
},
2018-04-13 17:19:50 +08:00
},
new FillFlowContainer
2018-04-13 17:19:50 +08:00
{
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Children = new Drawable[]
2018-04-13 17:19:50 +08:00
{
2019-06-22 07:52:07 +08:00
new Container
{
2019-06-22 07:52:07 +08:00
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding
{
Horizontal = WaveOverlayContainer.HORIZONTAL_PADDING - outer_gutter_width,
Top = 20,
Bottom = 20,
2019-06-22 07:52:07 +08:00
},
Children = new Drawable[]
{
new OsuSpriteText
{
Text = Title,
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold),
2019-06-22 07:52:07 +08:00
},
underscore = new Box
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 4 },
RelativeSizeAxes = Axes.X,
Height = 2,
}
}
},
// reverse ID flow is required for correct Z-ordering of the content (last item should be front-most).
// particularly important in BeatmapsSection, as it uses beatmap cards, which have expandable overhanging content.
content = new ReverseChildIDFillFlowContainer<Drawable>
{
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Padding = new MarginPadding
{
Horizontal = WaveOverlayContainer.HORIZONTAL_PADDING - outer_gutter_width,
Bottom = 20
}
},
},
2018-04-13 17:19:50 +08:00
}
};
}
2018-04-13 17:19:50 +08:00
[BackgroundDependencyLoader]
2020-01-30 05:26:21 +08:00
private void load(OverlayColourProvider colourProvider)
{
background.Colour = colourProvider.Background4;
2020-01-30 05:26:21 +08:00
underscore.Colour = colourProvider.Highlight1;
2018-04-13 17:19:50 +08:00
}
}
}