Jazz2/Editor/Tools/TileTools.h file

Namespaces

namespace Jazz2
Root namespace of Jazz² Resurrection.
namespace Jazz2::Editor

Classes

class Jazz2::Editor::StrokeTool
Base of the tools that paint tiles.
class Jazz2::Editor::BrushTool
Paints the stamp, or erases.
class Jazz2::Editor::RectangleTool
Fills a rectangle with the stamp.
class Jazz2::Editor::FillTool
Fills an area of the same tiles with the stamp.
class Jazz2::Editor::EyedropperTool
Picks tiles of the layer as the stamp.
class Jazz2::Editor::SelectTool
Selects a rectangle of tiles.
class Jazz2::Editor::WandTool
Selects an area of the same tiles.
class Jazz2::Editor::HandTool
Moves the view.

Functions

void DrawTileModifiers(Painter& painter, const DocumentLayer& layer, const LayerView& view, const Rectf& viewRect)
Marks the tiles of a layer seen in a rectangle of the screen that are translucent or invisible.
void DrawSelectionEdge(Painter& painter, float x, float y, float length, bool horizontal, float animTime)
Draws an edge of a selection as marching ants, short dashes moving along a dark line, as a bitmap editor has them.
auto WrapViewRect(const Recti& rect, Vector2i layerSize, const LayerView& view, Recti(&parts)[4]) -> std::int32_t
Splits a rectangle of cells of the view into rectangles of a layer, returns how many there are, at most 4.
auto MoveSelectedTiles(IToolHost& host, Vector2i offset) -> bool
Moves the selected tiles of the layer being edited by an offset, as one step, the selection with them.
auto CarrySelectedEvents(IToolHost& host, const TileSelection& selection, const String& name, Function<Vector2i(Vector2i)>&& mapCell, Function<Vector2i(Vector2i)>&& mapPixel, Function<void(Formats::EventRecord&)>&& transform) -> bool
Moves the events on the selected tiles of the sprite layer where the tiles go, as moving or mirroring them does.

Function documentation

void DrawSelectionEdge(Painter& painter, float x, float y, float length, bool horizontal, float animTime)

Draws an edge of a selection as marching ants, short dashes moving along a dark line, as a bitmap editor has them.

The edge goes right or down from x, y, as thick as a pixel of the interface. The dashes follow the diagonal of the screen, so they go on around corners, and move on with animTime, see IToolHost::GetAnimTime().

std::int32_t WrapViewRect(const Recti& rect, Vector2i layerSize, const LayerView& view, Recti(&parts)[4])

Splits a rectangle of cells of the view into rectangles of a layer, returns how many there are, at most 4.

A rectangle dragged over a layer that repeats is of the copy of the layer it was dragged over, while a selection is of the layer itself, and so of every copy. On an axis the layer repeats in, the rectangle is wrapped into the layer — into two parts if it goes over the end of a copy into the next one, all of it if it's as long as the layer. On the other axes it's as it is, what's outside of the layer is left to the one who takes it.

bool MoveSelectedTiles(IToolHost& host, Vector2i offset)

Moves the selected tiles of the layer being edited by an offset, as one step, the selection with them.

The tiles left behind become empty. Around a layer that repeats they wrap, otherwise nothing is moved if any of them would be outside of the layer. On the sprite layer the events on them go with them, see CarrySelectedEvents(). Returns false if nothing was moved.

bool CarrySelectedEvents(IToolHost& host, const TileSelection& selection, const String& name, Function<Vector2i(Vector2i)>&& mapCell, Function<Vector2i(Vector2i)>&& mapPixel, Function<void(Formats::EventRecord&)>&& transform)

Moves the events on the selected tiles of the sprite layer where the tiles go, as moving or mirroring them does.

mapCell returns the tile a selected one goes to, mapPixel the position in pixels a position on one goes to, for the events off the grid, which stay within the level. transform changes each event moved, as mirroring turns it, or is empty. Events at the tiles they go to are replaced, as the tiles there are. To be called between IToolHost::BeginChanges() and IToolHost::EndChanges() with the change of the tiles, before the selection moves. Returns false if there were no events to move or the selection isn't of the sprite layer.