41 lines
1.2 KiB
GDScript3
41 lines
1.2 KiB
GDScript3
|
extends PanelContainer
|
||
|
|
||
|
|
||
|
onready var v_scroll = get_node("MarginContainer/ScrollContainer/_v_scroll")
|
||
|
onready var margin_container = get_node("MarginContainer/ScrollContainer/MarginContainer")
|
||
|
onready var message_feed_container = get_node("MarginContainer/ScrollContainer/MarginContainer/MessageFeedContainer")
|
||
|
|
||
|
|
||
|
func _ready():
|
||
|
# warning-ignore:return_value_discarded
|
||
|
Data.messages.connect(
|
||
|
"message_added", self, "_on_data_message_added"
|
||
|
)
|
||
|
# warning-ignore:return_value_discarded
|
||
|
Data.messages.connect(
|
||
|
"message_group_added", self, "_on_data_message_group_added"
|
||
|
)
|
||
|
|
||
|
|
||
|
func scroll_to_newest():
|
||
|
yield(get_tree(), "idle_frame")
|
||
|
v_scroll.value = margin_container.rect_size.y
|
||
|
|
||
|
|
||
|
func _on_message_box_confirmed(content):
|
||
|
if PingSystem.unhandled_ping_count == 0 and not content.empty():
|
||
|
Data.messages.add_message(
|
||
|
content, Time.get_current_time(), Users.get_current()
|
||
|
)
|
||
|
|
||
|
|
||
|
func _on_data_message_added(message):
|
||
|
var node = message.create_node()
|
||
|
message.associated_message_group.associated_container.add(node)
|
||
|
scroll_to_newest()
|
||
|
|
||
|
|
||
|
func _on_data_message_group_added(message_group):
|
||
|
var container = message_group.create_container()
|
||
|
message_feed_container.add_child(container)
|