mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Implement ShowUnicode option behavior
This commit is contained in:
@ -10,12 +10,19 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Drawable
|
namespace osu.Game.Beatmaps.Drawable
|
||||||
{
|
{
|
||||||
class BeatmapSetHeader : Panel
|
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()
|
protected override void Selected()
|
||||||
{
|
{
|
||||||
@ -30,9 +37,35 @@ namespace osu.Game.Beatmaps.Drawable
|
|||||||
base.Deselected();
|
base.Deselected();
|
||||||
Width = 0.8f;
|
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)
|
public BeatmapSetHeader(BeatmapSetInfo beatmapSet, WorkingBeatmap working)
|
||||||
|
{
|
||||||
this.beatmapSet = beatmapSet;
|
this.beatmapSet = beatmapSet;
|
||||||
Children = new Framework.Graphics.Drawable[]
|
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 },
|
Padding = new MarginPadding { Top = 10, Left = 15, Right = 10, Bottom = 10 },
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
new SpriteText
|
{
|
||||||
title = new SpriteText
|
title = new SpriteText
|
||||||
{
|
{
|
||||||
Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode,
|
Font = @"Exo2.0-SemiBoldItalic",
|
||||||
Text = beatmapSet.Metadata.Title,
|
Text = beatmapSet.Metadata.Title,
|
||||||
TextSize = 22
|
TextSize = 22
|
||||||
new SpriteText
|
},
|
||||||
artist = new SpriteText
|
artist = new SpriteText
|
||||||
{
|
{
|
||||||
Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode,
|
Font = @"Exo2.0-MediumItalic",
|
||||||
Text = beatmapSet.Metadata.Artist,
|
Text = beatmapSet.Metadata.Artist,
|
||||||
TextSize = 16
|
TextSize = 16
|
||||||
},
|
},
|
||||||
|
@ -178,6 +178,9 @@ namespace osu.Game.Configuration
|
|||||||
Set(OsuConfig.CompatibilityContext, false);
|
Set(OsuConfig.CompatibilityContext, false);
|
||||||
Set(OsuConfig.CanForceOptimusCompatibility, true);
|
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)
|
public OsuConfigManager(BasicStorage storage) : base(storage)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ using osu.Framework.Graphics.Transformations;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
@ -38,6 +39,8 @@ namespace osu.Game.Overlays
|
|||||||
private TrackManager trackManager;
|
private TrackManager trackManager;
|
||||||
private BeatmapDatabase database;
|
private BeatmapDatabase database;
|
||||||
private Bindable<WorkingBeatmap> beatmapSource;
|
private Bindable<WorkingBeatmap> beatmapSource;
|
||||||
|
private Bindable<bool> preferUnicode;
|
||||||
|
private OsuConfigManager config;
|
||||||
private WorkingBeatmap current;
|
private WorkingBeatmap current;
|
||||||
|
|
||||||
public MusicController(BeatmapDatabase db = null)
|
public MusicController(BeatmapDatabase db = null)
|
||||||
@ -183,6 +186,9 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
if (database == null) database = osuGame.Beatmaps;
|
if (database == null) database = osuGame.Beatmaps;
|
||||||
trackManager = osuGame.Audio.Track;
|
trackManager = osuGame.Audio.Track;
|
||||||
|
config = osuGame.Config;
|
||||||
|
preferUnicode = osuGame.Config.GetBindable<bool>(OsuConfig.ShowUnicode);
|
||||||
|
preferUnicode.ValueChanged += preferUnicode_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
beatmapSource = osuGame?.Beatmap ?? new Bindable<WorkingBeatmap>();
|
beatmapSource = osuGame?.Beatmap ?? new Bindable<WorkingBeatmap>();
|
||||||
@ -191,7 +197,7 @@ namespace osu.Game.Overlays
|
|||||||
backgroundSprite = getScaledSprite(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4"));
|
backgroundSprite = getScaledSprite(fallbackTexture = game.Textures.Get(@"Backgrounds/bg4"));
|
||||||
AddInternal(backgroundSprite);
|
AddInternal(backgroundSprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
beatmapSource.ValueChanged += workingChanged;
|
beatmapSource.ValueChanged += workingChanged;
|
||||||
@ -210,6 +216,11 @@ namespace osu.Game.Overlays
|
|||||||
if (current.Track.HasCompleted && !current.Track.Looping) next();
|
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)
|
private void workingChanged(object sender = null, EventArgs e = null)
|
||||||
{
|
{
|
||||||
if (beatmapSource.Value == current) return;
|
if (beatmapSource.Value == current) return;
|
||||||
@ -281,9 +292,9 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private void updateDisplay(WorkingBeatmap beatmap, bool? isNext)
|
private void updateDisplay(WorkingBeatmap beatmap, bool? isNext)
|
||||||
{
|
{
|
||||||
BeatmapMetadata metadata = beatmap.Beatmap.Metadata;
|
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
|
||||||
title.Text = metadata.TitleUnicode ?? metadata.Title;
|
title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode);
|
||||||
artist.Text = metadata.ArtistUnicode ?? metadata.Artist;
|
artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode);
|
||||||
|
|
||||||
Sprite newBackground = getScaledSprite(beatmap.Background ?? fallbackTexture);
|
Sprite newBackground = getScaledSprite(beatmap.Background ?? fallbackTexture);
|
||||||
|
|
||||||
@ -324,6 +335,13 @@ namespace osu.Game.Overlays
|
|||||||
current?.Track?.Seek(current.Track.Length * position);
|
current?.Track?.Seek(current.Track.Length * position);
|
||||||
current?.Track?.Start();
|
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;
|
protected override bool OnClick(InputState state) => true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user