Jazz2::Editor::SetTileOverrideCommand class

Changes how the level overrides the pixels and the collision mask of a tile.

Each of them is either set, or the override is removed so the tile is as its tile set has it. Changes of the same tile by the same name are merged when it's allowed, so a stroke of the pencil is a single step.

Base classes

class EditCommand
Undoable change of a level being edited.

Public static functions

static auto FindDiffuse(const LevelDocument& document, std::uint16_t tileId) -> const Formats::TileDiffuseOverride*
Finds the override of the pixels of a tile, or returns nullptr.
static auto FindMask(const LevelDocument& document, std::uint16_t tileId) -> const Formats::TileMaskOverride*
Finds the override of the collision mask of a tile, or returns nullptr.

Constructors, destructors, conversion operators

SetTileOverrideCommand(const LevelDocument& document, std::uint16_t tileId, const std::uint8_t* indices, const std::uint8_t* mask, String name)
Creates a change of a tile, a nullptr removes the override of its pixels or of its mask.

Public functions

void Do(LevelDocument& document, DocumentChanges& changes) override
Applies the change to the document, again after it was undone.
void Undo(LevelDocument& document, DocumentChanges& changes) override
Reverts the change.
auto TryMerge(EditCommand& next) -> bool override
Tries to take over a change that follows this one, which was already applied.
auto CanMerge(EditCommand& next) -> bool override
Returns true if TryMerge() would take over next, without taking it over.
auto GetName() const -> String override
Returns the name shown in the history.
auto GetMemoryUsage() const -> std::size_t override
Returns the memory the command takes.
auto GetTileId() const -> std::uint16_t
Returns the tile ID of the tile.
auto IsOverriddenAfter() const -> bool
Returns true if the tile is overridden after the change, its pixels or its mask.

Function documentation

bool Jazz2::Editor::SetTileOverrideCommand::TryMerge(EditCommand& next) override

Tries to take over a change that follows this one, which was already applied.

Lets a continuous change, such as dragging a slider, be undone in a single step. Returns true if next was taken over, it's then dropped.

bool Jazz2::Editor::SetTileOverrideCommand::CanMerge(EditCommand& next) override

Returns true if TryMerge() would take over next, without taking it over.

A transaction is merged only if all of its changes can be, it asks each of them first. A command that merges has to say the same here as its TryMerge() does.