Add files via upload

This commit is contained in:
celisej567
2021-08-05 17:54:51 +03:00
committed by GitHub
parent d58ad89d11
commit 76b55e2a87
57 changed files with 5632 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using Sandbox;
using Sandbox.UI;
using Sandbox.UI.Construct;
using Sandbox.UI.Tests;
using System.Linq;
[Library]
public partial class EntityList : Panel
{
VirtualScrollPanel Canvas;
public EntityList()
{
AddClass( "spawnpage" );
AddChild( out Canvas, "canvas" );
Canvas.Layout.AutoColumns = true;
Canvas.Layout.ItemSize = new Vector2( 100, 100 );
Canvas.OnCreateCell = ( cell, data ) =>
{
var entry = (LibraryAttribute)data;
var btn = cell.Add.Button( entry.Title );
btn.AddClass( "icon" );
btn.AddEventListener( "onclick", () => ConsoleSystem.Run( "spawn_entity", entry.Name ) );
btn.Style.Background = new PanelBackground
{
Texture = Texture.Load( $"/entity/{entry.Name}.png", false )
};
};
var ents = Library.GetAllAttributes<Entity>().Where( x => x.Spawnable ).OrderBy( x => x.Title ).ToArray();
foreach ( var entry in ents )
{
Canvas.AddItem( entry );
}
}
}

37
code/ui/left/SpawnList.cs Normal file
View 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 ) );
}
}
}