2024-01-28 21:08:08 +00:00
|
|
|
extends LineEdit
|
|
|
|
|
2024-02-16 22:45:31 +00:00
|
|
|
func _ready():
|
|
|
|
modulate.a = 0.0
|
2024-02-25 18:47:13 +00:00
|
|
|
focus_entered.connect(on_focus_entered)
|
|
|
|
focus_exited.connect(on_focus_exited)
|
|
|
|
text_submitted.connect(on_text_submitted)
|
2024-02-16 22:45:31 +00:00
|
|
|
|
2024-02-27 22:21:44 +00:00
|
|
|
func _unhandled_key_input(event: InputEvent):
|
2024-02-25 18:47:13 +00:00
|
|
|
if UI.focus:
|
2024-01-28 21:08:08 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
if event.is_action_pressed("open_chat"):
|
|
|
|
call_deferred("grab_focus")
|
2024-01-29 11:32:06 +00:00
|
|
|
get_viewport().set_input_as_handled()
|
2024-01-28 21:08:08 +00:00
|
|
|
|
2024-02-25 18:47:13 +00:00
|
|
|
func on_focus_entered():
|
2024-02-16 22:45:31 +00:00
|
|
|
var tween := get_tree().create_tween()
|
|
|
|
tween.tween_property(self, "modulate", Color(1, 1, 1, 1), 0.2)
|
2024-01-28 21:08:08 +00:00
|
|
|
|
2024-02-25 18:47:13 +00:00
|
|
|
func on_focus_exited():
|
2024-02-16 22:45:31 +00:00
|
|
|
var tween := get_tree().create_tween()
|
|
|
|
tween.tween_property(self, "modulate", Color(1, 1, 1, 0), 0.2)
|
2024-01-28 21:08:08 +00:00
|
|
|
|
2024-02-25 18:47:13 +00:00
|
|
|
func on_text_submitted(message: String):
|
2024-01-28 21:08:08 +00:00
|
|
|
text = ""
|
|
|
|
release_focus()
|
2024-02-27 20:05:55 +00:00
|
|
|
|
2024-02-28 12:23:17 +00:00
|
|
|
if !message:
|
|
|
|
return
|
|
|
|
|
2024-02-27 20:05:55 +00:00
|
|
|
var chat := owner as Chat
|
|
|
|
chat.message_submitted.emit(message)
|