extends Control

@onready
var log_panel: Panel = %LogPanel

@onready
var log_box: VBoxContainer = %LogVBoxContainer

var log_rows: Array

func add_log_row(text: String) -> void:
	var log_row: String = get_time() + text
	log_rows.append(log_row)
	update_log()

func update_log() -> void:
	print("update_log")
	Settings.delete_children(log_box)
	for row: String in log_rows:
		var log_label: Label = Label.new()
		log_label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
		log_label.add_theme_font_size_override("font_size", 20)
		log_label.text = row
		log_label.autowrap_mode = TextServer.AUTOWRAP_WORD
		log_box.add_child(log_label)

func get_time() -> String:
	var dateTime: Dictionary = Time.get_datetime_dict_from_system()
	return "" + str(dateTime.hour) + ":" + str(dateTime.minute) + ":" + str(dateTime.second) + " "
