2019-10-20 11:33:33 +02:00
|
|
|
extends Popup
|
|
|
|
|
|
|
|
signal item_double_clicked(generator)
|
|
|
|
|
2020-02-08 09:37:46 +01:00
|
|
|
onready var tree = $Tree
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func init(graph_name : String, generator : MMGenGraph) -> void:
|
2020-02-08 09:37:46 +01:00
|
|
|
tree.clear()
|
|
|
|
var root : TreeItem = tree.create_item(null)
|
2019-10-20 11:33:33 +02:00
|
|
|
root.set_text(0, graph_name)
|
2019-10-22 08:28:24 +02:00
|
|
|
root.set_custom_color(0, Color(1, 1, 1))
|
2019-10-20 11:33:33 +02:00
|
|
|
root.set_metadata(0, generator)
|
|
|
|
fill_item(root, generator)
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func fill_item(parent : TreeItem, generator : MMGenGraph) -> void:
|
2019-10-20 11:33:33 +02:00
|
|
|
for c in generator.get_children():
|
|
|
|
if c is MMGenGraph:
|
2020-02-08 09:37:46 +01:00
|
|
|
var item : TreeItem = tree.create_item(parent)
|
2019-10-20 11:33:33 +02:00
|
|
|
item.set_text(0, c.get_type_name())
|
2019-10-22 08:28:24 +02:00
|
|
|
if c.is_editable():
|
|
|
|
item.set_custom_color(0, Color(1, 1, 1))
|
2019-10-20 11:33:33 +02:00
|
|
|
item.set_metadata(0, c)
|
|
|
|
fill_item(item, c)
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _on_Tree_item_double_clicked() -> void:
|
2020-02-08 09:37:46 +01:00
|
|
|
emit_signal("item_double_clicked", tree.get_selected().get_metadata(0))
|
2019-10-20 11:33:33 +02:00
|
|
|
queue_free()
|