Merge branch 'Menotdan-master'
This commit is contained in:
@@ -80,9 +80,9 @@ namespace FlaxEditor.Content
|
||||
/// <param name="sb">The String Builder.</param>
|
||||
protected virtual void OnBuildTooltipText(StringBuilder sb)
|
||||
{
|
||||
sb.Append("Type: ").Append(TypeName).AppendLine();
|
||||
sb.Append("Type: ").Append(Utilities.Utils.TranslateTypeName(TypeName)).AppendLine();
|
||||
sb.Append("Size: ").Append(Utilities.Utils.FormatBytesCount((int)new FileInfo(Path).Length)).AppendLine();
|
||||
sb.Append("Path: ").Append(Path).AppendLine();
|
||||
sb.Append("Path: ").Append(Utilities.Utils.GetAssetNamePathWithExt(Path)).AppendLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using FlaxEditor.GUI.Drag;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
@@ -137,7 +138,13 @@ namespace FlaxEditor.Content
|
||||
/// <inheritdoc />
|
||||
public override void UpdateTooltipText()
|
||||
{
|
||||
TooltipText = Path;
|
||||
string fileDescription = "Folder";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.Append("Type: ").Append(fileDescription).AppendLine();
|
||||
sb.Append("Path: ").Append(Utilities.Utils.GetAssetNamePathWithExt(Path)).AppendLine();
|
||||
|
||||
TooltipText = sb.ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using FlaxEditor.Content.GUI;
|
||||
using FlaxEditor.GUI.Drag;
|
||||
using FlaxEngine;
|
||||
@@ -353,11 +355,19 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the tooltip text text.
|
||||
/// Updates the tooltip text.
|
||||
/// </summary>
|
||||
public virtual void UpdateTooltipText()
|
||||
{
|
||||
TooltipText = "Path: " + Path;
|
||||
string fileExtension = System.IO.Path.GetExtension(Path);
|
||||
string fileDescription = Utilities.Utils.TranslateFileExtension(fileExtension);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.Append("Type: ").Append(fileDescription).AppendLine();
|
||||
sb.Append("Size: ").Append(Utilities.Utils.FormatBytesCount((int)new FileInfo(Path).Length)).AppendLine();
|
||||
sb.Append("Path: ").Append(Utilities.Utils.GetAssetNamePathWithExt(Path)).AppendLine();
|
||||
|
||||
TooltipText = sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -134,6 +134,13 @@ namespace FlaxEditor.Options
|
||||
[EditorDisplay("Interface"), EditorOrder(280), Tooltip("Editor content window orientation.")]
|
||||
public FlaxEngine.GUI.Orientation ContentWindowOrientation { get; set; } = FlaxEngine.GUI.Orientation.Horizontal;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the option to use type name translations.
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
[EditorDisplay("Interface"), EditorOrder(290), Tooltip("Attempt to translate asset type names.")]
|
||||
public bool TranslateTypeNames { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timestamps prefix mode for output log messages.
|
||||
/// </summary>
|
||||
|
||||
@@ -20,6 +20,8 @@ using FlaxEditor.SceneGraph;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using FlaxEditor.Options;
|
||||
using System.Linq;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
@@ -1017,6 +1019,76 @@ namespace FlaxEditor.Utilities
|
||||
node.Visible = isThisVisible | isAnyChildVisible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the asset type, translating if possible, and if enabled in InterfaceOptions.TranslateTypes.
|
||||
/// </summary>
|
||||
/// <param name="typeName">The type name.</param>
|
||||
/// <returns>The translated type name.</returns>
|
||||
public static string TranslateTypeName(string typeName)
|
||||
{
|
||||
// TODO: Surely there is a better way to get this value.
|
||||
if (!Editor.Instance.Options.Options.Interface.TranslateTypeNames)
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
string[] typeNamespaces = typeName.Split('.');
|
||||
string lastNamespace = typeNamespaces.Last();
|
||||
|
||||
// TODO: Add better handling for unconventional type names.
|
||||
try
|
||||
{
|
||||
// Adds spaces between capital letters.
|
||||
return string.Concat(lastNamespace.Select(x => Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' ');
|
||||
} catch {
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a description of a file from it's extension.
|
||||
/// </summary>
|
||||
/// <param name="fileExtension">The file's extension</param>
|
||||
/// <returns>The processed description.</returns>
|
||||
public static string TranslateFileExtension(string fileExtension)
|
||||
{
|
||||
string fileDescription = "";
|
||||
switch (fileExtension)
|
||||
{
|
||||
case ".cs":
|
||||
fileDescription = "C# Source Code";
|
||||
break;
|
||||
case ".cpp":
|
||||
fileDescription = "C++ Source Code";
|
||||
break;
|
||||
case ".h":
|
||||
fileDescription = "C++ Header File";
|
||||
break;
|
||||
case ".json":
|
||||
fileDescription = "JSON File";
|
||||
break;
|
||||
default:
|
||||
fileDescription = fileExtension;
|
||||
break;
|
||||
}
|
||||
|
||||
return fileDescription;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the asset name relative to the project root folder (with asset file extension)
|
||||
/// </summary>
|
||||
/// <param name="path">The asset path.</param>
|
||||
/// <returns>The processed name path.</returns>
|
||||
public static string GetAssetNamePathWithExt(string path)
|
||||
{
|
||||
var projectFolder = Globals.ProjectFolder;
|
||||
if (path.StartsWith(projectFolder))
|
||||
path = path.Substring(projectFolder.Length + 1);
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the asset name relative to the project root folder (without asset file extension)
|
||||
/// </summary>
|
||||
@@ -1024,9 +1096,7 @@ namespace FlaxEditor.Utilities
|
||||
/// <returns>The processed name path.</returns>
|
||||
public static string GetAssetNamePath(string path)
|
||||
{
|
||||
var projectFolder = Globals.ProjectFolder;
|
||||
if (path.StartsWith(projectFolder))
|
||||
path = path.Substring(projectFolder.Length + 1);
|
||||
path = GetAssetNamePathWithExt(path);
|
||||
return StringUtils.GetPathWithoutExtension(path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user