HammeriteBrushPropertyDef
Core: files, names and extension. Inherits RefCounted
One extendable property an addon has declared, on a brush or on the sky.
A def is the whole description of an authorable value: its key, its default, and enough of a hint for the editor to build the right control. It is NOT storage - the value lives sparsely in HammeriteBrush.properties, and a brush that has never been touched stores nothing at all and reads default straight off this def. Defs are created through HammeriteBrushPropertySchema.add(), never directly, so the key always carries its schema's namespace prefix (audio/zone_type) and two addons can never collide.
Properties
| Type | Name | Default |
|---|---|---|
Variant | default | |
StringName | key | |
String | label | |
float | max_value | |
float | min_value | |
Variant | option_values | |
Variant | options | |
bool | reference_is_list | |
StringName | reference_kind | |
float | step | |
String | tooltip |
Methods
| Returns | Method |
|---|---|
String | display_label() const |
bool | is_default(value) const |
int | option_of_value(value: int) const |
HammeriteBrushPropertyDef | set_range(low: float, high: float, increment: float = 0.1) |
HammeriteBrushPropertyDef | set_reference(kind: StringName, list: bool = false) |
HammeriteBrushPropertyDef | set_tooltip(text: String) |
StringName | short_name() const |
int | value_of_option(index: int) const |
Property descriptions
default
var default: Variant
Value used by every brush that has not overridden this property. Also decides the property's TYPE: the editor builds its control from typeof(default), so an int default with options set becomes a dropdown, a float becomes a spinbox, and so on.
key
var key: StringName
Namespaced key, <schema id>/<name> - the key used in HammeriteBrush.properties.
label
var label: String
Human-readable label for the editor row. Falls back to the un-namespaced name.
max_value
var max_value: float
The largest value the inspector offers. See min_value.
min_value
var min_value: float
Numeric bounds / granularity for int and float properties. Ignored for other types.
option_values
var option_values: Variant
What each of options STORES, where that is not its position in the list. Empty - the usual case - means the value is the index. It exists because a position is not an identity: a dropdown whose entries come from a table a game can add to renumbers every entry after the one added, and a map that stored 3 now means something else. Give the options stable ids here and what is stored survives the list changing. The audio addon's reverb preset is the worked example.
options
var options: Variant
Non-empty makes this an enum, drawn as a dropdown over these names.
reference_is_list
var reference_is_list: bool
Whether the value holds several names, separated by commas or spaces.
reference_kind
var reference_kind: StringName
The kind of thing the value names (HammeriteReferences) - a sound, a texture - or empty for a value that names nothing. Set with set_reference().
step
var step: float
The granularity the inspector steps and snaps by. See min_value.
tooltip
var tooltip: String
Tooltip shown on the property's label in the inspector.
Method descriptions
display_label()
func display_label() -> String
The label to show, falling back to the short name when none was given.
is_default()
func is_default(value) -> bool
True when value is this property's default, i.e. storing it on a brush would be redundant. Compared by value, so an int 0 and a float 0.0 are NOT the same default - a def's type is fixed by its default and the editor never produces the other one.
option_of_value()
func option_of_value(value: int) -> int
Which option stores value, or -1 for a value no option offers.
set_range()
func set_range(low: float, high: float, increment: float = 0.1) -> HammeriteBrushPropertyDef
Set numeric bounds and granularity, returning self so declarations chain off HammeriteBrushPropertySchema.add().
set_reference()
func set_reference(kind: StringName, list: bool = false) -> HammeriteBrushPropertyDef
Say the value names a thing of kind (HammeriteReferences), so a map records who provided it and is told when that changes. Returns self so declarations chain.
set_tooltip()
func set_tooltip(text: String) -> HammeriteBrushPropertyDef
Set the inspector tooltip, returning self so declarations chain.
short_name()
func short_name() -> StringName
The un-namespaced name (the part after the schema prefix).
value_of_option()
func value_of_option(index: int) -> int
What option index stores: its option_values entry, or the index itself.