BlockGrab class
#include <Jazz2/Editor/Tools/BlockGrab.h>
Grabs a block of tiles as the stamp by its two corners marked with a key, as B of Jazz Creation Station.
The first press marks the corner under the pointer, the second one the other corner, and the tiles between them become the stamp — of the layer being edited, with the events on them if it's the sprite layer, or of a tile set in the picker (see PressTileSet()). Where a block of the level is painted, its empty tiles leave the tiles there as they are, unless it's painted with Shift (see TileStamp::
With Mode::
Public types
-
enum class Mode : std::
uint8_t { Replace, Add, Subtract } - What the rectangle between the corners does.
Public static functions
-
static auto MakeStamp(const LevelDocument& document,
std::
int32_t layerIndex, const LayerView& view, const Recti& cells, const TileSelection* selection = nullptr) -> TileStamp - Makes a stamp of a rectangle of cells of the view of a layer, with the events on them if it's the sprite layer.
- static auto GrabSelection(IEditorContext& session, bool cut) -> bool
- Makes the selected tiles of the layer being edited the stamp, with the events on them, as a block grabbed.
Constructors, destructors, conversion operators
- BlockGrab(IEditorContext& session) explicit
- Creates a new instance.
Public functions
- auto PressLevel(Mode mode) -> bool
- Marks a corner of a block of the layer being edited at the pointer, or grabs the block if a corner is marked.
-
auto PressTileSet(std::
uint8_t source, std:: int32_t columns, Vector2i cell, Vector2i& start) -> bool - Marks a corner of a block of a tile set at a cell of the picker, or returns the other corner if one is marked.
- auto IsActive() const -> bool
- Returns
trueif a corner is marked. -
auto GetTileSetCorner(std::
uint8_t source, std:: int32_t columns, Vector2i& corner) const -> bool - Returns the corner marked in the picker of the tiles of a source,
falseif none is. - void Cancel()
- Forgets the corner marked.
- void DrawOverlay(Painter& painter, const ToolPointer& hover, bool hoverValid)
- Draws the block from the corner marked to the pointer, over the level.
Enum documentation
enum class Jazz2:: Editor:: BlockGrab:: Mode : std:: uint8_t
What the rectangle between the corners does.
| Enumerators | |
|---|---|
| Replace |
It's the block |
| Add |
It's added to the selection of the layer, the selected tiles are the block |
| Subtract |
It's taken out of the selection of the layer, the selected tiles left are the block |
Function documentation
static TileStamp Jazz2:: Editor:: BlockGrab:: MakeStamp(const LevelDocument& document,
std:: int32_t layerIndex,
const LayerView& view,
const Recti& cells,
const TileSelection* selection = nullptr)
Makes a stamp of a rectangle of cells of the view of a layer, with the events on them if it's the sprite layer.
The cells are wrapped as the layer repeats. Those outside of it are left out, as are those not selected if selection is given. Its empty tiles are transparent, see TileStamp::
static bool Jazz2:: Editor:: BlockGrab:: GrabSelection(IEditorContext& session,
bool cut)
Makes the selected tiles of the layer being edited the stamp, with the events on them, as a block grabbed.
With cut they're erased, with their events, as one step. Returns false if nothing is selected on the layer.
bool Jazz2:: Editor:: BlockGrab:: PressLevel(Mode mode)
Marks a corner of a block of the layer being edited at the pointer, or grabs the block if a corner is marked.
The mode is the one of the first press. Returns false if the pointer isn't over the level.
bool Jazz2:: Editor:: BlockGrab:: PressTileSet(std:: uint8_t source,
std:: int32_t columns,
Vector2i cell,
Vector2i& start)
Marks a corner of a block of a tile set at a cell of the picker, or returns the other corner if one is marked.
The tiles of the tile set are in rows of columns. Returns true with start set to the corner marked before once the block is complete, the picker picks it then as a drag over it would.