Files
MusicPlayer/popups/log_popup.gd
T
Sansan 8d21b0617d
Build / test (push) Successful in 41s
Build / build (push) Successful in 1m13s
Fix and tidy the Character select, Shortcuts, Log and QR popups
Character select
- A card only picks its character when it is clicked. Before, every card
  watched every click, so clicking below the panel could pick a card
  scrolled out of view there.
- Six columns of fixed-size cards that scroll for any number of
  characters, with a gap between the cards and the scrollbar.
- Pictures are read as PNG, JPG or WebP by their first bytes, so JPGs no
  longer print an error. Names are split into words ("Paper Mario") and
  the card under the mouse is highlighted.

Shortcuts
- Alt+Z restarts the song; it was listed as "Reset".
- Grouped by what the keys do, in sentence case, and the panel fits the
  list. A test checks that every button shortcut is listed.

Log
- Scrolls to the newest row, alternates row colours and says "Nothing
  has happened yet" when empty.

QR
- A title, and the code is set up in one place.
2026-10-07 15:24:43 +02:00

39 lines
1.2 KiB
GDScript

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)