extends VBoxContainer # warning-ignore:unused_signal signal topic_node_added(topic_node) const ADD_BUTTON = preload("res://user_interface/topic_panel/add_button.tscn") var currently_grabbed_topic = null var selected_topics = [] # For multi-selection. var _shift_hold = false var _toggle_selection_result func _ready(): # warning-ignore:return_value_discarded Data.topics.connect("topic_added", self, "_on_data_topic_added") # warning-ignore:return_value_discarded Data.topics.connect("topic_inserted", self, "_on_data_topic_inserted") # warning-ignore:return_value_discarded Data.connect("loaded", self, "_on_data_loaded") func _input(event): if event is InputEventKey: if event.scancode == KEY_DELETE and !event.is_pressed(): _delete_selected_topics() func set_all_previous_positions(): for topic in get_children(): if topic is TopicDraggable: if topic != currently_grabbed_topic: topic.set_previous_position() func check_all_passings(): if currently_grabbed_topic == null: return var did_passing_occur = false for topic in get_children(): if topic is TopicDraggable: if topic != currently_grabbed_topic: if topic.check_for_passing(): did_passing_occur = true if did_passing_occur: yield(get_tree(), "idle_frame") setup_all_tweens() func setup_all_tweens(): for topic in get_children(): if topic is TopicDraggable: if topic != currently_grabbed_topic: topic.setup_tween() func update_all_colors(): for topic in get_children(): if topic is TopicDraggable: topic.editable._update_color() func _delete_selected_topics(): for topic in selected_topics: topic.editable.associated_topic.get_ref().delete() selected_topics.clear() func _change_type_of_selected_topics(type: int): for topic in selected_topics: topic.editable.associated_topic.get_ref().change_type(type) topic.editable._adjust_appearance_to_user() selected_topics.clear() update_all_colors() func _on_data_topic_added(topic): var topic_node = topic.create_node() add_child(topic_node) topic_node.editable._adjust_appearance_to_user() func _on_data_topic_inserted(topic, position): var topic_node = topic.create_node() add_child(topic_node) move_child(topic_node, position) topic_node.editable._adjust_appearance_to_user() func _on_data_loaded(): add_child(ADD_BUTTON.instance())