HammeriteEditorTool
Editor. Inherits RefCounted
Base class for an editor tool: the one thing the author's clicks and keys go to in the viewports.
A tool is made for one use and thrown away. Construct it with the HammeriteMapEditor and hand it to HammeriteMapEditor.set_active_tool(). While it is active and a view has focus the editor calls _tool_input() for each event and _tool_process() each frame; when it is switched away from, or calls request_exit(), the editor calls _tool_exit() and then release(). Anything it draws over the level goes into gizmos from _tool_process(), every frame.
Properties
| Type | Name | Default |
|---|---|---|
HammeriteEditorCamera | camera | |
HammeriteGizmoBuffer | gizmos | |
HammeriteGrid | grid | |
HammeriteMapEditor | map_editor | |
Viewport | viewport |
Methods
| Returns | Method |
|---|---|
String | _get_manual_page() virtual |
String | _get_status_text() virtual |
String | _get_tool_name() virtual required |
bool | _holds_cursor() virtual |
void | _tool_exit() virtual required |
bool | _tool_input(event: InputEvent) virtual required |
void | _tool_process(delta: float) virtual required |
void | add_popup(popup: Control) |
HammeriteEditorTool | create(editor: HammeriteMapEditor) static |
void | draw_brush_wireframe(brush: HammeriteBrush, color: Color) |
void | draw_face_wireframe(face: HammeriteFace, color: Color) |
void | draw_oriented_box(box: HammeriteOrientedBoundingBox, color: Color) |
void | draw_quad(quad: HammeriteQuad3D, color: Color) |
String | format_number(value: float) static |
String | get_manual_page() |
String | get_status_text() |
String | get_tool_name() |
bool | holds_cursor() |
void | release() |
void | request_exit() |
void | setup(editor: HammeriteMapEditor) |
Plane | surface_facing_viewer(plane: Plane, view_direction: Vector3) static |
void | tool_exit() |
bool | tool_input(event: InputEvent) |
void | tool_process(delta: float) |
Signals
exit_requested
signal exit_requested()
Emitted by request_exit(). The editor connects it when the tool is made active, and answers by putting the select tool back.
Property descriptions
camera
var camera: HammeriteEditorCamera
The focused view's camera, read live from map_editor. Read-only.
gizmos
var gizmos: HammeriteGizmoBuffer
The editor's gizmo buffer for this frame. It starts each frame empty, so a tool draws into it from _tool_process() every frame it wants something shown.
grid
var grid: HammeriteGrid
The editor's snapping grid, read live from map_editor. Read-only.
map_editor
var map_editor: HammeriteMapEditor
The editor the tool was made for.
viewport
var viewport: Viewport
The focused view's SubViewport, read live from map_editor; null while no view has focus. Read-only.
Method descriptions
_get_manual_page()
func _get_manual_page() -> String
Override to name the tool's manual page, as get_manual_page() answers it. The base answers none.
_get_status_text()
func _get_status_text() -> String
Override to say what the tool is doing and what the author can press, as get_status_text() answers it. The base answers nothing.
_get_tool_name()
func _get_tool_name() -> String
Override to name the tool, as get_tool_name() answers it.
_holds_cursor()
func _holds_cursor() -> bool
Override to answer whether the tool is mid-drag, as holds_cursor() answers it. The base answers false.
_tool_exit()
func _tool_exit() -> void
Called once when the tool stops being the active one, before release(): take down anything it put in the scene or the map's previews.
_tool_input()
func _tool_input(event: InputEvent) -> bool
Called for each input event while the tool is active and a view has focus. Return true to consume the event; false lets the editor's own commands and selection handle it.
_tool_process()
func _tool_process(delta: float) -> void
Called every frame while the tool is active and a view has focus. delta is in seconds.
add_popup()
func add_popup(popup: Control) -> void
Shows popup among the tool's options panels. The editor frees every one a tool added when the tool is left.
create()
static func create(editor: HammeriteMapEditor) -> HammeriteEditorTool
Makes the tool for editor, ready to hand to HammeriteMapEditor.set_active_tool(). A native class is made with no arguments, so this stands in for new(editor).
draw_brush_wireframe()
func draw_brush_wireframe(brush: HammeriteBrush, color: Color) -> void
Draw a brush's face wireframes in the perspective view, where a tool previews it. The ortho views draw the brush itself.
draw_face_wireframe()
func draw_face_wireframe(face: HammeriteFace, color: Color) -> void
Outline face in the perspective view, for this frame.
draw_oriented_box()
func draw_oriented_box(box: HammeriteOrientedBoundingBox, color: Color) -> void
Draw box's twelve edges in every view, for this frame.
draw_quad()
func draw_quad(quad: HammeriteQuad3D, color: Color) -> void
Outline quad in every view, for this frame.
format_number()
static func format_number(value: float) -> String
value as a status line says it: 16, not 16.0, and 7.5 as it is.
get_manual_page()
func get_manual_page() -> String
The manual page about this tool, as <section>/<page>.md. Opening the manual while the tool is active opens it there.
get_status_text()
func get_status_text() -> String
What the tool is doing right now, and what the author can do about it. One short line, shown after the tool name in the viewport status label. Empty when the tool has nothing to add.
get_tool_name()
func get_tool_name() -> String
Name of the tool, as the viewport status label says it.
holds_cursor()
func holds_cursor() -> bool
Whether the tool is in the middle of a drag. While it is, the cursor is kept in the view the drag began in: a 2D view pans when the cursor reaches its edge, and the 3D view wraps it round to the other side. A tool following the cursor through HammeriteTransformHelper needs to do nothing else.
release()
func release() -> void
Let go of the tool's own history. UndoRedo holds every reference-counted object whose method it records, this tool's included, so a tool with any history would outlive the editor's last use of it; the editor calls this when it lets a tool go.
request_exit()
func request_exit() -> void
Ask the editor to stop this tool and return to the select tool. Emits exit_requested.
setup()
func setup(editor: HammeriteMapEditor) -> void
Binds a tool made with new() to editor: what create() does after making one. A script extending this calls it from its own _init where it called super(editor).
surface_facing_viewer()
static func surface_facing_viewer(plane: Plane, view_direction: Vector3) -> Plane
plane turned towards whoever is looking along view_direction: the side of the surface the author can see, which is the side anything built or placed on it belongs on.
Not the face's own normal. That points out of the face's brush, and a room is an air brush, so on a room's floor it points down into the rock: what followed it built stairs downwards into solid and put prefabs under the floor. A filled brush is meshed from both sides, so asking the brush which side is open cannot be right for all of them; the side being looked at always is.
tool_exit()
func tool_exit() -> void
Lets the tool take itself down: _tool_exit(), a script's override where it has one. What the editor calls as the tool is left.
tool_input()
func tool_input(event: InputEvent) -> bool
Hands event to the tool: _tool_input(), a script's override where it has one. What the editor calls; returns whether the event was consumed.
tool_process()
func tool_process(delta: float) -> void
Runs one frame of the tool: _tool_process(), a script's override where it has one. What the editor calls.