extends Control @onready var label := %RichTextLabel as RichTextLabel var pending_notifications = [] var tweening := false func _ready() -> void: modulate = Color(1, 1, 1, 0) # test notification in editor if GlobalConfig.DEBUG: call_deferred("test") func test(): show_notification("Hello, 1!", 42) show_notification("Hello, 2! very very long message, very very loooonnnggggggg!", 2) show_notification("Hello, 3!", 24) func show_notification(msg, number): if tweening: pending_notifications.append([msg, number]) else: label.text = msg tweening = true var tween = create_tween() # 0.5s to show the notification tween.tween_property(self, "modulate:a", 1, 0.5).set_trans(Tween.TRANS_CUBIC) # keep the notification if pending_notifications.size() > 0: tween.tween_interval(2) else: tween.tween_interval(3) # 0.5s to hide the notification tween.tween_property(self, "modulate:a", 0, 0.5).set_trans(Tween.TRANS_CUBIC) # callback tween.tween_callback(self._check_next) func _check_next(): tweening = false if pending_notifications.size() > 0: var n = pending_notifications.pop_front() show_notification(n[0], n[1])