StreamOverlay/lib/event_manager.gd
Mario Steele b47df7ad86 Updated EventManager
Fixed warning about losing percision on a float.
2026-03-06 21:22:36 -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.0
lbl.position = Vector2(get_tree().root.size / 2.0) - 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)