From 9206793ebcc0c2cc2d3e298f7eafdafc7db14b92 Mon Sep 17 00:00:00 2001 From: Mario Steele Date: Mon, 2 Mar 2026 02:06:01 -0600 Subject: [PATCH] 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. --- lib/event_manager.gd | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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()