2023-01-16 23:57:18 +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.
|
|
|
|
|
2023-01-17 01:12:59 +08:00
|
|
|
using System;
|
2023-01-17 01:03:38 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2023-01-16 23:57:18 +08:00
|
|
|
using osu.Framework.Allocation;
|
2023-10-11 10:17:50 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2023-01-17 01:21:19 +08:00
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2023-01-16 23:57:18 +08:00
|
|
|
using osu.Framework.Graphics;
|
2023-09-23 07:34:06 +08:00
|
|
|
using osu.Framework.Graphics.Colour;
|
2023-01-16 23:57:18 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2023-01-17 02:16:35 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2023-01-16 23:57:18 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2023-01-17 01:03:38 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2023-01-17 00:15:37 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2023-10-11 11:24:17 +08:00
|
|
|
using osu.Framework.Layout;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Framework.Localisation;
|
2023-01-17 01:12:59 +08:00
|
|
|
using osu.Game.Extensions;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Graphics;
|
2023-10-11 10:17:50 +08:00
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2023-01-16 23:57:18 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2023-01-17 01:03:38 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2023-01-17 01:12:59 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2023-01-17 00:15:37 +08:00
|
|
|
using osu.Game.Overlays;
|
2023-01-17 01:03:38 +08:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.UI;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Scoring;
|
2023-01-17 01:03:38 +08:00
|
|
|
using osu.Game.Screens.Select;
|
2023-09-23 07:34:06 +08:00
|
|
|
using osu.Game.Users;
|
2023-01-17 01:12:59 +08:00
|
|
|
using osu.Game.Users.Drawables;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Utils;
|
2023-01-16 23:57:18 +08:00
|
|
|
using osuTK;
|
2023-10-11 10:17:50 +08:00
|
|
|
using osuTK.Graphics;
|
2023-01-16 23:57:18 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Online.Leaderboards
|
|
|
|
{
|
2023-01-17 05:37:06 +08:00
|
|
|
public partial class LeaderboardScoreV2 : OsuClickableContainer, IHasContextMenu, IHasCustomTooltip<ScoreInfo>
|
2023-01-16 23:57:18 +08:00
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
/// <summary>
|
2024-05-06 13:26:00 +08:00
|
|
|
/// The maximum number of mods when contracted until the mods display width exceeds the <see cref="right_content_width"/>.
|
2023-10-11 10:17:50 +08:00
|
|
|
/// </summary>
|
|
|
|
public const int MAX_MODS_CONTRACTED = 13;
|
|
|
|
|
|
|
|
/// <summary>
|
2024-05-06 13:26:00 +08:00
|
|
|
/// The maximum number of mods when expanded until the mods display width exceeds the <see cref="right_content_width"/>.
|
2023-10-11 10:17:50 +08:00
|
|
|
/// </summary>
|
|
|
|
public const int MAX_MODS_EXPANDED = 4;
|
|
|
|
|
2024-05-06 13:26:00 +08:00
|
|
|
private const float right_content_width = 180;
|
2023-10-11 10:17:50 +08:00
|
|
|
private const float grade_width = 40;
|
2023-10-11 11:24:17 +08:00
|
|
|
private const float username_min_width = 100;
|
2023-10-11 10:17:50 +08:00
|
|
|
|
2023-01-17 00:35:27 +08:00
|
|
|
private readonly ScoreInfo score;
|
|
|
|
|
2023-01-17 02:03:17 +08:00
|
|
|
private const int height = 60;
|
2023-01-16 23:57:18 +08:00
|
|
|
private const int corner_radius = 10;
|
2023-01-17 00:15:37 +08:00
|
|
|
private const int transition_duration = 200;
|
|
|
|
|
2023-01-17 00:35:27 +08:00
|
|
|
private readonly int? rank;
|
|
|
|
|
|
|
|
private readonly bool isPersonalBest;
|
|
|
|
|
2023-01-17 00:15:37 +08:00
|
|
|
private Colour4 foregroundColour;
|
|
|
|
private Colour4 backgroundColour;
|
2023-10-11 10:17:50 +08:00
|
|
|
private ColourInfo totalScoreBackgroundGradient;
|
2023-01-16 23:57:18 +08:00
|
|
|
|
|
|
|
private static readonly Vector2 shear = new Vector2(0.15f, 0);
|
|
|
|
|
2023-09-24 10:40:57 +08:00
|
|
|
[Resolved]
|
|
|
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
2023-01-17 00:15:37 +08:00
|
|
|
|
2023-01-17 01:03:38 +08:00
|
|
|
[Resolved]
|
|
|
|
private SongSelect? songSelect { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private IDialogOverlay? dialogOverlay { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
2023-09-23 02:07:49 +08:00
|
|
|
private ScoreManager scoreManager { get; set; } = null!;
|
2023-01-17 01:03:38 +08:00
|
|
|
|
2023-01-16 23:57:18 +08:00
|
|
|
private Container content = null!;
|
2023-01-17 00:15:37 +08:00
|
|
|
private Box background = null!;
|
|
|
|
private Box foreground = null!;
|
|
|
|
|
2023-01-17 01:12:59 +08:00
|
|
|
private Drawable avatar = null!;
|
|
|
|
private ClickableAvatar innerAvatar = null!;
|
|
|
|
|
|
|
|
private OsuSpriteText nameLabel = null!;
|
2023-01-17 01:21:19 +08:00
|
|
|
private List<ScoreComponentLabel> statisticsLabels = null!;
|
2023-01-17 01:12:59 +08:00
|
|
|
|
2023-01-17 01:03:38 +08:00
|
|
|
protected Container RankContainer { get; private set; } = null!;
|
2023-01-17 01:12:59 +08:00
|
|
|
private FillFlowContainer flagBadgeAndDateContainer = null!;
|
2023-01-17 01:03:38 +08:00
|
|
|
private FillFlowContainer<ColouredModSwitchTiny> modsContainer = null!;
|
2023-10-11 10:17:50 +08:00
|
|
|
private OsuSpriteText modsCounter = null!;
|
2023-01-17 01:03:38 +08:00
|
|
|
|
|
|
|
private OsuSpriteText scoreText = null!;
|
|
|
|
private Drawable scoreRank = null!;
|
2023-10-11 10:17:50 +08:00
|
|
|
private Box totalScoreBackground = null!;
|
2023-01-17 01:03:38 +08:00
|
|
|
|
2023-10-11 11:24:17 +08:00
|
|
|
private Container centreContent = null!;
|
|
|
|
private FillFlowContainer usernameAndFlagContainer = null!;
|
|
|
|
private FillFlowContainer statisticsContainer = null!;
|
|
|
|
|
2023-01-17 02:24:03 +08:00
|
|
|
public ITooltip<ScoreInfo> GetCustomTooltip() => new LeaderboardScoreTooltip();
|
|
|
|
public virtual ScoreInfo TooltipContent => score;
|
|
|
|
|
2023-01-17 05:51:46 +08:00
|
|
|
public LeaderboardScoreV2(ScoreInfo score, int? rank, bool isPersonalBest = false)
|
2023-01-17 00:15:37 +08:00
|
|
|
{
|
2023-01-17 00:35:27 +08:00
|
|
|
this.score = score;
|
|
|
|
this.rank = rank;
|
2023-01-17 00:15:37 +08:00
|
|
|
this.isPersonalBest = isPersonalBest;
|
2023-09-23 07:21:53 +08:00
|
|
|
|
|
|
|
Shear = shear;
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
Height = height;
|
2023-01-17 00:15:37 +08:00
|
|
|
}
|
2023-01-16 23:57:18 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2023-09-23 02:07:49 +08:00
|
|
|
private void load()
|
2023-01-16 23:57:18 +08:00
|
|
|
{
|
2023-01-17 01:12:59 +08:00
|
|
|
var user = score.User;
|
|
|
|
|
2023-01-17 00:15:37 +08:00
|
|
|
foregroundColour = isPersonalBest ? colourProvider.Background1 : colourProvider.Background5;
|
|
|
|
backgroundColour = isPersonalBest ? colourProvider.Background2 : colourProvider.Background4;
|
2023-10-11 10:17:50 +08:00
|
|
|
totalScoreBackgroundGradient = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), backgroundColour);
|
2023-01-17 00:15:37 +08:00
|
|
|
|
2023-10-11 13:14:04 +08:00
|
|
|
statisticsLabels = GetStatistics(score).Select(s => new ScoreComponentLabel(s, score)
|
|
|
|
{
|
|
|
|
// ensure statistics container is the correct width when invalidating
|
|
|
|
AlwaysPresent = true,
|
|
|
|
}).ToList();
|
2023-01-17 01:21:19 +08:00
|
|
|
|
2023-01-16 23:57:18 +08:00
|
|
|
Child = content = new Container
|
|
|
|
{
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2023-01-17 00:15:37 +08:00
|
|
|
background = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = backgroundColour
|
|
|
|
},
|
|
|
|
new GridContainer
|
2023-01-16 23:57:18 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2023-01-17 00:15:37 +08:00
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.Absolute, 65),
|
|
|
|
new Dimension(),
|
2024-05-06 13:26:00 +08:00
|
|
|
new Dimension(GridSizeMode.Absolute, right_content_width),
|
2023-01-17 00:15:37 +08:00
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
2023-01-17 01:03:38 +08:00
|
|
|
new Drawable[]
|
2023-01-17 00:15:37 +08:00
|
|
|
{
|
2023-10-11 09:20:19 +08:00
|
|
|
new RankLabel(rank) { Shear = -shear },
|
2023-10-11 11:24:17 +08:00
|
|
|
centreContent = createCentreContent(user),
|
2023-10-11 09:15:05 +08:00
|
|
|
createRightContent()
|
2023-01-17 00:15:37 +08:00
|
|
|
}
|
|
|
|
}
|
2023-01-16 23:57:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2023-01-17 01:03:38 +08:00
|
|
|
|
2023-01-17 01:12:59 +08:00
|
|
|
innerAvatar.OnLoadComplete += d => d.FadeInFromZero(200);
|
|
|
|
|
2023-10-11 10:17:50 +08:00
|
|
|
modsContainer.Spacing = new Vector2(modsContainer.Children.Count > MAX_MODS_EXPANDED ? -20 : 2, 0);
|
2023-01-17 01:03:38 +08:00
|
|
|
modsContainer.Padding = new MarginPadding { Top = modsContainer.Children.Count > 0 ? 4 : 0 };
|
2023-01-16 23:57:18 +08:00
|
|
|
}
|
2023-01-17 00:15:37 +08:00
|
|
|
|
2023-10-11 09:29:18 +08:00
|
|
|
private Container createCentreContent(APIUser user) => new Container
|
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
Name = @"Centre container",
|
2023-10-11 09:29:18 +08:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
2023-01-17 00:15:37 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
foreground = new Box
|
2023-01-17 00:15:37 +08:00
|
|
|
{
|
2023-10-11 09:29:18 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2024-04-29 14:12:55 +08:00
|
|
|
Colour = foregroundColour
|
2023-10-11 09:29:18 +08:00
|
|
|
},
|
2024-04-29 14:12:55 +08:00
|
|
|
new UserCoverBackground
|
2023-10-11 09:29:18 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2024-04-29 14:12:55 +08:00
|
|
|
User = score.User,
|
|
|
|
Shear = -shear,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Colour = ColourInfo.GradientHorizontal(Colour4.White.Opacity(0.5f), Colour4.FromHex(@"222A27").Opacity(1)),
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColumnDimensions = new[]
|
2023-09-23 07:34:06 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
2023-01-17 01:12:59 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
new Container
|
2023-01-17 01:12:59 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2024-05-06 13:27:21 +08:00
|
|
|
CornerRadius = corner_radius,
|
|
|
|
Masking = true,
|
|
|
|
Child = avatar = new DelayedLoadWrapper(
|
2024-04-29 14:12:55 +08:00
|
|
|
innerAvatar = new ClickableAvatar(user)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(1.1f),
|
|
|
|
Shear = -shear,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
})
|
2023-09-23 08:00:51 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
Size = new Vector2(height)
|
2023-09-23 08:00:51 +08:00
|
|
|
},
|
2024-04-29 14:12:55 +08:00
|
|
|
},
|
|
|
|
usernameAndFlagContainer = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Padding = new MarginPadding { Horizontal = corner_radius },
|
|
|
|
Children = new Drawable[]
|
2023-09-23 08:00:51 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
flagBadgeAndDateContainer = new FillFlowContainer
|
2023-10-11 08:53:37 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
Shear = -shear,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
2023-10-11 09:29:18 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
new UpdateableFlag(user.CountryCode)
|
2023-10-11 11:24:17 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Size = new Vector2(24, 16),
|
2023-10-11 11:24:17 +08:00
|
|
|
},
|
2024-04-29 14:12:55 +08:00
|
|
|
new DateLabel(score.Date)
|
2023-10-11 11:24:17 +08:00
|
|
|
{
|
2024-04-29 14:12:55 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
UseFullGlyphHeight = false,
|
2023-10-11 11:24:17 +08:00
|
|
|
}
|
2023-09-23 08:00:51 +08:00
|
|
|
}
|
2024-04-29 14:12:55 +08:00
|
|
|
},
|
|
|
|
nameLabel = new TruncatingSpriteText
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Shear = -shear,
|
|
|
|
Text = user.Username,
|
|
|
|
Font = OsuFont.GetFont(size: 24, weight: FontWeight.SemiBold)
|
2023-01-17 01:12:59 +08:00
|
|
|
}
|
|
|
|
}
|
2024-04-29 14:12:55 +08:00
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
Child = statisticsContainer = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Name = @"Statistics container",
|
|
|
|
Padding = new MarginPadding { Right = 40 },
|
|
|
|
Spacing = new Vector2(25),
|
|
|
|
Shear = -shear,
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Children = statisticsLabels,
|
|
|
|
Alpha = 0,
|
|
|
|
}
|
2023-01-17 01:12:59 +08:00
|
|
|
}
|
2023-10-11 09:29:18 +08:00
|
|
|
}
|
2023-01-17 01:12:59 +08:00
|
|
|
},
|
2023-09-23 08:00:51 +08:00
|
|
|
},
|
2023-10-11 09:29:18 +08:00
|
|
|
},
|
|
|
|
};
|
2023-01-17 00:15:37 +08:00
|
|
|
|
2023-10-11 10:17:50 +08:00
|
|
|
private Container createRightContent() => new Container
|
2023-10-11 09:29:18 +08:00
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
Name = @"Right content",
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
2023-10-11 09:29:18 +08:00
|
|
|
Children = new Drawable[]
|
2023-01-17 01:03:38 +08:00
|
|
|
{
|
2023-10-11 09:29:18 +08:00
|
|
|
new Container
|
2023-01-17 01:03:38 +08:00
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Right = grade_width },
|
|
|
|
Child = new Box
|
2023-01-17 01:03:38 +08:00
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), OsuColour.ForRank(score.Rank)),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Width = grade_width,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Colour = OsuColour.ForRank(score.Rank),
|
|
|
|
},
|
|
|
|
new TrianglesV2
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
SpawnRatio = 2,
|
|
|
|
Velocity = 0.7f,
|
|
|
|
Colour = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), OsuColour.ForRank(score.Rank).Darken(0.2f)),
|
|
|
|
},
|
|
|
|
RankContainer = new Container
|
|
|
|
{
|
|
|
|
Shear = -shear,
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Width = grade_width,
|
|
|
|
Child = scoreRank = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Spacing = new Vector2(-2),
|
|
|
|
Colour = DrawableRank.GetRankNameColour(score.Rank),
|
|
|
|
Font = OsuFont.Numeric.With(size: 16),
|
|
|
|
Text = DrawableRank.GetRankName(score.Rank),
|
|
|
|
ShadowColour = Color4.Black.Opacity(0.3f),
|
|
|
|
ShadowOffset = new Vector2(0, 0.08f),
|
|
|
|
Shadow = true,
|
|
|
|
UseFullGlyphHeight = false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.X,
|
2024-05-03 14:00:04 +08:00
|
|
|
RelativeSizeAxes = Axes.Y,
|
2023-10-11 10:17:50 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Padding = new MarginPadding { Right = grade_width },
|
|
|
|
Child = new Container
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
Children = new Drawable[]
|
2023-10-11 09:29:18 +08:00
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
totalScoreBackground = new Box
|
2023-01-17 01:03:38 +08:00
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = totalScoreBackgroundGradient,
|
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0), OsuColour.ForRank(score.Rank).Opacity(0.5f)),
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Padding = new MarginPadding { Horizontal = corner_radius },
|
|
|
|
Children = new Drawable[]
|
2023-01-17 01:03:38 +08:00
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
scoreText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
UseFullGlyphHeight = false,
|
|
|
|
Shear = -shear,
|
|
|
|
Current = scoreManager.GetBindableTotalScoreString(score),
|
|
|
|
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
|
|
|
|
},
|
|
|
|
modsContainer = new FillFlowContainer<ColouredModSwitchTiny>
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Shear = -shear,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
ChildrenEnumerable = score.Mods.Select(mod => new ColouredModSwitchTiny(mod) { Scale = new Vector2(0.375f) })
|
|
|
|
},
|
|
|
|
modsCounter = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Shear = -shear,
|
|
|
|
Text = $"{score.Mods.Length} mods",
|
|
|
|
Alpha = 0,
|
|
|
|
}
|
2023-01-17 01:03:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-11 09:29:18 +08:00
|
|
|
}
|
|
|
|
};
|
2023-01-17 01:03:38 +08:00
|
|
|
|
2023-01-17 01:21:19 +08:00
|
|
|
protected (CaseTransformableString, LocalisableString DisplayAccuracy)[] GetStatistics(ScoreInfo model) => new[]
|
|
|
|
{
|
2023-01-18 03:13:50 +08:00
|
|
|
(BeatmapsetsStrings.ShowScoreboardHeadersCombo.ToUpper(), model.MaxCombo.ToString().Insert(model.MaxCombo.ToString().Length, "x")),
|
2023-01-17 01:21:19 +08:00
|
|
|
(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy.ToUpper(), model.DisplayAccuracy),
|
|
|
|
};
|
|
|
|
|
|
|
|
public override void Show()
|
|
|
|
{
|
|
|
|
foreach (var d in new[] { avatar, nameLabel, scoreText, scoreRank, flagBadgeAndDateContainer, modsContainer }.Concat(statisticsLabels))
|
|
|
|
d.FadeOut();
|
|
|
|
|
|
|
|
Alpha = 0;
|
|
|
|
|
|
|
|
content.MoveToY(75);
|
|
|
|
avatar.MoveToX(75);
|
|
|
|
nameLabel.MoveToX(150);
|
|
|
|
|
|
|
|
this.FadeIn(200);
|
|
|
|
content.MoveToY(0, 800, Easing.OutQuint);
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(100))
|
|
|
|
{
|
|
|
|
avatar.FadeIn(300, Easing.OutQuint);
|
|
|
|
nameLabel.FadeIn(350, Easing.OutQuint);
|
|
|
|
|
|
|
|
avatar.MoveToX(0, 300, Easing.OutQuint);
|
|
|
|
nameLabel.MoveToX(0, 350, Easing.OutQuint);
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(250))
|
|
|
|
{
|
|
|
|
scoreText.FadeIn(200);
|
|
|
|
scoreRank.FadeIn(200);
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(50))
|
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
Drawable modsDrawable = score.Mods.Length > MAX_MODS_CONTRACTED ? modsCounter : modsContainer;
|
|
|
|
var drawables = new[] { flagBadgeAndDateContainer, modsDrawable }.Concat(statisticsLabels).ToArray();
|
2023-01-17 01:21:19 +08:00
|
|
|
for (int i = 0; i < drawables.Length; i++)
|
|
|
|
drawables[i].FadeIn(100 + i * 50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-17 00:15:37 +08:00
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
{
|
|
|
|
updateState();
|
|
|
|
return base.OnHover(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
{
|
|
|
|
updateState();
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
{
|
2023-10-11 10:17:50 +08:00
|
|
|
var lightenedGradient = ColourInfo.GradientHorizontal(backgroundColour.Opacity(0).Lighten(0.2f), backgroundColour.Lighten(0.2f));
|
|
|
|
|
2023-01-17 00:15:37 +08:00
|
|
|
foreground.FadeColour(IsHovered ? foregroundColour.Lighten(0.2f) : foregroundColour, transition_duration, Easing.OutQuint);
|
|
|
|
background.FadeColour(IsHovered ? backgroundColour.Lighten(0.2f) : backgroundColour, transition_duration, Easing.OutQuint);
|
2023-10-11 10:17:50 +08:00
|
|
|
totalScoreBackground.FadeColour(IsHovered ? lightenedGradient : totalScoreBackgroundGradient, transition_duration, Easing.OutQuint);
|
2023-01-17 00:15:37 +08:00
|
|
|
}
|
2023-01-17 00:35:27 +08:00
|
|
|
|
2023-10-11 11:24:17 +08:00
|
|
|
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
|
|
|
|
{
|
|
|
|
Scheduler.AddOnce(() =>
|
|
|
|
{
|
|
|
|
// when width decreases
|
|
|
|
// - hide statistics, then
|
|
|
|
// - hide avatar, then
|
|
|
|
// - hide user and flag and show avatar again
|
|
|
|
|
|
|
|
if (centreContent.DrawWidth >= height + username_min_width || centreContent.DrawWidth < username_min_width)
|
|
|
|
avatar.FadeIn(transition_duration, Easing.OutQuint).MoveToX(0, transition_duration, Easing.OutQuint);
|
|
|
|
else
|
|
|
|
avatar.FadeOut(transition_duration, Easing.OutQuint).MoveToX(-avatar.DrawWidth, transition_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
if (centreContent.DrawWidth >= username_min_width)
|
|
|
|
usernameAndFlagContainer.FadeIn(transition_duration, Easing.OutQuint).MoveToX(0, transition_duration, Easing.OutQuint);
|
|
|
|
else
|
|
|
|
usernameAndFlagContainer.FadeOut(transition_duration, Easing.OutQuint).MoveToX(usernameAndFlagContainer.DrawWidth, transition_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
if (centreContent.DrawWidth >= height + statisticsContainer.DrawWidth + username_min_width)
|
|
|
|
statisticsContainer.FadeIn(transition_duration, Easing.OutQuint).MoveToX(0, transition_duration, Easing.OutQuint);
|
|
|
|
else
|
|
|
|
statisticsContainer.FadeOut(transition_duration, Easing.OutQuint).MoveToX(statisticsContainer.DrawWidth, transition_duration, Easing.OutQuint);
|
|
|
|
});
|
|
|
|
|
|
|
|
return base.OnInvalidate(invalidation, source);
|
|
|
|
}
|
|
|
|
|
2023-01-17 02:03:17 +08:00
|
|
|
#region Subclasses
|
|
|
|
|
2023-01-17 01:12:59 +08:00
|
|
|
private partial class DateLabel : DrawableDate
|
|
|
|
{
|
|
|
|
public DateLabel(DateTimeOffset date)
|
|
|
|
: base(date)
|
|
|
|
{
|
|
|
|
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Medium, italics: true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string Format() => Date.ToShortRelativeTime(TimeSpan.FromSeconds(30));
|
|
|
|
}
|
|
|
|
|
2023-01-17 01:21:19 +08:00
|
|
|
private partial class ScoreComponentLabel : Container
|
|
|
|
{
|
|
|
|
private readonly (LocalisableString Name, LocalisableString Value) statisticInfo;
|
|
|
|
private readonly ScoreInfo score;
|
|
|
|
|
|
|
|
private FillFlowContainer content = null!;
|
|
|
|
public override bool Contains(Vector2 screenSpacePos) => content.Contains(screenSpacePos);
|
|
|
|
|
|
|
|
public ScoreComponentLabel((LocalisableString Name, LocalisableString Value) statisticInfo, ScoreInfo score)
|
|
|
|
{
|
|
|
|
this.statisticInfo = statisticInfo;
|
|
|
|
this.score = score;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours, OverlayColourProvider colourProvider)
|
|
|
|
{
|
2023-01-18 03:13:50 +08:00
|
|
|
AutoSizeAxes = Axes.Both;
|
2023-01-17 01:21:19 +08:00
|
|
|
OsuSpriteText value;
|
|
|
|
Child = content = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Colour = colourProvider.Content2,
|
|
|
|
Text = statisticInfo.Name,
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
|
|
|
},
|
|
|
|
value = new OsuSpriteText
|
|
|
|
{
|
2023-01-18 03:13:50 +08:00
|
|
|
// We don't want the value setting the horizontal size, since it leads to wonky accuracy container length,
|
|
|
|
// since the accuracy is sometimes longer than its name.
|
|
|
|
BypassAutoSizeAxes = Axes.X,
|
2023-01-17 01:21:19 +08:00
|
|
|
Text = statisticInfo.Value,
|
|
|
|
Font = OsuFont.GetFont(size: 19, weight: FontWeight.Medium),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-01-18 03:13:50 +08:00
|
|
|
if (score.Combo != score.MaxCombo && statisticInfo.Name == BeatmapsetsStrings.ShowScoreboardHeadersCombo)
|
2023-01-17 01:21:19 +08:00
|
|
|
value.Colour = colours.Lime1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-17 00:35:27 +08:00
|
|
|
private partial class RankLabel : Container, IHasTooltip
|
|
|
|
{
|
|
|
|
public RankLabel(int? rank)
|
|
|
|
{
|
2023-10-11 09:20:19 +08:00
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
2023-01-17 00:35:27 +08:00
|
|
|
if (rank >= 1000)
|
|
|
|
TooltipText = $"#{rank:N0}";
|
|
|
|
|
|
|
|
Child = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Font = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold, italics: true),
|
|
|
|
Text = rank == null ? "-" : rank.Value.FormatRank().Insert(0, "#")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public LocalisableString TooltipText { get; }
|
|
|
|
}
|
2023-01-17 01:03:38 +08:00
|
|
|
|
2023-01-18 03:13:50 +08:00
|
|
|
private sealed partial class ColouredModSwitchTiny : ModSwitchTiny, IHasTooltip
|
2023-01-17 01:03:38 +08:00
|
|
|
{
|
2023-01-17 02:30:50 +08:00
|
|
|
private readonly IMod mod;
|
|
|
|
|
2023-01-17 01:03:38 +08:00
|
|
|
public ColouredModSwitchTiny(IMod mod)
|
|
|
|
: base(mod)
|
|
|
|
{
|
2023-01-17 02:30:50 +08:00
|
|
|
this.mod = mod;
|
2023-09-23 10:55:00 +08:00
|
|
|
Active.Value = true;
|
2023-01-17 02:16:35 +08:00
|
|
|
Masking = true;
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Roundness = 15,
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Colour = Colour4.Black.Opacity(0.15f),
|
|
|
|
Radius = 3,
|
|
|
|
Offset = new Vector2(-2, 0)
|
|
|
|
};
|
2023-01-17 01:03:38 +08:00
|
|
|
}
|
|
|
|
|
2023-01-18 03:13:50 +08:00
|
|
|
public LocalisableString TooltipText => (mod as Mod)?.IconTooltip ?? mod.Name;
|
2023-01-17 01:03:38 +08:00
|
|
|
}
|
|
|
|
|
2023-01-17 02:03:17 +08:00
|
|
|
#endregion
|
|
|
|
|
2023-01-17 01:03:38 +08:00
|
|
|
public MenuItem[] ContextMenuItems
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
List<MenuItem> items = new List<MenuItem>();
|
|
|
|
|
|
|
|
if (score.Mods.Length > 0 && modsContainer.Any(s => s.IsHovered) && songSelect != null)
|
|
|
|
items.Add(new OsuMenuItem("Use these mods", MenuItemType.Highlighted, () => songSelect.Mods.Value = score.Mods));
|
|
|
|
|
|
|
|
if (score.Files.Count <= 0) return items.ToArray();
|
|
|
|
|
2023-09-23 02:07:49 +08:00
|
|
|
items.Add(new OsuMenuItem("Export", MenuItemType.Standard, () => scoreManager.Export(score)));
|
2023-01-17 01:03:38 +08:00
|
|
|
items.Add(new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, () => dialogOverlay?.Push(new LocalScoreDeleteDialog(score))));
|
|
|
|
|
|
|
|
return items.ToArray();
|
|
|
|
}
|
|
|
|
}
|
2023-01-16 23:57:18 +08:00
|
|
|
}
|
|
|
|
}
|