mirror of
https://github.com/ppy/osu.git
synced 2026-06-01 23:40:39 +08:00
93b7c3324d
Using the same styling as osu!web + daily challenge. <img width="1920" height="1034" alt="Screenshot_20260409-164600" src="https://github.com/user-attachments/assets/97e2270e-af9f-478d-b2d6-c9fb8be16720" /> --------- Co-authored-by: Dean Herbert <pe@ppy.sh>
132 lines
4.9 KiB
C#
132 lines
4.9 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 System.Linq;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Cursor;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.Sprites;
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
|
{
|
|
public partial class MatchmakingStatsDisplay : CompositeDrawable, IHasCustomTooltip<MatchmakingStatsTooltipData>
|
|
{
|
|
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
|
|
|
[Resolved]
|
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
|
|
|
private OsuSpriteText rankText = null!;
|
|
|
|
public MatchmakingStatsDisplay()
|
|
{
|
|
AutoSizeAxes = Axes.Both;
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
InternalChildren = new Drawable[]
|
|
{
|
|
new Container
|
|
{
|
|
AutoSizeAxes = Axes.Both,
|
|
CornerRadius = 6,
|
|
BorderThickness = 2,
|
|
BorderColour = colourProvider.Background4,
|
|
Masking = true,
|
|
Children = new Drawable[]
|
|
{
|
|
new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Colour = colourProvider.Background4,
|
|
},
|
|
new FillFlowContainer
|
|
{
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Padding = new MarginPadding(3f),
|
|
AutoSizeAxes = Axes.Both,
|
|
Direction = FillDirection.Horizontal,
|
|
Children = new Drawable[]
|
|
{
|
|
new OsuSpriteText
|
|
{
|
|
Text = "Quick Play",
|
|
Margin = new MarginPadding { Horizontal = 5f, Vertical = 7f },
|
|
Font = OsuFont.GetFont(size: 12)
|
|
},
|
|
new Container
|
|
{
|
|
AutoSizeAxes = Axes.X,
|
|
RelativeSizeAxes = Axes.Y,
|
|
CornerRadius = 3,
|
|
Masking = true,
|
|
Children = new Drawable[]
|
|
{
|
|
new Box
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Colour = colourProvider.Background6,
|
|
},
|
|
rankText = new OsuSpriteText
|
|
{
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
UseFullGlyphHeight = false,
|
|
Colour = colourProvider.Content2,
|
|
Margin = new MarginPadding { Horizontal = 10f, Vertical = 5f }
|
|
},
|
|
}
|
|
},
|
|
}
|
|
},
|
|
}
|
|
},
|
|
};
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
User.BindValueChanged(_ => updateDisplay(), true);
|
|
}
|
|
|
|
private void updateDisplay()
|
|
{
|
|
if (User.Value == null)
|
|
{
|
|
Hide();
|
|
return;
|
|
}
|
|
|
|
APIUserMatchmakingStatistics[] stats = User.Value.User.MatchmakingStatistics;
|
|
|
|
if (stats.Length == 0)
|
|
{
|
|
Hide();
|
|
return;
|
|
}
|
|
|
|
APIUserMatchmakingStatistics[] mostRelevantStats = stats.OrderByDescending(s => s.Pool.Active).ThenByDescending(s => s.Pool.Id).ToArray();
|
|
APIUserMatchmakingStatistics mostRelevantStat = mostRelevantStats.First();
|
|
|
|
rankText.Text = $"#{mostRelevantStat.Rank:N0}";
|
|
|
|
TooltipContent = new MatchmakingStatsTooltipData(colourProvider, mostRelevantStats);
|
|
|
|
Show();
|
|
}
|
|
|
|
public ITooltip<MatchmakingStatsTooltipData> GetCustomTooltip() => new MatchmakingStatsTooltip();
|
|
|
|
public MatchmakingStatsTooltipData? TooltipContent { get; private set; }
|
|
}
|
|
}
|