1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 11:22:54 +08:00
Files
osu-lazer/osu.Game/Overlays/Profile/Header/Components/MatchmakingStatsTooltip.cs
T
Denis Titovets 34deaad718 Remove points statistic from MatchmakingStatsTooltip (#37495)
matches web

| master | `osu-web` | PR |
|-|-|-|
| <img width="335" height="81" alt="image"
src="https://github.com/user-attachments/assets/942fc6c0-488b-49b8-97d4-d2d81eeeed92"
/> | <img width="307" height="83" alt="image"
src="https://github.com/user-attachments/assets/3ade843e-c735-4697-bf89-622de2d23d9c"
/> | <img width="338" height="135" alt="image"
src="https://github.com/user-attachments/assets/5867023b-145d-4836-ba95-9e2bdd9e1bbc"
/> |
2026-04-27 13:58:37 +09:00

134 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.Extensions;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class MatchmakingStatsTooltip : VisibilityContainer, ITooltip<MatchmakingStatsTooltipData>
{
private Box background = null!;
private Container<TableContainer> tableContainer = null!;
public MatchmakingStatsTooltip()
{
AutoSizeAxes = Axes.Both;
CornerRadius = 20f;
Masking = true;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(0.25f),
Radius = 30f,
};
}
[BackgroundDependencyLoader]
private void load()
{
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
tableContainer = new Container<TableContainer>
{
AutoSizeAxes = Axes.Both,
Padding = new MarginPadding(15f),
}
};
}
public void SetContent(MatchmakingStatsTooltipData content)
{
var statistics = content.Statistics;
var colourProvider = content.ColourProvider;
background.Colour = colourProvider.Background4;
tableContainer.Child = new MatchmakingStatsTooltipTable(colourProvider)
{
AutoSizeAxes = Axes.Both,
Columns =
[
new TableColumn(dimension: new Dimension(GridSizeMode.AutoSize)),
new TableColumn(dimension: new Dimension(GridSizeMode.AutoSize)),
new TableColumn(RankingsStrings.MatchmakingWins, dimension: new Dimension(GridSizeMode.AutoSize)),
new TableColumn(RankingsStrings.MatchmakingPlays, dimension: new Dimension(GridSizeMode.AutoSize)),
new TableColumn(RankingsStrings.MatchmakingRating, dimension: new Dimension(GridSizeMode.AutoSize)),
],
RowSize = new Dimension(GridSizeMode.AutoSize),
Content = statistics.Select(s => createRow(colourProvider, s)).ToArray().ToRectangular()
};
}
private Drawable[] createRow(OverlayColourProvider colourProvider, APIUserMatchmakingStatistics stat)
{
return
[
new StatisticText(colourProvider)
{
Text = stat.Pool.Name,
Colour = Color4.White
},
new StatisticText(colourProvider) { Text = $"#{stat.Rank:N0}" },
new StatisticText(colourProvider) { Text = stat.FirstPlacements.ToString("N0") },
new StatisticText(colourProvider) { Text = stat.Plays.ToString("N0") },
new StatisticText(colourProvider) { Text = stat.Rating.ToString("N0") + (stat.IsRatingProvisional ? "*" : string.Empty) }
];
}
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
public void Move(Vector2 pos) => Position = pos;
private partial class MatchmakingStatsTooltipTable : TableContainer
{
private readonly OverlayColourProvider colourProvider;
public MatchmakingStatsTooltipTable(OverlayColourProvider colourProvider)
{
this.colourProvider = colourProvider;
}
protected override Drawable CreateHeader(int index, TableColumn? column)
{
return new StatisticText(colourProvider)
{
Text = column?.Header ?? string.Empty,
};
}
}
private partial class StatisticText : OsuSpriteText
{
public StatisticText(OverlayColourProvider colourProvider)
{
Font = OsuFont.GetFont(size: 12);
Padding = new MarginPadding { Horizontal = 5, Vertical = 2 };
Colour = colourProvider.Content2;
}
}
}
public record MatchmakingStatsTooltipData(OverlayColourProvider ColourProvider, APIUserMatchmakingStatistics[] Statistics);
}