Merge pull request #1813 from ColdVolcano/wedge-unicode

Permit BeatmapInfoWedge to display Unicode artist and title
This commit is contained in:
Dean Herbert
2018-01-04 15:17:35 +09:00
committed by GitHub

View File

@ -20,6 +20,7 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -86,6 +87,8 @@ namespace osu.Game.Screens.Select
public OsuSpriteText ArtistLabel { get; private set; } public OsuSpriteText ArtistLabel { get; private set; }
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 UnicodeBindableString artistBinding;
public BufferedWedgeInfo(WorkingBeatmap working) public BufferedWedgeInfo(WorkingBeatmap working)
{ {
@ -93,7 +96,7 @@ namespace osu.Game.Screens.Select
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(LocalisationEngine localisation)
{ {
var beatmapInfo = working.BeatmapInfo; var beatmapInfo = working.BeatmapInfo;
var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
@ -102,6 +105,9 @@ namespace osu.Game.Screens.Select
CacheDrawnFrameBuffer = true; CacheDrawnFrameBuffer = true;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
titleBinding = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
artistBinding = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
Children = new Drawable[] Children = new Drawable[]
{ {
// We will create the white-to-black gradient by modulating transparency and having // We will create the white-to-black gradient by modulating transparency and having
@ -167,13 +173,11 @@ namespace osu.Game.Screens.Select
TitleLabel = new OsuSpriteText TitleLabel = new OsuSpriteText
{ {
Font = @"Exo2.0-MediumItalic", Font = @"Exo2.0-MediumItalic",
Text = string.IsNullOrEmpty(metadata.Source) ? metadata.Title : metadata.Source + " — " + metadata.Title,
TextSize = 28, TextSize = 28,
}, },
ArtistLabel = new OsuSpriteText ArtistLabel = new OsuSpriteText
{ {
Font = @"Exo2.0-MediumItalic", Font = @"Exo2.0-MediumItalic",
Text = metadata.Artist,
TextSize = 17, TextSize = 17,
}, },
MapperContainer = new FillFlowContainer MapperContainer = new FillFlowContainer
@ -193,6 +197,15 @@ namespace osu.Game.Screens.Select
} }
} }
}; };
artistBinding.ValueChanged += value => setMetadata(metadata.Source);
artistBinding.TriggerChange();
}
private void setMetadata(string source)
{
ArtistLabel.Text = artistBinding.Value;
TitleLabel.Text = string.IsNullOrEmpty(source) ? titleBinding.Value : source + " — " + titleBinding.Value;
ForceRedraw();
} }
private InfoLabel[] getInfoLabels() private InfoLabel[] getInfoLabels()