class_name LogPopup extends BasePopup ## The game log: a row with the time for each thing that happens in the quiz, such as a ## player getting a point. Opened with Alt+L. The newest row is at the bottom and is ## scrolled into view. @onready var log_panel: Panel = %LogPanel @onready var log_box: VBoxContainer = %LogVBoxContainer @onready var log_scroll: ScrollContainer = %LogScrollContainer @onready var empty_label: Label = %EmptyLabel func _ready() -> void: visibility_changed.connect(_on_visibility_changed) func add_log_row(text: String) -> void: var row: int = log_box.get_child_count() log_box.add_child(ListRow.create(get_time() + text, row, &"TextLarge")) empty_label.visible = false _scroll_to_newest.call_deferred() func get_time() -> String: var time: Dictionary = Time.get_time_dict_from_system() return "%02d:%02d:%02d " % [time.hour, time.minute, time.second] func _on_visibility_changed() -> void: if visible: empty_label.visible = log_box.get_child_count() == 0 _scroll_to_newest.call_deferred() # Deferred, as the list only knows its new height once the new row is laid out func _scroll_to_newest() -> void: await get_tree().process_frame log_scroll.scroll_vertical = int(log_scroll.get_v_scroll_bar().max_value)