Editor/Tool/ArchShelfSettingsDialog.cs

An editor dialog UI for configuring which architecture subtools are visible on each shelf. It lists shells, shows non-fixed subtools as checkboxes reflecting ArchToolSettings, and allows showing all tools or closing.

File Access
using Editor;

namespace Sunless.Architecture;

// The shelf's own settings: which subtools stand on it. Everything stands by default, and what is taken off here
// is gone from the column until it is put back.
public sealed class ArchShelfSettingsDialog : Dialog
{
	public ArchShelfSettingsDialog( Widget parent ) : base( parent )
	{
		Window.Title = "Architecture Tools";
		Window.SetWindowIcon( "tune" );
		Window.Size = new Vector2( 320, 480 );

		Layout = Layout.Column();
		Layout.Margin = 12;
		Layout.Spacing = 6;

		Layout.Add( ArchPartUi.Wrapped( "Take a tool off the shelf it stands on. Pick the tool again in the scene view for the column to be rebuilt." ) );

		foreach ( var shell in ArchShelves.Shells )
		{
			BuildShell( shell );
		}

		Layout.AddStretchCell();

		var footer = Layout.AddRow();
		footer.Spacing = 4;
		footer.AddStretchCell();
		footer.Add( new Button( "Show Everything", "visibility" ) { Clicked = ShowEverything } );
		footer.Add( new Button.Primary( "Done", "check" ) { Clicked = Close } );
	}

	void BuildShell( string shell )
	{
		Layout.AddSeparator();

		var heading = new Label( char.ToUpperInvariant( shell[0] ) + shell[1..] );
		heading.SetStyles( "font-weight: bold;" );
		Layout.Add( heading );

		foreach ( var entry in ArchShelves.All( shell ) )
		{
			if ( entry.Fixed )
			{
				continue;
			}

			Layout.Add( Row( entry ) );
		}
	}

	Checkbox Row( ArchSubtoolEntry entry )
	{
		var stands = new Checkbox( entry.Caption ) { Value = !ArchToolSettings.Hidden( entry.Ident ) };

		stands.Toggled += () => ArchToolSettings.Hide( entry.Ident, !stands.Value );

		return stands;
	}

	void ShowEverything()
	{
		ArchToolSettings.ShowEverything();
		Close();
	}
}