2018-10-09 07:24:44 +02:00
|
|
|
tool
|
|
|
|
extends HBoxContainer
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _ready() -> void:
|
2018-10-28 16:26:37 +01:00
|
|
|
$Type.clear()
|
|
|
|
for t in $Types.get_children():
|
|
|
|
$Type.add_item(t.name)
|
|
|
|
_on_Type_item_selected($Type.selected)
|
2018-10-13 17:31:37 +02:00
|
|
|
|
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-10-09 07:24:44 +02:00
|
|
|
if data.has("name"):
|
|
|
|
$Name.text = data.name
|
|
|
|
if data.has("label"):
|
|
|
|
$Label.text = data.label
|
|
|
|
if !data.has("type"):
|
|
|
|
return
|
2018-10-28 16:26:37 +01:00
|
|
|
var type = $Types.get_node(data.type)
|
|
|
|
type.set_model_data(data)
|
|
|
|
var selected = type.get_index()
|
|
|
|
$Type.selected = selected
|
|
|
|
_on_Type_item_selected(selected)
|
2018-10-09 07:24:44 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_model_data() -> Dictionary:
|
2018-10-28 16:26:37 +01:00
|
|
|
var data = $Types.get_node($Type.get_item_text($Type.selected)).get_model_data()
|
|
|
|
data.name=$Name.text
|
|
|
|
data.label=$Label.text
|
|
|
|
data.type=$Type.get_item_text($Type.selected)
|
2018-10-09 07:24:44 +02: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()
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _on_Type_item_selected(ID) -> void:
|
2018-10-28 16:26:37 +01:00
|
|
|
for t in $Types.get_children():
|
|
|
|
t.visible = false
|
|
|
|
var t = $Types.get_child(ID)
|
|
|
|
if t != null:
|
|
|
|
t.visible = true
|
2018-10-26 22:44:47 +02:00
|
|
|
else:
|
2018-10-28 16:26:37 +01:00
|
|
|
print(ID)
|