MenuArchive¶
Namespace Nfty.Ticket in assembly Nfty.Ticket.
Reads a .mnu Menu: every weight, rule and colorization a rolled asset needs, plus its art, with no imaging library involved.
Remarks¶
This assembly decodes no pixels — that is the whole point of Nfty.Ticket being package-free. In atlas mode MenuArchive.ArtBytes() hands back the WHOLE atlas PNG's bytes and MenuArchive.Cell() the rect inside it; the caller crops. In loose mode the "rect" is simply the whole image, so a caller can treat both modes through one code path without ever asking which mode a Menu was written in.
Owns the open archive. MenuArchive.Open() opens the file and keeps it open for the life of this object — MenuArchive.ArtBytes() reads from it lazily rather than eagerly decoding everything up front, which is what lets a host page through a large Menu's art without holding it all in memory at once. Dispose frees the archive (and, for MenuArchive.Open(), the file it was opened from).
Properties¶
Book¶
The Menu's manifest: every weight, rule, colorization and cell rect.
Methods¶
ArtBytes(string)¶
One cell's art, as raw PNG bytes.
Parameters
cellKey(string) - A key fromMenuBook.CellKey().
Returns. In atlas mode, the whole atlas PNG's bytes — use MenuArchive.Cell() to find where this cell sits inside them. In loose mode, that one variant's own PNG bytes in full.
Exceptions
KeyNotFoundException- The Menu has no cell forcellKey.InvalidDataException- The archive is missing the entry the manifest points at.
Cell(string)¶
Where cellKey's art sits inside the bytes MenuArchive.ArtBytes() returns.
Parameters
cellKey(string) - A key fromMenuBook.CellKey().
Returns. The cell rect — the whole image in loose mode, so a caller can treat both modes with one code path.
Exceptions
KeyNotFoundException- The Menu has no cell forcellKey.
Depth(string)¶
One variant's depth map, when it has one.
Parameters
cellKey(string) - A key fromMenuBook.CellKey().
Returns. null when the variant carries no depth data — "paper" for the Rise feature — otherwise a DepthMap sized to that cell's MenuCell.Width and MenuCell.Height.
Exceptions
KeyNotFoundException- The Menu has no cell forcellKey— the same check, and the same message,MenuArchive.Cell()makes.InvalidDataException- A stored depth entry's length disagrees with the cell's dimensions, naming the key.
Remarks
Read lazily, like MenuArchive.ArtBytes() — not eagerly at MenuArchive.Open() — for the same reason: most variants carry no depth data at all, and this assembly stays package-free, so nothing here decodes a pixel either way; a .dep entry is already raw bytes in the exact layout DepthMap.FromBytes() expects.
Dispose()¶
Closes the underlying archive, and the file it was opened from.
Layer(string, string)¶
One layer's definition — kind, colorization and variants — as the recipe it belongs to records it.
Parameters
recipeId(string) - The recipe.ingredientId(string) - The layer within that recipe.
Returns. The layer, exactly as the Menu manifest carries it.
Exceptions
KeyNotFoundException- The Menu has no recipe namedrecipeId, or that recipe has no layer namedingredientId. Both cases are reported by this single method — naming which of the two failed — so a caller (Plating.Plate, chiefly) never has to reach intoMenuArchive.Bookitself to answer the question, and never hits the BCL's unnamed default message for either.
Open(Stream)¶
Opens a .mnu from an already-open stream.
Parameters
stream(Stream) - A seekable stream over the archive's bytes. Ownership passes to the returnedMenuArchive— it is closed when that object is disposed.
Returns. The open archive; the caller disposes it.
Exceptions
NotSupportedException- The manifest declares a schema newer than this build reads.InvalidDataException- The stream is not a readable Menu.
Open(string)¶
Opens a .mnu file for reading.
Parameters
path(string) - The Menu to open.
Returns. The open archive; the caller disposes it.
Exceptions
NotSupportedException- The manifest declares a schema newer than this build reads.InvalidDataException- The file is not a readable Menu.