mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 07:22:38 +08:00
1230da33a5
- Adds sorting and display styles. - Saves sort/display modes to the config. - Improves performance, especially on the 2nd+ time opening the overlay. https://github.com/user-attachments/assets/e32b50d0-58a1-4eef-b18c-988fb497e545 --- Coming off some recent feedback in https://github.com/ppy/osu/discussions/33426#discussioncomment-13431275, I decided to take a bit of a detour and get a little bit more functionality in. Sorting by rank, although it should technically work, doesn't work right now. This is because the osu!web API doesn't return user rank on `/user/` lookups - it's only returned for the friends request. I'm leaving this open as a discussion topic. - We can make osu!web return the rank and osu! will require no further changes to work correctly, or - We can try to implement additional paths through `osu-server-spectator` which would blow this PR out of proportion and is best left for a task of its own. For simplicity, I've re-implemented this display mostly as its own component for now, lifting code from `FriendDisplay` which was recently overhauled. These implementations should eventually be combined somehow but that's dependent on: 1. Figuring out the styling - friends can display offline users for which it makes no sense to display the "spectate" button. 2. Figuring out how to handle the different users/presence pathways. It's mostly a code complexity issue. --------- Co-authored-by: Dean Herbert <pe@ppy.sh> Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
// 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.Extensions.Color4Extensions;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Users
|
|
{
|
|
public partial class UserBrickPanel : UserPanel
|
|
{
|
|
public UserBrickPanel(APIUser user)
|
|
: base(user)
|
|
{
|
|
AutoSizeAxes = Axes.Both;
|
|
CornerRadius = 6;
|
|
}
|
|
|
|
// Matches osu!web styling.
|
|
protected override Drawable? CreateBackground() => Empty();
|
|
|
|
protected override Drawable CreateLayout() => new FillFlowContainer
|
|
{
|
|
AutoSizeAxes = Axes.Both,
|
|
Direction = FillDirection.Horizontal,
|
|
Spacing = new Vector2(5, 0),
|
|
Margin = new MarginPadding
|
|
{
|
|
Horizontal = 10,
|
|
Vertical = 3,
|
|
},
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Children = new Drawable[]
|
|
{
|
|
new CircularContainer
|
|
{
|
|
Anchor = Anchor.CentreLeft,
|
|
Origin = Anchor.CentreLeft,
|
|
Masking = true,
|
|
Width = 4,
|
|
Height = 13,
|
|
Child = new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Colour = string.IsNullOrEmpty(User.Colour) ? Color4Extensions.FromHex("0087ca") : Color4Extensions.FromHex(User.Colour)
|
|
}
|
|
},
|
|
CreateUsername().With(u =>
|
|
{
|
|
u.Anchor = Anchor.CentreLeft;
|
|
u.Origin = Anchor.CentreLeft;
|
|
u.Font = OsuFont.GetFont(size: 13, weight: FontWeight.Bold);
|
|
})
|
|
}
|
|
};
|
|
}
|
|
}
|