Files
sbox-public/game/editor/MovieMaker/Code/BlockDisplay/ThumbnailBlockItem.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

28 lines
614 B
C#

namespace Editor.MovieMaker.BlockDisplays;
#nullable enable
public abstract class ThumbnailBlockItem<T> : PropertyBlockItem<T>
{
protected abstract Pixmap? GetThumbnail();
protected override void OnPaint()
{
base.OnPaint();
if ( GetThumbnail() is { } thumb )
{
Paint.Draw( LocalRect.Contain( Height ), thumb, 0.5f );
}
}
}
public sealed class ResourceBlockItem<T> : ThumbnailBlockItem<T>
where T : Resource
{
protected override Pixmap? GetThumbnail() => Block.GetValue( Block.TimeRange.Start ) is { ResourcePath: { } path }
? AssetSystem.FindByPath( path )?.GetAssetThumb()
: null;
}