diff --git a/Source/Editor/CustomEditors/CustomEditorPresenter.cs b/Source/Editor/CustomEditors/CustomEditorPresenter.cs
index 7f19de195..be7b4de5c 100644
--- a/Source/Editor/CustomEditors/CustomEditorPresenter.cs
+++ b/Source/Editor/CustomEditors/CustomEditorPresenter.cs
@@ -139,7 +139,7 @@ namespace FlaxEditor.CustomEditors
///
protected override void OnModified()
{
- Presenter.Modified?.Invoke();
+ Presenter.OnModified();
base.OnModified();
}
@@ -354,6 +354,14 @@ namespace FlaxEditor.CustomEditors
ExpandGroups(this, false);
}
+ ///
+ /// Invokes event.
+ ///
+ public void OnModified()
+ {
+ Modified?.Invoke();
+ }
+
///
/// Called when selection gets changed.
///
diff --git a/Source/Editor/CustomEditors/Dedicated/LocalizationSettingsEditor.cs b/Source/Editor/CustomEditors/Dedicated/LocalizationSettingsEditor.cs
new file mode 100644
index 000000000..374b1aacb
--- /dev/null
+++ b/Source/Editor/CustomEditors/Dedicated/LocalizationSettingsEditor.cs
@@ -0,0 +1,81 @@
+// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
+
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using FlaxEditor.Content.Settings;
+using FlaxEditor.CustomEditors.Editors;
+using FlaxEditor.Scripting;
+using FlaxEngine;
+using FlaxEngine.Utilities;
+
+namespace FlaxEditor.CustomEditors.Dedicated
+{
+ [CustomEditor(typeof(LocalizationSettings))]
+ sealed class LocalizationSettingsEditor : GenericEditor
+ {
+ ///
+ public override void Initialize(LayoutElementsContainer layout)
+ {
+ var settings = (LocalizationSettings)Values[0];
+ var tablesLength = settings.LocalizedStringTables?.Length ?? 0;
+ var tables = new List(tablesLength);
+ for (int i = 0; i < tablesLength; i++)
+ {
+ var table = settings.LocalizedStringTables[i];
+ if (table && !table.WaitForLoaded())
+ tables.Add(table);
+ }
+ var locales = tables.GroupBy(x => x.Locale);
+ var tableEntries = new Dictionary>();
+ var allKeys = new HashSet();
+ foreach (var e in locales)
+ {
+ foreach (var table in e)
+ {
+ var entries = table.Entries;
+ tableEntries[table] = entries;
+ allKeys.AddRange(entries.Keys);
+ }
+ }
+
+ {
+ var group = layout.Group("Preview");
+
+ // Current language and culture preview management
+ group.Object("Current Language", new CustomValueContainer(new ScriptType(typeof(CultureInfo)), Localization.CurrentLanguage, (instance, index) => Localization.CurrentLanguage, (instance, index, value) => Localization.CurrentLanguage = value as CultureInfo), null, "Current UI display language for the game preview.");
+ group.Object("Current Culture", new CustomValueContainer(new ScriptType(typeof(CultureInfo)), Localization.CurrentCulture, (instance, index) => Localization.CurrentCulture, (instance, index, value) => Localization.CurrentCulture = value as CultureInfo), null, "Current values formatting culture for the game preview.");
+ }
+
+ {
+ var group = layout.Group("Locales");
+
+ // Show all existing locales
+ foreach (var e in locales)
+ {
+ var culture = new CultureInfo(e.Key);
+ var prop = group.AddPropertyItem(CultureInfoEditor.GetName(culture), culture.NativeName);
+ int count = e.Sum(x => tableEntries[x].Values.Count(y => y != null && y.Length != 0 && !string.IsNullOrEmpty(y[0])));
+ prop.Label(string.Format("Progress: {0}% ({1}/{2})", (int)(((float)count / allKeys.Count * 100.0f)), count, allKeys.Count));
+ prop.Label("Tables:");
+ foreach (var table in e)
+ {
+ var namePath = table.Path;
+ if (namePath.StartsWith(Globals.ProjectFolder))
+ namePath = namePath.Substring(Globals.ProjectFolder.Length + 1);
+ var tableLabel = prop.ClickableLabel(namePath).CustomControl;
+ tableLabel.TextColorHighlighted = Color.Wheat;
+ tableLabel.DoubleClick += delegate { Editor.Instance.Windows.ContentWin.Select(table); };
+ }
+ group.Space(10);
+ }
+ }
+
+ {
+ // Raw asset data editing
+ var group = layout.Group("Data");
+ base.Initialize(group);
+ }
+ }
+ }
+}
diff --git a/Source/Editor/CustomEditors/Editors/CultureInfoEditor.cs b/Source/Editor/CustomEditors/Editors/CultureInfoEditor.cs
index eb559d66b..e442c04cd 100644
--- a/Source/Editor/CustomEditors/Editors/CultureInfoEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/CultureInfoEditor.cs
@@ -81,7 +81,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
}
- public static void UpdateFilter(TreeNode node, string filterText)
+ private static void UpdateFilter(TreeNode node, string filterText)
{
// Update children
bool isAnyChildVisible = false;
@@ -106,6 +106,12 @@ namespace FlaxEditor.CustomEditors.Editors
}
private void ShowPicker()
+ {
+ var menu = CreatePicker(Culture, value => { Culture = value; });
+ menu.Show(_label, new Vector2(0, _label.Height));
+ }
+
+ internal static ContextMenuBase CreatePicker(CultureInfo value, Action changed)
{
var menu = new ContextMenuBase
{
@@ -150,7 +156,6 @@ namespace FlaxEditor.CustomEditors.Editors
node.Parent = parent;
lcidToNode[culture.LCID] = node;
}
- var value = Culture;
if (value != null)
tree.Select((TreeNode)lcidToNode[value.LCID]);
tree.SelectedChanged += delegate(List before, List after)
@@ -158,7 +163,7 @@ namespace FlaxEditor.CustomEditors.Editors
if (after.Count == 1)
{
menu.Hide();
- Culture = (CultureInfo)after[0].Tag;
+ changed((CultureInfo)after[0].Tag);
}
};
searchBox.TextChanged += delegate
@@ -172,10 +177,10 @@ namespace FlaxEditor.CustomEditors.Editors
menu.PerformLayout();
};
root.ExpandAll(true);
- menu.Show(_label, new Vector2(0, _label.Height));
+ return menu;
}
- private static string GetName(CultureInfo value)
+ internal static string GetName(CultureInfo value)
{
return value != null ? string.Format("{0} - {1}", value.Name, value.EnglishName) : null;
}