1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-09 22:07:24 +08:00

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
2.2 KiB
C#
Raw Normal View History

// 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 18:19:50 +09:00
using osu.Framework.Allocation;
2021-04-20 17:06:01 +09:00
using osu.Framework.Bindables;
2017-04-25 15:53:21 +08:00
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Extensions;
2021-04-20 17:06:01 +09:00
using osu.Game.Localisation;
2018-04-13 18:19:50 +09:00
namespace osu.Game.Overlays.Settings.Sections.General
{
public partial class LanguageSettings : SettingsSubsection
{
private SettingsDropdown<Language> languageSelection = null!;
private Bindable<string> frameworkLocale = null!;
private IBindable<LocalisationParameters> localisationParameters = null!;
2021-04-20 17:06:01 +09:00
2021-08-11 15:25:08 +08:00
protected override LocalisableString Header => GeneralSettingsStrings.LanguageHeader;
2018-04-13 18:19:50 +09:00
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig, OsuConfigManager config, LocalisationManager localisation)
{
2021-04-20 17:06:01 +09:00
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
localisationParameters = localisation.CurrentParameters.GetBoundCopy();
2021-04-20 17:06:01 +09:00
2016-11-08 18:13:20 -05:00
Children = new Drawable[]
{
2021-04-20 17:06:01 +09:00
languageSelection = new SettingsEnumDropdown<Language>
{
2021-08-11 15:25:08 +08:00
LabelText = GeneralSettingsStrings.LanguageDropdown,
2021-04-20 17:06:01 +09:00
},
new SettingsCheckbox
2016-11-08 18:13:20 -05:00
{
LabelText = GeneralSettingsStrings.PreferOriginalMetadataLanguage,
Current = frameworkConfig.GetBindable<bool>(FrameworkSetting.ShowUnicode)
2016-11-08 18:13:20 -05:00
},
new SettingsCheckbox
{
2022-04-07 18:20:15 +09:00
LabelText = GeneralSettingsStrings.Prefer24HourTimeDisplay,
Current = config.GetBindable<bool>(OsuSetting.Prefer24HourTime)
},
2016-11-08 18:13:20 -05:00
};
2021-04-20 17:06:01 +09:00
localisationParameters.BindValueChanged(p
=> languageSelection.Current.Value = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue), true);
2021-04-20 17:06:01 +09:00
languageSelection.Current.BindValueChanged(val => frameworkLocale.Value = val.NewValue.ToCultureCode());
}
}
}