2020-02-28 05:26:21 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-11-28 04:35:02 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-11-29 01:09:05 +08:00
|
|
|
|
using System.Collections.Generic;
|
2019-11-28 04:35:02 +08:00
|
|
|
|
using System.Linq;
|
2021-08-29 20:00:28 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2019-11-28 04:35:02 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Users;
|
2020-02-05 02:02:10 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2021-07-28 00:22:47 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-07-30 21:24:10 +08:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-11-28 04:35:02 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Rankings.Tables
|
|
|
|
|
{
|
|
|
|
|
public abstract partial class UserBasedTable : RankingsTable<UserStatistics>
|
|
|
|
|
{
|
2019-11-29 01:09:05 +08:00
|
|
|
|
protected UserBasedTable(int page, IReadOnlyList<UserStatistics> rankings)
|
|
|
|
|
: base(page, rankings)
|
2019-11-28 04:35:02 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-30 21:24:10 +08:00
|
|
|
|
protected virtual IEnumerable<LocalisableString> GradeColumns => new List<LocalisableString> { RankingsStrings.Statss, RankingsStrings.Stats, RankingsStrings.Stata };
|
2020-02-28 05:23:50 +08:00
|
|
|
|
|
2022-01-09 21:32:33 +08:00
|
|
|
|
protected override Drawable CreateRowBackground(UserStatistics item)
|
|
|
|
|
{
|
|
|
|
|
var background = base.CreateRowBackground(item);
|
|
|
|
|
|
2022-01-09 21:46:15 +08:00
|
|
|
|
// see: https://github.com/ppy/osu-web/blob/9de00a0b874c56893d98261d558d78d76259d81b/resources/views/multiplayer/rooms/_rankings_table.blade.php#L23
|
2022-01-09 21:32:33 +08:00
|
|
|
|
if (!item.User.Active)
|
|
|
|
|
background.Alpha = 0.5f;
|
|
|
|
|
|
|
|
|
|
return background;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Drawable[] CreateRowContent(int index, UserStatistics item)
|
|
|
|
|
{
|
|
|
|
|
var content = base.CreateRowContent(index, item);
|
|
|
|
|
|
2022-01-09 21:46:15 +08:00
|
|
|
|
// see: https://github.com/ppy/osu-web/blob/9de00a0b874c56893d98261d558d78d76259d81b/resources/views/multiplayer/rooms/_rankings_table.blade.php#L23
|
2022-01-09 21:32:33 +08:00
|
|
|
|
if (!item.User.Active)
|
|
|
|
|
{
|
|
|
|
|
foreach (var d in content)
|
|
|
|
|
d.Alpha = 0.5f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-28 00:46:49 +08:00
|
|
|
|
protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[]
|
2020-02-28 05:23:50 +08:00
|
|
|
|
{
|
2021-07-30 21:24:10 +08:00
|
|
|
|
new RankingsTableColumn(RankingsStrings.StatAccuracy, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
|
new RankingsTableColumn(RankingsStrings.StatPlayCount, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
2020-03-16 05:03:54 +08:00
|
|
|
|
}.Concat(CreateUniqueHeaders())
|
2021-07-28 00:46:49 +08:00
|
|
|
|
.Concat(GradeColumns.Select(grade => new GradeTableColumn(grade, Anchor.Centre, new Dimension(GridSizeMode.AutoSize))))
|
2020-03-16 05:03:54 +08:00
|
|
|
|
.ToArray();
|
|
|
|
|
|
2022-07-18 13:40:34 +08:00
|
|
|
|
protected sealed override CountryCode GetCountryCode(UserStatistics item) => item.User.CountryCode;
|
2019-11-28 04:35:02 +08:00
|
|
|
|
|
2019-11-28 18:07:43 +08:00
|
|
|
|
protected sealed override Drawable CreateFlagContent(UserStatistics item)
|
2019-11-28 04:35:02 +08:00
|
|
|
|
{
|
2020-02-28 05:26:21 +08:00
|
|
|
|
var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE, italics: true))
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
TextAnchor = Anchor.CentreLeft
|
|
|
|
|
};
|
2019-11-28 04:35:02 +08:00
|
|
|
|
username.AddUserLink(item.User);
|
|
|
|
|
return username;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-28 18:07:43 +08:00
|
|
|
|
protected sealed override Drawable[] CreateAdditionalContent(UserStatistics item) => new[]
|
2019-11-28 04:35:02 +08:00
|
|
|
|
{
|
2021-07-31 13:27:20 +08:00
|
|
|
|
new ColouredRowText { Text = item.DisplayAccuracy, },
|
2021-07-31 13:29:38 +08:00
|
|
|
|
new ColouredRowText { Text = item.PlayCount.ToLocalisableString(@"N0") },
|
2019-11-28 04:35:02 +08:00
|
|
|
|
}.Concat(CreateUniqueContent(item)).Concat(new[]
|
|
|
|
|
{
|
2021-07-31 13:29:38 +08:00
|
|
|
|
new ColouredRowText { Text = (item.GradesCount[ScoreRank.XH] + item.GradesCount[ScoreRank.X]).ToLocalisableString(@"N0"), },
|
|
|
|
|
new ColouredRowText { Text = (item.GradesCount[ScoreRank.SH] + item.GradesCount[ScoreRank.S]).ToLocalisableString(@"N0"), },
|
|
|
|
|
new ColouredRowText { Text = item.GradesCount[ScoreRank.A].ToLocalisableString(@"N0"), }
|
2019-11-28 04:35:02 +08:00
|
|
|
|
}).ToArray();
|
|
|
|
|
|
2021-07-28 00:46:49 +08:00
|
|
|
|
protected abstract RankingsTableColumn[] CreateUniqueHeaders();
|
2019-11-28 04:35:02 +08:00
|
|
|
|
|
|
|
|
|
protected abstract Drawable[] CreateUniqueContent(UserStatistics item);
|
2020-03-16 05:03:54 +08:00
|
|
|
|
|
2021-07-28 00:46:49 +08:00
|
|
|
|
private class GradeTableColumn : RankingsTableColumn
|
|
|
|
|
{
|
|
|
|
|
public GradeTableColumn(LocalisableString? header = null, Anchor anchor = Anchor.TopLeft, Dimension dimension = null, bool highlighted = false)
|
|
|
|
|
: base(header, anchor, dimension, highlighted)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override HeaderText CreateHeaderText() => new GradeHeaderText(Header, Highlighted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private partial class GradeHeaderText : HeaderText
|
2020-03-16 05:03:54 +08:00
|
|
|
|
{
|
2021-07-28 00:46:49 +08:00
|
|
|
|
public GradeHeaderText(LocalisableString text, bool isHighlighted)
|
2020-03-16 05:03:54 +08:00
|
|
|
|
: base(text, isHighlighted)
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
// Grade columns have extra horizontal padding for readibility
|
2021-07-28 00:46:49 +08:00
|
|
|
|
Horizontal = 20,
|
2021-07-31 01:06:25 +08:00
|
|
|
|
Vertical = 5
|
2020-03-16 05:03:54 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-28 04:35:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|