2022-05-14 20:51:48 +02:00
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 ( )
2022-06-04 13:33:00 +02:00
message . associated_message_group . get_ref ( ) . associated_container . add ( node )
2022-05-14 20:51:48 +02:00
scroll_to_newest ( )
func _on_data_message_group_added ( message_group ) :
var container = message_group . create_container ( )
message_feed_container . add_child ( container )