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 |
|---|---|---|
StringName | key | &"" |
String | label | "" |
Variant | default | null |
PackedStringArray | options | PackedStringArray() |
PackedInt32Array | option_values | PackedInt32Array() |
float | min_value | -65536.0 |
float | max_value | 65536.0 |
float | step | 0.1 |
String | tooltip | "" |
StringName | reference_kind | &"" |
bool | reference_is_list | false |
Methods
| Returns | Method |
|---|---|
int | value_of_option(index: int) |
int | option_of_value(value: int) |
HammeriteBrushPropertyDef | set_range(low: float, high: float, increment: float = 0.1) |
HammeriteBrushPropertyDef | set_tooltip(text: String) |
HammeriteBrushPropertyDef | set_reference(kind: StringName, list: bool = false) |
StringName | short_name() |
String | display_label() |
bool | is_default(value) |
Property descriptions
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.
default
var default: Variant = null
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.
options
var options: PackedStringArray = PackedStringArray()
Non-empty makes this an enum, drawn as a dropdown over these names.
option_values
var option_values: PackedInt32Array = PackedInt32Array()
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.
min_value
var min_value: float = -65536.0
Numeric bounds / granularity for int and float properties. Ignored for other types.
max_value
var max_value: float = 65536.0
The largest value the inspector offers. See min_value.
step
var step: float = 0.1
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.
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().
reference_is_list
var reference_is_list: bool = false
Whether the value holds several names, separated by commas or spaces.
Method descriptions
value_of_option()
func value_of_option(index: int) -> int
What option index stores: its option_values entry, or the index itself.
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_tooltip()
func set_tooltip(text: String) -> HammeriteBrushPropertyDef
Set the inspector tooltip, returning self so declarations chain.
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.
short_name()
func short_name() -> StringName
The un-namespaced name (the part after the schema prefix).
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.