2022-02-20 03:47:30 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2022-02-17 06:18:14 +08:00
|
|
|
|
using System;
|
2018-12-14 18:51:27 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-11-28 15:33:42 +08:00
|
|
|
|
using System.Linq;
|
2017-11-16 20:29:07 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-08-14 01:54:07 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-03-04 15:37:34 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-06-04 09:26:30 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-02-12 12:04:46 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2019-12-15 18:18:12 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2021-06-26 01:10:04 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2022-02-21 12:42:26 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2017-03-04 15:37:34 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-08-14 01:54:07 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-03-04 15:37:34 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-12-15 18:18:12 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-12-17 11:25:28 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2017-08-14 01:54:07 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
2019-12-17 11:25:28 +08:00
|
|
|
|
using osu.Game.Screens.Select;
|
2018-11-28 15:12:57 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2019-06-18 01:57:57 +08:00
|
|
|
|
using osu.Game.Users.Drawables;
|
2018-12-14 18:51:27 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2019-11-01 23:46:13 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2022-01-28 12:53:48 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2023-09-28 15:47:41 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-12-19 22:02:56 +08:00
|
|
|
|
using osu.Game.Utils;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-12-14 18:51:27 +08:00
|
|
|
|
namespace osu.Game.Online.Leaderboards
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2022-02-01 13:28:18 +08:00
|
|
|
|
public partial class LeaderboardScore : OsuClickableContainer, IHasContextMenu, IHasCustomTooltip<ScoreInfo>
|
2018-12-14 18:51:27 +08:00
|
|
|
|
{
|
2018-12-22 14:20:35 +08:00
|
|
|
|
public const float HEIGHT = 60;
|
|
|
|
|
|
2021-09-07 15:46:27 +08:00
|
|
|
|
public readonly ScoreInfo Score;
|
|
|
|
|
|
2017-03-04 15:37:34 +08:00
|
|
|
|
private const float corner_radius = 5;
|
2017-03-19 15:34:29 +08:00
|
|
|
|
private const float edge_margin = 5;
|
2017-03-13 20:33:25 +08:00
|
|
|
|
private const float background_alpha = 0.25f;
|
2019-07-14 17:47:35 +08:00
|
|
|
|
private const float rank_width = 35;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-12-14 18:51:27 +08:00
|
|
|
|
protected Container RankContainer { get; private set; }
|
|
|
|
|
|
2020-02-20 13:51:25 +08:00
|
|
|
|
private readonly int? rank;
|
2022-01-10 13:36:05 +08:00
|
|
|
|
private readonly bool isOnlineScope;
|
2018-12-14 18:51:27 +08:00
|
|
|
|
|
2017-11-16 20:29:07 +08:00
|
|
|
|
private Box background;
|
|
|
|
|
private Container content;
|
2017-11-23 19:23:47 +08:00
|
|
|
|
private Drawable avatar;
|
2018-12-14 18:51:27 +08:00
|
|
|
|
private Drawable scoreRank;
|
2017-11-16 20:29:07 +08:00
|
|
|
|
private OsuSpriteText nameLabel;
|
2022-01-18 12:58:12 +08:00
|
|
|
|
|
|
|
|
|
public GlowingSpriteText ScoreText { get; private set; }
|
|
|
|
|
|
2022-02-17 17:12:35 +08:00
|
|
|
|
private FillFlowContainer flagBadgeAndDateContainer;
|
2017-11-16 20:29:07 +08:00
|
|
|
|
private FillFlowContainer<ModIcon> modsContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-12-14 18:51:27 +08:00
|
|
|
|
private List<ScoreComponentLabel> statisticsLabels;
|
2019-12-18 04:56:30 +08:00
|
|
|
|
|
2022-11-19 00:03:09 +08:00
|
|
|
|
[Resolved(canBeNull: true)]
|
2022-04-18 17:09:14 +08:00
|
|
|
|
private IDialogOverlay dialogOverlay { get; set; }
|
2018-12-14 18:51:27 +08:00
|
|
|
|
|
2022-11-19 00:03:09 +08:00
|
|
|
|
[Resolved(canBeNull: true)]
|
2020-07-12 07:02:47 +08:00
|
|
|
|
private SongSelect songSelect { get; set; }
|
|
|
|
|
|
2022-02-01 13:28:18 +08:00
|
|
|
|
public ITooltip<ScoreInfo> GetCustomTooltip() => new LeaderboardScoreTooltip();
|
2022-02-02 12:23:49 +08:00
|
|
|
|
public virtual ScoreInfo TooltipContent => Score;
|
2022-02-01 13:28:18 +08:00
|
|
|
|
|
2022-12-15 20:01:38 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private ScoreManager scoreManager { get; set; } = null!;
|
2022-12-11 17:30:24 +08:00
|
|
|
|
|
2022-01-10 13:36:05 +08:00
|
|
|
|
public LeaderboardScore(ScoreInfo score, int? rank, bool isOnlineScope = true)
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2021-09-07 16:45:21 +08:00
|
|
|
|
Score = score;
|
|
|
|
|
|
2019-07-14 17:47:35 +08:00
|
|
|
|
this.rank = rank;
|
2022-01-10 13:36:05 +08:00
|
|
|
|
this.isOnlineScope = isOnlineScope;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-04 15:37:34 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-12-22 14:20:35 +08:00
|
|
|
|
Height = HEIGHT;
|
2017-11-16 20:29:07 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-16 20:29:07 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-12-15 20:01:38 +08:00
|
|
|
|
private void load(IAPIProvider api, OsuColour colour)
|
2017-11-16 20:29:07 +08:00
|
|
|
|
{
|
2021-09-07 15:46:27 +08:00
|
|
|
|
var user = Score.User;
|
2018-12-14 18:51:27 +08:00
|
|
|
|
|
2021-09-07 15:46:27 +08:00
|
|
|
|
statisticsLabels = GetStatistics(Score).Select(s => new ScoreComponentLabel(s)).ToList();
|
2018-12-14 18:51:27 +08:00
|
|
|
|
|
2020-12-26 20:54:10 +08:00
|
|
|
|
ClickableAvatar innerAvatar;
|
2019-03-17 12:43:23 +08:00
|
|
|
|
|
2017-03-04 15:37:34 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-08-18 12:09:55 +08:00
|
|
|
|
new RankLabel(rank)
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2017-03-18 05:29:55 +08:00
|
|
|
|
Width = rank_width,
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
2017-03-04 17:01:55 +08:00
|
|
|
|
content = new Container
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-02-17 17:12:35 +08:00
|
|
|
|
Padding = new MarginPadding { Left = rank_width },
|
2017-03-04 15:37:34 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-01-10 13:36:05 +08:00
|
|
|
|
Colour = user.OnlineID == api.LocalUser.Value.Id && isOnlineScope ? colour.Green : Color4.Black,
|
2017-03-13 20:33:25 +08:00
|
|
|
|
Alpha = background_alpha,
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding(edge_margin),
|
2017-11-23 19:23:47 +08:00
|
|
|
|
Children = new[]
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2017-04-02 15:17:13 +08:00
|
|
|
|
avatar = new DelayedLoadWrapper(
|
2020-12-26 20:54:10 +08:00
|
|
|
|
innerAvatar = new ClickableAvatar(user)
|
2017-03-19 16:29:10 +08:00
|
|
|
|
{
|
2017-04-02 14:56:12 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
|
Masking = true,
|
2017-06-12 11:48:47 +08:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2017-03-28 13:24:21 +08:00
|
|
|
|
{
|
2017-04-02 14:56:12 +08:00
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 1,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
2017-03-28 13:24:21 +08:00
|
|
|
|
},
|
2017-04-02 14:56:12 +08:00
|
|
|
|
})
|
|
|
|
|
{
|
2017-04-04 08:47:52 +08:00
|
|
|
|
RelativeSizeAxes = Axes.None,
|
2018-12-22 14:20:35 +08:00
|
|
|
|
Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
2018-12-22 14:20:35 +08:00
|
|
|
|
Position = new Vector2(HEIGHT - edge_margin, 0f),
|
2017-03-04 15:37:34 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-13 23:31:46 +08:00
|
|
|
|
nameLabel = new OsuSpriteText
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2018-12-14 18:51:27 +08:00
|
|
|
|
Text = user.Username,
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 23, weight: FontWeight.Bold, italics: true)
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2022-02-18 04:26:59 +08:00
|
|
|
|
Origin = Anchor.BottomLeft,
|
2024-01-16 15:44:50 +08:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = 28,
|
2017-03-05 10:38:01 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2017-03-04 15:37:34 +08:00
|
|
|
|
Spacing = new Vector2(10f, 0f),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2022-02-17 17:12:35 +08:00
|
|
|
|
flagBadgeAndDateContainer = new FillFlowContainer
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2022-02-18 04:26:59 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2022-02-17 17:12:35 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5f, 0f),
|
2022-02-18 04:26:59 +08:00
|
|
|
|
Width = 87f,
|
2017-03-04 15:37:34 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2022-07-18 13:40:34 +08:00
|
|
|
|
new UpdateableFlag(user.CountryCode)
|
2017-03-19 11:09:58 +08:00
|
|
|
|
{
|
2022-02-18 04:26:59 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2022-06-16 01:53:04 +08:00
|
|
|
|
Size = new Vector2(28, 20),
|
2017-03-19 11:09:58 +08:00
|
|
|
|
},
|
2022-02-17 17:12:35 +08:00
|
|
|
|
new DateLabel(Score.Date)
|
|
|
|
|
{
|
2022-02-18 04:26:59 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2022-02-17 17:12:35 +08:00
|
|
|
|
},
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
2022-02-18 04:26:59 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2017-03-04 15:37:34 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-03-05 10:38:01 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2018-06-04 09:22:44 +08:00
|
|
|
|
Margin = new MarginPadding { Left = edge_margin },
|
2018-12-14 18:51:27 +08:00
|
|
|
|
Children = statisticsLabels
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-03-18 05:16:59 +08:00
|
|
|
|
new FillFlowContainer
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2017-03-18 05:16:59 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-03-04 15:37:34 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2017-03-18 05:16:59 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5f, 0f),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2022-01-18 12:58:12 +08:00
|
|
|
|
ScoreText = new GlowingSpriteText
|
2019-07-21 17:14:55 +08:00
|
|
|
|
{
|
|
|
|
|
TextColour = Color4.White,
|
2020-03-11 09:18:41 +08:00
|
|
|
|
GlowColour = Color4Extensions.FromHex(@"83ccfa"),
|
2021-09-07 15:46:27 +08:00
|
|
|
|
Current = scoreManager.GetBindableTotalScoreString(Score),
|
2019-07-21 17:14:55 +08:00
|
|
|
|
Font = OsuFont.Numeric.With(size: 23),
|
|
|
|
|
},
|
2018-12-14 18:51:27 +08:00
|
|
|
|
RankContainer = new Container
|
2017-03-18 05:16:59 +08:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(40f, 20f),
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2021-09-07 15:46:27 +08:00
|
|
|
|
scoreRank = new UpdateableRank(Score.Rank)
|
2017-03-18 05:16:59 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-12-14 18:51:27 +08:00
|
|
|
|
Size = new Vector2(40f)
|
2017-03-18 05:16:59 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
2017-08-14 01:54:07 +08:00
|
|
|
|
modsContainer = new FillFlowContainer<ModIcon>
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-03-05 10:38:01 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2023-09-28 15:47:41 +08:00
|
|
|
|
ChildrenEnumerable = Score.Mods.AsOrdered().Select(mod => new ModIcon(mod) { Scale = new Vector2(0.375f) })
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2019-03-17 12:43:23 +08:00
|
|
|
|
|
|
|
|
|
innerAvatar.OnLoadComplete += d => d.FadeInFromZero(200);
|
2017-11-16 20:29:07 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-16 20:29:07 +08:00
|
|
|
|
public override void Show()
|
|
|
|
|
{
|
2022-02-17 17:12:35 +08:00
|
|
|
|
foreach (var d in new[] { avatar, nameLabel, ScoreText, scoreRank, flagBadgeAndDateContainer, modsContainer }.Concat(statisticsLabels))
|
2017-11-16 20:29:07 +08:00
|
|
|
|
d.FadeOut();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-16 20:29:07 +08:00
|
|
|
|
Alpha = 0;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-16 20:29:07 +08:00
|
|
|
|
content.MoveToY(75);
|
|
|
|
|
avatar.MoveToX(75);
|
|
|
|
|
nameLabel.MoveToX(150);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-16 20:29:07 +08:00
|
|
|
|
this.FadeIn(200);
|
|
|
|
|
content.MoveToY(0, 800, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
|
using (BeginDelayedSequence(100))
|
2017-03-04 17:01:55 +08:00
|
|
|
|
{
|
2017-11-16 20:29:07 +08:00
|
|
|
|
avatar.FadeIn(300, Easing.OutQuint);
|
|
|
|
|
nameLabel.FadeIn(350, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-16 20:29:07 +08:00
|
|
|
|
avatar.MoveToX(0, 300, Easing.OutQuint);
|
|
|
|
|
nameLabel.MoveToX(0, 350, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
|
using (BeginDelayedSequence(250))
|
2017-11-16 20:29:07 +08:00
|
|
|
|
{
|
2022-01-18 12:58:12 +08:00
|
|
|
|
ScoreText.FadeIn(200);
|
2017-11-16 20:29:07 +08:00
|
|
|
|
scoreRank.FadeIn(200);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-07-05 23:52:39 +08:00
|
|
|
|
using (BeginDelayedSequence(50))
|
2017-11-16 20:29:07 +08:00
|
|
|
|
{
|
2022-02-17 17:12:35 +08:00
|
|
|
|
var drawables = new Drawable[] { flagBadgeAndDateContainer, modsContainer }.Concat(statisticsLabels).ToArray();
|
2017-11-16 20:29:07 +08:00
|
|
|
|
for (int i = 0; i < drawables.Length; i++)
|
|
|
|
|
drawables[i].FadeIn(100 + i * 50);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-12-22 14:23:32 +08:00
|
|
|
|
protected virtual IEnumerable<LeaderboardScoreStatistic> GetStatistics(ScoreInfo model) => new[]
|
|
|
|
|
{
|
2022-01-28 12:53:48 +08:00
|
|
|
|
new LeaderboardScoreStatistic(FontAwesome.Solid.Link, BeatmapsetsStrings.ShowScoreboardHeadersCombo, model.MaxCombo.ToString()),
|
|
|
|
|
new LeaderboardScoreStatistic(FontAwesome.Solid.Crosshairs, BeatmapsetsStrings.ShowScoreboardHeadersAccuracy, model.DisplayAccuracy)
|
2018-12-22 14:23:32 +08:00
|
|
|
|
};
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2017-03-18 06:45:51 +08:00
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
background.FadeTo(0.5f, 300, Easing.OutQuint);
|
2018-10-02 11:02:47 +08:00
|
|
|
|
return base.OnHover(e);
|
2017-03-18 06:45:51 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
2017-03-18 06:45:51 +08:00
|
|
|
|
{
|
2017-07-23 02:50:25 +08:00
|
|
|
|
background.FadeTo(background_alpha, 200, Easing.OutQuint);
|
2018-10-02 11:02:47 +08:00
|
|
|
|
base.OnHoverLost(e);
|
2017-03-18 06:45:51 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-04 09:26:30 +08:00
|
|
|
|
private partial class ScoreComponentLabel : Container, IHasTooltip
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2018-06-04 09:22:44 +08:00
|
|
|
|
private const float icon_size = 20;
|
|
|
|
|
private readonly FillFlowContainer content;
|
|
|
|
|
|
2018-06-04 09:26:30 +08:00
|
|
|
|
public override bool Contains(Vector2 screenSpacePos) => content.Contains(screenSpacePos);
|
2018-06-04 09:22:44 +08:00
|
|
|
|
|
2021-06-26 01:10:04 +08:00
|
|
|
|
public LocalisableString TooltipText { get; }
|
2018-06-04 09:26:30 +08:00
|
|
|
|
|
2018-12-22 14:20:35 +08:00
|
|
|
|
public ScoreComponentLabel(LeaderboardScoreStatistic statistic)
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2019-11-12 17:45:42 +08:00
|
|
|
|
TooltipText = statistic.Name;
|
2018-12-14 18:51:27 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-04 09:26:30 +08:00
|
|
|
|
Child = content = new FillFlowContainer
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2018-06-04 09:22:44 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2022-02-01 15:20:40 +08:00
|
|
|
|
Padding = new MarginPadding { Right = 10 },
|
2018-06-04 09:22:44 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-03-04 15:37:34 +08:00
|
|
|
|
{
|
2018-06-04 09:22:44 +08:00
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(icon_size),
|
|
|
|
|
Rotation = 45,
|
2020-03-11 09:18:41 +08:00
|
|
|
|
Colour = Color4Extensions.FromHex(@"3087ac"),
|
2019-04-02 18:55:24 +08:00
|
|
|
|
Icon = FontAwesome.Solid.Square,
|
2018-06-04 09:22:44 +08:00
|
|
|
|
Shadow = true,
|
|
|
|
|
},
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(icon_size - 6),
|
2020-03-11 09:18:41 +08:00
|
|
|
|
Colour = Color4Extensions.FromHex(@"a4edff"),
|
2018-12-22 14:20:35 +08:00
|
|
|
|
Icon = statistic.Icon,
|
2018-06-04 09:22:44 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-01-16 22:39:37 +08:00
|
|
|
|
new OsuSpriteText
|
2018-06-04 09:22:44 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2019-07-21 17:14:55 +08:00
|
|
|
|
Text = statistic.Value,
|
2024-01-16 22:39:37 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold, fixedWidth: true)
|
2018-06-04 09:22:44 +08:00
|
|
|
|
},
|
2017-03-04 15:37:34 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2020-08-18 12:09:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private partial class RankLabel : Container, IHasTooltip
|
|
|
|
|
{
|
|
|
|
|
public RankLabel(int? rank)
|
|
|
|
|
{
|
2020-08-18 14:08:51 +08:00
|
|
|
|
if (rank >= 1000)
|
|
|
|
|
TooltipText = $"#{rank:N0}";
|
2020-08-18 12:09:55 +08:00
|
|
|
|
|
|
|
|
|
Child = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Font = OsuFont.GetFont(size: 20, italics: true),
|
2020-12-19 22:02:56 +08:00
|
|
|
|
Text = rank == null ? "-" : rank.Value.FormatRank()
|
2020-08-18 12:09:55 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-26 01:10:04 +08:00
|
|
|
|
public LocalisableString TooltipText { get; }
|
2017-03-04 15:37:34 +08:00
|
|
|
|
}
|
2018-12-22 14:20:35 +08:00
|
|
|
|
|
2022-02-17 06:18:14 +08:00
|
|
|
|
private partial class DateLabel : DrawableDate
|
|
|
|
|
{
|
|
|
|
|
public DateLabel(DateTimeOffset date)
|
2022-02-17 17:12:35 +08:00
|
|
|
|
: base(date)
|
2022-02-17 06:18:14 +08:00
|
|
|
|
{
|
2022-02-17 17:12:35 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold, italics: true);
|
2022-02-17 06:18:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-21 12:42:26 +08:00
|
|
|
|
protected override string Format() => Date.ToShortRelativeTime(TimeSpan.FromSeconds(30));
|
2022-02-17 06:18:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-22 14:20:35 +08:00
|
|
|
|
public class LeaderboardScoreStatistic
|
|
|
|
|
{
|
2019-03-27 18:29:27 +08:00
|
|
|
|
public IconUsage Icon;
|
2021-07-24 04:37:08 +08:00
|
|
|
|
public LocalisableString Value;
|
2022-01-28 12:53:48 +08:00
|
|
|
|
public LocalisableString Name;
|
2018-12-22 14:20:35 +08:00
|
|
|
|
|
2022-01-28 12:53:48 +08:00
|
|
|
|
public LeaderboardScoreStatistic(IconUsage icon, LocalisableString name, LocalisableString value)
|
2018-12-22 14:20:35 +08:00
|
|
|
|
{
|
|
|
|
|
Icon = icon;
|
|
|
|
|
Name = name;
|
|
|
|
|
Value = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-17 11:25:28 +08:00
|
|
|
|
|
2019-12-18 04:56:30 +08:00
|
|
|
|
public MenuItem[] ContextMenuItems
|
2019-12-17 11:25:28 +08:00
|
|
|
|
{
|
2019-12-19 14:41:07 +08:00
|
|
|
|
get
|
2019-12-18 04:56:30 +08:00
|
|
|
|
{
|
2019-12-19 14:41:07 +08:00
|
|
|
|
List<MenuItem> items = new List<MenuItem>();
|
|
|
|
|
|
2023-12-06 06:33:25 +08:00
|
|
|
|
if (Score.Mods.Length > 0 && songSelect != null)
|
2021-09-07 15:46:27 +08:00
|
|
|
|
items.Add(new OsuMenuItem("Use these mods", MenuItemType.Highlighted, () => songSelect.Mods.Value = Score.Mods));
|
2020-07-12 07:02:47 +08:00
|
|
|
|
|
2021-11-24 12:42:07 +08:00
|
|
|
|
if (Score.Files.Count > 0)
|
2022-07-04 01:23:17 +08:00
|
|
|
|
{
|
2023-07-23 13:03:35 +08:00
|
|
|
|
items.Add(new OsuMenuItem(Localisation.CommonStrings.Export, MenuItemType.Standard, () => scoreManager.Export(Score)));
|
2022-01-28 12:53:48 +08:00
|
|
|
|
items.Add(new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, () => dialogOverlay?.Push(new LocalScoreDeleteDialog(Score))));
|
2022-07-04 01:23:17 +08:00
|
|
|
|
}
|
2019-12-19 14:41:07 +08:00
|
|
|
|
|
|
|
|
|
return items.ToArray();
|
|
|
|
|
}
|
2019-12-18 04:56:30 +08:00
|
|
|
|
}
|
2017-03-04 15:37:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|