mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-05-25 07:16:33 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
40 lines
761 B
C#
40 lines
761 B
C#
namespace Editor.MapEditor;
|
|
|
|
public class EntityTreeView : TreeView
|
|
{
|
|
public Action<string> OnItemSelected { get; set; }
|
|
|
|
public EntityTreeView( Widget parent ) : base( parent )
|
|
{
|
|
ItemDrag = ( a ) =>
|
|
{
|
|
if ( a is not EntityDataNode entityNode )
|
|
return false;
|
|
|
|
var drag = new Drag( this );
|
|
drag.Data.Text = $"entity:{entityNode.Value.Name}";
|
|
drag.Execute();
|
|
|
|
return true;
|
|
};
|
|
ItemSelected = OnItemClicked;
|
|
}
|
|
|
|
protected void OnItemClicked( object value )
|
|
{
|
|
if ( value is not EntityDataNode entityNode )
|
|
return;
|
|
|
|
OnItemSelected.Invoke( entityNode.Value.Name );
|
|
}
|
|
|
|
protected override void OnPaint()
|
|
{
|
|
Paint.ClearPen();
|
|
Paint.SetBrush( Theme.ControlBackground );
|
|
Paint.DrawRect( LocalRect );
|
|
|
|
base.OnPaint();
|
|
}
|
|
}
|