Fix language selector in first run dialog not updating after changing language in settings

This commit is contained in:
Bartłomiej Dach 2022-12-21 19:30:21 +01:00
parent 19f66c806e
commit 3ec31a5f51
No known key found for this signature in database

View File

@ -87,18 +87,21 @@ namespace osu.Game.Overlays.FirstRunSetup
});
frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
frameworkLocale.BindValueChanged(_ => onLanguageChange());
localisationParameters = localisation.CurrentParameters.GetBoundCopy();
localisationParameters.BindValueChanged(p =>
{
var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue);
localisationParameters.BindValueChanged(_ => onLanguageChange(), true);
}
// Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded.
// Scheduling ensures the button animation plays smoothly after any blocking operation completes.
// Note that a delay is required (the alternative would be a double-schedule; delay feels better).
updateSelectedDelegate?.Cancel();
updateSelectedDelegate = Scheduler.AddDelayed(() => updateSelectedStates(language), 50);
}, true);
private void onLanguageChange()
{
var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, localisationParameters.Value);
// Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded.
// Scheduling ensures the button animation plays smoothly after any blocking operation completes.
// Note that a delay is required (the alternative would be a double-schedule; delay feels better).
updateSelectedDelegate?.Cancel();
updateSelectedDelegate = Scheduler.AddDelayed(() => updateSelectedStates(language), 50);
}
private void updateSelectedStates(Language language)