<commit_before>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. 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;
using osu.Game.Users;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Game.Graphics.Containers;

namespace osu.Game.Overlays.Rankings.Tables
{
    public class CountriesTable : RankingsTable<CountryStatistics>
    {
        public CountriesTable(int page, IReadOnlyList<CountryStatistics> rankings)
            : base(page, rankings)
        {
        }

        protected override TableColumn[] CreateAdditionalHeaders() => new[]
        {
            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)),
        };

        protected override Country GetCountry(CountryStatistics item) => item.Country;

        protected override Drawable CreateFlagContent(CountryStatistics item) => new CountryName(item.Country);

        protected override Drawable[] CreateAdditionalContent(CountryStatistics item) => new Drawable[]
        {
            new ColoredRowText
            {
                Text = $@"{item.ActiveUsers:N0}",
            },
            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
            {
                Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}",
            }
        };

        private class CountryName : OsuHoverContainer
        {
            protected override IEnumerable<Drawable> EffectTargets => new[] { text };

            [Resolved(canBeNull: true)]
            private RankingsOverlay rankings { get; set; }

            private readonly OsuSpriteText text;
            private readonly Country country;

            public CountryName(Country country)
            {
                this.country = country;

                AutoSizeAxes = Axes.Both;
                Add(text = new OsuSpriteText
                {
                    Font = OsuFont.GetFont(size: 12),
                    Text = country.FullName ?? string.Empty,
                });
            }

            [BackgroundDependencyLoader]
            private void load(OverlayColourProvider colourProvider)
            {
                IdleColour = colourProvider.Light2;
                HoverColour = colourProvider.Content2;

                Action = () => rankings?.ShowCountry(country);
            }
        }
    }
}<commit_msg>Make CountryName use LinkFlowContainer for consistency<commit_after>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. 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;
using osu.Game.Users;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using System.Collections.Generic;
using osu.Framework.Allocation;

namespace osu.Game.Overlays.Rankings.Tables
{
    public class CountriesTable : RankingsTable<CountryStatistics>
    {
        public CountriesTable(int page, IReadOnlyList<CountryStatistics> rankings)
            : base(page, rankings)
        {
        }

        protected override TableColumn[] CreateAdditionalHeaders() => new[]
        {
            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)),
        };

        protected override Country GetCountry(CountryStatistics item) => item.Country;

        protected override Drawable CreateFlagContent(CountryStatistics item) => new CountryName(item.Country);

        protected override Drawable[] CreateAdditionalContent(CountryStatistics item) => new Drawable[]
        {
            new ColoredRowText
            {
                Text = $@"{item.ActiveUsers:N0}",
            },
            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
            {
                Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}",
            }
        };

        private class CountryName : LinkFlowContainer
        {
            [Resolved(canBeNull: true)]
            private RankingsOverlay rankings { get; set; }

            private readonly Country country;

            public CountryName(Country country) : base(t => t.Font = OsuFont.GetFont(size: 12))
            {
                this.country = country;

                AutoSizeAxes = Axes.X;
                RelativeSizeAxes = Axes.Y;
                TextAnchor = Anchor.CentreLeft;

                AddLink(country.FullName ?? string.Empty, () => rankings?.ShowCountry(country));
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09964577237024488, 'fraction_numerical': 0.0033882642846142, 'mean_word_length': 2.021870637505817, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3743816', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1664, 'n_words': 374}