Jazz2::Editor::DocumentChanges class

Collects what changed in a level being edited.

Edit commands report what they change, the editor then brings everything that shows the level up to date at once. Changed tiles are tracked as one area for each layer, changed events as one area of the grid.

Constructors, destructors, conversion operators

DocumentChanges()

Public functions

auto IsEmpty() const -> bool
Returns true if nothing changed.
auto GetKinds() const -> DocumentChangeKind
Returns all kinds of changes.
auto HasAny(DocumentChangeKind kinds) const -> bool
Returns true if any of the given kinds changed.
auto GetTileAreas() const -> ArrayView<const DocumentTileArea>
Returns the changed areas of layers.
auto GetEventArea() const -> const Recti&
Returns the changed area of the event grid, or an empty rectangle.
auto AreTileAreasComplete() const -> bool
Returns false if tiles changed that may be outside of GetTileAreas().
auto IsEventAreaComplete() const -> bool
Returns false if events changed that may be outside of GetEventArea().
auto GetLayerOrder() const -> ArrayView<const std::int32_t>
Returns the index each layer had before, for each index it has now, if the layers were only moved.
void Add(DocumentChangeKind kinds)
Adds changes of the given kinds.
void AddLayerMove(std::int32_t from, std::int32_t to, std::int32_t count)
Adds a move of a layer of count layers, from an index to another one, see GetLayerOrder().
void AddTiles(std::int32_t layer, const Recti& area)
Adds changed tiles of a layer.
void AddEvents(const Recti& area)
Adds changed events.
void Add(const DocumentChanges& other)
Adds all changes of another collection.
void Clear()
Clears all changes.

Function documentation

bool Jazz2::Editor::DocumentChanges::AreTileAreasComplete() const

Returns false if tiles changed that may be outside of GetTileAreas().

A change reported only by its kind, as a snapshot of layers restored, doesn't tell which tiles it changed, all of them have to be taken as changed then.

bool Jazz2::Editor::DocumentChanges::IsEventAreaComplete() const

Returns false if events changed that may be outside of GetEventArea().

An event off the grid is in the area of the tile its position is in.

ArrayView<const std::int32_t> Jazz2::Editor::DocumentChanges::GetLayerOrder() const

Returns the index each layer had before, for each index it has now, if the layers were only moved.

Empty if the layers weren't moved, or if they changed otherwise too — added, removed, resized or replaced by a snapshot (see DocumentChangeKind::LayerStructure).

void Jazz2::Editor::DocumentChanges::Add(DocumentChangeKind kinds)

Adds changes of the given kinds.

Tiles and events added this way are of no known area, see AreTileAreasComplete() and IsEventAreaComplete(), those of a known one are added by AddTiles() and AddEvents().