1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 21:52:56 +08:00
osu-lazer/osu.Game/Users/UserGridPanel.cs

140 lines
5.3 KiB
C#
Raw Normal View History

2020-03-04 13:41:21 +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.
2020-03-04 17:20:49 +08:00
using osu.Framework.Allocation;
2020-03-04 15:35:43 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2020-03-04 17:20:49 +08:00
using osu.Game.Overlays.Profile.Header.Components;
2020-03-04 13:41:21 +08:00
using osuTK;
2020-03-04 19:58:15 +08:00
namespace osu.Game.Users
2020-03-04 13:41:21 +08:00
{
2020-03-04 19:58:15 +08:00
public class UserGridPanel : UserPanel
2020-03-04 13:41:21 +08:00
{
2020-03-04 17:20:49 +08:00
private const int margin = 10;
2020-03-04 19:58:15 +08:00
public UserGridPanel(User user)
2020-03-04 13:41:21 +08:00
: base(user)
{
2020-03-04 19:58:15 +08:00
Height = 120;
2020-03-04 13:41:21 +08:00
CornerRadius = 10;
}
2020-03-04 15:35:43 +08:00
2020-03-04 17:20:49 +08:00
[BackgroundDependencyLoader]
private void load()
{
2020-03-05 07:38:30 +08:00
Background.FadeTo(0.3f);
2020-03-04 17:20:49 +08:00
}
protected override Drawable CreateLayout()
2020-03-04 15:35:43 +08:00
{
2020-03-04 17:20:49 +08:00
FillFlowContainer details;
var layout = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(margin),
Child = new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
2020-03-05 07:31:19 +08:00
new Dimension(GridSizeMode.Absolute, margin),
2020-03-04 17:20:49 +08:00
new Dimension()
},
Content = new[]
{
new Drawable[]
{
CreateAvatar().With(avatar =>
{
avatar.Size = new Vector2(60);
avatar.Masking = true;
avatar.CornerRadius = 6;
}),
2020-03-05 07:31:19 +08:00
new Container
2020-03-04 17:20:49 +08:00
{
2020-03-05 07:31:19 +08:00
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = margin },
Child = new GridContainer
2020-03-04 17:20:49 +08:00
{
2020-03-05 07:31:19 +08:00
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
2020-03-04 17:20:49 +08:00
{
2020-03-05 07:31:19 +08:00
new Dimension()
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
Content = new[]
{
new Drawable[]
2020-03-04 17:20:49 +08:00
{
2020-03-05 07:31:19 +08:00
details = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(6),
Children = new Drawable[]
{
CreateFlag(),
}
}
},
new Drawable[]
{
CreateUsername().With(username =>
{
username.Anchor = Anchor.CentreLeft;
username.Origin = Anchor.CentreLeft;
})
2020-03-04 17:20:49 +08:00
}
2020-03-05 07:31:19 +08:00
}
2020-03-04 17:20:49 +08:00
}
}
},
2020-03-05 07:31:19 +08:00
new[]
{
Empty(),
Empty()
},
2020-03-04 17:20:49 +08:00
new Drawable[]
{
CreateStatusIcon().With(icon =>
{
icon.Anchor = Anchor.Centre;
icon.Origin = Anchor.Centre;
}),
CreateStatusMessage(false).With(message =>
{
message.Anchor = Anchor.CentreLeft;
message.Origin = Anchor.CentreLeft;
message.Margin = new MarginPadding { Left = margin };
})
}
}
}
};
if (User.IsSupporter)
{
details.Add(new SupporterIcon
{
Height = 26,
SupportLevel = User.SupportLevel
});
}
return layout;
}
2020-03-04 13:41:21 +08:00
}
}