Merge remote-tracking branch 'origin/master' into 1.9

This commit is contained in:
Wojtek Figat
2024-05-31 22:12:03 +02:00
40 changed files with 552 additions and 222 deletions

View File

@@ -2,7 +2,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using FlaxEngine;
namespace FlaxEditor.Modules
@@ -119,6 +121,30 @@ namespace FlaxEditor.Modules
return _customData.TryGetValue(key, out value);
}
/// <summary>
/// Tries to get the custom data by the key.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the <paramref name="value" /> parameter. This parameter is passed uninitialized.</param>
/// <returns>The custom data.</returns>
public bool TryGetCustomData(string key, out bool value)
{
value = false;
return _customData.TryGetValue(key, out var valueStr) && bool.TryParse(valueStr, out value);
}
/// <summary>
/// Tries to get the custom data by the key.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the <paramref name="value" /> parameter. This parameter is passed uninitialized.</param>
/// <returns>The custom data.</returns>
public bool TryGetCustomData(string key, out float value)
{
value = 0.0f;
return _customData.TryGetValue(key, out var valueStr) && float.TryParse(valueStr, out value);
}
/// <summary>
/// Sets the custom data.
/// </summary>
@@ -130,6 +156,28 @@ namespace FlaxEditor.Modules
_isDirty = true;
}
/// <summary>
/// Sets the custom data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetCustomData(string key, bool value)
{
SetCustomData(key, value.ToString());
}
/// <summary>
/// Sets the custom data.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetCustomData(string key, float value)
{
SetCustomData(key, value.ToString(CultureInfo.InvariantCulture));
}
/// <summary>
/// Removes the custom data.
/// </summary>

View File

@@ -127,13 +127,12 @@ namespace FlaxEditor.Modules
public void RequestStartPlayGame()
{
if (!Editor.StateMachine.IsEditMode)
{
return;
}
var firstScene = Content.Settings.GameSettings.Load().FirstScene;
if (firstScene == Guid.Empty)
{
Editor.LogWarning("No First Scene assigned in Game Settings.");
if (Level.IsAnySceneLoaded)
Editor.Simulation.RequestStartPlayScenes();
return;
@@ -141,6 +140,9 @@ namespace FlaxEditor.Modules
if (!FlaxEngine.Content.GetAssetInfo(firstScene.ID, out var info))
{
Editor.LogWarning("Invalid First Scene in Game Settings.");
if (Level.IsAnySceneLoaded)
Editor.Simulation.RequestStartPlayScenes();
return;
}
// Load scenes after entering the play mode

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using FlaxEditor.Scripting;
@@ -65,7 +66,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
{
var key = "T:" + GetXmlKey(type.Type.FullName);
if (xml.TryGetValue(key, out var xmlDoc))
text += '\n' + xmlDoc;
text += '\n' + FilterWhitespaces(xmlDoc);
}
}
@@ -262,6 +263,27 @@ namespace FlaxEditor.Modules.SourceCodeEditing
return Regex.Replace(typeFullNameString, @"\[.*\]", string.Empty).Replace('+', '.');
}
private static string FilterWhitespaces(string str)
{
if (str.Contains(" ", StringComparison.Ordinal))
{
var sb = new StringBuilder();
var prev = str[0];
sb.Append(prev);
for (int i = 1; i < str.Length; i++)
{
var c = str[i];
if (prev != ' ' || c != ' ')
{
sb.Append(c);
}
prev = c;
}
str = sb.ToString();
}
return str;
}
private Dictionary<string, string> GetXmlDocs(Assembly assembly)
{
if (!_xmlCache.TryGetValue(assembly, out var result))

View File

@@ -511,11 +511,11 @@ namespace FlaxEditor.Modules
{
var bounds = node["Bounds"];
var isMaximizedText = bounds.GetAttribute("IsMaximized");
if (!string.IsNullOrEmpty(isMaximizedText))
isMaximized = bool.Parse(isMaximizedText);
if (!string.IsNullOrEmpty(isMaximizedText) && bool.TryParse(isMaximizedText, out var tmpBool))
isMaximized = tmpBool;
var isMinimizedText = bounds.GetAttribute("IsMinimized");
if (!string.IsNullOrEmpty(isMinimizedText))
isMinimized = bool.Parse(isMinimizedText);
if (!string.IsNullOrEmpty(isMinimizedText) && bool.TryParse(isMinimizedText, out tmpBool))
isMinimized = tmpBool;
float x = float.Parse(bounds.GetAttribute("X"), CultureInfo.InvariantCulture);
float y = float.Parse(bounds.GetAttribute("Y"), CultureInfo.InvariantCulture);
float width = float.Parse(bounds.GetAttribute("Width"), CultureInfo.InvariantCulture);