Merge branch 'ui-fixes' of git://github.com/stefnotch/FlaxEngine into stefnotch-ui-fixes

This commit is contained in:
Wojtek Figat
2021-03-08 22:36:46 +01:00
5 changed files with 37 additions and 12 deletions

View File

@@ -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);
}
}
}

View File

@@ -289,6 +289,10 @@ namespace FlaxEditor.GUI.Docking
}
OnSelectedTabChanged();
}
else if (autoFocus && _selectedTab != null && !_selectedTab.ContainsFocus)
{
_selectedTab.Focus();
}
}
/// <summary>

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -232,20 +232,30 @@ namespace FlaxEngine
return result;
}
private static IEnumerable<string> GraphemeClusters(this string s)
{
var enumerator = System.Globalization.StringInfo.GetTextElementEnumerator(s);
while (enumerator.MoveNext())
{
yield return (string)enumerator.Current;
}
}
/// <summary>
/// Reverses the specified input string.
/// </summary>
/// <remarks>Correctly handles all UTF-16 strings</remarks>
/// <param name="s">The string to reverse.</param>
/// <returns>The reversed string.</returns>
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+)\\)$");
/// <summary>
/// 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 '<name><num>' 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 '<name> (<num>)' 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))