diff --git a/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs index f8a38931e2..59995d669c 100644 --- a/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs @@ -10,12 +10,19 @@ using osu.Game.Database; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; +using osu.Framework; +using osu.Framework.Configuration; +using osu.Game.Configuration; namespace osu.Game.Beatmaps.Drawable { class BeatmapSetHeader : Panel { - public Action GainedSelection; + public Action GainedSelection; + private BeatmapSetInfo beatmapSet; + private SpriteText title, artist; + private OsuConfigManager config; + private Bindable preferUnicode; protected override void Selected() { @@ -30,9 +37,35 @@ namespace osu.Game.Beatmaps.Drawable base.Deselected(); Width = 0.8f; } + + protected override void Load(BaseGame game) + { + base.Load(game); + var osuGame = game as OsuGameBase; + if (osuGame != null) + { + config = osuGame.Config; + preferUnicode = osuGame.Config.GetBindable(OsuConfig.ShowUnicode); + preferUnicode.ValueChanged += preferUnicode_changed; + preferUnicode_changed(preferUnicode, null); + } + } + private void preferUnicode_changed(object sender, EventArgs e) + { + title.Text = config.GetUnicodeString(beatmapSet.Metadata.Title, beatmapSet.Metadata.TitleUnicode); + artist.Text = config.GetUnicodeString(beatmapSet.Metadata.Artist, beatmapSet.Metadata.ArtistUnicode); + } + + protected override void Dispose(bool isDisposing) + { + if (preferUnicode != null) + preferUnicode.ValueChanged -= preferUnicode_changed; + base.Dispose(isDisposing); + } public BeatmapSetHeader(BeatmapSetInfo beatmapSet, WorkingBeatmap working) { + this.beatmapSet = beatmapSet; Children = new Framework.Graphics.Drawable[] { working.Background == null ? new Box{ RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 255) } : new Sprite @@ -51,16 +84,16 @@ namespace osu.Game.Beatmaps.Drawable AutoSizeAxes = Axes.Both, Children = new[] { - new SpriteText + title = new SpriteText { Font = @"Exo2.0-SemiBoldItalic", - Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode, + Text = beatmapSet.Metadata.Title, TextSize = 22 }, - new SpriteText + artist = new SpriteText { Font = @"Exo2.0-MediumItalic", - Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode, + Text = beatmapSet.Metadata.Artist, TextSize = 16 }, new FlowContainer diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 6c05603285..c828f2eb40 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -178,6 +178,9 @@ namespace osu.Game.Configuration Set(OsuConfig.CompatibilityContext, false); Set(OsuConfig.CanForceOptimusCompatibility, true); } + + public string GetUnicodeString(string nonunicode, string unicode) + => Get(OsuConfig.ShowUnicode) ? unicode ?? nonunicode : nonunicode ?? unicode; public OsuConfigManager(BasicStorage storage) : base(storage) { diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 310bae37e4..d7f2bfc546 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -17,6 +17,7 @@ using osu.Framework.Graphics.Transformations; using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics; @@ -38,6 +39,8 @@ namespace osu.Game.Overlays private TrackManager trackManager; private BeatmapDatabase database; private Bindable beatmapSource; + private Bindable preferUnicode; + private OsuConfigManager config; private WorkingBeatmap current; public MusicController(BeatmapDatabase db = null) @@ -183,6 +186,9 @@ namespace osu.Game.Overlays { if (database == null) database = osuGame.Beatmaps; trackManager = osuGame.Audio.Track; + config = osuGame.Config; + preferUnicode = osuGame.Config.GetBindable(OsuConfig.ShowUnicode); + preferUnicode.ValueChanged += preferUnicode_changed; } beatmapSource = osuGame?.Beatmap ?? new Bindable(); @@ -191,7 +197,7 @@ namespace osu.Game.Overlays backgroundSprite = getScaledSprite(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4")); AddInternal(backgroundSprite); } - + protected override void LoadComplete() { beatmapSource.ValueChanged += workingChanged; @@ -210,6 +216,11 @@ namespace osu.Game.Overlays if (current.Track.HasCompleted && !current.Track.Looping) next(); } + void preferUnicode_changed(object sender, EventArgs e) + { + updateDisplay(current, false); + } + private void workingChanged(object sender = null, EventArgs e = null) { if (beatmapSource.Value == current) return; @@ -281,9 +292,9 @@ namespace osu.Game.Overlays private void updateDisplay(WorkingBeatmap beatmap, bool? isNext) { - BeatmapMetadata metadata = beatmap.Beatmap.Metadata; - title.Text = metadata.TitleUnicode ?? metadata.Title; - artist.Text = metadata.ArtistUnicode ?? metadata.Artist; + BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); + artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); Sprite newBackground = getScaledSprite(beatmap.Background ?? fallbackTexture); @@ -324,6 +335,13 @@ namespace osu.Game.Overlays current?.Track?.Seek(current.Track.Length * position); current?.Track?.Start(); } + + protected override void Dispose(bool isDisposing) + { + if (preferUnicode != null) + preferUnicode.ValueChanged -= preferUnicode_changed; + base.Dispose(isDisposing); + } protected override bool OnClick(InputState state) => true;