changed to use attribute to add items to the content context menu, this also allows users to add their own items to the CM

This commit is contained in:
Chandler Cox
2022-11-02 17:57:40 -05:00
parent 050635b2cd
commit a1e4400994
35 changed files with 109 additions and 152 deletions

View File

@@ -11,14 +11,12 @@ namespace FlaxEditor.Content
/// A <see cref="AnimationGraphFunction"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Animation/Animation Graph Function")]
public class AnimationGraphFunctionProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Animation Graph Function";
/// <inheritdoc />
public override string CategoryName => "Animation";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)
{

View File

@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
/// A <see cref="AnimationGraph"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Animation/Animation Graph")]
public class AnimationGraphProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Animation Graph";
/// <inheritdoc />
public override string CategoryName => "Animation";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -14,13 +14,11 @@ namespace FlaxEditor.Content
/// A <see cref="Animation"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Animation/Animation")]
public class AnimationProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Animation";
/// <inheritdoc />
public override string CategoryName => "Animation";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -22,11 +22,6 @@ namespace FlaxEditor.Content
/// </summary>
public abstract string TypeName { get; }
/// <summary>
/// The category name used to sort in context menus
/// </summary>
public abstract string CategoryName { get; }
/// <summary>
/// Checks if this proxy supports the given asset type id at the given path.
/// </summary>

View File

@@ -62,9 +62,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Audio Clip";
/// <inheritdoc />
public override string CategoryName => "Audio";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -12,6 +12,7 @@ namespace FlaxEditor.Content
/// Context proxy object for C# script files.
/// </summary>
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
[ContentContextMenu("New/C# Script")]
public class CSharpScriptProxy : ScriptProxy
{
/// <summary>

View File

@@ -38,13 +38,11 @@ namespace FlaxEditor.Content
/// A <see cref="CollisionData"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Physics/Collision Data")]
class CollisionDataProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Collision Data";
/// <inheritdoc />
public override string CategoryName => "Physics";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -75,6 +75,7 @@ namespace FlaxEditor.Content
/// Context proxy object for C++ script files.
/// </summary>
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
[ContentContextMenu("New/C++/C++ Script")]
public class CppScriptProxy : CppProxy
{
/// <inheritdoc />
@@ -98,6 +99,7 @@ namespace FlaxEditor.Content
/// Context proxy object for C++ Json Asset files.
/// </summary>
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
[ContentContextMenu("New/C++/C++ Function Library")]
public class CppStaticClassProxy : CppProxy
{
/// <inheritdoc />
@@ -115,6 +117,7 @@ namespace FlaxEditor.Content
/// Context proxy object for C++ Json Asset files.
/// </summary>
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
[ContentContextMenu("New/C++/C++ Json Asset")]
public class CppAssetProxy : CppProxy
{
/// <inheritdoc />

View File

@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Cube Texture";
/// <inheritdoc />
public override string CategoryName => "Texture";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -17,9 +17,6 @@ namespace FlaxEditor.Content
{
/// <inheritdoc />
public override string Name => "Font";
/// <inheritdoc />
public override string CategoryName => "Font";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
/// A <see cref="GameplayGlobals"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Gameplay Globals")]
public class GameplayGlobalsProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Gameplay Globals";
/// <inheritdoc />
public override string CategoryName => "Globals";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "IES Profile";
/// <inheritdoc />
public override string CategoryName => "Lighting";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -22,6 +22,7 @@ namespace FlaxEditor.Content
/// Json assets proxy.
/// </summary>
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
[ContentContextMenu("New/Json Asset")]
public abstract class JsonAssetProxy : JsonAssetBaseProxy
{
/// <summary>
@@ -31,9 +32,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Json Asset";
/// <inheritdoc />
public override string CategoryName => "Json Asset";
/// <inheritdoc />
public override string FileExtension => Extension;
@@ -168,20 +166,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name { get; } = Utilities.Utils.GetPropertyNameUI(typeof(T).Name);
private string _categoryName;
/// <inheritdoc />
public override string CategoryName => _categoryName;
/// <summary>
/// Sets the category name
/// </summary>
/// <param name="name">This is the category name</param>
public void SetCategoryName(string name)
{
_categoryName = name;
}
/// <inheritdoc />
public override bool CanCreate(ContentFolder targetLocation)
{

View File

@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
/// A <see cref="MaterialFunction"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Material/Material Function")]
public class MaterialFunctionProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Material Function";
/// <inheritdoc />
public override string CategoryName => "Material";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -14,15 +14,13 @@ namespace FlaxEditor.Content
/// A <see cref="MaterialInstance"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Material/Material Instance")]
public class MaterialInstanceProxy : BinaryAssetProxy
{
private MaterialPreview _preview;
/// <inheritdoc />
public override string Name => "Material Instance";
/// <inheritdoc />
public override string CategoryName => "Material";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -15,15 +15,13 @@ namespace FlaxEditor.Content
/// A <see cref="Material"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Material/Material")]
public class MaterialProxy : BinaryAssetProxy
{
private MaterialPreview _preview;
/// <inheritdoc />
public override string Name => "Material";
/// <inheritdoc />
public override string CategoryName => "Material";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -21,9 +21,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Model";
/// <inheritdoc />
public override string CategoryName => "Model";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
/// A <see cref="ParticleEmitterFunction"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Particles/Particle Emitter Function")]
public class ParticleEmitterFunctionProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Particle Emitter Function";
/// <inheritdoc />
public override string CategoryName => "Particles";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
/// A <see cref="ParticleEmitter"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Particles/Particle Emitter")]
public class ParticleEmitterProxy : BinaryAssetProxy
{
private ParticleEmitterPreview _preview;
@@ -22,9 +23,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Particle Emitter";
/// <inheritdoc />
public override string CategoryName => "Particles";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -39,6 +39,7 @@ namespace FlaxEditor.Content
/// A <see cref="ParticleSystem"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Particles/Particle System")]
public class ParticleSystemProxy : BinaryAssetProxy
{
private ParticleSystemPreview _preview;
@@ -46,9 +47,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Particle System";
/// <inheritdoc />
public override string CategoryName => "Particles";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
/// Content proxy for <see cref="PrefabItem"/>.
/// </summary>
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
[ContentContextMenu("New/Prefab")]
public sealed class PrefabProxy : JsonAssetBaseProxy
{
private PrefabPreview _preview;
@@ -31,9 +32,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Prefab";
/// <inheritdoc />
public override string CategoryName => "Prefab";
/// <inheritdoc />
public override string FileExtension => Extension;

View File

@@ -15,9 +15,6 @@ namespace FlaxEditor.Content
{
/// <inheritdoc />
public override string Name => "Previews Cache";
/// <inheritdoc />
public override string CategoryName => "Previews Cache";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -40,9 +40,6 @@ namespace FlaxEditor.Content
{
/// <inheritdoc />
public override string Name => "Scene Animation";
/// <inheritdoc />
public override string CategoryName => "Animation";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -10,6 +10,7 @@ namespace FlaxEditor.Content
/// Content proxy for <see cref="SceneItem"/>.
/// </summary>
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
[ContentContextMenu("New/Scene")]
public sealed class SceneProxy : JsonAssetBaseProxy
{
/// <summary>
@@ -19,9 +20,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Scene";
/// <inheritdoc />
public override string CategoryName => "Scene";
/// <inheritdoc />
public override string FileExtension => Extension;

View File

@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
/// Content proxy for json settings assets (e.g <see cref="GameSettings"/> or <see cref="TimeSettings"/>).
/// </summary>
/// <seealso cref="FlaxEditor.Content.JsonAssetProxy" />
[ContentContextMenu("New/Settings")]
public class SettingsProxy : JsonAssetProxy
{
private readonly Type _type;
@@ -20,9 +21,6 @@ namespace FlaxEditor.Content
/// Gets the settings type.
/// </summary>
public Type Type => _type;
/// <inheritdoc />
public override string CategoryName => "Settings";
/// <summary>
/// Initializes a new instance of the <see cref="SettingsProxy"/> class.

View File

@@ -14,9 +14,6 @@ namespace FlaxEditor.Content
{
/// <inheritdoc />
public override string Name => "Shader";
/// <inheritdoc />
public override string CategoryName => "Shader";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
/// A <see cref="SkeletonMask"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Animation/Skeleton Mask")]
public class SkeletonMaskProxy : BinaryAssetProxy
{
/// <inheritdoc />
public override string Name => "Skeleton Mask";
/// <inheritdoc />
public override string CategoryName => "Animation";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)

View File

@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Skinned Model";
/// <inheritdoc />
public override string CategoryName => "Model";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Sprite Atlas";
/// <inheritdoc />
public override string CategoryName => "Sprites";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Texture";
/// <inheritdoc />
public override string CategoryName => "Texture";
/// <inheritdoc />
public override bool CanReimport(ContentItem item)

View File

@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
/// A <see cref="VisualScript"/> asset proxy object.
/// </summary>
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
[ContentContextMenu("New/Visual Script")]
public class VisualScriptProxy : BinaryAssetProxy, IScriptTypesContainer
{
internal VisualScriptProxy()
@@ -24,9 +25,6 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override string Name => "Visual Script";
/// <inheritdoc />
public override string CategoryName => "Scripting";
/// <inheritdoc />
public override EditorWindow Open(Editor editor, ContentItem item)