Просмотр исходного кода

Fix LocaleExtension SetRawSource usages + language perf improvement (#7121)

* Avoid Avalonia CompiledBindingPathBuilder.SetRawSource

* Improve UI language change performance
Julien Lebosquain 1 год назад
Родитель
Сommit
e85ee673b1

+ 5 - 2
src/Ryujinx/Common/Locale/LocaleExtension.cs

@@ -21,7 +21,7 @@ namespace Ryujinx.Ava.Common.Locale
 
             var builder = new CompiledBindingPathBuilder();
 
-            builder.SetRawSource(LocaleManager.Instance)
+            builder
                 .Property(new ClrPropertyInfo("Item",
                 obj => (LocaleManager.Instance[keyToUse]),
                 null,
@@ -32,7 +32,10 @@ namespace Ryujinx.Ava.Common.Locale
 
             var path = builder.Build();
 
-            var binding = new CompiledBindingExtension(path);
+            var binding = new CompiledBindingExtension(path)
+            {
+                Source = LocaleManager.Instance
+            };
 
             return binding.ProvideValue(serviceProvider);
         }

+ 3 - 1
src/Ryujinx/Common/Locale/LocaleManager.cs

@@ -139,9 +139,11 @@ namespace Ryujinx.Ava.Common.Locale
 
             foreach (var item in locale)
             {
-                this[item.Key] = item.Value;
+                _localeStrings[item.Key] = item.Value;
             }
 
+            OnPropertyChanged("Item");
+
             LocaleChanged?.Invoke();
         }