diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-28 00:09:55 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-28 00:09:55 -0400 |
commit | 7446b4accb7b456d5ada064dab607b64e11c2895 (patch) | |
tree | d6f59a21de7ca0bc837bbe95b4de7cb4e4e87667 /Archipelago/messages.gd | |
parent | a33a7e1e60c48d61a42c540fd5083a3b0dc07b6e (diff) | |
download | lingo-archipelago-7446b4accb7b456d5ada064dab607b64e11c2895.tar.gz lingo-archipelago-7446b4accb7b456d5ada064dab607b64e11c2895.tar.bz2 lingo-archipelago-7446b4accb7b456d5ada064dab607b64e11c2895.zip |
Item names are colored by type in messages
The messages node is now a vertical box container with individual RichTextLabels for each line.
Diffstat (limited to 'Archipelago/messages.gd')
-rw-r--r-- | Archipelago/messages.gd | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/Archipelago/messages.gd b/Archipelago/messages.gd index 3a2b4b2..d5589ef 100644 --- a/Archipelago/messages.gd +++ b/Archipelago/messages.gd | |||
@@ -1,54 +1,60 @@ | |||
1 | extends Node | 1 | extends Node |
2 | 2 | ||
3 | var _message_queue = [] | 3 | var _message_queue = [] |
4 | var _font | ||
5 | var _container | ||
6 | var _ordered_labels = [] | ||
4 | 7 | ||
5 | 8 | ||
6 | func _ready(): | 9 | func _ready(): |
7 | var label = Label.new() | 10 | _container = VBoxContainer.new() |
8 | label.set_name("label") | 11 | _container.set_name("Container") |
9 | label.margin_right = 1920.0 | 12 | _container.anchor_bottom = 1 |
10 | label.margin_bottom = 1080.0 - 20 | 13 | _container.margin_left = 20.0 |
11 | label.margin_left = 20.0 | 14 | _container.margin_right = 1920.0 |
12 | label.align = Label.ALIGN_LEFT | 15 | _container.margin_top = 0.0 |
13 | label.valign = Label.VALIGN_BOTTOM | 16 | _container.margin_bottom = -20.0 |
14 | 17 | _container.alignment = BoxContainer.ALIGN_END | |
15 | var dynamic_font = DynamicFont.new() | 18 | _container.mouse_filter = Control.MOUSE_FILTER_IGNORE |
16 | dynamic_font.font_data = load("res://fonts/Lingo.ttf") | 19 | self.add_child(_container) |
17 | dynamic_font.size = 36 | 20 | |
18 | dynamic_font.outline_color = Color(0, 0, 0, 1) | 21 | _font = DynamicFont.new() |
19 | dynamic_font.outline_size = 2 | 22 | _font.font_data = load("res://fonts/Lingo.ttf") |
20 | label.add_font_override("font", dynamic_font) | 23 | _font.size = 36 |
21 | 24 | _font.outline_color = Color(0, 0, 0, 1) | |
22 | add_child(label) | 25 | _font.outline_size = 2 |
26 | |||
27 | |||
28 | func _add_message(text): | ||
29 | var new_label = RichTextLabel.new() | ||
30 | new_label.push_font(_font) | ||
31 | new_label.append_bbcode(text) | ||
32 | new_label.fit_content_height = true | ||
33 | |||
34 | _container.add_child(new_label) | ||
35 | _ordered_labels.push_back(new_label) | ||
23 | 36 | ||
24 | 37 | ||
25 | func showMessage(text): | 38 | func showMessage(text): |
26 | var label = self.get_node("label") | 39 | if _ordered_labels.size() >= 9: |
27 | if label.text.count("\n") >= 9: | ||
28 | _message_queue.append(text) | 40 | _message_queue.append(text) |
29 | return | 41 | return |
30 | 42 | ||
31 | if !label.text == "": | 43 | _add_message(text) |
32 | label.text += "\n" | ||
33 | label.text += text | ||
34 | return | ||
35 | 44 | ||
36 | label.text = text | 45 | if _ordered_labels.size() > 1: |
46 | return | ||
37 | 47 | ||
38 | var timeout = 10.0 | 48 | var timeout = 10.0 |
39 | while label.text != "": | 49 | while !_ordered_labels.empty(): |
40 | yield(get_tree().create_timer(timeout), "timeout") | 50 | yield(get_tree().create_timer(timeout), "timeout") |
41 | 51 | ||
42 | var newline = label.text.find("\n") | 52 | var to_remove = _ordered_labels.pop_front() |
43 | if newline == -1: | 53 | to_remove.queue_free() |
44 | label.text = "" | ||
45 | else: | ||
46 | label.text = label.text.substr(newline + 1) | ||
47 | 54 | ||
48 | if !_message_queue.empty(): | 55 | if !_message_queue.empty(): |
49 | var next_msg = _message_queue.pop_front() | 56 | var next_msg = _message_queue.pop_front() |
50 | label.text += "\n" | 57 | _add_message(next_msg) |
51 | label.text += next_msg | ||
52 | 58 | ||
53 | if timeout > 4: | 59 | if timeout > 4: |
54 | timeout -= 3 | 60 | timeout -= 3 |