- A Quiz settings button under the player bar opens a small card above it with the quiz settings, including Auto repeat, which moves there from under the player bar. The card does not dim the quiz, so it can be changed during a song, and grows to fit its rows. - A Settings button in the top bar opens the application settings: server, fullscreen and songs to download ahead. Quick sync is gone, as the server no longer has it, and the server list is in Settings. - Labels use sentence case, and seconds to hide show as whole numbers. - Debug builds switch to the local server and a low winning score in the Settings autoload, before any scene asks the server for anything. The DEBUG label moves to the top bar, so it shows on every tab. - Search moves from the top bar back to the quiz toolbar, as the Statistics tab has its own search.
85 lines
2.8 KiB
GDScript
85 lines
2.8 KiB
GDScript
class_name SettingsPopup
|
|
extends BasePopup
|
|
## The application settings: which MusicServer to use, fullscreen and how many songs to
|
|
## download ahead. Opened from the Settings button in the top bar.
|
|
##
|
|
## The quiz settings, such as the winning score, are in [QuizSettingsCard].
|
|
|
|
## Emitted when another MusicServer is picked.
|
|
signal server_changed
|
|
|
|
@onready var settings_panel: Panel = %SettingsPanel
|
|
@onready var select_server_button: OptionButton = %SelectServerButton
|
|
@onready var fullscreen_button: CheckButton = %FullscreenButton
|
|
@onready var cache_label: Label = %CacheLabel
|
|
@onready var lower_cache_button: Button = %LowerCacheButton
|
|
@onready var increase_cache_button: Button = %IncreaseCacheButton
|
|
@onready var local_button: CheckButton = %LocalButton
|
|
|
|
|
|
func _ready() -> void:
|
|
for server: String in Settings.SERVERS:
|
|
select_server_button.add_item(server)
|
|
fullscreen_button.button_pressed = Settings.fullscreen
|
|
select_server_button.select(Settings.selected_server)
|
|
cache_label.text = str(Playlist.number_of_tracks_to_preload)
|
|
|
|
fullscreen_button.pressed.connect(fullscreen)
|
|
local_button.pressed.connect(local_play)
|
|
lower_cache_button.pressed.connect(lower_cache)
|
|
increase_cache_button.pressed.connect(increase_cache)
|
|
select_server_button.item_selected.connect(select_server)
|
|
visibility_changed.connect(_on_visibility_changed)
|
|
# Alt+Enter switches fullscreen from the main window, which resizes the window
|
|
get_window().size_changed.connect(_update_fullscreen_button)
|
|
|
|
|
|
func fullscreen() -> void:
|
|
Settings.fullscreen = !Settings.fullscreen
|
|
if Settings.fullscreen:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
|
if !Settings.fullscreen:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
|
|
|
|
|
func local_play() -> void:
|
|
Settings.play_local = !Settings.play_local
|
|
|
|
|
|
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)
|
|
|
|
|
|
func increase_cache() -> void:
|
|
Playlist.number_of_tracks_to_preload += 1
|
|
cache_label.text = str(Playlist.number_of_tracks_to_preload)
|
|
|
|
|
|
func select_server(new_server: int) -> void:
|
|
GameLog.debug("select_server")
|
|
_use_server(new_server)
|
|
|
|
|
|
## Picks [param new_server] in the list and uses it.
|
|
func set_selected_server(new_server: int) -> void:
|
|
GameLog.debug("set_selected_server")
|
|
select_server_button.select(new_server)
|
|
_use_server(new_server)
|
|
|
|
|
|
func _use_server(new_server: int) -> void:
|
|
Settings.default_path = Settings.SERVERS[new_server]
|
|
Settings.selected_server = new_server
|
|
GameLog.debug("Settings.default_path: " + Settings.default_path)
|
|
server_changed.emit()
|
|
|
|
|
|
func _on_visibility_changed() -> void:
|
|
if visible:
|
|
_update_fullscreen_button()
|
|
|
|
|
|
func _update_fullscreen_button() -> void:
|
|
fullscreen_button.set_pressed_no_signal(Settings.fullscreen)
|