Apply changes in-line with framework localisation changes

This commit is contained in:
smoogipoo 2018-09-19 14:07:46 +09:00
parent 492b5edb02
commit 28f31540c4
11 changed files with 39 additions and 60 deletions

View File

@ -7,11 +7,11 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
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.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.States; using osu.Framework.Input.States;
using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Direct
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation) private void load(OsuColour colours)
{ {
Content.CornerRadius = 4; Content.CornerRadius = 4;
@ -74,13 +74,13 @@ namespace osu.Game.Overlays.Direct
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = localisation.GetUnicodePreference(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), Text = new LocalisedString((SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title)),
TextSize = 18, TextSize = 18,
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = localisation.GetUnicodePreference(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), Text = new LocalisedString((SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist)),
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
}, },

View File

@ -10,8 +10,8 @@ using osu.Framework.Graphics.Colour;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
namespace osu.Game.Overlays.Direct namespace osu.Game.Overlays.Direct
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Direct
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(LocalisationEngine localisation, OsuColour colours) private void load(OsuColour colours)
{ {
Content.CornerRadius = 5; Content.CornerRadius = 5;
@ -94,13 +94,13 @@ namespace osu.Game.Overlays.Direct
{ {
new OsuSpriteText new OsuSpriteText
{ {
Current = localisation.GetUnicodePreference(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), Text = new LocalisedString((SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title)),
TextSize = 18, TextSize = 18,
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
new OsuSpriteText new OsuSpriteText
{ {
Current = localisation.GetUnicodePreference(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), Text = new LocalisedString((SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist)),
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
}, },
} }

View File

@ -50,7 +50,7 @@ namespace osu.Game.Overlays.KeyBinding
private FillFlowContainer<KeyButton> buttons; private FillFlowContainer<KeyButton> buttons;
public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend(text.Text); public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend((string)text.Text);
public KeyBindingRow(object action, IEnumerable<Framework.Input.Bindings.KeyBinding> bindings) public KeyBindingRow(object action, IEnumerable<Framework.Input.Bindings.KeyBinding> bindings)
{ {

View File

@ -28,8 +28,8 @@ namespace osu.Game.Overlays.Music
private SpriteIcon handle; private SpriteIcon handle;
private TextFlowContainer text; private TextFlowContainer text;
private IEnumerable<SpriteText> titleSprites; private IEnumerable<SpriteText> titleSprites;
private UnicodeBindableString titleBind; private ILocalisedBindableString titleBind;
private UnicodeBindableString artistBind; private ILocalisedBindableString artistBind;
public readonly BeatmapSetInfo BeatmapSetInfo; public readonly BeatmapSetInfo BeatmapSetInfo;
@ -74,7 +74,7 @@ namespace osu.Game.Overlays.Music
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation) private void load(OsuColour colours, LocalisationManager localisation)
{ {
hoverColour = colours.Yellow; hoverColour = colours.Yellow;
artistColour = colours.Gray9; artistColour = colours.Gray9;
@ -97,11 +97,10 @@ namespace osu.Game.Overlays.Music
}, },
}; };
titleBind = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); titleBind = localisation.GetLocalisedString(new LocalisedString((metadata.TitleUnicode, metadata.Title)));
artistBind = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); artistBind = localisation.GetLocalisedString(new LocalisedString((metadata.ArtistUnicode, metadata.Artist)));
artistBind.ValueChanged += newText => recreateText(); artistBind.BindValueChanged(newText => recreateText(), true);
artistBind.TriggerChange();
} }
private void recreateText() private void recreateText()

View File

