Jazz2::Formats::LevelPreview struct

Preview of a level shown in the list of custom levels, see LevelFile::PreviewChunk.

What the game shows around the start of the level: all layers composited from the farthest one on, ordered by their depth as the game draws them, at the parallax of the game (see Tiles::LayerDescription::GetGameplayOrigin()), a view of 384 × 216 pixels made Scale times smaller, each pixel the average of a few points of the level. A layer of solid color is just its color, the layers of effects (x-ray and blur behind) aren't drawn, a reflection mirrors what is behind it below its horizon, without the ripples, over the view or where the layer is, and a palette-shifted layer takes the colors further in the palette, as the game draws it.

The level comes through an ISource, so the level editor, which keeps a level in a form of its own, makes it the same way as the converter of the original levels, which hands it a RecordSource.

Public types

struct TilePixels
Pixels of a tile as stored in its tile set.
class ISource
Layers of a level and the pixels of their tiles, as the preview takes them.
class RecordSource
A level in the form its file stores it, with its tile sets in memory.
class StartPicker
Picks the start of a level the preview is made around.

Public static variables

static std::int32_t Width constexpr
Width of the preview in pixels.
static std::int32_t Height constexpr
Height of the preview in pixels.
static std::int32_t Scale constexpr
Pixels of the level in a pixel of the preview, each way.

Public static functions

static void Make(ISource& source, nCine::Vector2f start, const std::uint32_t* palette, SmallVectorImpl<std::uint8_t>& data)
Makes the preview, the payload of LevelFile::PreviewChunk.
static auto Decode(ArrayView<const std::uint8_t> data, SmallVectorImpl<std::uint8_t>& rgba, nCine::Vector2i& size) -> bool
Decodes the payload of LevelFile::PreviewChunk to RGBA pixels, row by row.
static auto Read(StringView path, SmallVectorImpl<std::uint8_t>& rgba, nCine::Vector2i& size) -> bool
Reads the preview of a level file as RGBA pixels, row by row.

Constructors, destructors, conversion operators

LevelPreview() deleted

Function documentation

static void Jazz2::Formats::LevelPreview::Make(ISource& source, nCine::Vector2f start, const std::uint32_t* palette, SmallVectorImpl<std::uint8_t>& data)

Makes the preview, the payload of LevelFile::PreviewChunk.

start is where the level starts in pixels (see StartPicker), palette the 256 colors the 8-bit tiles are shown in. Leaves data empty if the level has no sprite layer.

static bool Jazz2::Formats::LevelPreview::Decode(ArrayView<const std::uint8_t> data, SmallVectorImpl<std::uint8_t>& rgba, nCine::Vector2i& size)

Decodes the payload of LevelFile::PreviewChunk to RGBA pixels, row by row.

Returns false if it's too short, or too large to be a preview.

static bool Jazz2::Formats::LevelPreview::Read(StringView path, SmallVectorImpl<std::uint8_t>& rgba, nCine::Vector2i& size)

Reads the preview of a level file as RGBA pixels, row by row.

Returns false if the level has none, or one too large to be one of them.