1using Fjord.Graphics;
2using Fjord.Scenes;
3using Fjord.Ui;
4
5public class Notification
6{
7 public string Message;
8 public float Life;
9
10 public Notification(string message, float life)
11 {
12 this.Message = message;
13 this.Life = life;
14 }
15}
16
17public class NotificationScene : Scene
18{
19 public List<Notification> Notifications = new();
20
21 public NotificationScene(int width, int height) : base(width, height)
22 {
23 }
24
25 public override void Awake()
26 {
27 ClearColor = new(0, 0, 0, 0);
28 CaptureMouseInput = false;
29 }
30
31 public override void Sleep()
32 {
33
34 }
35
36 public override void Update()
37 {
38 foreach(var notif in Notifications)
39 {
40 notif.Life -= 5 * DeltaTime;
41 }
42
43 List<string> removeList = new();
44 new UiBuilder()
45 .ForEach(Notifications, e => {
46 if(e.Life < 0)
47 removeList.Add(e.Message);
48 return new UiBuilder()
49 .Button(e.Message, () => {
50 removeList.Add(e.Message);
51 })
52 .Build();
53 })
54 .Render();
55
56 removeList.ForEach(e => Notifications.RemoveAll(n => n.Message == e));
57 }
58}