Add offline mode: play from a music folder instead of the server
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:
1 parent
b120440404
commit
222d231b1b
42 files changed
+8245
-474
No files matched your search
@@ -296,6 +296,56 @@ func run(on_state: Callable) -> void:
|
||||
winner_popup.close()
|
||||
await _settle()
|
||||
|
||||
# Playing from a music folder: a soundtrack folder, then a prepared quiz in Settings
|
||||
var music: String = _make_music_folders()
|
||||
var settings_popup: SettingsPopup = _node("SettingsPopup")
|
||||
# Songs are picked at random; the same picks every time keep the pictures the same
|
||||
seed(1)
|
||||
settings_popup.use_music_folder(music.path_join("Soundtracks"))
|
||||
await _settle()
|
||||
_call("play_next_song")
|
||||
# A playing song is stopped first, which takes half a second
|
||||
await _main.get_tree().create_timer(0.7).timeout
|
||||
await _settle()
|
||||
_call("show_answer_pressed")
|
||||
await _settle()
|
||||
await on_state.call("offline", null)
|
||||
settings_popup.use_music_folder(music.path_join("Musiktävling"))
|
||||
settings_popup.open()
|
||||
await _settle()
|
||||
await on_state.call("popup_SettingsWindow_offline", settings_popup)
|
||||
settings_popup.close()
|
||||
# The end of a prepared quiz, where two players share the most points
|
||||
var scores: Array[int] = [7, 12, 12, 3, 9]
|
||||
for index: int in Settings.player_array.size():
|
||||
Settings.player_array[index].player_score = scores[index % scores.size()]
|
||||
_call("show_final_winners")
|
||||
var final_popup: WinnerPopup = _node("WinnerPopup")
|
||||
await _settle()
|
||||
await on_state.call("popup_WinnerWindow_prepared_quiz", final_popup)
|
||||
final_popup.close()
|
||||
settings_popup.use_server()
|
||||
await _settle()
|
||||
|
||||
|
||||
# Writes a soundtrack folder and a prepared quiz with copies of the test song, and
|
||||
# returns the folder they are in
|
||||
static func _make_music_folders() -> String:
|
||||
var root: String = OS.get_user_data_dir().path_join("ui_tour_music")
|
||||
var song: PackedByteArray = FileAccess.get_file_as_bytes("res://tests/data/short.mp3")
|
||||
var files: Array[String] = [
|
||||
"Soundtracks/Chrono Trigger/Corridors of Time.mp3",
|
||||
"Soundtracks/Final Fantasy VI/Dancing Mad.mp3",
|
||||
"Soundtracks/Secret of Mana/Into the Thick of It.mp3",
|
||||
"Musiktävling/01. Opening.mp3",
|
||||
"Musiktävling/02. Ace Combat 7 - Daredevil.mp3",
|
||||
]
|
||||
for file: String in files:
|
||||
var path: String = root.path_join(file)
|
||||
DirAccess.make_dir_recursive_absolute(path.get_base_dir())
|
||||
FileAccess.open(path, FileAccess.WRITE).store_buffer(song)
|
||||
return root
|
||||
|
||||
|
||||
## Returns where every Control and Window in [param subtree] is on screen, keyed by its
|
||||
## path from [param main]: [code]{"rect": [x, y, width, height], "visible": bool}[/code].
|
||||
|
||||
Reference in new issue
Block a user