diff --git a/Source/Editor/Content/Items/AssetItem.cs b/Source/Editor/Content/Items/AssetItem.cs
index 6697ed27c..120d0e416 100644
--- a/Source/Editor/Content/Items/AssetItem.cs
+++ b/Source/Editor/Content/Items/AssetItem.cs
@@ -80,9 +80,9 @@ namespace FlaxEditor.Content
/// The String Builder.
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();
}
///
diff --git a/Source/Editor/Content/Items/ContentFolder.cs b/Source/Editor/Content/Items/ContentFolder.cs
index cbbc15f24..974b813ee 100644
--- a/Source/Editor/Content/Items/ContentFolder.cs
+++ b/Source/Editor/Content/Items/ContentFolder.cs
@@ -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
///
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();
}
///
diff --git a/Source/Editor/Content/Items/ContentItem.cs b/Source/Editor/Content/Items/ContentItem.cs
index 284f3f1b3..b4a4caa9a 100644
--- a/Source/Editor/Content/Items/ContentItem.cs
+++ b/Source/Editor/Content/Items/ContentItem.cs
@@ -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
}
///
- /// Updates the tooltip text text.
+ /// Updates the tooltip text.
///
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();
}
///
diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs
index acfb7f5e8..d8e30d62b 100644
--- a/Source/Editor/Options/InterfaceOptions.cs
+++ b/Source/Editor/Options/InterfaceOptions.cs
@@ -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;
+ ///
+ /// Gets or sets the option to use type name translations.
+ ///
+ [DefaultValue(true)]
+ [EditorDisplay("Interface"), EditorOrder(290), Tooltip("Attempt to translate asset type names.")]
+ public bool TranslateTypeNames { get; set; } = true;
+
///
/// Gets or sets the timestamps prefix mode for output log messages.
///
diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs
index ade084431..6ef5a8ea0 100644
--- a/Source/Editor/Utilities/Utils.cs
+++ b/Source/Editor/Utilities/Utils.cs
@@ -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;
}
+ ///
+ /// Gets the asset type, translating if possible, and if enabled in InterfaceOptions.TranslateTypes.
+ ///
+ /// The type name.
+ /// The translated type name.
+ 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;
+ }
+ }
+
+ ///
+ /// Gets a description of a file from it's extension.
+ ///
+ /// The file's extension
+ /// The processed description.
+ 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;
+ }
+
+
+ ///
+ /// Gets the asset name relative to the project root folder (with asset file extension)
+ ///
+ /// The asset path.
+ /// The processed name path.
+ public static string GetAssetNamePathWithExt(string path)
+ {
+ var projectFolder = Globals.ProjectFolder;
+ if (path.StartsWith(projectFolder))
+ path = path.Substring(projectFolder.Length + 1);
+ return path;
+ }
+
///
/// Gets the asset name relative to the project root folder (without asset file extension)
///
@@ -1024,9 +1096,7 @@ namespace FlaxEditor.Utilities
/// The processed name path.
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);
}