StreamOverlay/lib/event_manager.gd
Mario Steele 9206793ebc Updated EventManager
Added queue for alerts, so that they aren't all firing off in one time.
Updated ready to check if the root has the MainWin node (When running a
specific scene, may not be present)
Added function to queue up alert, and processing of queued alerts.
2026-03-02 02:06:01 -06:00

43 lines
1.2 KiB
GDScript

extends Node
var ol: OverlayWindow
var _queue: Array[Alert] = []
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
if get_tree().root.has_node("MainWin"):
ol = get_tree().root.get_node("MainWin")
func add_alert(alert: Alert) -> void:
if get_children().any(func(x): return x is Alert):
_queue.append(alert)
else:
add_child(alert)
func _process(_d: float) -> void:
if _queue.is_empty(): return
if get_children().any(func(x): return x is Alert):
return
var alert: Alert = _queue.pop_front()
add_child(alert)
func test_notification(msg: String) -> void:
var lbl = Label.new()
lbl.label_settings = LabelSettings.new()
lbl.label_settings.font_size = 75
lbl.label_settings.font_color = Color.DODGER_BLUE
lbl.text = msg
lbl.modulate.a = 0
lbl.ready.connect(func() -> void:
var half: Vector2 = lbl.size / 2
lbl.position = Vector2(get_tree().root.size / 2) - half
var tw := create_tween()
tw.tween_property(lbl, "modulate:a", 1.0, 0.5)
tw.tween_interval(2.5)
tw.parallel().tween_property(lbl, "position:y", get_tree().root.size.y + 10, 3.0)
tw.parallel().tween_property(lbl, "modulate:a", 0, 3.0)
await tw.finished
lbl.queue_free()
)
add_child(lbl)