1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Localise ranking tables.

This commit is contained in:
Lucas A 2021-07-30 15:24:10 +02:00
parent 9717281969
commit db1ed873e4
5 changed files with 34 additions and 27 deletions

View File

@ -9,6 +9,8 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Resources.Localisation.Web;
using osu.Framework.Localisation;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
{ {
@ -21,12 +23,12 @@ namespace osu.Game.Overlays.Rankings.Tables
protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[] protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[]
{ {
new RankingsTableColumn("Active Users", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatActiveUsers, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatPlayCount, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Ranked Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatRankedScore, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Avg. Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatAverageScore, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Performance", Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true), new RankingsTableColumn(RankingsStrings.StatPerformance, Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true),
new RankingsTableColumn("Avg. Perf.", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatAveragePerformance, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
}; };
protected override Country GetCountry(CountryStatistics item) => item.Country; protected override Country GetCountry(CountryStatistics item) => item.Country;
@ -37,27 +39,27 @@ namespace osu.Game.Overlays.Rankings.Tables
{ {
new ColoredRowText new ColoredRowText
{ {
Text = $@"{item.ActiveUsers:N0}", Text = item.ActiveUsers.ToLocalisableString("N0")
}, },
new ColoredRowText new ColoredRowText
{ {
Text = $@"{item.PlayCount:N0}", Text = item.PlayCount.ToLocalisableString("N0")
}, },
new ColoredRowText new ColoredRowText
{ {
Text = $@"{item.RankedScore:N0}", Text = item.RankedScore.ToLocalisableString("N0")
}, },
new ColoredRowText new ColoredRowText
{ {
Text = $@"{item.RankedScore / Math.Max(item.ActiveUsers, 1):N0}", Text = (item.RankedScore / Math.Max(item.ActiveUsers, 1)).ToLocalisableString("N0")
}, },
new RowText new RowText
{ {
Text = $@"{item.Performance:N0}", Text = item.Performance.ToLocalisableString("N0")
}, },
new ColoredRowText new ColoredRowText
{ {
Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}", Text = (item.Performance / Math.Max(item.ActiveUsers, 1)).ToLocalisableString("N0")
} }
}; };

View File

@ -4,6 +4,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
@ -17,12 +19,12 @@ namespace osu.Game.Overlays.Rankings.Tables
protected override RankingsTableColumn[] CreateUniqueHeaders() => new[] protected override RankingsTableColumn[] CreateUniqueHeaders() => new[]
{ {
new RankingsTableColumn("Performance", Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true), new RankingsTableColumn(RankingsStrings.StatPerformance, Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true),
}; };
protected override Drawable[] CreateUniqueContent(UserStatistics item) => new Drawable[] protected override Drawable[] CreateUniqueContent(UserStatistics item) => new Drawable[]
{ {
new RowText { Text = $@"{item.PP:N0}", } new RowText { Text = item.PP.ToLocalisableString("N0"), }
}; };
} }
} }

View File

@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Rankings.Tables
private OsuSpriteText createIndexDrawable(int index) => new RowText private OsuSpriteText createIndexDrawable(int index) => new RowText
{ {
Text = $"#{index + 1}", Text = (index + 1).ToLocalisableString("\\##"),
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.SemiBold) Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.SemiBold)
}; };

View File

@ -4,6 +4,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
@ -17,19 +19,19 @@ namespace osu.Game.Overlays.Rankings.Tables
protected override RankingsTableColumn[] CreateUniqueHeaders() => new[] protected override RankingsTableColumn[] CreateUniqueHeaders() => new[]
{ {
new RankingsTableColumn("Total Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatTotalScore, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Ranked Score", Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true) new RankingsTableColumn(RankingsStrings.StatRankedScore, Anchor.Centre, new Dimension(GridSizeMode.AutoSize), true)
}; };
protected override Drawable[] CreateUniqueContent(UserStatistics item) => new Drawable[] protected override Drawable[] CreateUniqueContent(UserStatistics item) => new Drawable[]
{ {
new ColoredRowText new ColoredRowText
{ {
Text = $@"{item.TotalScore:N0}", Text = item.TotalScore.ToLocalisableString("N0"),
}, },
new RowText new RowText
{ {
Text = $@"{item.RankedScore:N0}", Text = item.RankedScore.ToLocalisableString("N0")
} }
}; };
} }

View File

@ -10,6 +10,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Users; using osu.Game.Users;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
{ {
@ -20,12 +21,12 @@ namespace osu.Game.Overlays.Rankings.Tables
{ {
} }
protected virtual IEnumerable<string> GradeColumns => new List<string> { "SS", "S", "A" }; protected virtual IEnumerable<LocalisableString> GradeColumns => new List<LocalisableString> { RankingsStrings.Statss, RankingsStrings.Stats, RankingsStrings.Stata };
protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[] protected override RankingsTableColumn[] CreateAdditionalHeaders() => new[]
{ {
new RankingsTableColumn("Accuracy", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatAccuracy, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new RankingsTableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)), new RankingsTableColumn(RankingsStrings.StatPlayCount, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
}.Concat(CreateUniqueHeaders()) }.Concat(CreateUniqueHeaders())
.Concat(GradeColumns.Select(grade => new GradeTableColumn(grade, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)))) .Concat(GradeColumns.Select(grade => new GradeTableColumn(grade, Anchor.Centre, new Dimension(GridSizeMode.AutoSize))))
.ToArray(); .ToArray();
@ -47,12 +48,12 @@ namespace osu.Game.Overlays.Rankings.Tables
protected sealed override Drawable[] CreateAdditionalContent(UserStatistics item) => new[] protected sealed override Drawable[] CreateAdditionalContent(UserStatistics item) => new[]
{ {
new ColoredRowText { Text = item.DisplayAccuracy, }, new ColoredRowText { Text = item.DisplayAccuracy, },
new ColoredRowText { Text = $@"{item.PlayCount:N0}", }, new ColoredRowText { Text = item.PlayCount.ToLocalisableString("N0") },
}.Concat(CreateUniqueContent(item)).Concat(new[] }.Concat(CreateUniqueContent(item)).Concat(new[]
{ {
new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.XH] + item.GradesCount[ScoreRank.X]:N0}", }, new ColoredRowText { Text = (item.GradesCount[ScoreRank.XH] + item.GradesCount[ScoreRank.X]).ToLocalisableString("N0"), },
new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.SH] + item.GradesCount[ScoreRank.S]:N0}", }, new ColoredRowText { Text = (item.GradesCount[ScoreRank.SH] + item.GradesCount[ScoreRank.S]).ToLocalisableString("N0"), },
new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.A]:N0}", } new ColoredRowText { Text = item.GradesCount[ScoreRank.A].ToLocalisableString("N0"), }
}).ToArray(); }).ToArray();
protected abstract RankingsTableColumn[] CreateUniqueHeaders(); protected abstract RankingsTableColumn[] CreateUniqueHeaders();
@ -78,7 +79,7 @@ namespace osu.Game.Overlays.Rankings.Tables
{ {
// Grade columns have extra horizontal padding for readibility // Grade columns have extra horizontal padding for readibility
Horizontal = 20, Horizontal = 20,
Vertical = 5 Vertical = 150
}; };
} }
} }