SetTilesCommand class
#include <Jazz2/Editor/Document/Commands.h>
Changes tiles of a layer.
The tiles are collected first — the document isn't touched until the command is executed — so a tool can show them while they are being drawn. The tile the document has when a tile is first set is the one restored by undo.
Base classes
- class EditCommand
- Undoable change of a level being edited.
Public types
- struct Change
- Change of a single tile.
Constructors, destructors, conversion operators
-
SetTilesCommand(const LevelDocument& document,
std::
int32_t layer, String name) - Creates an empty change of a layer.
Public functions
-
void Set(std::
int32_t x, std:: int32_t y, const TileRef& tile) - Sets a tile, positions outside of the layer are ignored.
- void Seal()
- Completes the collection.
- auto IsEmpty() const -> bool
- Returns
trueif there's nothing to change. -
auto GetLayer() const -> std::
int32_t - Returns the layer.
- auto GetArea() const -> Recti
- Returns the area of all changed tiles.
- auto GetChanges() const -> ArrayView<const Change>
- Returns the changes collected so far, the same tile may be there more than once until sealed.
- 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 GetName() const -> String override
- Returns the name shown in the history.
-
auto GetMemoryUsage() const -> std::
size_t override - Returns the memory the command takes.
Function documentation
ArrayView<const Change> Jazz2:: Editor:: SetTilesCommand:: GetChanges() const
Returns the changes collected so far, the same tile may be there more than once until sealed.
A sealed command of many changes keeps them compressed, it returns none then.