Files
sbox-public/game/editor/Hammer/Code/Tools/EntityTool/EntityTreeView.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

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();
}
}