1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 03:22:57 +08:00
osu-lazer/osu.Game/Overlays/Profile/ProfileSection.cs

140 lines
4.9 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;
2019-06-23 22:08:18 +08:00
using osu.Framework.Extensions.Color4Extensions;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
2019-06-22 07:40:33 +08:00
using osu.Framework.Graphics.Colour;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
2019-06-22 07:40:33 +08:00
using osu.Game.Graphics.Backgrounds;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics.Sprites;
using osu.Game.Users;
namespace osu.Game.Overlays.Profile
{
public abstract class ProfileSection : Container
2018-04-13 17:19:50 +08:00
{
public abstract string Title { get; }
public abstract string Identifier { get; }
private readonly FillFlowContainer 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;
public readonly Bindable<User> User = new Bindable<User>();
protected ProfileSection()
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
2018-04-13 17:19:50 +08:00
InternalChildren = new Drawable[]
{
background = new Box
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
2018-04-13 17:19:50 +08:00
},
2019-06-22 07:40:33 +08:00
new SectionTriangles
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
},
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 = UserProfileOverlay.CONTENT_X_MARGIN,
2019-06-22 07:52:07 +08:00
Top = 15,
Bottom = 10,
},
Children = new Drawable[]
{
new OsuSpriteText
{
Text = Title,
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
},
underscore = new Box
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 4 },
RelativeSizeAxes = Axes.X,
Height = 2,
}
}
},
content = new FillFlowContainer
{
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Padding = new MarginPadding
{
Horizontal = UserProfileOverlay.CONTENT_X_MARGIN,
Bottom = 20
}
},
},
2018-04-13 17:19:50 +08:00
}
};
}
2018-04-13 17:19:50 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.GreySeafoamDarker;
2019-06-22 07:52:07 +08:00
underscore.Colour = colours.Seafoam;
2018-04-13 17:19:50 +08:00
}
2019-06-22 07:40:33 +08:00
private class SectionTriangles : Container
{
private readonly Triangles triangles;
private readonly Box foreground;
public SectionTriangles()
{
RelativeSizeAxes = Axes.X;
Height = 100;
Masking = true;
Children = new Drawable[]
{
triangles = new Triangles
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both,
2019-06-23 22:08:18 +08:00
TriangleScale = 3,
2019-06-22 07:40:33 +08:00
},
foreground = new Box
{
RelativeSizeAxes = Axes.Both,
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
triangles.ColourLight = colours.GreySeafoamDark;
triangles.ColourDark = colours.GreySeafoamDarker.Darken(0.2f);
2019-06-23 22:08:18 +08:00
foreground.Colour = ColourInfo.GradientVertical(colours.GreySeafoamDarker, colours.GreySeafoamDarker.Opacity(0));
2019-06-22 07:40:33 +08:00
}
}
2018-04-13 17:19:50 +08:00
}
}