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

TypeNameDefault
HammeriteMapEditormap_editornull
Viewportviewportnull
HammeriteEditorCameracameranull
HammeriteGridgridnull
HammeriteGizmoBuffergizmosnull

Methods

ReturnsMethod
voidrelease()
Stringformat_number(value: float) static
Stringget_tool_name() abstract
Stringget_status_text()
Stringget_manual_page()
voidrequest_exit()
Viewportget_viewport()
HammeriteEditorCameraget_camera()
HammeriteGridget_grid()
Planesurface_facing_viewer(plane: Plane, view_direction: Vector3) static
voidadd_popup(popup: Control)
voiddraw_brush_wireframe(brush: HammeriteBrush, color: Color)
voiddraw_face_wireframe(face: HammeriteFace, color: Color)
voiddraw_quad(quad: HammeriteQuad3D, color: Color)
voiddraw_oriented_box(box: HammeriteOrientedBoundingBox, color: Color)

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

map_editor

var map_editor: HammeriteMapEditor = null

The editor the tool was made for.

viewport

var viewport: Viewport = null

The focused view's SubViewport, read live from map_editor; null while no view has focus. Read-only.

camera

var camera: HammeriteEditorCamera = null

The focused view's camera, read live from map_editor. Read-only.

grid

var grid: HammeriteGrid = null

The editor's snapping grid, read live from map_editor. Read-only.

gizmos

var gizmos: HammeriteGizmoBuffer = null

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.

Method descriptions

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.

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_tool_name()

abstract func get_tool_name() -> String

Name of the tool, as the viewport status label says it.

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_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.

request_exit()

func request_exit() -> void

Ask the editor to stop this tool and return to the select tool. Emits exit_requested.

get_viewport()

func get_viewport() -> Viewport

Getter for viewport.

get_camera()

func get_camera() -> HammeriteEditorCamera

Getter for camera.

get_grid()

func get_grid() -> HammeriteGrid

Getter for grid.

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.

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.

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_quad()

func draw_quad(quad: HammeriteQuad3D, color: Color) -> void

Outline quad in every 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.

class SimpleToolPopup

A small options panel for a tool: a title and a column of typed fields and buttons. Hand it to add_popup().

Properties

TypeNameDefault
Dictionary[StringName, Control]field_inputs{}
Labeltitle_label
VBoxContainercontent_container

Methods

ReturnsMethod
voidset_title(title: String)
voidadd_separator()
voidadd_field(name: StringName, default_value, label: String, disabled: bool = false)
Buttonadd_button(name: StringName, label: String)
Labeladd_note(text: String)
boolhas_field(name: StringName)
voidset_value(name: StringName, value)

Signals

value_changed

signal value_changed(name: StringName, new_value)

The author changed field name to new_value: an int, float, String or bool, matching the field's default.

button_pressed

signal button_pressed(name: StringName)

The button added as name by add_button() was pressed.

Property descriptions

field_inputs

var field_inputs: Dictionary[StringName, Control] = {}

Each field's control by name: a SpinBox, LineEdit or CheckBox. The popup's own dictionary.

title_label

var title_label: Label

Shows the text given to set_title().

content_container

var content_container: VBoxContainer

The column everything is added to, title first.

Method descriptions

set_title()

func set_title(title: String) -> void

Sets the text at the top of the popup.

add_separator()

func add_separator() -> void

Adds a horizontal rule below what is there so far.

add_field()

func add_field(name: StringName, default_value, label: String, disabled: bool = false) -> void

Adds a labelled field named name, its control chosen by default_value's type: a SpinBox for int or float (range ±65536), a LineEdit for String, a CheckBox for bool. Any other type is an error. Changes emit value_changed.

add_button()

func add_button(name: StringName, label: String) -> Button

A tool parameter that is an action rather than a value, e.g. rotating what is being drawn. Emits button_pressed with name.

add_note()

func add_note(text: String) -> Label

A line of explanation, for when what a tool does depends on state that is not in the popup.

has_field()

func has_field(name: StringName) -> bool

Whether a field named name has been added.

set_value()

func set_value(name: StringName, value) -> void

Shows value in field name without emitting value_changed. Does nothing for a name with no field.

Hammerite 1.0 · built from a6dd634, 2026-10-10