Part of #41. The top bar has Quiz and Statistics tabs instead of the Statistics button. The Statistics tab replaces the quiz below the top bar (the song keeps playing) and shows every soundtrack as a card with its plays, last played date and most and least played songs, loaded from the new GET /api/v1/statistics/soundtracks. The cards can be searched (with the Search popup's matching, now in SoundtrackSearch), filtered on played or never played, and sorted A-Z, Z-A, most or least played. Clicking a card opens a popup with all its songs. Screenshots of the other states only differ in the top bar, and the layout baseline is taken again with the new statistics states.
33 lines
1.2 KiB
GDScript
33 lines
1.2 KiB
GDScript
class_name TopBar
|
|
extends Control
|
|
## The bar along the top of the main window, with the title, the Quiz and Statistics tabs
|
|
## and the buttons for things that are not part of a quiz.
|
|
|
|
signal search_pressed
|
|
signal sync_pressed
|
|
signal shortcuts_pressed
|
|
signal about_pressed
|
|
signal qr_pressed
|
|
## Emitted when a tab is chosen: [code]&"quiz"[/code] or [code]&"statistics"[/code].
|
|
signal tab_selected(tab: StringName)
|
|
|
|
@onready var sync_button: Button = $SyncButton
|
|
@onready var quiz_tab: Button = $QuizTab
|
|
@onready var statistics_tab: Button = $StatisticsTab
|
|
|
|
|
|
func _ready() -> void:
|
|
$SearchButton.pressed.connect(search_pressed.emit)
|
|
sync_button.pressed.connect(sync_pressed.emit)
|
|
$ShortcutsButton.pressed.connect(shortcuts_pressed.emit)
|
|
$AboutButton.pressed.connect(about_pressed.emit)
|
|
$QRButton.pressed.connect(qr_pressed.emit)
|
|
quiz_tab.pressed.connect(tab_selected.emit.bind(&"quiz"))
|
|
statistics_tab.pressed.connect(tab_selected.emit.bind(&"statistics"))
|
|
|
|
|
|
## Shows [param tab] as the chosen tab, without emitting [signal tab_selected].
|
|
func select_tab(tab: StringName) -> void:
|
|
quiz_tab.set_pressed_no_signal(tab == &"quiz")
|
|
statistics_tab.set_pressed_no_signal(tab == &"statistics")
|