@ -47,7 +47,6 @@ namespace osu.Game.Overlays
private PlaylistOverlay playlist; private PlaylistOverlay playlist;
private BeatmapManager beatmaps; private BeatmapManager beatmaps;
private LocalisationEngine localisation;
private List<BeatmapSetInfo> beatmapSets; private List<BeatmapSetInfo> beatmapSets;
private BeatmapSetInfo currentSet; private BeatmapSetInfo currentSet;
@ -67,11 +66,10 @@ namespace osu.Game.Overlays
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours, LocalisationEngine localisation) private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour colours)
{ {
this.beatmap.BindTo(beatmap); this.beatmap.BindTo(beatmap);
this.beatmaps = beatmaps; this.beatmaps = beatmaps;
this.localisation = localisation;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -351,17 +349,14 @@ namespace osu.Game.Overlays
{ {
if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
{ {
title.Current = null;
title.Text = @"Nothing to play"; title.Text = @"Nothing to play";
artist.Current = null;
artist.Text = @"Nothing to play"; artist.Text = @"Nothing to play";
} }
else else
{ {
BeatmapMetadata metadata = beatmap.Metadata; BeatmapMetadata metadata = beatmap.Metadata;
title.Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); title.Text = new LocalisedString((metadata.TitleUnicode, metadata.Title));
artist.Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); artist.Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist));
} }
}); });

View File

@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Profile.Sections
public string TooltipText { get; } public string TooltipText { get; }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay) private void load(BeatmapSetOverlay beatmapSetOverlay)
{ {
Action = () => Action = () =>
{ {
@ -46,16 +46,14 @@ namespace osu.Game.Overlays.Profile.Sections
{ {
new OsuSpriteText new OsuSpriteText
{ {
Current = locale.GetUnicodePreference( Text = new LocalisedString(($"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ",
$"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")),
$"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] "
),
TextSize = 15, TextSize = 15,
Font = "Exo2.0-SemiBoldItalic", Font = "Exo2.0-SemiBoldItalic",
}, },
new OsuSpriteText new OsuSpriteText
{ {
Current = locale.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist), Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)),
TextSize = 12, TextSize = 12,
Padding = new MarginPadding { Top = 3 }, Padding = new MarginPadding { Top = 3 },
Font = "Exo2.0-RegularItalic", Font = "Exo2.0-RegularItalic",

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation; using osu.Framework.Localisation;
@ -14,8 +13,6 @@ namespace osu.Game.Screens.Multi.Components
{ {
private readonly OsuSpriteText beatmapTitle, beatmapDash, beatmapArtist; private readonly OsuSpriteText beatmapTitle, beatmapDash, beatmapArtist;
private LocalisationEngine localisation;
public float TextSize public float TextSize
{ {
set { beatmapTitle.TextSize = beatmapDash.TextSize = beatmapArtist.TextSize = value; } set { beatmapTitle.TextSize = beatmapDash.TextSize = beatmapArtist.TextSize = value; }
@ -48,12 +45,6 @@ namespace osu.Game.Screens.Multi.Components
}; };
} }
[BackgroundDependencyLoader]
private void load(LocalisationEngine localisation)
{
this.localisation = localisation;
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
@ -64,15 +55,14 @@ namespace osu.Game.Screens.Multi.Components
{ {
if (beatmap == null) if (beatmap == null)
{ {
beatmapTitle.Current = beatmapArtist.Current = null;
beatmapTitle.Text = "Changing map"; beatmapTitle.Text = "Changing map";
beatmapDash.Text = beatmapArtist.Text = string.Empty; beatmapDash.Text = beatmapArtist.Text = string.Empty;
} }
else else
{ {
beatmapTitle.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title); beatmapTitle.Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title));
beatmapDash.Text = @" - "; beatmapDash.Text = @" - ";
beatmapArtist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist); beatmapArtist.Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist));
} }
} }
} }

View File

@ -290,7 +290,7 @@ namespace osu.Game.Screens.Play
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(LocalisationEngine localisation) private void load()
{ {
var metadata = beatmap?.BeatmapInfo?.Metadata ?? new BeatmapMetadata(); var metadata = beatmap?.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
@ -307,7 +307,7 @@ namespace osu.Game.Screens.Play
{ {
new OsuSpriteText new OsuSpriteText
{ {
Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title), Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)),
TextSize = 36, TextSize = 36,
Font = @"Exo2.0-MediumItalic", Font = @"Exo2.0-MediumItalic",
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
@ -315,7 +315,7 @@ namespace osu.Game.Screens.Play
}, },
new OsuSpriteText new OsuSpriteText
{ {
Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist), Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist)),
TextSize = 26, TextSize = 26,
Font = @"Exo2.0-MediumItalic", Font = @"Exo2.0-MediumItalic",
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,

