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 = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
frameworkLocale.BindValueChanged(_ => onLanguageChange());
localisationParameters = localisation.CurrentParameters.GetBoundCopy(); localisationParameters = localisation.CurrentParameters.GetBoundCopy();
localisationParameters.BindValueChanged(p => localisationParameters.BindValueChanged(_ => onLanguageChange(), true);
{ }
var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, p.NewValue);
// Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded. private void onLanguageChange()
// 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). var language = LanguageExtensions.GetLanguageFor(frameworkLocale.Value, localisationParameters.Value);
updateSelectedDelegate?.Cancel();
updateSelectedDelegate = Scheduler.AddDelayed(() => updateSelectedStates(language), 50); // Changing language may cause a short period of blocking the UI thread while the new glyphs are loaded.
}, true); // 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) private void updateSelectedStates(Language language)