diary/user_interface/topic_panel/topic_feed.gd

83 lines
1.8 KiB
GDScript3
Raw Permalink Normal View History

extends VBoxContainer
# warning-ignore:unused_signal
signal topic_node_added(topic_node)
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")
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():
2022-05-21 14:56:02 +02:00
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():
2022-05-21 14:56:02 +02:00
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():
2022-05-21 14:56:02 +02:00
if topic is TopicDraggable:
if topic != currently_grabbed_topic:
topic.setup_tween()
func update_all_colors():
for topic in get_children():
2022-05-21 14:56:02 +02:00
if topic is TopicDraggable:
topic.editable._update_color()
func _delete_selected_topics():
for topic in selected_topics:
2022-05-21 14:56:02 +02:00
topic.editable.associated_topic.delete()
selected_topics.clear()
2022-05-21 14:56:02 +02:00
func _change_type_of_selected_topics(type: int):
for topic in selected_topics:
topic.editable.associated_topic.change_type(type)
topic.editable._adjust_appearance_to_user()
selected_topics.clear()
update_all_colors()
func _on_data_topic_added(topic, position):
var topic_node = topic.create_node()
add_child(topic_node)
2022-05-21 14:56:02 +02:00
move_child(topic_node, position)
topic_node.editable._adjust_appearance_to_user()