Revert "Use shorter, relative path for displaying Asset Tooltips."

This reverts commit 4c906f4040.

undo changes from master branch which I don't want for this seperate change.
This commit is contained in:
Menotdan
2023-05-07 23:04:11 -04:00
parent 141555377b
commit 296ac0b940
5 changed files with 8 additions and 102 deletions

View File

@@ -80,9 +80,9 @@ namespace FlaxEditor.Content
/// <param name="sb">The String Builder.</param>
protected virtual void OnBuildTooltipText(StringBuilder sb)
{
sb.Append("Type: ").Append(Utilities.Utils.TranslateTypeName(TypeName)).AppendLine();
sb.Append("Type: ").Append(TypeName).AppendLine();
sb.Append("Size: ").Append(Utilities.Utils.FormatBytesCount((int)new FileInfo(Path).Length)).AppendLine();
sb.Append("Path: ").Append(Utilities.Utils.GetAssetNamePathWithExt(Path)).AppendLine();
sb.Append("Path: ").Append(Path).AppendLine();
}
/// <inheritdoc />

View File

@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using FlaxEditor.GUI.Drag;
using FlaxEngine;
using FlaxEngine.GUI;
@@ -138,13 +137,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void UpdateTooltipText()
{
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();
TooltipText = Path;
}
/// <inheritdoc />

View File

@@ -2,8 +2,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using FlaxEditor.Content.GUI;
using FlaxEditor.GUI.Drag;
using FlaxEngine;
@@ -355,19 +353,11 @@ namespace FlaxEditor.Content
}
/// <summary>
/// Updates the tooltip text.
/// Updates the tooltip text text.
/// </summary>
public virtual void UpdateTooltipText()
{
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();
TooltipText = "Path: " + Path;
}
/// <summary>

View File

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

View File

@@ -20,8 +20,6 @@ using FlaxEditor.SceneGraph;
using FlaxEditor.Scripting;
using FlaxEngine;
using FlaxEngine.GUI;
using FlaxEditor.Options;
using System.Linq;
namespace FlaxEngine
{
@@ -1019,76 +1017,6 @@ 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>
@@ -1096,7 +1024,9 @@ namespace FlaxEditor.Utilities
/// <returns>The processed name path.</returns>
public static string GetAssetNamePath(string path)
{
path = GetAssetNamePathWithExt(path);
var projectFolder = Globals.ProjectFolder;
if (path.StartsWith(projectFolder))
path = path.Substring(projectFolder.Length + 1);
return StringUtils.GetPathWithoutExtension(path);
}