diff --git a/lib/event_manager.gd b/lib/event_manager.gd index 276a2f48..c482ec3e 100644 --- a/lib/event_manager.gd +++ b/lib/event_manager.gd @@ -2,11 +2,25 @@ extends Node var ol: OverlayWindow +var _queue: Array[Alert] = [] # Called when the node enters the scene tree for the first time. func _ready() -> void: - ol = get_tree().root.get_node("MainWin") + 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()