Jazz2::Editor::Annotation struct

A bookmark or a note placed in a level, for the editor only.

A bookmark remembers a place of the level under a number from 1 to 9, a note is a text at a place. Both are kept in the editor-only chunk ann2 (see Formats::LevelFile::IsEditorOnlyChunk()), so the exported level has none of them. They're changed by a SetChunkCommand, so they're undone as any other change.

The chunk is u8 version (2), varuint count, then for each one a varuint size of its record and the record: i32 X, i32 Y, u8 slot, varuint length and the text. Version 2 adds to a record u32 color, the author as varuint length and text, i64 time, u8 flags (1 resolved), varuint number of replies, each its author, i64 time and text. A newer version may add fields at the end of a record, a reader skips those it doesn't know.

Public types

struct Reply
A reply to a note.

Public static variables

static std::uint32_t Chunk constexpr
Tag of the chunk they're kept in.
static std::uint32_t LegacyChunk constexpr
Tag of the chunk 3.9.0 kept them in, without a version, only read.

Public static functions

static void Read(const LevelDocument& document, SmallVectorImpl<Annotation>& annotations)
Reads all of them from a level.
static void Write(LevelDocument& document, const SmallVectorImpl<Annotation>& annotations)
Replaces all of them in a level, directly.
static void Serialize(const SmallVectorImpl<Annotation>& annotations, SmallVectorImpl<std::uint8_t>& data)
Writes all of them into bytes of the chunk, no bytes for none.
static void UpgradeLegacyChunk(LevelDocument& document)
Converts the chunk of 3.9.0 to the current one, if the level has it.

Public functions

auto IsBookmark() const -> bool
Returns true if it's a bookmark.

Public variables

std::int32_t X
Position in the level in pixels.
std::int32_t Y
Position in the level in pixels.
std::uint8_t Slot
Number of a bookmark, from 1 to 9, 0 for a note.
String Text
Text of a note, or the name of a bookmark, may be empty.
std::uint32_t Color
Color as.
String Author
Who wrote the note, may be empty.
std::int64_t Time
When the note was written, in seconds since 1970, 0 if it isn't known.
bool Resolved
Whether what the note is about was done, the note is shown dimmer then.
SmallVector<Reply, 0> Replies
Replies to the note, the oldest first.

Function documentation

static void Jazz2::Editor::Annotation::Read(const LevelDocument& document, SmallVectorImpl<Annotation>& annotations)

Reads all of them from a level.

The legacy chunk wins over the current one if the level has both, it was written by 3.9.0 after this version saved the level, as this version never writes it.

static void Jazz2::Editor::Annotation::Write(LevelDocument& document, const SmallVectorImpl<Annotation>& annotations)

Replaces all of them in a level, directly.

Not undoable by itself, for a change made within another undoable step. Otherwise use Serialize() and a SetChunkCommand of Chunk.

static void Jazz2::Editor::Annotation::UpgradeLegacyChunk(LevelDocument& document)

Converts the chunk of 3.9.0 to the current one, if the level has it.

What the legacy chunk can't hold is kept from the current one for the annotations that are the same in both.

Variable documentation

std::uint32_t Jazz2::Editor::Annotation::Color

Color as.

R | G << 8 | B << 16 | A << 24, 0 for the usual one