osu/osu.Game/Users/UserGridPanel.cs

143 lines
5.4 KiB
C#
Raw Normal View History

2020-03-04 05:41:21 +00: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 07:37:17 +00:00
#nullable disable
2020-03-04 09:20:49 +00:00
using osu.Framework.Allocation;
2020-03-04 07:35:43 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
2020-03-04 09:20:49 +00:00
using osu.Game.Overlays.Profile.Header.Components;
2020-03-04 05:41:21 +00:00
using osuTK;
2020-03-04 11:58:15 +00:00
namespace osu.Game.Users
2020-03-04 05:41:21 +00:00
{
2022-11-24 05:32:20 +00:00
public partial class UserGridPanel : ExtendedUserPanel
2020-03-04 05:41:21 +00:00
{
2020-03-04 09:20:49 +00:00
private const int margin = 10;
public UserGridPanel(APIUser user)
2020-03-04 05:41:21 +00:00
: base(user)
{
2020-03-04 11:58:15 +00:00
Height = 120;
2020-03-04 05:41:21 +00:00
CornerRadius = 10;
}
2020-03-04 07:35:43 +00:00
2020-03-04 09:20:49 +00:00
[BackgroundDependencyLoader]
private void load()
{
2020-03-04 23:38:30 +00:00
Background.FadeTo(0.3f);
2020-03-04 09:20:49 +00:00
}
protected override Drawable CreateLayout()
2020-03-04 07:35:43 +00:00
{
2020-03-04 09:20:49 +00: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-04 23:31:19 +00:00
new Dimension(GridSizeMode.Absolute, margin),
2020-03-04 09:20:49 +00:00
new Dimension()
},
Content = new[]
{
new Drawable[]
{
CreateAvatar().With(avatar =>
{
avatar.Size = new Vector2(60);
avatar.Masking = true;
avatar.CornerRadius = 6;
}),
2020-03-04 23:31:19 +00:00
new Container
2020-03-04 09:20:49 +00:00
{
2020-03-04 23:31:19 +00:00
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = margin },
Child = new GridContainer
2020-03-04 09:20:49 +00:00
{
2020-03-04 23:31:19 +00:00
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
2020-03-04 09:20:49 +00:00
{
2020-03-04 23:31:19 +00:00
new Dimension()
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
Content = new[]
{
new Drawable[]
2020-03-04 09:20:49 +00:00
{
2020-03-04 23:31:19 +00: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 09:20:49 +00:00
}
2020-03-04 23:31:19 +00:00
}
2020-03-04 09:20:49 +00:00
}
}
},
2020-03-04 23:31:19 +00:00
new[]
{
Empty(),
Empty()
},
2020-03-04 09:20:49 +00: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 05:41:21 +00:00
}
}