diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-28 15:51:23 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-28 15:51:23 -0400 |
commit | 5a2d1f6f2462636d8389adb46ba3ff237ffe32c7 (patch) | |
tree | 1d42273b7010150e2702b1347f58c6af5ad506c3 /client/Archipelago/messages.gd | |
parent | 6fd6d493cd16b41bf88742ff6f4b7635ec3fa67c (diff) | |
download | lingo2-archipelago-5a2d1f6f2462636d8389adb46ba3ff237ffe32c7.tar.gz lingo2-archipelago-5a2d1f6f2462636d8389adb46ba3ff237ffe32c7.tar.bz2 lingo2-archipelago-5a2d1f6f2462636d8389adb46ba3ff237ffe32c7.zip |
[Client] Added messages overlay
Diffstat (limited to 'client/Archipelago/messages.gd')
-rw-r--r-- | client/Archipelago/messages.gd | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/client/Archipelago/messages.gd b/client/Archipelago/messages.gd new file mode 100644 index 0000000..52f38b9 --- /dev/null +++ b/client/Archipelago/messages.gd | |||
@@ -0,0 +1,61 @@ | |||
1 | extends CanvasLayer | ||
2 | |||
3 | var _message_queue = [] | ||
4 | var _font | ||
5 | var _container | ||
6 | var _ordered_labels = [] | ||
7 | |||
8 | |||
9 | func _ready(): | ||
10 | _container = VBoxContainer.new() | ||
11 | _container.set_name("Container") | ||
12 | _container.anchor_bottom = 1 | ||
13 | _container.offset_left = 20.0 | ||
14 | _container.offset_right = 1920.0 | ||
15 | _container.offset_top = 0.0 | ||
16 | _container.offset_bottom = -20.0 | ||
17 | _container.alignment = BoxContainer.ALIGNMENT_END | ||
18 | _container.mouse_filter = Control.MOUSE_FILTER_IGNORE | ||
19 | self.add_child(_container) | ||
20 | |||
21 | _font = load("res://assets/fonts/Lingo2.ttf") | ||
22 | |||
23 | |||
24 | func _add_message(text): | ||
25 | var new_label = RichTextLabel.new() | ||
26 | new_label.push_font(_font) | ||
27 | new_label.push_font_size(36) | ||
28 | new_label.push_outline_color(Color(0, 0, 0, 1)) | ||
29 | new_label.push_outline_size(2) | ||
30 | new_label.append_text(text) | ||
31 | new_label.fit_content = true | ||
32 | |||
33 | _container.add_child(new_label) | ||
34 | _ordered_labels.push_back(new_label) | ||
35 | |||
36 | |||
37 | func showMessage(text): | ||
38 | if _ordered_labels.size() >= 9: | ||
39 | _message_queue.append(text) | ||
40 | return | ||
41 | |||
42 | _add_message(text) | ||
43 | |||
44 | if _ordered_labels.size() > 1: | ||
45 | return | ||
46 | |||
47 | var timeout = 10.0 | ||
48 | while !_ordered_labels.is_empty(): | ||
49 | await get_tree().create_timer(timeout).timeout | ||
50 | |||
51 | var to_remove = _ordered_labels.pop_front() | ||
52 | var to_tween = get_tree().create_tween().bind_node(to_remove) | ||
53 | to_tween.tween_property(to_remove, "modulate:a", 0.0, 0.5) | ||
54 | to_tween.tween_callback(to_remove.queue_free) | ||
55 | |||
56 | if !_message_queue.is_empty(): | ||
57 | var next_msg = _message_queue.pop_front() | ||
58 | _add_message(next_msg) | ||
59 | |||
60 | if timeout > 4: | ||
61 | timeout -= 3 | ||