This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
Jessist/addons/dialogue_manager/components/error_list.gd

42 lines
831 B
GDScript3
Raw Normal View History

2022-06-18 13:05:48 +02:00
tool
extends ScrollContainer
signal error_pressed(error)
const ErrorButton = preload("res://addons/dialogue_manager/components/error_button.tscn")
onready var list: VBoxContainer = $List
var errors: Array setget set_errors
func set_errors(next_errors: Array) -> void:
errors = next_errors
if errors.size() == 0:
visible = false
else:
visible = true
rect_min_size.y = min(200, errors.size() * 25)
for child in list.get_children():
child.queue_free()
for error in errors:
var error_button = ErrorButton.instance()
list.add_child(error_button)
error_button.text = "Line %d: %s" % [error.get("line") + 1, error.get("message")]
error_button.connect("pressed", self, "_on_error_pressed", [error])
### Signals
func _on_error_pressed(error) -> void:
emit_signal("error_pressed", error)