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.
This commit is contained in:
Mario Steele 2026-03-02 02:06:01 -06:00
parent d44f1dbfb5
commit 9206793ebc

View file

@ -2,11 +2,25 @@ extends Node
var ol: OverlayWindow var ol: OverlayWindow
var _queue: Array[Alert] = []
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: 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: func test_notification(msg: String) -> void:
var lbl = Label.new() var lbl = Label.new()