Add offline mode: play from a music folder instead of the server
Build / test (push) Successful in 1m2s
Build / build (push) Successful in 1m12s

Settings has a Music folder row. A folder with subfolders is played as
soundtracks: Next picks a random subfolder and a random song in it, the
subfolder is the answer's soundtrack and the file name without its type the
song. The inspiration list and Search show the subfolders.

A folder with songs and no subfolders is a prepared quiz, played once in order
(natural sort) or at random, showing only the song title. It has no winning
score: after the last song Next becomes Show winner, and the players with the
most points win, ties included.

While a folder is used nothing but the characters is asked from the server:
Sync, QR, Statistics, the update check and play counting are off. Characters
fall back to the cached pictures when the server can't be reached. mp3, ogg and
wav play; other files and broken ones are skipped.

The old local playback code, the hidden Open button and the hidden Local toggle
are removed. Next now waits for the song to start before preparing the next one.
This commit is contained in:
Sansan committed 2026-10-07 23:07:47 +02:00
1 parent b120440404
commit 222d231b1b
42 files changed
+8245 -474

No files matched your search

+2 -2
View File
@@ -98,9 +98,9 @@ unique_name_in_owner = true
visible = false
layout_mode = 1
offset_left = 700.0
offset_top = 419.0
offset_top = 405.0
offset_right = 700.0
offset_bottom = 419.0
offset_bottom = 405.0
[node name="SoundtrackStatsPopup" parent="." unique_id=1213999001 instance=ExtResource("soundtrack_stats_popup_scene")]
visible = false
+14
View File
@@ -53,6 +53,20 @@ horizontal_alignment = 2
vertical_alignment = 1
text_overrun_behavior = 3
[node name="OfflineLabel" type="Label" parent="." unique_id=1959221259]
visible = false
layout_mode = 0
offset_left = 1096.0
offset_top = 12.0
offset_right = 1432.0
offset_bottom = 50.0
mouse_filter = 1
theme_type_variation = &"HighlightMedium"
text = "Offline: Music"
horizontal_alignment = 2
vertical_alignment = 1
text_overrun_behavior = 3
[node name="SyncButton" type="Button" parent="." unique_id=1228313556]
layout_mode = 0
offset_left = 1450.0
+9 -1
View File
@@ -38,7 +38,7 @@ func _ready() -> void:
sync_popup.sync_started.connect(_on_sync_started)
sync_popup.sync_finished.connect(_on_sync_finished)
quiz.server_changed.connect(search_popup.get_list_of_soundtracks)
quiz.server_changed.connect(top_bar.check_for_update)
quiz.server_changed.connect(_on_music_source_changed)
quiz.event_logged.connect(log_popup.add_log_row)
statistics_view.soundtrack_selected.connect(soundtrack_stats_popup.show_soundtrack)
@@ -46,6 +46,14 @@ func _ready() -> void:
show_about_if_new_version()
# After another server or a music folder was picked. Statistics need the server.
func _on_music_source_changed() -> void:
top_bar.update_offline_state()
top_bar.check_for_update()
if Settings.is_offline() && statistics_view.visible:
show_tab(&"quiz")
## Opens the About popup, with what is new, the first time this version starts.
func show_about_if_new_version() -> void:
if Settings.last_seen_version == Settings.version:
+30 -3
View File
@@ -2,6 +2,12 @@ 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.
##
## With a music folder picked, the buttons that need the server are turned off and the
## folder's name is shown.
## Shown on the buttons that need the server while a music folder is used.
const OFFLINE_TOOLTIP: String = "Not available with a music folder"
signal sync_pressed
signal settings_pressed
@@ -14,6 +20,8 @@ signal tab_selected(tab: StringName)
@onready var sync_button: Button = $SyncButton
@onready var debug_label: Label = $DebugLabel
@onready var update_label: Label = $UpdateLabel
@onready var offline_label: Label = $OfflineLabel
@onready var qr_button: Button = $QRButton
@onready var quiz_tab: Button = $QuizTab
@onready var statistics_tab: Button = $StatisticsTab
@@ -25,22 +33,41 @@ func _ready() -> void:
$SettingsButton.pressed.connect(settings_pressed.emit)
$ShortcutsButton.pressed.connect(shortcuts_pressed.emit)
$AboutButton.pressed.connect(about_pressed.emit)
$QRButton.pressed.connect(qr_pressed.emit)
qr_button.pressed.connect(qr_pressed.emit)
quiz_tab.pressed.connect(tab_selected.emit.bind(&"quiz"))
statistics_tab.pressed.connect(tab_selected.emit.bind(&"statistics"))
update_offline_state()
check_for_update()
## Turns the buttons that need the server off or on, after a music folder was picked or
## the server is used again.
func update_offline_state() -> void:
var offline: bool = Settings.is_offline()
for button: Button in [sync_button, qr_button, statistics_tab]:
button.disabled = offline
button.tooltip_text = OFFLINE_TOOLTIP if offline else ""
offline_label.visible = offline
if offline:
offline_label.text = "Offline: " + Settings.music_folder.display_name()
offline_label.tooltip_text = Settings.music_folder.path
update_label.visible = false
## Asks the server for the newest MusicPlayer release and tells the user when it is newer
## than this one.
## than this one. Not asked while a music folder is used.
func check_for_update() -> void:
if Settings.is_offline():
update_label.visible = false
return
MusicServerClient.fetch_latest_client_version(show_latest_version)
## Shows that [param latest] is available when it is newer than this version, and hides
## the message otherwise.
func show_latest_version(latest: Variant) -> void:
var newer: bool = latest is String && is_newer_version(latest, Settings.version)
var newer: bool = latest is String && is_newer_version(latest, Settings.version) \
&& !Settings.is_offline()
update_label.visible = newer
if newer:
update_label.text = "Version %s is available" % latest