DemoCookBook¶
Namespace Nfty.Core.Demo in assembly Nfty.Core.
The sample CookBook that ships inside nfty: a small collection of layered chests, present in every build and every download, so nobody's first launch is an empty screen.
Remarks¶
It is embedded, not installed beside the executable. nfty ships in four shapes, two of which are a single .exe — a file people copy onto a stick and run somewhere else. A sample that lived next to the binary would be present in two of those four and absent in the two most likely to travel, which makes "always available" a claim rather than a fact. The archive is ~10 KB; carrying it inside the assembly costs nothing and cannot be separated from the app.
The bytes are a build output that is committed, generated by tools/demo/build-demo.py from the art in tools/demo/draw-chest-art.py. That is the same arrangement Themes/Icons.axaml has with assets/icons/*.svg, and for the same reason: the generator is the source, but the app must not need Python to build. DemoCookBook Tests reads, validates and cooks these bytes, so the two cannot drift in silence.
Nothing here writes anywhere by itself. DemoCookBook.WriteTo() takes the folder from its caller — a front-end that knows where the user's writable space is — because a Core type that picked its own directory would be reaching into the machine from the one layer that has no business knowing about it.
Fields¶
DisplayName¶
The CookBook's display name, for a front-end that wants to name it before opening it.
FileName¶
The file name the demo is written out as.
Summary¶
public const string Summary = "A sample collection of layered chests — two Recipes, all three layer kinds, and a few hundred thousand possible assets.";
One line describing what the demo is, for a button caption or a status message. Stated here rather than in each front-end so the CLI and the GUI say the same thing.
Methods¶
Bytes()¶
The embedded archive's bytes.
Returns. A new array each call, so a caller cannot mutate the copy the next one gets.
Open()¶
Opens the embedded archive for reading.
Returns. A fresh, seekable stream over the .cbk bytes; the caller disposes it.
Exceptions
InvalidOperationException- The resource is missing from the assembly, which means the build dropped it — a broken build, not a runtime condition.
WriteTo(string, bool)¶
Writes the demo into directory and returns the file's path.
Parameters
directory(string) - Where to put it. Created if it does not exist.overwrite(bool) - Whether to replace a copy that is already there. The default isfalse— and that default is the point: the demo is meant to be edited, so a second "open the demo" must hand back the book with the user's changes in it rather than silently reverting their work. Passtruefor an explicit "reset the demo".
Returns. The full path to the archive.
Exceptions
ArgumentException-directoryis null or whitespace.