Jazz2::Editor::GroundLineTool class

Draws ground along a line, with slopes as steep as the line, and changes it later.

Each click adds a point of the surface, with Ctrl at a corner of a tile. The right button lays the ground as one step: the tiles the line goes through get pieces of ground of the tile set whose collision mask follows the line the closest (see TileShapes), preferring those the levels use so; below them it's filled down to the ground that's there, at most a few tiles deep, and those tiles and the ones around are chosen by their neighbors (see SmartTileModel).

What is laid is chosen in the options of the tool (see SplineKind): ground below the line, a ceiling above it, a floating band, or a closed shape whose points go around it. The line is straight between its points or a smooth curve through them.

The line is kept with the level (see TerrainSpline): its points can be dragged — the ground follows while dragged, laid for good when let go —, a click on the line adds one, Shift+click removes one, and the right button on the line removes the ground. Every change lays the ground again — tiles it wrote get back what was there before, tiles changed by hand since stay as they are. Lines can overlap: a tile a line laid later wrote over stays as it is, owned by the line below still, and shows again once the line above is taken away. Where the collision of the ground laid misses the line, its surface is drawn red.

The points of a new line stay while the view is moved by the hand for a while (Space) between the clicks.

Base classes

class EditorTool
Tool used in the view of the level editor.

Public static variables

static std::int32_t MaxDepth constexpr
Most tiles below the surface that are filled.

Public static functions

static auto ApplySpline(IToolHost& host, SmallVectorImpl<TerrainSpline>& splines, std::int32_t index, const TerrainSpline* spline, StringView name) -> bool
Lays ground along a line again, or for the first time, or removes it, as one step.
static auto TraceSelection(IToolHost& host) -> bool
Makes a line along the top of the selected ground, so ground that's there can be changed by it.
static void SampleLine(const TerrainSpline& spline, SmallVectorImpl<Vector2f>& line)
Returns the line as fine points, straight between its points or along the curve through them, closed if it's a shape.
static auto GetLineY(ArrayView<const Vector2f> line, float x) -> float
Returns the height of a line at a position, of the fine points of a line that goes from left to right.

Constructors, destructors, conversion operators

GroundLineTool(IToolHost& host) explicit

Public functions

auto GetType() const -> EditorToolType override
Returns the type.
void OnActivate() override
Called when the tool is chosen.
void OnDeactivate() override
Called when another tool is chosen, anything in progress is cancelled.
void OnPointerDown(const ToolPointer& pointer) override
Called when the pointer is pressed over the view.
void OnPointerMove(const ToolPointer& pointer) override
Called when the pointer moves over the view, pressed or not.
void OnPointerUp(const ToolPointer& pointer) override
Called when the pointer is released.
void Cancel() override
Cancels what the tool is doing.
auto IsBusy() const -> bool override
Returns true if the tool is in the middle of something.
auto HasPointerCapture() const -> bool override
Returns true if the tool follows the pointer pressed, another tool can't be taken for a while then.
void DrawOverlay(Painter& painter, const ToolPointer& hover, bool hoverValid) override
Draws what the tool shows over the view.
auto GetHint() const -> StringView override
Returns a hint of how the tool is used.
void BuildOptions(ToolOptionsBuilder& builder) override
Makes the options of the tool shown in the toolbar while it's chosen, none by default.
auto GetSelectedSpline() const -> std::int32_t
Returns the line last clicked or laid, of the lines of the level, or -1 if it's not there anymore.

Function documentation

static bool Jazz2::Editor::GroundLineTool::ApplySpline(IToolHost& host, SmallVectorImpl<TerrainSpline>& splines, std::int32_t index, const TerrainSpline* spline, StringView name)

Lays ground along a line again, or for the first time, or removes it, as one step.

index is the line in splines to change, -1 to add spline; spline is the line as it should be, or nullptr to remove it.

static bool Jazz2::Editor::GroundLineTool::TraceSelection(IToolHost& host)

Makes a line along the top of the selected ground, so ground that's there can be changed by it.

The line follows the collision masks of the topmost solid tiles of each column of the selection, and the solid tiles of the selection are its own, with nothing before them — dragging the line lower takes ground away. Returns false if there's no ground selected.

bool Jazz2::Editor::GroundLineTool::HasPointerCapture() const override

Returns true if the tool follows the pointer pressed, another tool can't be taken for a while then.

A tool in the middle of something clicked point by point, as a path, doesn't, the hand can move the view between the clicks. It's IsBusy() by default.