mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-05-24 14:56:44 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
41 lines
946 B
C#
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 );
|
|
}
|
|
}
|