Editor/UI/ArchGuide.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Sunless.Architecture;
// A tool's how-to, opened from the HOW TO chip in its sidebar header and read in its own window. The sidebar says
// the one line the gesture needs and nothing else; everything an author would otherwise have to be told in a
// paragraph standing over the controls is written here instead, where it can be as long as it needs to be.
public sealed class ArchGuide {
public string Ident { get; init; }
public string Title { get; init; }
public string Lead { get; init; }
public ArchGuideChapter[] Chapters { get; init; } = Array.Empty<ArchGuideChapter>();
}
// A picture is drawn where Editor/Guides/<Picture>.png is on disk and simply absent where it is not, so a chapter
// can name art nobody has drawn yet and still read. Plates are the tool's OWN icon art, which is what lets a
// chapter show the very choices it is describing with no new file at all.
public sealed class ArchGuideChapter {
public string Heading { get; init; }
public string Picture { get; init; }
public string[] Body { get; init; } = Array.Empty<string>();
public string[] Steps { get; init; } = Array.Empty<string>();
public ArchGuidePlate[] Plates { get; init; } = Array.Empty<ArchGuidePlate>();
}
public sealed class ArchGuidePlate {
public string Slug { get; init; }
public string Glyph { get; init; }
public string Caption { get; init; }
}
// Written out rather than discovered, like every other table in this library. A tool with nothing written here
// shows no chip at all, so the chip's presence is itself the promise that there IS more to read.
public static class ArchGuides {
public static ArchGuide For( ArchSubtool subtool ) {
return subtool is null ? null : For( ArchIcons.SubtoolSlug( subtool ) );
}
public static ArchGuide For( string ident ) {
return ArchGuidesWritten.Standing().FirstOrDefault( guide => guide.Ident == ident );
}
public static IReadOnlyList<ArchGuide> All() => ArchGuidesWritten.Standing().ToList();
}