Jazz2::Formats::LayerPropertiesChunk struct

Chunk with what the records of the layers have no room for.

The name of a layer, the number it had in the original game, how the sprite layer is drawn, the parameters and the texture of its own of a textured layer, and how a layer is blended over what is behind it. The level editor shows the names, and scripts find layers by them; a script of JJ2+ refers to the eight layers of a level of the original game by their numbers, 1 to 8 from the front (jjLayers[n]), whatever order they are drawn in — the converter keeps all eight of them, even an empty one, and gives them their numbers here. Without a number, scripts count the layers from the sprite layer, which is layer 4. The record of the sprite layer ends after its size, so its renderer type and its color are here, and only those that keep its tiles where they are take effect (see Tiles::LayerDescription::IsSpriteLayerRenderer()). A reader that doesn't know the chunk draws the layers as their records say, the sprite layer as ordinary tiles. It's written only for the layers that have any of it, and kept when the level is exported.

The payload is varuint count × (varuint index of the layer in file order, varuint size of its fields, then the fields), each field u8 Field, varuint size and its value:

A field of a kind this version doesn't know is skipped, and so are the bytes a newer version adds after a value; a field shorter than its value is ignored. A layer without a field has its default, a layer without an entry all of them.

Public types

struct Entry
Properties of one layer.
enum class Field : std::uint8_t { Name = 1, OriginalNumber, SpriteLook, Textured, Texture, Blend }
Kind of a field of an entry.

Public static variables

static std::uint32_t Tag constexpr
Tag of the chunk.
static std::int32_t TextureSize constexpr
Width and height of a texture of its own in pixels, as the textures of JJ2+ and of 8×8 tiles.
static std::size_t MaxNameLength constexpr
Largest length of a name in bytes, a longer one is cut short at a whole character.
static std::uint8_t OriginalLayerCount constexpr
Number of the layers of a level of the original game.

Public static functions

static auto Read(ArrayView<const std::uint8_t> data, SmallVectorImpl<Entry>& layers) -> bool
Reads the payload, returns false if it's damaged and layers is left empty then.
static void Write(ArrayView<const Entry> layers, SmallVectorImpl<std::uint8_t>& data)
Writes the payload of the layers that have any property other than its default, nothing if there are none.

Constructors, destructors, conversion operators

LayerPropertiesChunk() deleted

Enum documentation

enum class Jazz2::Formats::LayerPropertiesChunk::Field : std::uint8_t

Kind of a field of an entry.

Enumerators
Name

Name of the layer

OriginalNumber

Number of the layer in the original game

SpriteLook

Renderer type and color of the sprite layer

Textured

Parameters of a textured layer, see TexturedLayerParams

Texture

Texture of its own of a textured layer

Blend

How the layer is blended over what is behind it

Function documentation

static void Jazz2::Formats::LayerPropertiesChunk::Write(ArrayView<const Entry> layers, SmallVectorImpl<std::uint8_t>& data)

Writes the payload of the layers that have any property other than its default, nothing if there are none.

A texture of another size than TextureSize × TextureSize isn't written, a parameter that isn't finite is written as its default.