Editor UI window for the HotCode About dialog. It constructs a fixed-size window with logo, wordmark, descriptive labels and a Close button, handling single-instance open and basic paint/layout.
using Sandbox;
using Editor;
using System;
/// <summary>
/// Help → About HotCode: the chili, the wordmark, and what HotCode does.
/// </summary>
public class AboutWindow : Window
{
private static AboutWindow _open;
public static void Open()
{
if ( _open.IsValid() )
{
_open.Raise();
return;
}
_open = new AboutWindow();
}
private AboutWindow()
{
WindowTitle = "About HotCode";
SetWindowIcon( HotCodeLogo.WindowIcon );
DeleteOnClose = true;
Size = new Vector2( 460, 420 );
MinimumSize = Size;
Canvas = new Widget( this );
Canvas.OnPaintOverride = () =>
{
Paint.ClearPen();
Paint.SetBrush( Theme.TabBackground );
Paint.DrawRect( Canvas.LocalRect );
return true;
};
Canvas.Layout = Layout.Column();
Canvas.Layout.Margin = 24;
Canvas.Layout.Spacing = 6;
var top = Canvas.Layout.AddRow();
top.AddStretchCell();
top.Add( new LogoWidget( Canvas, 132, badge: false ) );
top.AddStretchCell();
var name = Canvas.Layout.AddRow();
name.AddStretchCell();
name.Add( new WordmarkWidget( Canvas, 30 ) );
name.AddStretchCell();
AddCentred( "A code editor built right into s&box", Theme.TextLight, 600 );
Canvas.Layout.AddSpacingCell( 10 );
Canvas.Layout.AddSeparator( 1, Theme.Border );
Canvas.Layout.AddSpacingCell( 6 );
AddCentred( "Autocomplete · Parameter hints · Go to Definition", Theme.Text, 400 );
AddCentred( "Errors while you type · Live compile results · Hotload", Theme.Text, 400 );
Canvas.Layout.AddStretchCell();
var footer = Canvas.Layout.AddRow();
footer.AddStretchCell();
footer.Add( new Button.Primary( "Close", "close", Canvas ) { Clicked = () => Close() } );
Show();
}
private void AddCentred( string text, Color colour, int weight )
{
var label = Canvas.Layout.Add( new Label( text, Canvas ) );
label.Alignment = TextFlag.Center;
label.SetStyles( $"color: {colour.Hex}; font-weight: {weight};" );
}
}