mirror of
https://github.com/celisej567/gm_construct_port.git
synced 2026-09-19 20:11:46 +03:00
Add files via upload
This commit is contained in:
37
code/ui/left/SpawnList.cs
Normal file
37
code/ui/left/SpawnList.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Sandbox;
|
||||
using Sandbox.UI;
|
||||
using Sandbox.UI.Tests;
|
||||
|
||||
[Library]
|
||||
public partial class SpawnList : Panel
|
||||
{
|
||||
VirtualScrollPanel Canvas;
|
||||
|
||||
public SpawnList()
|
||||
{
|
||||
AddClass( "spawnpage" );
|
||||
AddChild( out Canvas, "canvas" );
|
||||
|
||||
Canvas.Layout.AutoColumns = true;
|
||||
Canvas.Layout.ItemSize = new Vector2( 100, 100 );
|
||||
Canvas.OnCreateCell = ( cell, data ) =>
|
||||
{
|
||||
var file = (string)data;
|
||||
var panel = cell.Add.Panel( "icon" );
|
||||
panel.AddEventListener( "onclick", () => ConsoleSystem.Run( "spawn", "models/" + file ) );
|
||||
panel.Style.Background = new PanelBackground
|
||||
{
|
||||
Texture = Texture.Load( $"/models/{file}_c.png", false )
|
||||
};
|
||||
};
|
||||
|
||||
foreach ( var file in FileSystem.Mounted.FindFile( "models", "*.vmdl_c.png", true ) )
|
||||
{
|
||||
if ( string.IsNullOrWhiteSpace( file ) ) continue;
|
||||
if ( file.Contains( "_lod0" ) ) continue;
|
||||
if ( file.Contains( "clothes" ) ) continue;
|
||||
|
||||
Canvas.AddItem( file.Remove( file.Length - 6 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user