Add better tooltips to all files and folders.
This commit is contained in:
@@ -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,13 +355,19 @@ namespace FlaxEditor.Content
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the tooltip text text.
|
||||
/// Updates the tooltip text.
|
||||
/// </summary>
|
||||
public virtual void UpdateTooltipText()
|
||||
{
|
||||
Editor.Log(FlaxEditor.Utilities.Utils.GetAssetNamePath(Path));
|
||||
string fileExtension = System.IO.Path.GetExtension(Path);
|
||||
string fileDescription = Utilities.Utils.TranslateFileExtension(fileExtension);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
TooltipText = "Path: " + Path;
|
||||
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>
|
||||
|
||||
@@ -1045,12 +1045,42 @@ namespace FlaxEditor.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
///
|
||||
/// <returns>The processed name path.</returns>
|
||||
public static string GetAssetNamePathWithExt(string path)
|
||||
{
|
||||
var projectFolder = Globals.ProjectFolder;
|
||||
@@ -1064,7 +1094,6 @@ namespace FlaxEditor.Utilities
|
||||
/// </summary>
|
||||
/// <param name="path">The asset path.</param>
|
||||
/// <returns>The processed name path.</returns>
|
||||
///
|
||||
public static string GetAssetNamePath(string path)
|
||||
{
|
||||
path = GetAssetNamePathWithExt(path);
|
||||
|
||||
Reference in New Issue
Block a user