2020-05-16 17:17:32 +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.
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2022-07-18 12:13:08 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2020-05-16 17:17:32 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Effects;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-01-28 12:53:48 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2020-05-16 17:17:32 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Online.Leaderboards;
|
2022-01-28 12:53:48 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2020-10-07 15:17:28 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-05-16 17:17:32 +08:00
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
using osu.Game.Users.Drawables;
|
|
|
|
|
using osu.Game.Utils;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Ranking.Contracted
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The content that appears in the middle of a contracted <see cref="ScorePanel"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ContractedPanelMiddleContent : CompositeDrawable
|
|
|
|
|
{
|
|
|
|
|
private readonly ScoreInfo score;
|
|
|
|
|
|
2020-08-28 21:51:48 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private ScoreManager scoreManager { get; set; } = null!;
|
|
|
|
|
|
2020-05-16 17:17:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a new <see cref="ContractedPanelMiddleContent"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="score">The <see cref="ScoreInfo"/> to display.</param>
|
|
|
|
|
public ContractedPanelMiddleContent(ScoreInfo score)
|
|
|
|
|
{
|
|
|
|
|
this.score = score;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
InternalChild = new GridContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-05-16 17:28:15 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
CornerExponent = 2.5f,
|
|
|
|
|
CornerRadius = 20,
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 1,
|
|
|
|
|
Offset = new Vector2(0, 4)
|
|
|
|
|
},
|
2020-05-16 17:17:32 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-05-21 16:47:14 +08:00
|
|
|
|
new Box
|
2020-05-16 17:17:32 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-05-21 16:47:14 +08:00
|
|
|
|
Colour = Color4Extensions.FromHex("444")
|
|
|
|
|
},
|
|
|
|
|
new UserCoverBackground
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
User = score.User,
|
|
|
|
|
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.5f), Color4Extensions.FromHex("#444").Opacity(0))
|
2020-05-16 17:17:32 +08:00
|
|
|
|
},
|
2020-05-16 17:28:15 +08:00
|
|
|
|
new FillFlowContainer
|
2020-05-16 17:17:32 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-05-16 17:28:15 +08:00
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 10),
|
2020-05-16 17:17:32 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-05-16 17:28:15 +08:00
|
|
|
|
new UpdateableAvatar(score.User)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2020-05-21 16:47:14 +08:00
|
|
|
|
Size = new Vector2(110),
|
2020-05-16 17:28:15 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
CornerExponent = 2.5f,
|
|
|
|
|
CornerRadius = 20,
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 8,
|
|
|
|
|
Offset = new Vector2(0, 4),
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-12-13 16:37:27 +08:00
|
|
|
|
Text = score.RealmUser.Username,
|
2020-05-16 17:28:15 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 16, weight: FontWeight.SemiBold)
|
|
|
|
|
},
|
2020-05-16 17:17:32 +08:00
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
2020-05-16 17:28:15 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2020-05-16 17:17:32 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2020-05-16 17:28:15 +08:00
|
|
|
|
Spacing = new Vector2(0, 5),
|
2020-10-07 15:17:28 +08:00
|
|
|
|
ChildrenEnumerable = score.GetStatisticsForDisplay().Where(s => !s.Result.IsBonus()).Select(createStatistic)
|
2020-05-16 17:28:15 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Margin = new MarginPadding { Top = 10 },
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 5),
|
|
|
|
|
Children = new[]
|
2020-05-16 17:17:32 +08:00
|
|
|
|
{
|
2022-01-28 12:53:48 +08:00
|
|
|
|
createStatistic(BeatmapsetsStrings.ShowScoreboardHeadersCombo, $"x{score.MaxCombo}"),
|
|
|
|
|
createStatistic(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy, $"{score.Accuracy.FormatAccuracy()}"),
|
2020-05-16 17:17:32 +08:00
|
|
|
|
}
|
2020-05-16 17:28:15 +08:00
|
|
|
|
},
|
2021-07-21 15:38:18 +08:00
|
|
|
|
new ModFlowDisplay
|
2020-05-16 17:28:15 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-07-21 15:38:18 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2020-05-16 17:28:15 +08:00
|
|
|
|
Current = { Value = score.Mods },
|
2021-07-21 15:38:18 +08:00
|
|
|
|
IconScale = 0.5f,
|
2020-05-16 17:17:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Vertical = 5 },
|
|
|
|
|
Child = new GridContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2020-09-09 16:04:02 +08:00
|
|
|
|
Current = scoreManager.GetBindableTotalScoreString(score),
|
2020-05-16 17:17:32 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, fixedWidth: true),
|
|
|
|
|
Spacing = new Vector2(-1, 0)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Top = 2 },
|
|
|
|
|
Child = new DrawableRank(score.Rank)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(),
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, 45),
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-07 14:35:04 +08:00
|
|
|
|
private Drawable createStatistic(HitResultDisplayStatistic result)
|
|
|
|
|
=> createStatistic(result.DisplayName, result.MaxCount == null ? $"{result.Count}" : $"{result.Count}/{result.MaxCount}");
|
2020-09-25 19:22:59 +08:00
|
|
|
|
|
2022-01-28 12:53:48 +08:00
|
|
|
|
private Drawable createStatistic(LocalisableString key, string value) => new Container
|
2020-05-16 17:17:32 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2022-07-18 12:13:08 +08:00
|
|
|
|
Text = key.ToTitle(),
|
2020-05-16 17:17:32 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Text = value,
|
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
|
|
|
|
Colour = Color4Extensions.FromHex("#FFDD55")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|