diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs index 278428332..e176f2b70 100644 --- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs @@ -579,7 +579,13 @@ namespace FlaxEditor.CustomEditors.Dedicated for (int i = 0; i < uiControls.Count; i++) { var uiControl = (UIControl)uiControls[i]; + string previousName = uiControl.Control?.GetType()?.Name ?? typeof(UIControl).Name; uiControl.Control = (Control)controlType.CreateInstance(); + if (uiControl.Name.StartsWith(previousName)) + { + string newName = controlType.Name + uiControl.Name.Substring(previousName.Length); + uiControl.Name = StringUtils.IncrementNameNumber(newName, x => uiControl.Parent.GetChild(x) == null); + } } } } @@ -588,7 +594,13 @@ namespace FlaxEditor.CustomEditors.Dedicated for (int i = 0; i < uiControls.Count; i++) { var uiControl = (UIControl)uiControls[i]; + string previousName = uiControl.Control?.GetType()?.Name ?? typeof(UIControl).Name; uiControl.Control = (Control)controlType.CreateInstance(); + if (uiControl.Name.StartsWith(previousName)) + { + string newName = controlType.Name + uiControl.Name.Substring(previousName.Length); + uiControl.Name = StringUtils.IncrementNameNumber(newName, x => uiControl.Parent.GetChild(x) == null); + } } } diff --git a/Source/Editor/GUI/Docking/DockPanel.cs b/Source/Editor/GUI/Docking/DockPanel.cs index b514ae7a2..74f2d5ab0 100644 --- a/Source/Editor/GUI/Docking/DockPanel.cs +++ b/Source/Editor/GUI/Docking/DockPanel.cs @@ -289,6 +289,10 @@ namespace FlaxEditor.GUI.Docking } OnSelectedTabChanged(); } + else if (autoFocus && _selectedTab != null && !_selectedTab.ContainsFocus) + { + _selectedTab.Focus(); + } } /// diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index 5aeba8b28..47a102011 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -1165,7 +1165,7 @@ namespace FlaxEditor.Viewport UpdateView(dt, ref moveDelta, ref mouseDelta, out _); } } - if (_input.IsMouseLeftDown) + if (_input.IsMouseLeftDown && false) { // Calculate smooth mouse delta not dependant on viewport size Vector2 offset = _viewMousePos - _startPos; diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 3db4df799..5f6ab1613 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -222,7 +222,7 @@ namespace FlaxEditor.Windows } else if (((ContainerControl)_tree.GetChild(0)).ChildrenCount == 0) { - overlayText = "No scene"; + overlayText = "No scene\nOpen one from the content window"; } if (overlayText != null) { diff --git a/Source/Engine/Utilities/StringUtils.cs b/Source/Engine/Utilities/StringUtils.cs index cb04afbfc..ff6beb4ec 100644 --- a/Source/Engine/Utilities/StringUtils.cs +++ b/Source/Engine/Utilities/StringUtils.cs @@ -232,20 +232,30 @@ namespace FlaxEngine return result; } + private static IEnumerable GraphemeClusters(this string s) + { + var enumerator = System.Globalization.StringInfo.GetTextElementEnumerator(s); + while (enumerator.MoveNext()) + { + yield return (string)enumerator.Current; + } + } + /// /// Reverses the specified input string. /// + /// Correctly handles all UTF-16 strings /// The string to reverse. /// The reversed string. public static string Reverse(this string s) { - char[] charArray = s.ToCharArray(); - Array.Reverse(charArray); - return new string(charArray); + string[] graphemes = s.GraphemeClusters().ToArray(); + Array.Reverse(graphemes); + return string.Concat(graphemes); } - private static readonly Regex IncNameRegex1 = new Regex("^(\\d+)"); - private static readonly Regex IncNameRegex2 = new Regex("^\\)(\\d+)\\("); + private static readonly Regex IncNameRegex1 = new Regex("(\\d+)$"); + private static readonly Regex IncNameRegex2 = new Regex("\\((\\d+)\\)$"); /// /// Tries to parse number in the name brackets at the end of the value and then increment it to create a new name. @@ -264,14 +274,13 @@ namespace FlaxEngine int index; int MaxChecks = 10000; string result; - string reversed = name.Reverse(); // Find '' case - var match = IncNameRegex1.Match(reversed); + var match = IncNameRegex1.Match(name); if (match.Success && match.Groups.Count == 2) { // Get result - string num = match.Groups[0].Value.Reverse(); + string num = match.Groups[0].Value; // Parse value if (int.TryParse(num, out index)) @@ -294,12 +303,12 @@ namespace FlaxEngine } // Find ' ()' case - match = IncNameRegex2.Match(reversed); + match = IncNameRegex2.Match(name); if (match.Success && match.Groups.Count == 2) { // Get result string num = match.Groups[0].Value; - num = num.Substring(1, num.Length - 2).Reverse(); + num = num.Substring(1, num.Length - 2); // Parse value if (int.TryParse(num, out index))