Files
sbox-public/game/addons/tools/Code/Editor/ProjectSettings/ProjectSettingsHeader.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

63 lines
1.4 KiB
C#

namespace Editor;
internal class ProjectSettingsHeader : Widget
{
public Project Project { get; set; }
public ProjectSettingsHeader( Widget parent, Project project ) : base( parent )
{
Project = project;
MinimumSize = new Vector2( 250, 42 );
Layout = Layout.Row();
Layout.Alignment = TextFlag.Center;
if ( Project.IsPublished && !Project.Config.IsStandaloneOnly )
{
var row = Layout.Row();
row.AddStretchCell();
row.Add( new Button( $"View Package", "launch" ) { Clicked = () => EditorUtility.OpenFolder( Project.EditUrl ) } );
row.AddSpacingCell( 16 );
Layout.Add( row );
}
}
protected override void OnPaint()
{
if ( Project is null )
return;
Paint.Antialiasing = true;
Package.TryGetCached( Project.Config.FullIdent, out var package );
var inner = LocalRect.Shrink( 12, 6 );
var icon = inner;
icon.Width = inner.Height;
//
// Icon
//
if ( package?.Thumb != null )
{
Paint.SetPen( Theme.Text );
Paint.Draw( icon, package?.Thumb );
}
else
{
Paint.SetPen( Theme.Text );
Paint.DrawIcon( inner, "settings", 22, TextFlag.LeftCenter );
}
inner.Left = icon.Right + 12;
Paint.SetHeadingFont( 9, 400 );
Paint.DrawText( inner, Project.Config.Title, TextFlag.LeftTop );
Paint.SetDefaultFont( 8, 400 );
Paint.SetPen( Theme.Text.WithAlpha( 0.5f ) );
Paint.DrawText( inner, Project.Config.FullIdent, TextFlag.LeftBottom );
}
}