// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using FlaxEditor.Content.Thumbnails;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.Content
{
///
/// Base class for all asset proxy objects used to manage .
///
///
[HideInEditor]
public abstract class AssetProxy : ContentProxy
{
///
public override bool IsAsset => true;
///
/// Gets the full name of the asset type (stored data format).
///
public abstract string TypeName { get; }
///
/// Checks if this proxy supports the given asset type id at the given path.
///
/// The asset type identifier.
/// The asset path.
/// True if proxy supports assets of the given type id and path.
public virtual bool AcceptsAsset(string typeName, string path)
{
return typeName == TypeName && path.EndsWith(FileExtension, StringComparison.OrdinalIgnoreCase);
}
///
/// Constructs the item for the asset.
///
/// The asset path.
/// The asset type name identifier.
/// The asset identifier.
/// Created item.
public abstract AssetItem ConstructItem(string path, string typeName, ref Guid id);
///
/// Called when thumbnail request gets prepared for drawing.
///
/// The request.
public virtual void OnThumbnailDrawPrepare(ThumbnailRequest request)
{
}
///
/// Determines whether thumbnail can be drawn for the specified item.
///
/// The request.
/// true if this thumbnail can be drawn for the specified item; otherwise, false.
public virtual bool CanDrawThumbnail(ThumbnailRequest request)
{
return true;
}
///
/// Called when thumbnail drawing begins. Proxy should setup scene GUI for guiRoot.
///
/// The request to render thumbnail.
/// The GUI root container control.
/// GPU context.
public virtual void OnThumbnailDrawBegin(ThumbnailRequest request, ContainerControl guiRoot, GPUContext context)
{
guiRoot.AddChild(new Label
{
Text = Name,
AnchorPreset = AnchorPresets.StretchAll,
Offsets = Margin.Zero,
Wrapping = TextWrapping.WrapWords
});
}
///
/// Called when thumbnail drawing ends. Proxy should clear custom GUI from guiRoot from that should be not destroyed.
///
/// The request to render thumbnail.
/// The GUI root container control.
public virtual void OnThumbnailDrawEnd(ThumbnailRequest request, ContainerControl guiRoot)
{
}
///
/// Called when thumbnail requests cleans data after drawing.
///
/// The request.
public virtual void OnThumbnailDrawCleanup(ThumbnailRequest request)
{
}
}
}