osu/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs

82 lines
3.0 KiB
C#
Raw Normal View History

2020-03-15 17:32:12 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2019-09-27 16:33:52 +00:00
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using System;
2019-11-27 18:56:22 +00:00
using osu.Game.Users;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
2019-11-28 17:09:05 +00:00
using System.Collections.Generic;
2020-02-13 16:01:26 +00:00
using osu.Framework.Allocation;
2019-09-27 16:33:52 +00:00
namespace osu.Game.Overlays.Rankings.Tables
{
2019-11-27 18:56:22 +00:00
public class CountriesTable : RankingsTable<CountryStatistics>
2019-09-27 16:33:52 +00:00
{
2019-11-28 17:09:05 +00:00
public CountriesTable(int page, IReadOnlyList<CountryStatistics> rankings)
: base(page, rankings)
2019-09-27 16:33:52 +00:00
{
}
protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[]
2019-09-27 16:33:52 +00:00
{
new RankingsTableColumn("Active Users", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Ranked Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Avg. Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Performance", Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true),
new RankingsTableColumn("Avg. Perf.", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
2019-09-27 16:33:52 +00:00
};
protected override Country GetCountry(CountryStatistics item) => item.Country;
2020-02-13 16:01:26 +00:00
protected override Drawable CreateFlagContent(CountryStatistics item) => new CountryName(item.Country);
2019-11-27 20:58:31 +00:00
protected override Drawable[] CreateAdditionalContent(CountryStatistics item) => new Drawable[]
2019-09-27 16:33:52 +00:00
{
2019-10-01 11:12:03 +00:00
new ColoredRowText
2019-09-27 16:33:52 +00:00
{
Text = $@"{item.ActiveUsers:N0}",
},
2019-10-01 11:12:03 +00:00
new ColoredRowText
{
Text = $@"{item.PlayCount:N0}",
},
new ColoredRowText
{
Text = $@"{item.RankedScore:N0}",
},
new ColoredRowText
{
Text = $@"{item.RankedScore / Math.Max(item.ActiveUsers, 1):N0}",
},
new RowText
{
Text = $@"{item.Performance:N0}",
},
new ColoredRowText
2019-09-27 16:33:52 +00:00
{
Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}",
}
};
2020-02-13 16:01:26 +00:00
private class CountryName : LinkFlowContainer
2020-02-13 16:01:26 +00:00
{
2020-02-19 13:49:39 +00:00
[Resolved(canBeNull: true)]
private RankingsOverlay rankings { get; set; }
2020-02-27 21:35:02 +00:00
public CountryName(Country country)
: base(t => t.Font = OsuFont.GetFont(size: 12))
2020-02-13 16:01:26 +00:00
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
TextAnchor = Anchor.CentreLeft;
2020-02-19 13:49:39 +00:00
2020-03-15 17:32:12 +00:00
if (!string.IsNullOrEmpty(country.FullName))
AddLink(country.FullName, () => rankings?.ShowCountry(country));
2020-02-13 16:01:26 +00:00
}
}
2019-09-27 16:33:52 +00:00
}
}