mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Merge pull request #158 from SirCmpwn/implement-options
Implement ShowUnicode option behavior
This commit is contained in:
commit
12bc259071
@ -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[]
|
||||
{
|
||||
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
|
||||
|
@ -178,6 +178,9 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.CompatibilityContext, false);
|
||||
Set(OsuConfig.CanForceOptimusCompatibility, true);
|
||||
}
|
||||
|
||||
public string GetUnicodeString(string nonunicode, string unicode)
|
||||
=> Get<bool>(OsuConfig.ShowUnicode) ? unicode ?? nonunicode : nonunicode ?? unicode;
|
||||
|
||||
public OsuConfigManager(BasicStorage storage) : base(storage)
|
||||
{
|
||||
|
@ -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<WorkingBeatmap> beatmapSource;
|
||||
private Bindable<bool> 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<bool>(OsuConfig.ShowUnicode);
|
||||
preferUnicode.ValueChanged += preferUnicode_changed;
|
||||
}
|
||||
|
||||
beatmapSource = osuGame?.Beatmap ?? new Bindable<WorkingBeatmap>();
|
||||
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user