2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2021-04-20 16:06:01 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-15 11:50:34 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2022-04-06 05:07:58 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2021-06-16 17:10:03 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2021-04-20 16:06:01 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.General
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class LanguageSettings : SettingsSubsection
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-11-11 05:56:24 +08:00
|
|
|
|
private SettingsDropdown<Language> languageSelection = null!;
|
|
|
|
|
private Bindable<string> frameworkLocale = null!;
|
|
|
|
|
private IBindable<LocalisationParameters> localisationParameters = null!;
|
2021-04-20 16:06:01 +08:00
|
|
|
|
|
2021-08-11 15:25:08 +08:00
|
|
|
|
protected override LocalisableString Header => GeneralSettingsStrings.LanguageHeader;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-11-11 05:56:24 +08:00
|
|
|
|
private void load(FrameworkConfigManager frameworkConfig, OsuConfigManager config, LocalisationManager localisation)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-04-20 16:06:01 +08:00
|
|
|
|
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
|
2022-11-11 05:56:24 +08:00
|
|
|
|
localisationParameters = localisation.CurrentParameters.GetBoundCopy();
|
2021-04-20 16:06:01 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-04-20 16:06:01 +08:00
|
|
|
|
languageSelection = new SettingsEnumDropdown<Language>
|
|
|
|
|
{
|
2021-08-11 15:25:08 +08:00
|
|
|
|
LabelText = GeneralSettingsStrings.LanguageDropdown,
|
2021-04-20 16:06:01 +08:00
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
2021-08-13 17:15:18 +08:00
|
|
|
|
LabelText = GeneralSettingsStrings.PreferOriginalMetadataLanguage,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowUnicode)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2022-04-06 05:07:58 +08:00
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
2022-04-07 17:20:15 +08:00
|
|
|
|
LabelText = GeneralSettingsStrings.Prefer24HourTimeDisplay,
|
2022-04-06 05:07:58 +08:00
|
|
|
|
Current = config.GetBindable<bool>(OsuSetting.Prefer24HourTime)
|
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
2021-04-20 16:06:01 +08:00
|
|
|
|
|
2022-11-11 05:56:24 +08:00
|
|
|
|
localisationParameters.BindValueChanged(p
|
|
|
|
|
=> languageSelection.Current.Value = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue), true);
|
2021-04-20 16:06:01 +08:00
|
|
|
|
|
2021-06-16 17:10:03 +08:00
|
|
|
|
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|