FakeToolHost class
#include <Jazz2/Editor/Tests/FakeToolHost.h>
Host of the tools of the level editor for tests, only over a document and its history.
Nothing is shown — there's no shown level, camera nor interface, so previews of tiles and messages are only recorded. Every layer is in the view from its tile (0, 0) at the top left of the screen, a pixel of the level for a pixel of the screen, so a cell of any layer is at the same place, see MakePointer(). Changes are executed as the editor executes them, the tile ID space grows with them, and the selections follow them.
Only in debug builds, for EditorSelfTest.
Base classes
- class IToolHost
- What tools need from the level editor.
Public types
- struct PreviewedTile
- A tile shown before it's changed, see PreviewTile().
- struct RevertedArea
- An area shown again as the level has it, see RevertPreview().
Constructors, destructors, conversion operators
- FakeToolHost(LevelDocument& document) explicit
- Creates a host of a document, the document has to live longer.
- ~FakeToolHost() override
- FakeToolHost(const FakeToolHost&) deleted
Public functions
- auto operator=(const FakeToolHost&) -> FakeToolHost& deleted
- auto GetDocument() -> LevelDocument& override
- Returns the level being edited.
-
auto GetCurrentLayer() const -> std::
int32_t override - Returns the layer being edited.
-
auto IsLayerEditable(std::
int32_t layer) const -> bool override - Returns
trueif a layer can be changed, it's not locked or hidden. -
auto GetLayerView(std::
int32_t layer) -> LayerView override - Returns how a layer is shown in the view.
- auto GetStamp() -> TileStamp& override
- Returns the stamp of the brush.
- void SetStamp(TileStamp&& stamp) override
- Sets the stamp of the brush.
- auto GetSelection() -> TileSelection& override
- Returns the selected tiles.
-
void Execute(std::
unique_ptr<EditCommand> command, bool allowMerge = false) override - Executes an edit command.
- void BeginChanges(String name) override
- void EndChanges() override
- Ends changes started by BeginChanges().
-
void PreviewTile(std::
int32_t layer, std:: int32_t x, std:: int32_t y, const TileRef& tile) override - Shows a tile in the view before it's changed in the level.
-
void RevertPreview(std::
int32_t layer, const Recti& area) override - Shows tiles of an area as the level has them, undoing a preview.
-
auto GetTileMap() -> Tiles::
TileMap* override - Returns the shown level, or
nullptr. - auto GetCamera() -> EditorCamera* override
- Returns the camera, or
nullptr. - void ShowMessage(StringView text) override
- auto GetEventBrush() -> EventStamp& override
- Returns the events the event tool places.
- auto GetEventSelection() -> EventSelection& override
- Returns the selected events.
- auto GetEventPreviews() -> EventPreviews& override
- Returns what draws events.
- auto GetAnimTime() const -> float override
- Returns the time animations of the interface are at.
- auto GetSurface() const -> Surface* override
- Returns the surface of the interface, for a tool that shows something over it, or
nullptr. - auto GetSmartTiles() -> SmartTileModel& override
- Returns what knows how the tiles of the default tile set of the level fit together, it starts learning it.
- auto GetTileShapes() -> const TileShapes& override
- Returns the shapes of the masks of the default tile set of the level.
- auto GetHistory() -> CommandHistory&
- Returns the history of the document.
-
void SetCurrentLayer(std::
int32_t layer) - Sets the layer being edited.
-
auto MakePointer(Vector2i cell,
MouseButton button = MouseButton::Left,
std::
int32_t modifiers = 0) const -> ToolPointer - Returns the pointer over the middle of a cell, see FakeToolHost.
-
auto MakePointerAt(Vector2f world,
MouseButton button = MouseButton::Left,
std::
int32_t modifiers = 0) const -> ToolPointer - Returns the pointer at a position in pixels of the level.
-
void Click(EditorTool& tool,
Vector2i cell,
MouseButton button = MouseButton::Left,
std::
int32_t modifiers = 0) - Presses the pointer over a cell and releases it there.
-
void Drag(EditorTool& tool,
Vector2i from,
Vector2i to,
MouseButton button = MouseButton::Left,
std::
int32_t modifiers = 0) - Presses the pointer over a cell, moves it to another one and releases it there.
- auto Undo() -> bool
- Undoes the last change, as the editor does, returns
falseif there was none. - auto Redo() -> bool
- Redoes the last undone change, as the editor does, returns
falseif there was none. - void ClearRecorded()
- Forgets the previews, reverted areas and messages recorded.
Public variables
- SmallVector<PreviewedTile, 0> Previews
- Tiles shown before they were changed, in the order they were.
- SmallVector<RevertedArea, 0> Reverts
- Areas shown again as the level has them, in the order they were.
- SmallVector<String, 0> Messages
- Messages shown, in the order they were.