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.
28 lines
1.1 KiB
GDScript
28 lines
1.1 KiB
GDScript
class_name SoundtrackStatsPopup
|
|
extends BasePopup
|
|
## Shows a soundtrack's play statistics and every song in it, most played first.
|
|
## Opened by clicking a card in the statistics view.
|
|
|
|
@onready var title_label: Label = %TitleLabel
|
|
@onready var summary_label: Label = %SummaryLabel
|
|
@onready var song_list: VBoxContainer = %SongList
|
|
|
|
|
|
## Shows [param soundtrack] and opens the popup.
|
|
func show_soundtrack(soundtrack: SoundtrackWithSongs) -> void:
|
|
title_label.text = soundtrack.soundtrack_name
|
|
var summary: PackedStringArray = [SoundtrackCard.played_text(soundtrack.soundtrack_played)]
|
|
var last_played: String = SoundtrackCard.last_played_text(soundtrack.soundtrack_last_played)
|
|
if !last_played.is_empty():
|
|
summary.append(last_played)
|
|
summary.append("%d %s" % [soundtrack.songs.size(),
|
|
"song" if soundtrack.songs.size() == 1 else "songs"])
|
|
summary_label.text = " · ".join(summary)
|
|
|
|
Settings.delete_children(song_list)
|
|
var songs: Array[SongInfoForStats] = SoundtrackCard.songs_by_plays(soundtrack.songs)
|
|
for row: int in songs.size():
|
|
song_list.add_child(ListRow.create(SoundtrackCard.song_text(songs[row]), row,
|
|
&"TextLarge"))
|
|
open()
|