View File

@ -13,7 +13,6 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -24,6 +23,7 @@ using osu.Game.Screens.Select.Leaderboards;
using osu.Game.Users; using osu.Game.Users;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Localisation;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking
{ {
@ -328,7 +328,7 @@ namespace osu.Game.Screens.Ranking
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation) private void load(OsuColour colours)
{ {
title.Colour = artist.Colour = colours.BlueDarker; title.Colour = artist.Colour = colours.BlueDarker;
versionMapper.Colour = colours.Gray8; versionMapper.Colour = colours.Gray8;
@ -341,8 +341,8 @@ namespace osu.Game.Screens.Ranking
versionMapper.Text = $"{beatmap.Version} - " + versionMapper.Text; versionMapper.Text = $"{beatmap.Version} - " + versionMapper.Text;
} }
title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title); title.Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title));
artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist); artist.Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist));
} }
} }

View File

@ -131,8 +131,8 @@ namespace osu.Game.Screens.Select
public FillFlowContainer MapperContainer { get; private set; } public FillFlowContainer MapperContainer { get; private set; }
public FillFlowContainer InfoLabelContainer { get; private set; } public FillFlowContainer InfoLabelContainer { get; private set; }
private UnicodeBindableString titleBinding; private ILocalisedBindableString titleBinding;
private UnicodeBindableString artistBinding; private ILocalisedBindableString artistBinding;
private readonly WorkingBeatmap beatmap; private readonly WorkingBeatmap beatmap;
private readonly RulesetInfo ruleset; private readonly RulesetInfo ruleset;
@ -144,7 +144,7 @@ namespace osu.Game.Screens.Select
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(LocalisationEngine localisation) private void load(LocalisationManager localisation)
{ {
var beatmapInfo = beatmap.BeatmapInfo; var beatmapInfo = beatmap.BeatmapInfo;
var metadata = beatmapInfo.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); var metadata = beatmapInfo.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
@ -153,8 +153,8 @@ namespace osu.Game.Screens.Select
CacheDrawnFrameBuffer = true; CacheDrawnFrameBuffer = true;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
titleBinding = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); titleBinding = localisation.GetLocalisedString(new LocalisedString((metadata.TitleUnicode, metadata.Title)));
artistBinding = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); artistBinding = localisation.GetLocalisedString(new LocalisedString((metadata.ArtistUnicode, metadata.Artist)));
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -38,11 +38,8 @@ namespace osu.Game.Screens.Select.Carousel
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(LocalisationEngine localisation, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay, DialogOverlay overlay) private void load(BeatmapManager manager, BeatmapSetOverlay beatmapOverlay, DialogOverlay overlay)
{ {
if (localisation == null)
throw new ArgumentNullException(nameof(localisation));
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore); restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
dialogOverlay = overlay; dialogOverlay = overlay;
if (beatmapOverlay != null) if (beatmapOverlay != null)
@ -67,14 +64,14 @@ namespace osu.Game.Screens.Select.Carousel
new OsuSpriteText new OsuSpriteText
{ {
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
Current = localisation.GetUnicodePreference(beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title), Text = new LocalisedString((beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title)),
TextSize = 22, TextSize = 22,
Shadow = true, Shadow = true,
}, },
new OsuSpriteText new OsuSpriteText
{ {
Font = @"Exo2.0-SemiBoldItalic", Font = @"Exo2.0-SemiBoldItalic",
Current = localisation.GetUnicodePreference(beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist), Text = new LocalisedString((beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist)),
TextSize = 17, TextSize = 17,
Shadow = true, Shadow = true,
}, },