Save the quiz and continue it after a restart; load characters from a folder
The quiz is saved to current_quiz.json in the config folder after every change, and the game goes on where it was when it starts again: the players with their points and characters, every song with who got a point for it and whether it was played, answered or is playing, and the songs downloaded ahead with their files. The song that was playing is ready to play again. Songs whose files are gone are downloaded again. On a server, the saved songs are checked against the server's playlist. If it changed, e.g. after a sync, or another server is used, the quiz starts over with the same players. A quiz from a music folder continues offline, including how far a prepared quiz has come. A new game is saved like any other change, and a file that can't be read starts a new quiz. Characters can be read from a folder picked in Settings instead of the server, for this session. A music folder with a characters folder brings its own characters, e.g. for a themed quiz; that folder is not counted as a soundtrack. When the characters come from somewhere else, players pick their characters again. Closes #11, closes #44
This commit is contained in:
1 parent
4a934840f6
commit
e4352a9f34
33 files changed
+2886
-499
No files matched your search
@@ -7,6 +7,8 @@ extends BasePopup
|
||||
##
|
||||
## A music folder (see [MusicFolder]) is used instead of the server until Use server is
|
||||
## pressed or the game is closed. The settings that need the server are off meanwhile.
|
||||
## A folder of characters (see [FolderCharacters]) is used the same way; without one, a
|
||||
## music folder's own [code]characters[/code] folder is used, or else the server's.
|
||||
##
|
||||
## The quiz settings, such as the winning score, are in [QuizSettingsCard].
|
||||
|
||||
@@ -14,6 +16,9 @@ extends BasePopup
|
||||
## order is changed. A new game starts.
|
||||
signal server_changed
|
||||
|
||||
## Emitted when a folder of characters is picked or Use server is pressed for them.
|
||||
signal characters_changed
|
||||
|
||||
## Space between the rows and the panel's edges.
|
||||
const PADDING: Vector2 = Vector2(20, 12)
|
||||
|
||||
@@ -33,6 +38,11 @@ const PADDING: Vector2 = Vector2(20, 12)
|
||||
@onready var play_order_row: HBoxContainer = %PlayOrderRow
|
||||
@onready var play_order_button: OptionButton = %PlayOrderButton
|
||||
@onready var folder_dialog: FileDialog = %FolderDialog
|
||||
@onready var characters_label: Label = %CharactersLabel
|
||||
@onready var choose_characters_button: Button = %ChooseCharactersButton
|
||||
@onready var use_server_characters_button: Button = %UseServerCharactersButton
|
||||
@onready var characters_error_label: Label = %CharactersErrorLabel
|
||||
@onready var character_folder_dialog: FileDialog = %CharacterFolderDialog
|
||||
@onready var open_config_folder_button: Button = %OpenConfigFolderButton
|
||||
|
||||
## Shows a folder in the system's file manager. The tests replace it, so no file manager
|
||||
@@ -54,6 +64,9 @@ func _ready() -> void:
|
||||
choose_folder_button.pressed.connect(folder_dialog.popup_centered)
|
||||
folder_dialog.dir_selected.connect(use_music_folder)
|
||||
use_server_button.pressed.connect(use_server)
|
||||
choose_characters_button.pressed.connect(character_folder_dialog.popup_centered)
|
||||
character_folder_dialog.dir_selected.connect(use_character_folder)
|
||||
use_server_characters_button.pressed.connect(use_server_characters)
|
||||
open_config_folder_button.pressed.connect(open_config_folder)
|
||||
open_config_folder_button.tooltip_text = Settings.config_dir()
|
||||
play_order_button.item_selected.connect(_on_play_order_selected)
|
||||
@@ -104,6 +117,26 @@ func open_config_folder() -> void:
|
||||
show_folder.call(dir)
|
||||
|
||||
|
||||
## Reads the characters from the folder at [param path] instead of the server. A folder
|
||||
## without pictures is not used, and the popup says so.
|
||||
func use_character_folder(path: String) -> void:
|
||||
if FolderCharacters.picture_names(path).is_empty():
|
||||
characters_error_label.text = "No pictures found in " + path.trim_suffix("/").get_file()
|
||||
characters_error_label.visible = true
|
||||
_fit_to_rows()
|
||||
return
|
||||
Settings.character_folder = path.trim_suffix("/")
|
||||
_show_music_source()
|
||||
characters_changed.emit()
|
||||
|
||||
|
||||
## Uses the server's characters again, or the music folder's own if it has them.
|
||||
func use_server_characters() -> void:
|
||||
Settings.character_folder = ""
|
||||
_show_music_source()
|
||||
characters_changed.emit()
|
||||
|
||||
|
||||
func lower_cache() -> void:
|
||||
Playlist.number_of_tracks_to_preload = maxi(Playlist.number_of_tracks_to_preload - 1, 1)
|
||||
cache_label.text = str(Playlist.number_of_tracks_to_preload)
|
||||
@@ -141,6 +174,7 @@ func _on_visibility_changed() -> void:
|
||||
add_to_database_button.set_pressed_no_signal(Settings.add_to_stats)
|
||||
else:
|
||||
folder_error_label.visible = false
|
||||
characters_error_label.visible = false
|
||||
_fit_to_rows()
|
||||
|
||||
|
||||
@@ -162,6 +196,15 @@ func _show_music_source() -> void:
|
||||
folder_label.text = folder.display_name()
|
||||
folder_label.tooltip_text = folder.path
|
||||
play_order_row.visible = folder != null && folder.kind == MusicFolder.Kind.PREPARED_QUIZ
|
||||
characters_error_label.visible = false
|
||||
use_server_characters_button.visible = !Settings.character_folder.is_empty()
|
||||
characters_label.tooltip_text = Settings.characters_dir()
|
||||
if !Settings.character_folder.is_empty():
|
||||
characters_label.text = Settings.character_folder.get_file()
|
||||
elif !Settings.characters_dir().is_empty():
|
||||
characters_label.text = "From " + folder.display_name()
|
||||
else:
|
||||
characters_label.text = "From the server"
|
||||
for control: BaseButton in [select_server_button, low_played_button, add_to_database_button]:
|
||||
control.disabled = folder != null
|
||||
_fit_to_rows()
|
||||
|
||||
Reference in new issue
Block a user