1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 06:02:56 +08:00
osu-lazer/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
3.4 KiB
C#
Raw Normal View History

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