about summary refs log tree commit diff stats
path: root/Archipelago
diff options
context:
space:
mode:
Diffstat (limited to 'Archipelago')
-rw-r--r--Archipelago/client.gd42
-rw-r--r--Archipelago/messages.gd68
2 files changed, 70 insertions, 40 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 0531fe6..46b9ff0 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd
@@ -293,13 +293,14 @@ func _on_data():
293 var i = 0 293 var i = 0
294 for item in message["items"]: 294 for item in message["items"]:
295 if _map_loaded: 295 if _map_loaded:
296 processItem(item["item"], message["index"] + i, item["player"]) 296 processItem(item["item"], message["index"] + i, item["player"], item["flags"])
297 else: 297 else:
298 _held_items.append( 298 _held_items.append(
299 { 299 {
300 "item": item["item"], 300 "item": item["item"],
301 "index": message["index"] + i, 301 "index": message["index"] + i,
302 "from": item["player"] 302 "from": item["player"],
303 "flags": item["flags"]
303 } 304 }
304 ) 305 )
305 i += 1 306 i += 1
@@ -324,6 +325,8 @@ func _on_data():
324 if _player_name_by_slot.has(message["receiving"]): 325 if _player_name_by_slot.has(message["receiving"]):
325 player_name = _player_name_by_slot[message["receiving"]] 326 player_name = _player_name_by_slot[message["receiving"]]
326 327
328 var item_color = colorForItemType(message["item"]["flags"])
329
327 var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages") 330 var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages")
328 if message["type"] == "Hint": 331 if message["type"] == "Hint":
329 var is_for = "" 332 var is_for = ""
@@ -331,11 +334,16 @@ func _on_data():
331 is_for = " for %s" % player_name 334 is_for = " for %s" % player_name
332 if !message.has("found") || !message["found"]: 335 if !message.has("found") || !message["found"]:
333 messages_node.showMessage( 336 messages_node.showMessage(
334 "Hint: %s%s is on %s" % [item_name, is_for, location_name] 337 (
338 "Hint: [color=%s]%s[/color]%s is on %s"
339 % [item_color, item_name, is_for, location_name]
340 )
335 ) 341 )
336 else: 342 else:
337 if message["receiving"] != _slot: 343 if message["receiving"] != _slot:
338 messages_node.showMessage("Sent %s to %s" % [item_name, player_name]) 344 messages_node.showMessage(
345 "Sent [color=%s]%s[/color] to %s" % [item_color, item_name, player_name]
346 )
339 347
340 elif cmd == "Bounced": 348 elif cmd == "Bounced":
341 if ( 349 if (
@@ -486,7 +494,7 @@ func mapFinishedLoading():
486 emit_signal("evaluate_solvability") 494 emit_signal("evaluate_solvability")
487 495
488 for item in _held_items: 496 for item in _held_items:
489 processItem(item["item"], item["index"], item["from"]) 497 processItem(item["item"], item["index"], item["from"], item["flags"])
490 498
491 sendMessage([{"cmd": "LocationChecks", "locations": _held_locations}]) 499 sendMessage([{"cmd": "LocationChecks", "locations": _held_locations}])
492 500
@@ -495,7 +503,7 @@ func mapFinishedLoading():
495 _held_locations = [] 503 _held_locations = []
496 504
497 505
498func processItem(item, index, from): 506func processItem(item, index, from, flags):
499 global._print(item) 507 global._print(item)
500 508
501 var stringified = String(item) 509 var stringified = String(item)
@@ -522,7 +530,7 @@ func processItem(item, index, from):
522 if _item_name_to_id["Progressive Orange Tower"] == item and _tower_floors < orange_tower.size(): 530 if _item_name_to_id["Progressive Orange Tower"] == item and _tower_floors < orange_tower.size():
523 var subitem_name = "Orange Tower - %s Floor" % orange_tower[_tower_floors] 531 var subitem_name = "Orange Tower - %s Floor" % orange_tower[_tower_floors]
524 global._print(subitem_name) 532 global._print(subitem_name)
525 processItem(_item_name_to_id[subitem_name], null, null) 533 processItem(_item_name_to_id[subitem_name], null, null, null)
526 _tower_floors += 1 534 _tower_floors += 1
527 535
528 if _color_shuffle and color_items.has(_item_id_to_name[item]): 536 if _color_shuffle and color_items.has(_item_id_to_name[item]):
@@ -547,11 +555,15 @@ func processItem(item, index, from):
547 if _player_name_by_slot.has(from): 555 if _player_name_by_slot.has(from):
548 player_name = _player_name_by_slot[from] 556 player_name = _player_name_by_slot[from]
549 557
558 var item_color = colorForItemType(flags)
559
550 var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages") 560 var messages_node = get_tree().get_root().get_node("Spatial/AP_Messages")
551 if from == _slot: 561 if from == _slot:
552 messages_node.showMessage("Found %s" % item_name) 562 messages_node.showMessage("Found [color=%s]%s[/color]" % [item_color, item_name])
553 else: 563 else:
554 messages_node.showMessage("Received %s from %s" % [item_name, player_name]) 564 messages_node.showMessage(
565 "Received [color=%s]%s[/color] from %s" % [item_color, item_name, player_name]
566 )
555 567
556 var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects") 568 var effects_node = get_tree().get_root().get_node("Spatial/AP_Effects")
557 if item_name == "Slowness Trap": 569 if item_name == "Slowness Trap":
@@ -566,3 +578,15 @@ func doorIsVanilla(door):
566 578
567func paintingIsVanilla(painting): 579func paintingIsVanilla(painting):
568 return !_mentioned_paintings.has(painting) 580 return !_mentioned_paintings.has(painting)
581
582
583func colorForItemType(flags):
584 var int_flags = int(flags)
585 if int_flags & 1: # progression
586 return "#bc51e0"
587 elif int_flags & 2: # useful
588 return "#2b67ff"
589 elif int_flags & 4: # trap
590 return "#d63a22"
591 else: # filler
592 return "#14de9e"
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 @@
1extends Node 1extends Node
2 2
3var _message_queue = [] 3var _message_queue = []
4var _font
5var _container
6var _ordered_labels = []
4 7
5 8
6func _ready(): 9func _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
28func _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
25func showMessage(text): 38func 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