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:
parent
d44f1dbfb5
commit
9206793ebc
1 changed files with 15 additions and 1 deletions
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue