diff --git a/Source/Editor/Content/Items/AssetItem.cs b/Source/Editor/Content/Items/AssetItem.cs
index 120d0e416..1ce2f6bc4 100644
--- a/Source/Editor/Content/Items/AssetItem.cs
+++ b/Source/Editor/Content/Items/AssetItem.cs
@@ -1,8 +1,6 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
-using System.IO;
-using System.Text;
using FlaxEngine;
using FlaxEngine.GUI;
@@ -38,14 +36,6 @@ namespace FlaxEditor.Content
ID = id;
}
- ///
- public override void UpdateTooltipText()
- {
- var sb = new StringBuilder();
- OnBuildTooltipText(sb);
- TooltipText = sb.ToString();
- }
-
private sealed class TooltipDoubleClickHook : Control
{
public AssetItem Item;
@@ -74,20 +64,25 @@ namespace FlaxEditor.Content
hook.Item = this;
}
- ///
- /// Called when building tooltip text.
- ///
- /// The String Builder.
- protected virtual void OnBuildTooltipText(StringBuilder sb)
- {
- 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(Utilities.Utils.GetAssetNamePathWithExt(Path)).AppendLine();
- }
-
///
public override ContentItemType ItemType => ContentItemType.Asset;
+ ///
+ public override string TypeDescription
+ {
+ get
+ {
+ // Translate asset type name
+ var typeName = TypeName;
+ string[] typeNamespaces = typeName.Split('.');
+ if (typeNamespaces.Length != 0 && typeNamespaces.Length != 0)
+ {
+ typeName = Utilities.Utils.GetPropertyNameUI(typeNamespaces[typeNamespaces.Length - 1]);
+ }
+ return typeName;
+ }
+ }
+
///
/// Determines whether asset is of the specified type (included inheritance checks).
///
diff --git a/Source/Editor/Content/Items/CSharpScriptItem.cs b/Source/Editor/Content/Items/CSharpScriptItem.cs
index 9a214a0e8..fd6381eea 100644
--- a/Source/Editor/Content/Items/CSharpScriptItem.cs
+++ b/Source/Editor/Content/Items/CSharpScriptItem.cs
@@ -19,6 +19,9 @@ namespace FlaxEditor.Content
{
}
+ ///
+ public override string TypeDescription => "C# Source Code";
+
///
public override SpriteHandle DefaultThumbnail => Editor.Instance.Icons.CSharpScript128;
}
diff --git a/Source/Editor/Content/Items/ContentFolder.cs b/Source/Editor/Content/Items/ContentFolder.cs
index 974b813ee..86c374fee 100644
--- a/Source/Editor/Content/Items/ContentFolder.cs
+++ b/Source/Editor/Content/Items/ContentFolder.cs
@@ -121,6 +121,9 @@ namespace FlaxEditor.Content
///
public override bool Exists => Directory.Exists(Path);
+ ///
+ public override string TypeDescription => "Folder";
+
///
public override SpriteHandle DefaultThumbnail => Editor.Instance.Icons.Folder128;
@@ -136,15 +139,10 @@ namespace FlaxEditor.Content
}
///
- public override void UpdateTooltipText()
+ protected override void OnBuildTooltipText(StringBuilder sb)
{
- string fileDescription = "Folder";
- StringBuilder sb = new StringBuilder();
-
- sb.Append("Type: ").Append(fileDescription).AppendLine();
+ sb.Append("Type: ").Append(TypeDescription).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 b4a4caa9a..4fe75d2c2 100644
--- a/Source/Editor/Content/Items/ContentItem.cs
+++ b/Source/Editor/Content/Items/ContentItem.cs
@@ -275,6 +275,11 @@ namespace FlaxEditor.Content
///
public string NamePath => FlaxEditor.Utilities.Utils.GetAssetNamePath(Path);
+ ///
+ /// Gets the content item type description (for UI).
+ ///
+ public abstract string TypeDescription { get; }
+
///
/// Gets the default name of the content item thumbnail. Returns null if not used.
///
@@ -359,15 +364,28 @@ namespace FlaxEditor.Content
///
public virtual void UpdateTooltipText()
{
- string fileExtension = System.IO.Path.GetExtension(Path);
- string fileDescription = Utilities.Utils.TranslateFileExtension(fileExtension);
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
+ OnBuildTooltipText(sb);
+ if (sb.Length != 0 && sb[sb.Length - 1] == '\n')
+ {
+ // Remove new-line from end
+ int sub = 1;
+ if (sb.Length != 1 && sb[sb.Length - 2] == '\r')
+ sub = 2;
+ sb.Length -= sub;
+ }
+ TooltipText = sb.ToString();
+ }
- sb.Append("Type: ").Append(fileDescription).AppendLine();
+ ///
+ /// Called when building tooltip text.
+ ///
+ /// The output string builder.
+ protected virtual void OnBuildTooltipText(StringBuilder sb)
+ {
+ sb.Append("Type: ").Append(TypeDescription).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/Content/Items/CppScriptItem.cs b/Source/Editor/Content/Items/CppScriptItem.cs
index c4fbb99e8..aea12ecd3 100644
--- a/Source/Editor/Content/Items/CppScriptItem.cs
+++ b/Source/Editor/Content/Items/CppScriptItem.cs
@@ -19,6 +19,9 @@ namespace FlaxEditor.Content
{
}
+ ///
+ public override string TypeDescription => Path.EndsWith(".h") ? "C++ Header File" : "C++ Source Code";
+
///
public override SpriteHandle DefaultThumbnail => Editor.Instance.Icons.CPPScript128;
}
diff --git a/Source/Editor/Content/Items/FileItem.cs b/Source/Editor/Content/Items/FileItem.cs
index 5e355087a..1136ee87e 100644
--- a/Source/Editor/Content/Items/FileItem.cs
+++ b/Source/Editor/Content/Items/FileItem.cs
@@ -25,6 +25,9 @@ namespace FlaxEditor.Content
///
public override ContentItemSearchFilter SearchFilter => ContentItemSearchFilter.Other;
+ ///
+ public override string TypeDescription => "File";
+
///
public override SpriteHandle DefaultThumbnail => Editor.Instance.Icons.Document128;
}
diff --git a/Source/Editor/Content/Items/NewItem.cs b/Source/Editor/Content/Items/NewItem.cs
index da8b0ca9a..94d95f15b 100644
--- a/Source/Editor/Content/Items/NewItem.cs
+++ b/Source/Editor/Content/Items/NewItem.cs
@@ -39,6 +39,9 @@ namespace FlaxEditor.Content
///
public override ContentItemSearchFilter SearchFilter => ContentItemSearchFilter.Other;
+ ///
+ public override string TypeDescription => "New";
+
///
public override SpriteHandle DefaultThumbnail => Editor.Instance.Icons.Document128;
diff --git a/Source/Editor/Content/Items/SceneItem.cs b/Source/Editor/Content/Items/SceneItem.cs
index cf2ada96b..6a56004f0 100644
--- a/Source/Editor/Content/Items/SceneItem.cs
+++ b/Source/Editor/Content/Items/SceneItem.cs
@@ -27,6 +27,9 @@ namespace FlaxEditor.Content
///
public override ContentItemSearchFilter SearchFilter => ContentItemSearchFilter.Scene;
+ ///
+ public override string TypeDescription => "Scene";
+
///
public override SpriteHandle DefaultThumbnail => Editor.Instance.Icons.Scene128;
diff --git a/Source/Editor/Content/Items/ShaderSourceItem.cs b/Source/Editor/Content/Items/ShaderSourceItem.cs
index b5572787c..1e8f8360f 100644
--- a/Source/Editor/Content/Items/ShaderSourceItem.cs
+++ b/Source/Editor/Content/Items/ShaderSourceItem.cs
@@ -26,6 +26,9 @@ namespace FlaxEditor.Content
///
public override ContentItemSearchFilter SearchFilter => ContentItemSearchFilter.Shader;
+ ///
+ public override string TypeDescription => "Shader Source Code";
+
///
public override SpriteHandle DefaultThumbnail => Editor.Instance.Icons.Document128;
}
diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs
index d8e30d62b..acfb7f5e8 100644
--- a/Source/Editor/Options/InterfaceOptions.cs
+++ b/Source/Editor/Options/InterfaceOptions.cs
@@ -134,13 +134,6 @@ 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 6ef5a8ea0..5f836e069 100644
--- a/Source/Editor/Utilities/Utils.cs
+++ b/Source/Editor/Utilities/Utils.cs
@@ -20,8 +20,6 @@ using FlaxEditor.SceneGraph;
using FlaxEditor.Scripting;
using FlaxEngine;
using FlaxEngine.GUI;
-using FlaxEditor.Options;
-using System.Linq;
namespace FlaxEngine
{
@@ -993,7 +991,7 @@ namespace FlaxEditor.Utilities
}
///
- /// Updates (recursivly) search popup tree structures based on the filter text.
+ /// Updates (recursively) search popup tree structures based on the filter text.
///
public static void UpdateSearchPopupFilter(TreeNode node, string filterText)
{
@@ -1019,63 +1017,6 @@ 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)
///