From cf3e83ca6225340ee507b21ef87c08ff2293cdfb Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 25 Apr 2017 15:53:21 +0800 Subject: [PATCH 1/4] Save ShowUnicode in framework config. --- osu.Game/Configuration/OsuConfigManager.cs | 11 ----------- .../Options/Sections/General/LanguageOptions.cs | 7 ++++--- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index addb2c2995..7e77de09b0 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -163,16 +163,6 @@ namespace osu.Game.Configuration Set(OsuConfig.UpdateFailCount, 0).Disabled = true; //Set(OsuConfig.TreeSortMode, TreeGroupMode.Show_All).Disabled = true; //Set(OsuConfig.TreeSortMode2, TreeSortMode.Title).Disabled = true; - bool unicodeDefault = false; - switch (Get(OsuConfig.Language)) - { - case @"zh": - case @"ja": - case @"ko": - unicodeDefault = true; - break; - } - Set(OsuConfig.ShowUnicode, unicodeDefault); Set(OsuConfig.PermanentSongInfo, false).Disabled = true; Set(OsuConfig.Ticker, false).Disabled = true; Set(OsuConfig.CompatibilityContext, false).Disabled = true; @@ -339,7 +329,6 @@ namespace osu.Game.Configuration SaveUsername, TreeSortMode, TreeSortMode2, - ShowUnicode, PermanentSongInfo, Ticker, CompatibilityContext, diff --git a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs index 98b67342cb..1387f981d3 100644 --- a/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs +++ b/osu.Game/Overlays/Options/Sections/General/LanguageOptions.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; @@ -13,7 +14,7 @@ namespace osu.Game.Overlays.Options.Sections.General protected override string Header => "Language"; [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(OsuConfigManager osuConfig, FrameworkConfigManager frameworkConfig) { Children = new Drawable[] { @@ -21,12 +22,12 @@ namespace osu.Game.Overlays.Options.Sections.General new OsuCheckbox { LabelText = "Prefer metadata in original language", - Bindable = config.GetBindable(OsuConfig.ShowUnicode) + Bindable = frameworkConfig.GetBindable(FrameworkConfig.ShowUnicode) }, new OsuCheckbox { LabelText = "Use alternative font for chat display", - Bindable = config.GetBindable(OsuConfig.AlternativeChatFont) + Bindable = osuConfig.GetBindable(OsuConfig.AlternativeChatFont) }, }; } From 4cb18361c1193eff3fe53947ac47af45b04d9118 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 26 Apr 2017 19:41:37 +0800 Subject: [PATCH 2/4] Use localisation engine for unicode text. --- .../Beatmaps/Drawables/BeatmapSetHeader.cs | 26 +++++-------- osu.Game/Overlays/MusicController.cs | 17 ++++---- osu.Game/Screens/Ranking/ResultsPageScore.cs | 39 ++++++++----------- 3 files changed, 36 insertions(+), 46 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 534578337f..db8f0b3a50 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -1,19 +1,18 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . +// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using System.Collections.Generic; +using OpenTK; +using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Game.Configuration; +using osu.Framework.Localisation; using osu.Game.Graphics.Sprites; -using OpenTK; -using OpenTK.Graphics; namespace osu.Game.Beatmaps.Drawables { @@ -23,8 +22,6 @@ namespace osu.Game.Beatmaps.Drawables private readonly SpriteText title; private readonly SpriteText artist; - private Bindable preferUnicode; - private readonly WorkingBeatmap beatmap; private readonly FillFlowContainer difficultyIcons; @@ -82,15 +79,12 @@ namespace osu.Game.Beatmaps.Drawables } [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(LocalisationEngine localisation) { - preferUnicode = config.GetBindable(OsuConfig.ShowUnicode); - preferUnicode.ValueChanged += unicode => - { - title.Text = unicode ? beatmap.BeatmapSetInfo.Metadata.TitleUnicode : beatmap.BeatmapSetInfo.Metadata.Title; - artist.Text = unicode ? beatmap.BeatmapSetInfo.Metadata.ArtistUnicode : beatmap.BeatmapSetInfo.Metadata.Artist; - }; - preferUnicode.TriggerChange(); + title.Current = localisation.GetUnicodePreference( + beatmap.BeatmapSetInfo.Metadata.TitleUnicode, beatmap.BeatmapSetInfo.Metadata.Title); + artist.Current = localisation.GetUnicodePreference( + beatmap.BeatmapSetInfo.Metadata.ArtistUnicode, beatmap.BeatmapSetInfo.Metadata.Artist); } private class PanelBackground : BufferedContainer @@ -112,7 +106,7 @@ namespace osu.Game.Beatmaps.Drawables Depth = -1, Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.Both, - // This makes the gradient not be perfectly horizontal, but diagonal at a ~40° angle + // This makes the gradient not be perfectly horizontal, but diagonal at a ~40° angle Shear = new Vector2(0.8f, 0), Alpha = 0.5f, Children = new[] diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index f960d9e0ae..8fc7eaa69a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -24,6 +24,7 @@ using osu.Framework.Graphics.Primitives; using osu.Game.Graphics.Sprites; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Localisation; namespace osu.Game.Overlays { @@ -41,9 +42,9 @@ namespace osu.Game.Overlays private TrackManager trackManager; private Bindable beatmapSource; - private Bindable preferUnicode; private WorkingBeatmap current; private BeatmapDatabase beatmaps; + private LocalisationEngine localisation; private Container dragContainer; @@ -81,7 +82,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuGameBase game, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours) + private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, LocalisationEngine localisation) { Children = new Drawable[] { @@ -187,8 +188,7 @@ namespace osu.Game.Overlays this.beatmaps = beatmaps; trackManager = game.Audio.Track; - preferUnicode = config.GetBindable(OsuConfig.ShowUnicode); - preferUnicode.ValueChanged += unicode => updateDisplay(current, TransformDirection.None); + this.localisation = localisation; beatmapSource = game.Beatmap ?? new Bindable(); playList = beatmaps.GetAllWithChildren(); @@ -308,16 +308,19 @@ namespace osu.Game.Overlays { Task.Run(() => { - if (beatmap?.Beatmap == null) + if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists { + title.Current = null; title.Text = @"Nothing to play"; + + artist = null; artist.Text = @"Nothing to play"; } else { BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; - title.Text = preferUnicode ? metadata.TitleUnicode : metadata.Title; - artist.Text = preferUnicode ? metadata.ArtistUnicode : metadata.Artist; + title.Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); + artist.Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); } }); diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index 1c2a126211..0bd64c4c69 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -1,30 +1,29 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Game.Configuration; +using osu.Framework.Localisation; +using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Rulesets.Scoring; +using osu.Game.Screens.Play; using osu.Game.Screens.Select.Leaderboards; using osu.Game.Users; -using OpenTK; -using OpenTK.Graphics; -using System; -using System.Collections.Generic; -using osu.Framework.Extensions.Color4Extensions; -using osu.Game.Beatmaps; -using osu.Game.Screens.Play; -using osu.Game.Rulesets.Scoring; -using osu.Framework.Graphics.Colour; -using System.Linq; namespace osu.Game.Screens.Ranking { @@ -272,8 +271,6 @@ namespace osu.Game.Screens.Ranking { private readonly BeatmapInfo beatmap; - private Bindable preferUnicode; - private readonly OsuSpriteText title; private readonly OsuSpriteText artist; private readonly OsuSpriteText versionMapper; @@ -323,20 +320,16 @@ namespace osu.Game.Screens.Ranking } [BackgroundDependencyLoader] - private void load(OsuColour colours, OsuConfigManager config) + private void load(OsuColour colours, LocalisationEngine localisation) { title.Colour = artist.Colour = colours.BlueDarker; versionMapper.Colour = colours.Gray8; versionMapper.Text = $"{beatmap.Version} - mapped by {beatmap.Metadata.Author}"; - - preferUnicode = config.GetBindable(OsuConfig.ShowUnicode); - preferUnicode.ValueChanged += unicode => - { - title.Text = unicode ? beatmap.Metadata.TitleUnicode : beatmap.Metadata.Title; - artist.Text = unicode ? beatmap.Metadata.ArtistUnicode : beatmap.Metadata.Artist; - }; - preferUnicode.TriggerChange(); + title.Current = localisation.GetUnicodePreference( + beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title); + artist.Current = localisation.GetUnicodePreference( + beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist); } } From 061c3cacbdc5d26d18355fff4ac92af63d750f76 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 26 Apr 2017 20:04:32 +0800 Subject: [PATCH 3/4] CI fixes. --- osu.Game/Overlays/MusicController.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8fc7eaa69a..291462c335 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -10,21 +10,20 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Configuration; +using osu.Framework.Extensions; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input; +using osu.Framework.Localisation; using osu.Framework.MathUtils; using osu.Game.Beatmaps; -using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Game.Graphics.Sprites; -using osu.Framework.Extensions; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Localisation; namespace osu.Game.Overlays { @@ -313,7 +312,7 @@ namespace osu.Game.Overlays title.Current = null; title.Text = @"Nothing to play"; - artist = null; + artist.Current = null; artist.Text = @"Nothing to play"; } else From ad92e6d73293068b440194fa2fbf850ffaa9b8a0 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 27 Apr 2017 12:42:56 +0800 Subject: [PATCH 4/4] Remove OsuConfig.Language too. --- osu.Game/Configuration/OsuConfigManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 7e77de09b0..30cd31c113 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -92,7 +92,6 @@ namespace osu.Game.Configuration Set(OsuConfig.IgnoreBeatmapSamples, false).Disabled = true; Set(OsuConfig.IgnoreBeatmapSkins, false).Disabled = true; Set(OsuConfig.IgnoreList, string.Empty).Disabled = true; - Set(OsuConfig.Language, @"unknown").Disabled = true; Set(OsuConfig.AllowNowPlayingHighlights, false).Disabled = true; Set(OsuConfig.LastVersion, string.Empty).Disabled = true; Set(OsuConfig.LastVersionPermissionsFailed, string.Empty).Disabled = true;