2019-09-27 19:33:52 +03: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 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.Sprites;
|
|
|
|
|
using osu.Game.Graphics;
|
2019-11-28 20:09:05 +03:00
|
|
|
|
using System.Collections.Generic;
|
2020-02-13 19:01:26 +03:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-02-19 16:49:39 +03:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-09-27 19:33:52 +03:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Rankings.Tables
|
|
|
|
|
{
|
2019-11-27 21:56:22 +03:00
|
|
|
|
public 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
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-27 21:46:41 +03:00
|
|
|
|
protected override TableColumn[] CreateAdditionalHeaders() => new[]
|
2019-09-27 19:33:52 +03:00
|
|
|
|
{
|
2019-11-03 14:31:23 +03:00
|
|
|
|
new TableColumn("Active Users", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
|
new TableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
|
new TableColumn("Ranked Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
|
new TableColumn("Avg. Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
|
new TableColumn("Performance", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
|
|
|
|
new TableColumn("Avg. Perf.", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
2019-09-27 19:33:52 +03:00
|
|
|
|
};
|
|
|
|
|
|
2019-11-27 23:35:02 +03:00
|
|
|
|
protected override Country GetCountry(CountryStatistics item) => item.Country;
|
|
|
|
|
|
2020-02-13 19:01:26 +03:00
|
|
|
|
protected override Drawable CreateFlagContent(CountryStatistics item) => new CountryName(item.Country);
|
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
|
|
|
|
{
|
2019-10-01 14:12:03 +03:00
|
|
|
|
new ColoredRowText
|
2019-09-27 19:33:52 +03:00
|
|
|
|
{
|
|
|
|
|
Text = $@"{item.ActiveUsers:N0}",
|
|
|
|
|
},
|
2019-10-01 14:12:03 +03: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 19:33:52 +03:00
|
|
|
|
{
|
|
|
|
|
Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}",
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-02-13 19:01:26 +03:00
|
|
|
|
|
2020-02-19 16:49:39 +03:00
|
|
|
|
private class CountryName : OsuHoverContainer
|
2020-02-13 19:01:26 +03:00
|
|
|
|
{
|
2020-02-19 16:49:39 +03:00
|
|
|
|
protected override IEnumerable<Drawable> EffectTargets => new[] { text };
|
|
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private RankingsOverlay rankings { get; set; }
|
|
|
|
|
|
|
|
|
|
private readonly OsuSpriteText text;
|
|
|
|
|
private readonly Country country;
|
|
|
|
|
|
2020-02-13 19:01:26 +03:00
|
|
|
|
public CountryName(Country country)
|
|
|
|
|
{
|
2020-02-19 16:49:39 +03:00
|
|
|
|
this.country = country;
|
|
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Add(text = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 12),
|
|
|
|
|
Text = country.FullName ?? string.Empty,
|
|
|
|
|
});
|
2020-02-13 19:01:26 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
2020-02-19 16:49:39 +03:00
|
|
|
|
IdleColour = colourProvider.Light2;
|
|
|
|
|
HoverColour = colourProvider.Content2;
|
|
|
|
|
|
|
|
|
|
Action = () => rankings?.ShowCountry(country);
|
2020-02-13 19:01:26 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-27 19:33:52 +03:00
|
|
|
|
}
|
|
|
|
|
}
|