SetLevelTilesCommand class
#include <Jazz2/Editor/Document/Commands.h>
Changes the pixels or the masks of tiles the level stores in itself, see Formats::
The tiles stay as many and of the same kind, so the level shows the change at once without being loaded again. Consecutive changes are merged, so a stroke is a single step. Only a tile set the level stores in itself can be changed, a command made for any other slot does nothing. The data is swapped with the document instead of copied, so a step keeps a single copy of the tile set.
Base classes
- class EditCommand
- Undoable change of a level being edited.
Constructors, destructors, conversion operators
-
SetLevelTilesCommand(const LevelDocument& document,
std::
int32_t slot, SmallVector<std:: uint8_t, 0>&& data, String name, std:: int32_t flags = -1) - Creates a change of the extra tile set
slotto the tile set file indata.
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
trueif TryMerge() would take overnext, 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.
Function documentation
Jazz2:: Editor:: SetLevelTilesCommand:: SetLevelTilesCommand(const LevelDocument& document,
std:: int32_t slot,
SmallVector<std:: uint8_t, 0>&& data,
String name,
std:: int32_t flags = -1)
Creates a change of the extra tile set slot to the tile set file in data.
With flags other than -1, the flags of the tile set record change too, as when the colors of its tiles are matched to the palette no longer (see Formats::
bool Jazz2:: Editor:: SetLevelTilesCommand:: 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:: SetLevelTilesCommand:: 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.