Save the quiz settings to the config folder
The quiz card's settings are saved to quiz_settings.cfg in OS.get_config_dir() on every change and loaded at start. Debug builds use their own file, and MUSICPLAYER_CONFIG_DIR moves the file elsewhere so tests never touch it. Count plays in statistics and Prefer less played soundtracks are not saved and move from the quiz card to the Settings popup.
This commit is contained in:
1 parent
b510aa47f2
commit
92e3a66075
15 files changed
+835
-591
No files matched your search
@@ -16,7 +16,7 @@ panel = NodePath("SettingsPanel")
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 520.0
|
||||
offset_bottom = 172.0
|
||||
offset_bottom = 242.0
|
||||
theme_type_variation = &"PopupBackground"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="SettingsPanel" unique_id=1796635163]
|
||||
@@ -25,7 +25,7 @@ layout_mode = 0
|
||||
offset_left = 20.0
|
||||
offset_top = 12.0
|
||||
offset_right = 500.0
|
||||
offset_bottom = 160.0
|
||||
offset_bottom = 230.0
|
||||
|
||||
[node name="Label" type="Label" parent="SettingsPanel/VBoxContainer" unique_id=1111531402]
|
||||
layout_mode = 2
|
||||
@@ -85,6 +85,20 @@ focus_mode = 0
|
||||
action_mode = 0
|
||||
text = "+1"
|
||||
|
||||
[node name="LowPlayedCheckButton" type="CheckButton" parent="SettingsPanel/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
action_mode = 0
|
||||
text = "Prefer less played soundtracks"
|
||||
|
||||
[node name="AddToDatabaseCheckButton" type="CheckButton" parent="SettingsPanel/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
action_mode = 0
|
||||
text = "Count plays in statistics"
|
||||
|
||||
[node name="LocalButton" type="CheckButton" parent="SettingsPanel/VBoxContainer" unique_id=905844805]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
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 application settings: which MusicServer to use, fullscreen, how many songs to
|
||||
## download ahead, whether to prefer less played soundtracks and whether plays count in
|
||||
## the statistics. Opened from the Settings button in the top bar.
|
||||
##
|
||||
## The quiz settings, such as the winning score, are in [QuizSettingsCard].
|
||||
|
||||
@@ -14,6 +15,8 @@ signal server_changed
|
||||
@onready var cache_label: Label = %CacheLabel
|
||||
@onready var lower_cache_button: Button = %LowerCacheButton
|
||||
@onready var increase_cache_button: Button = %IncreaseCacheButton
|
||||
@onready var low_played_button: CheckButton = %LowPlayedCheckButton
|
||||
@onready var add_to_database_button: CheckButton = %AddToDatabaseCheckButton
|
||||
@onready var local_button: CheckButton = %LocalButton
|
||||
|
||||
|
||||
@@ -29,6 +32,9 @@ func _ready() -> void:
|
||||
lower_cache_button.pressed.connect(lower_cache)
|
||||
increase_cache_button.pressed.connect(increase_cache)
|
||||
select_server_button.item_selected.connect(select_server)
|
||||
low_played_button.toggled.connect(
|
||||
func(on: bool) -> void: Settings.use_low_played_mode = on)
|
||||
add_to_database_button.toggled.connect(func(on: bool) -> void: Settings.add_to_stats = on)
|
||||
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)
|
||||
@@ -75,9 +81,12 @@ func _use_server(new_server: int) -> void:
|
||||
server_changed.emit()
|
||||
|
||||
|
||||
# Winning a game turns statistics off, so the toggles are refreshed every time this opens
|
||||
func _on_visibility_changed() -> void:
|
||||
if visible:
|
||||
_update_fullscreen_button()
|
||||
low_played_button.set_pressed_no_signal(Settings.use_low_played_mode)
|
||||
add_to_database_button.set_pressed_no_signal(Settings.add_to_stats)
|
||||
|
||||
|
||||
func _update_fullscreen_button() -> void:
|
||||
|
||||
Reference in new issue
Block a user