2018-10-09 07:24:44 +02:00
|
|
|
tool
|
|
|
|
extends HBoxContainer
|
|
|
|
|
2019-10-26 13:51:15 +02:00
|
|
|
func update_up_down_button() -> void:
|
|
|
|
var parent = get_parent()
|
|
|
|
if parent == null:
|
|
|
|
return
|
|
|
|
$Up.disabled = (get_index() == 0)
|
|
|
|
$Down.disabled = (get_index() == get_parent().get_child_count()-2)
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func set_model_data(data) -> void:
|
2018-11-11 19:18:26 +01:00
|
|
|
$Name.text = data.name
|
|
|
|
$Label.text = data.label
|
|
|
|
if data.type == "rgb":
|
|
|
|
$Type.selected = 1
|
|
|
|
elif data.type == "rgba":
|
|
|
|
$Type.selected = 2
|
2019-12-15 12:41:00 +01:00
|
|
|
elif data.type == "sdf2d":
|
|
|
|
$Type.selected = 3
|
|
|
|
elif data.type == "sdf3d":
|
|
|
|
$Type.selected = 4
|
2018-11-11 19:18:26 +01:00
|
|
|
else:
|
|
|
|
$Type.selected = 0
|
|
|
|
$Default.text = data.default
|
2019-12-15 12:41:00 +01:00
|
|
|
$Function.pressed = data.has("function") and data.function
|
2018-11-11 19:18:26 +01:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_model_data() -> Dictionary:
|
2018-11-11 19:18:26 +01:00
|
|
|
var data = { name=$Name.text, label=$Label.text, default=$Default.text }
|
|
|
|
if $Type.selected == 1:
|
|
|
|
data.type = "rgb"
|
|
|
|
elif $Type.selected == 2:
|
|
|
|
data.type = "rgba"
|
2019-12-15 12:41:00 +01:00
|
|
|
elif $Type.selected == 3:
|
|
|
|
data.type = "sdf2d"
|
|
|
|
elif $Type.selected == 4:
|
|
|
|
data.type = "sdf3d"
|
2018-11-11 19:18:26 +01:00
|
|
|
else:
|
|
|
|
data.type = "f"
|
2019-12-15 12:41:00 +01:00
|
|
|
if $Function.pressed:
|
|
|
|
data.function = true
|
2018-11-11 19:18:26 +01:00
|
|
|
return data
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _on_Delete_pressed() -> void:
|
2019-10-26 13:51:15 +02:00
|
|
|
var p = get_parent()
|
|
|
|
p.remove_child(self)
|
|
|
|
p.update_up_down_buttons()
|
2018-10-09 07:24:44 +02:00
|
|
|
queue_free()
|
2019-10-26 13:51:15 +02:00
|
|
|
|
|
|
|
func _on_Up_pressed() -> void:
|
|
|
|
get_parent().move_child(self, get_index() - 1)
|
|
|
|
get_parent().update_up_down_buttons()
|
|
|
|
|
|
|
|
func _on_Down_pressed() -> void:
|
|
|
|
get_parent().move_child(self, get_index() + 1)
|
|
|
|
get_parent().update_up_down_buttons()
|