mirror of
https://github.com/Relintai/gdfxr.git
synced 2025-04-28 09:45:02 +02:00
45 lines
827 B
GDScript
45 lines
827 B
GDScript
@tool
|
|
extends HBoxContainer
|
|
|
|
signal param_changed(name, value)
|
|
signal param_reset(name)
|
|
|
|
@export var options: Array :
|
|
set = set_options
|
|
@export var parameter: String # Could be PackedStringArray, but pybabel won't catch that
|
|
|
|
@onready var option_button := $OptionButton as OptionButton
|
|
|
|
|
|
func _ready():
|
|
set_options(options)
|
|
|
|
|
|
func set_options(v: Array) -> void:
|
|
options = v
|
|
|
|
if is_inside_tree():
|
|
option_button.clear()
|
|
for item in options:
|
|
option_button.add_item(item)
|
|
|
|
|
|
func set_value(v: int) -> void:
|
|
option_button.select(v)
|
|
|
|
|
|
func get_value() -> int:
|
|
return option_button.selected
|
|
|
|
|
|
func set_resetable(v: bool) -> void:
|
|
$Reset.disabled = not v
|
|
|
|
|
|
func _on_OptionButton_item_selected(index: int):
|
|
emit_signal("param_changed", parameter, index)
|
|
|
|
|
|
func _on_Reset_pressed():
|
|
emit_signal("param_reset", parameter)
|