2022-05-14 20:51:48 +02:00
extends PanelContainer
onready var text_edit = get_node ( " MarginContainer/ContentFitTextEdit " )
onready var message_denied_sound = get_node ( " MessageDeniedSound " )
func _ready ( ) :
# warning-ignore:return_value_discarded
Users . connect ( " switched " , self , " _on_user_switched " )
2022-06-05 14:22:08 +02:00
func _input ( event ) :
if not text_edit . has_focus ( ) or not text_edit . text . empty ( ) :
return
if event is InputEventKey and event . scancode == KEY_UP :
if event . is_pressed ( ) and not event . is_echo ( ) :
Data . messages . get_last_message_of_user (
Users . get_current ( )
) . associated_node . _enable_edit_mode ( )
2022-05-14 20:51:48 +02:00
func _on_message_box_confirmed ( content ) :
if PingSystem . unhandled_ping_count == 0 and not content . empty ( ) :
text_edit . text = " "
text_edit . _on_text_changed ( ) # To go back to minimum height.
else :
message_denied_sound . play ( )
func _on_user_switched ( ) :
Users . get_inactive ( ) . message_box_content = text_edit . text
text_edit . text = Users . get_current ( ) . message_box_content
text_edit . _on_text_changed ( ) # To adjust height.
text_edit . select_all ( )