Editor/Tool/ArchShelfSettingsDialog.cs
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." ) );
BuildDataRoot();
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 BuildDataRoot() {
Layout.AddSeparator();
var heading = new Label( "Data" );
heading.SetStyles( "font-weight: bold;" );
Layout.Add( heading );
Layout.Add( ArchPartUi.Wrapped( $"Folder under Assets/ that every catalogue is read from and written to - kits, openings, cornices, pillars, plans and the rest. This project files them in '{ArchDataRoot.Default}'; point it elsewhere to work out of another folder." ) );
var root = new LineEdit( ArchDataRoot.Current ) { PlaceholderText = ArchDataRoot.Default };
root.EditingFinished += () => ArchDataRoot.Set( root.Text );
var row = Layout.AddRow();
row.Spacing = 4;
row.Add( root, 1 );
row.Add( new Button( "Default", "restart_alt" ) { Clicked = () => { ArchDataRoot.Reset(); root.Text = ArchDataRoot.Current; } } );
}
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();
}
}