1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 07:27:25 +08:00

Localise scoreboard

This commit is contained in:
Lucas A 2021-08-16 13:38:57 +02:00
parent 7bebbf9f74
commit 1f942d15f8
5 changed files with 35 additions and 28 deletions

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Select.Leaderboards;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
@ -30,15 +31,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
switch (scope)
{
default:
text.Text = @"No scores have been set yet. Maybe you can be the first!";
text.Text = BeatmapsetsStrings.ShowScoreboardNoScoresGlobal;
break;
case BeatmapLeaderboardScope.Friend:
text.Text = @"None of your friends have set a score on this map yet.";
text.Text = BeatmapsetsStrings.ShowScoreboardNoScoresFriend;
break;
case BeatmapLeaderboardScope.Country:
text.Text = @"No one from your country has set a score on this map yet.";
text.Text = BeatmapsetsStrings.ShowScoreboardNoScoresCountry;
break;
}
}

View File

@ -20,6 +20,7 @@ using osuTK;
using osuTK.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.BeatmapSet.Scores
{
@ -93,13 +94,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
var columns = new List<TableColumn>
{
new TableColumn("rank", Anchor.CentreRight, new Dimension(GridSizeMode.AutoSize)),
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersRank, Anchor.CentreRight, new Dimension(GridSizeMode.AutoSize)),
new TableColumn("", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 70)), // grade
new TableColumn("score", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)),
new TableColumn("accuracy", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, minSize: 60, maxSize: 70)),
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersScore, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)),
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy, Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, minSize: 60, maxSize: 70)),
new TableColumn("", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 25)), // flag
new TableColumn("player", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 125)),
new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 120))
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersPlayer, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 125)),
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersCombo, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 120))
};
// All statistics across all scores, unordered.
@ -124,9 +125,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}
if (showPerformancePoints)
columns.Add(new TableColumn("pp", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 30)));
columns.Add(new TableColumn(BeatmapsetsStrings.ShowScoreboardHeaderspp, Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 30)));
columns.Add(new TableColumn("mods", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)));
columns.Add(new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersMods, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)));
return columns.ToArray();
}
@ -140,7 +141,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
new OsuSpriteText
{
Text = $"#{index + 1}",
Text = (index + 1).ToLocalisableString(@"\##"),
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
},
new UpdateableRank(score.Rank)
@ -168,7 +169,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
username,
new OsuSpriteText
{
Text = $@"{score.MaxCombo:N0}x",
Text = score.MaxCombo.ToLocalisableString(@"0\x"),
Font = OsuFont.GetFont(size: text_size),
Colour = score.MaxCombo == score.Beatmap?.MaxCombo ? highAccuracyColour : Color4.White
}
@ -183,7 +184,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
content.Add(new OsuSpriteText
{
Text = stat.MaxCount == null ? $"{stat.Count}" : $"{stat.Count}/{stat.MaxCount}",
Text = stat.MaxCount == null ? stat.Count.ToLocalisableString(@"N0") : (LocalisableString)$"{stat.Count}/{stat.MaxCount}",
Font = OsuFont.GetFont(size: text_size),
Colour = stat.Count == 0 ? Color4.Gray : Color4.White
});
@ -193,7 +194,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
content.Add(new OsuSpriteText
{
Text = $@"{score.PP:N0}",
Text = score.PP.ToLocalisableString(@"N0"),
Font = OsuFont.GetFont(size: text_size)
});
}

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -13,6 +14,7 @@ using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
@ -61,9 +63,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Spacing = new Vector2(margin, 0),
Children = new Drawable[]
{
totalScoreColumn = new TextColumn("total score", largeFont, top_columns_min_width),
accuracyColumn = new TextColumn("accuracy", largeFont, top_columns_min_width),
maxComboColumn = new TextColumn("max combo", largeFont, top_columns_min_width)
totalScoreColumn = new TextColumn(BeatmapsetsStrings.ShowScoreboardHeadersScoreTotal, largeFont, top_columns_min_width),
accuracyColumn = new TextColumn(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy, largeFont, top_columns_min_width),
maxComboColumn = new TextColumn(BeatmapsetsStrings.ShowScoreboardHeadersCombo, largeFont, top_columns_min_width)
}
},
new FillFlowContainer
@ -81,7 +83,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Direction = FillDirection.Horizontal,
Spacing = new Vector2(margin, 0),
},
ppColumn = new TextColumn("pp", smallFont, bottom_columns_min_width),
ppColumn = new TextColumn(BeatmapsetsStrings.ShowScoreboardHeaderspp, smallFont, bottom_columns_min_width),
modsColumn = new ModsInfoColumn(),
}
},
@ -111,10 +113,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
score = value;
accuracyColumn.Text = value.DisplayAccuracy;
maxComboColumn.Text = $@"{value.MaxCombo:N0}x";
maxComboColumn.Text = value.MaxCombo.ToLocalisableString(@"0\x");
ppColumn.Alpha = value.Beatmap?.Status.GrantsPerformancePoints() == true ? 1 : 0;
ppColumn.Text = $@"{value.PP:N0}";
ppColumn.Text = value.PP.ToLocalisableString(@"N0");
statisticsColumns.ChildrenEnumerable = value.GetStatisticsForDisplay().Select(createStatisticsColumn);
modsColumn.Mods = value.Mods;
@ -126,7 +128,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private TextColumn createStatisticsColumn(HitResultDisplayStatistic stat) => new TextColumn(stat.DisplayName, smallFont, bottom_columns_min_width)
{
Text = stat.MaxCount == null ? $"{stat.Count}" : $"{stat.Count}/{stat.MaxCount}"
Text = stat.MaxCount == null ? stat.Count.ToLocalisableString(@"N0") : (LocalisableString)$"{stat.Count}/{stat.MaxCount}"
};
private class InfoColumn : CompositeDrawable
@ -134,7 +136,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private readonly Box separator;
private readonly OsuSpriteText text;
public InfoColumn(string title, Drawable content, float? minWidth = null)
public InfoColumn(LocalisableString title, Drawable content, float? minWidth = null)
{
AutoSizeAxes = Axes.Both;
Margin = new MarginPadding { Vertical = 5 };
@ -194,12 +196,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{
private readonly SpriteText text;
public TextColumn(string title, FontUsage font, float? minWidth = null)
public TextColumn(LocalisableString title, FontUsage font, float? minWidth = null)
: this(title, new OsuSpriteText { Font = font }, minWidth)
{
}
private TextColumn(string title, SpriteText text, float? minWidth = null)
private TextColumn(LocalisableString title, SpriteText text, float? minWidth = null)
: base(title, text, minWidth)
{
this.text = text;

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
@ -126,7 +127,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
public int? ScorePosition
{
set => rankText.Text = value == null ? "-" : $"#{value}";
set => rankText.Text = value == null ? (LocalisableString)"-" : value.ToLocalisableString(@"\##");
}
/// <summary>

View File

@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System.ComponentModel;
using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Screens.Select.Leaderboards
{
@ -10,13 +12,13 @@ namespace osu.Game.Screens.Select.Leaderboards
[Description("Local Ranking")]
Local,
[Description("Country Ranking")]
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowScoreboardCountry))]
Country,
[Description("Global Ranking")]
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowScoreboardGlobal))]
Global,
[Description("Friend Ranking")]
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowScoreboardFriend))]
Friend,
}
}