2022-05-14 20:51:48 +02:00
extends Reference
class_name Message
const MESSAGE_NODE = preload ( " res://user_interface/chat_panel/message_node.tscn " )
var associated_node : Control
2022-06-04 13:33:00 +02:00
var associated_message_group : WeakRef
2022-05-14 20:51:48 +02:00
var content : String
var time_stamp : int
func get_user ( ) - > User :
2022-06-04 13:33:00 +02:00
return associated_message_group . get_ref ( ) . associated_user
2022-05-14 20:51:48 +02:00
func delete ( ) :
2022-06-04 13:33:00 +02:00
associated_message_group . get_ref ( ) . delete ( self )
Data . messages . dirty_flag = true
2022-06-05 14:22:08 +02:00
Data . messages . message_count -= 1
2022-06-04 13:33:00 +02:00
func edit ( new_content : String ) :
content = new_content
Data . messages . dirty_flag = true
2022-05-14 20:51:48 +02:00
# Used by the MessageFeed, to spawn message nodes.
func create_node ( ) - > Control :
var message_node = MESSAGE_NODE . instance ( )
associated_node = message_node
2022-06-04 13:33:00 +02:00
message_node . associated_message = weakref ( self )
if associated_message_group :
if associated_message_group . get_ref ( ) . messages . size ( ) > 1 :
message_node . follow_up = true
2022-05-14 20:51:48 +02:00
return message_node