Implement ShowUnicode option behavior

This commit is contained in:
Drew DeVault
2016-11-10 21:35:58 -05:00
parent 788c11de10
commit d49b418449
3 changed files with 63 additions and 9 deletions

View File

@ -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<BeatmapSetHeader> GainedSelection;
public Action<BeatmapSetHeader> GainedSelection;
private BeatmapSetInfo beatmapSet;
private SpriteText title, artist;
private OsuConfigManager config;
private Bindable<bool> 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<bool>(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[]
{
@ -51,16 +84,16 @@ namespace osu.Game.Beatmaps.Drawable
Padding = new MarginPadding { Top = 10, Left = 15, Right = 10, Bottom = 10 },
AutoSizeAxes = Axes.Both,
Children = new[]
new SpriteText
{
title = new SpriteText
{
Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode,
Font = @"Exo2.0-SemiBoldItalic",
Text = beatmapSet.Metadata.Title,
TextSize = 22
new SpriteText
},
artist = new SpriteText
{
Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode,
Font = @"Exo2.0-MediumItalic",
Text = beatmapSet.Metadata.Artist,
TextSize = 16
},