// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.GUI.ContextMenu;
using FlaxEditor.Windows;
using FlaxEngine;
namespace FlaxEditor.Content
{
///
/// Base class for assets proxy objects used to manage .
///
[HideInEditor]
public abstract class ContentProxy
{
///
/// Gets the asset type name (used by GUI, should be localizable).
///
public abstract string Name { get; }
///
/// Gets the default name for the new items created by this proxy.
///
public virtual string NewItemName => Name;
///
/// Determines whether this proxy is for the specified item.
///
/// The item.
/// true if is proxy for asset item; otherwise, false.
public abstract bool IsProxyFor(ContentItem item);
///
/// Determines whether this proxy is for the specified asset.
///
/// true if is proxy for asset item; otherwise, false.
public virtual bool IsProxyFor() where T : Asset
{
return false;
}
///
/// Gets a value indicating whether this proxy if for assets.
///
public virtual bool IsAsset => false;
///
/// Gets the file extension used by the items managed by this proxy.
/// ALL LOWERCASE! WITHOUT A DOT! example: for 'myFile.TxT' proper extension is 'txt'
///
public abstract string FileExtension { get; }
///
/// Opens the specified item.
///
///
/// The item.
/// Opened window or null if cannot do it.
public abstract EditorWindow Open(Editor editor, ContentItem item);
///
/// Gets a value indicating whether content items used by this proxy can be exported.
///
public virtual bool CanExport => false;
///
/// Exports the specified item.
///
/// The item.
/// The output path.
public virtual void Export(ContentItem item, string outputPath)
{
throw new NotImplementedException();
}
///
/// Determines whether the specified filename is valid for this proxy.
///
/// The filename.
/// true if the filename is valid, otherwise false.
public virtual bool IsFileNameValid(string filename)
{
return true;
}
///
/// Determines whether this proxy can create items in the specified target location.
///
/// The target location.
/// true if this proxy can create items in the specified target location; otherwise, false.
public virtual bool CanCreate(ContentFolder targetLocation)
{
return false;
}
///
/// Determines whether this proxy can reimport specified item.
///
/// The item.
/// true if this proxy can reimport given item; otherwise, false.
public virtual bool CanReimport(ContentItem item)
{
return CanCreate(item.ParentFolder);
}
///
/// Creates new item at the specified output path.
///
/// The output path.
/// The custom argument provided for the item creation. Can be used as a source of data or null.
public virtual void Create(string outputPath, object arg)
{
throw new NotImplementedException();
}
///
/// Called when content window wants to show the context menu. Allows to add custom functions for the given asset type.
///
/// The menu.
/// The item.
public virtual void OnContentWindowContextMenu(ContextMenu menu, ContentItem item)
{
}
///
/// Gets the unique accent color for that asset type.
///
public abstract Color AccentColor { get; }
///
/// Releases resources and unregisters the proxy utilities. Called during editor closing. For custom proxies from game/plugin modules it should be called before scripting reload.
///
public virtual void Dispose()
{
}
}
}