Files
sbox-public/game/editor/MovieMaker/Code/BlockDisplay/StringBlockItem.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

38 lines
904 B
C#

using Sandbox.MovieMaker;
namespace Editor.MovieMaker.BlockDisplays;
#nullable enable
public sealed class StringBlockItem : PropertyBlockItem<string?>
{
protected override void OnPaint()
{
base.OnPaint();
if ( Block is IPaintHintBlock hintBlock )
{
foreach ( var hintRange in hintBlock.GetPaintHints( Block.TimeRange ) )
{
PaintRange( hintRange );
}
}
else
{
PaintRange( Block.TimeRange );
}
}
private void PaintRange( MovieTimeRange range )
{
if ( Block.GetValue( range.Start ) is not { } value ) return;
var origin = Parent.Session.TimeToPixels( Block.TimeRange.Start );
var left = Parent.Session.TimeToPixels( range.Start ) - origin;
var right = Parent.Session.TimeToPixels( range.End ) - origin;
Paint.SetPen( Color.White.WithAlpha( 0.5f ), 12f );
Paint.DrawText( new Rect( left, LocalRect.Top, right - left, LocalRect.Height ), value );
}
}