2020-03-15 18:32:12 +01:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-09-27 19:33:52 +03:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2019-09-27 19:33:52 +03:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using System;
|
2019-11-27 21:56:22 +03:00
|
|
|
using osu.Game.Users;
|
2019-11-27 23:35:02 +03:00
|
|
|
using osu.Game.Graphics;
|
2020-02-27 22:22:22 +01:00
|
|
|
using osu.Game.Graphics.Containers;
|
2019-11-28 20:09:05 +03:00
|
|
|
using System.Collections.Generic;
|
2020-02-13 19:01:26 +03:00
|
|
|
using osu.Framework.Allocation;
|
2022-07-16 04:40:37 +03:00
|
|
|
using osu.Framework.Extensions;
|
2021-08-29 15:00:28 +03:00
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2021-07-30 15:24:10 +02:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-09-27 19:33:52 +03:00
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Rankings.Tables
|
|
|
|
{
|
2022-11-24 14:32:20 +09:00
|
|
|
public partial class CountriesTable : RankingsTable<CountryStatistics>
|
2019-09-27 19:33:52 +03:00
|
|
|
{
|
2019-11-28 20:09:05 +03:00
|
|
|
public CountriesTable(int page, IReadOnlyList<CountryStatistics> rankings)
|
|
|
|
: base(page, rankings)
|
2019-09-27 19:33:52 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-07-27 18:46:49 +02:00
|
|
|
protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[]
|
2019-09-27 19:33:52 +03:00
|
|
|
{
|
2021-07-30 15:24:10 +02:00
|
|
|
new RankingsTableColumn(RankingsStrings.StatActiveUsers, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
new RankingsTableColumn(RankingsStrings.StatPlayCount, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
new RankingsTableColumn(RankingsStrings.StatRankedScore, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
new RankingsTableColumn(RankingsStrings.StatAverageScore, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
new RankingsTableColumn(RankingsStrings.StatPerformance, Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true),
|
|
|
|
new RankingsTableColumn(RankingsStrings.StatAveragePerformance, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
2019-09-27 19:33:52 +03:00
|
|
|
};
|
|
|
|
|
2022-07-18 08:40:34 +03:00
|
|
|
protected override CountryCode GetCountryCode(CountryStatistics item) => item.Code;
|
2019-11-27 23:35:02 +03:00
|
|
|
|
2022-07-18 08:40:34 +03:00
|
|
|
protected override Drawable CreateFlagContent(CountryStatistics item) => new CountryName(item.Code);
|
2019-11-27 23:35:02 +03:00
|
|
|
|
2019-11-27 23:58:31 +03:00
|
|
|
protected override Drawable[] CreateAdditionalContent(CountryStatistics item) => new Drawable[]
|
2019-09-27 19:33:52 +03:00
|
|
|
{
|
2021-07-31 14:27:20 +09:00
|
|
|
new ColouredRowText
|
2019-09-27 19:33:52 +03:00
|
|
|
{
|
2021-07-31 14:27:20 +09:00
|
|
|
Text = item.ActiveUsers.ToLocalisableString(@"N0")
|
2019-09-27 19:33:52 +03:00
|
|
|
},
|
2021-07-31 14:27:20 +09:00
|
|
|
new ColouredRowText
|
2019-10-01 14:12:03 +03:00
|
|
|
{
|
2021-07-31 14:27:20 +09:00
|
|
|
Text = item.PlayCount.ToLocalisableString(@"N0")
|
2019-10-01 14:12:03 +03:00
|
|
|
},
|
2021-07-31 14:27:20 +09:00
|
|
|
new ColouredRowText
|
2019-10-01 14:12:03 +03:00
|
|
|
{
|
2021-07-31 14:27:20 +09:00
|
|
|
Text = item.RankedScore.ToLocalisableString(@"N0")
|
2019-10-01 14:12:03 +03:00
|
|
|
},
|
2021-07-31 14:27:20 +09:00
|
|
|
new ColouredRowText
|
2019-10-01 14:12:03 +03:00
|
|
|
{
|
2021-07-31 14:27:20 +09:00
|
|
|
Text = (item.RankedScore / Math.Max(item.ActiveUsers, 1)).ToLocalisableString(@"N0")
|
2019-10-01 14:12:03 +03:00
|
|
|
},
|
|
|
|
new RowText
|
|
|
|
{
|
2021-07-31 14:27:20 +09:00
|
|
|
Text = item.Performance.ToLocalisableString(@"N0")
|
2019-10-01 14:12:03 +03:00
|
|
|
},
|
2021-07-31 14:27:20 +09:00
|
|
|
new ColouredRowText
|
2019-09-27 19:33:52 +03:00
|
|
|
{
|
2021-07-31 14:27:20 +09:00
|
|
|
Text = (item.Performance / Math.Max(item.ActiveUsers, 1)).ToLocalisableString(@"N0")
|
2019-09-27 19:33:52 +03:00
|
|
|
}
|
|
|
|
};
|
2020-02-13 19:01:26 +03:00
|
|
|
|
2022-11-24 14:32:20 +09:00
|
|
|
private partial class CountryName : LinkFlowContainer
|
2020-02-13 19:01:26 +03:00
|
|
|
{
|
2020-02-19 16:49:39 +03:00
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
private RankingsOverlay rankings { get; set; }
|
|
|
|
|
2022-07-18 08:40:34 +03:00
|
|
|
public CountryName(CountryCode countryCode)
|
2020-02-27 22:35:02 +01:00
|
|
|
: base(t => t.Font = OsuFont.GetFont(size: 12))
|
2020-02-13 19:01:26 +03:00
|
|
|
{
|
2020-02-27 22:22:22 +01:00
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
TextAnchor = Anchor.CentreLeft;
|
2020-02-19 16:49:39 +03:00
|
|
|
|
2022-07-18 08:54:35 +03:00
|
|
|
if (countryCode != CountryCode.Unknown)
|
2022-07-18 08:40:34 +03:00
|
|
|
AddLink(countryCode.GetDescription(), () => rankings?.ShowCountry(countryCode));
|
2020-02-13 19:01:26 +03:00
|
|
|
}
|
|
|
|
}
|
2019-09-27 19:33:52 +03:00
|
|
|
}
|
|
|
|
}
|