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

41 lines
946 B
C#

namespace Editor.MapEditor;
partial class EntityTool : IEntityTool
{
Widget Container { get; set; }
EntitySelector EntitySelector { get; set; }
public void CreateUI( Widget container )
{
// Keep a reference to our container so we can hotload from C#
Container = container;
Container.Layout = Layout.Column();
Container.Layout.Margin = 0;
Container.Layout.Spacing = 0;
RefreshUI();
}
[Event( "tools.gamedata.refresh" )]
[EditorEvent.Hotload]
public void RefreshUI()
{
//
// Careful touching any of this, if you do this shit wrong it will all crash
//
if ( !Container.IsValid() ) return;
var oldSelected = GetCurrentEntityClassName();
if ( EntitySelector.IsValid() && EntitySelector.IsValid ) EntitySelector.Destroy();
Container.Layout.Clear( true );
EntitySelector = new EntitySelector( Container );
EntitySelector.SelectedEntity = oldSelected;
Container.Layout.Add( EntitySelector, 1 );
}
}